babylon.d.ts 1.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Set of assets to keep when moving a scene into an asset container.
  7. */
  8. class KeepAssets {
  9. /**
  10. * Cameras to keep.
  11. */
  12. cameras: Camera[];
  13. /**
  14. * Lights to keep.
  15. */
  16. lights: Light[];
  17. /**
  18. * Meshes to keep.
  19. */
  20. meshes: AbstractMesh[];
  21. /**
  22. * Skeletons to keep.
  23. */
  24. skeletons: Skeleton[];
  25. /**
  26. * ParticleSystems to keep.
  27. */
  28. particleSystems: ParticleSystem[];
  29. /**
  30. * Animations to keep.
  31. */
  32. animations: Animation[];
  33. /**
  34. * MultiMaterials to keep.
  35. */
  36. multiMaterials: MultiMaterial[];
  37. /**
  38. * Materials to keep.
  39. */
  40. materials: Material[];
  41. /**
  42. * MorphTargetManagers to keep.
  43. */
  44. morphTargetManagers: MorphTargetManager[];
  45. /**
  46. * Geometries to keep.
  47. */
  48. geometries: Geometry[];
  49. /**
  50. * TransformNodes to keep.
  51. */
  52. transformNodes: TransformNode[];
  53. /**
  54. * LensFlareSystems to keep.
  55. */
  56. lensFlareSystems: LensFlareSystem[];
  57. /**
  58. * ShadowGenerators to keep.
  59. */
  60. shadowGenerators: ShadowGenerator[];
  61. /**
  62. * ActionManagers to keep.
  63. */
  64. actionManagers: ActionManager[];
  65. /**
  66. * Sounds to keep.
  67. */
  68. sounds: Sound[];
  69. }
  70. /**
  71. * Container with a set of assets that can be added or removed from a scene.
  72. */
  73. class AssetContainer {
  74. /**
  75. * The scene the AssetContainer belongs to.
  76. */
  77. scene: Scene;
  78. /**
  79. * Cameras populated in the container.
  80. */
  81. cameras: Camera[];
  82. /**
  83. * Lights populated in the container.
  84. */
  85. lights: Light[];
  86. /**
  87. * Meshes populated in the container.
  88. */
  89. meshes: AbstractMesh[];
  90. /**
  91. * Skeletons populated in the container.
  92. */
  93. skeletons: Skeleton[];
  94. /**
  95. * ParticleSystems populated in the container.
  96. */
  97. particleSystems: IParticleSystem[];
  98. /**
  99. * Animations populated in the container.
  100. */
  101. animations: Animation[];
  102. /**
  103. * MultiMaterials populated in the container.
  104. */
  105. multiMaterials: MultiMaterial[];
  106. /**
  107. * Materials populated in the container.
  108. */
  109. materials: Material[];
  110. /**
  111. * MorphTargetManagers populated in the container.
  112. */
  113. morphTargetManagers: MorphTargetManager[];
  114. /**
  115. * Geometries populated in the container.
  116. */
  117. geometries: Geometry[];
  118. /**
  119. * TransformNodes populated in the container.
  120. */
  121. transformNodes: TransformNode[];
  122. /**
  123. * LensFlareSystems populated in the container.
  124. */
  125. lensFlareSystems: LensFlareSystem[];
  126. /**
  127. * ShadowGenerators populated in the container.
  128. */
  129. shadowGenerators: ShadowGenerator[];
  130. /**
  131. * ActionManagers populated in the container.
  132. */
  133. actionManagers: ActionManager[];
  134. /**
  135. * Sounds populated in the container.
  136. */
  137. sounds: Sound[];
  138. /**
  139. * Instantiates an AssetContainer.
  140. * @param scene The scene the AssetContainer belongs to.
  141. */
  142. constructor(scene: Scene);
  143. /**
  144. * Adds all the assets from the container to the scene.
  145. */
  146. addAllToScene(): void;
  147. /**
  148. * Removes all the assets in the container from the scene
  149. */
  150. removeAllFromScene(): void;
  151. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  152. /**
  153. * Removes all the assets contained in the scene and adds them to the container.
  154. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  155. */
  156. moveAllFromScene(keepAssets?: KeepAssets): void;
  157. }
  158. }
  159. interface Window {
  160. mozIndexedDB: IDBFactory;
  161. webkitIndexedDB: IDBFactory;
  162. msIndexedDB: IDBFactory;
  163. webkitURL: typeof URL;
  164. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  165. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  166. WebGLRenderingContext: WebGLRenderingContext;
  167. MSGesture: MSGesture;
  168. CANNON: any;
  169. AudioContext: AudioContext;
  170. webkitAudioContext: AudioContext;
  171. PointerEvent: any;
  172. Math: Math;
  173. Uint8Array: Uint8ArrayConstructor;
  174. Float32Array: Float32ArrayConstructor;
  175. mozURL: typeof URL;
  176. msURL: typeof URL;
  177. VRFrameData: any;
  178. DracoDecoderModule: any;
  179. }
  180. interface WebGLRenderingContext {
  181. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  182. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  183. vertexAttribDivisor(index: number, divisor: number): void;
  184. createVertexArray(): any;
  185. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  186. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  187. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  188. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  189. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  190. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  191. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  192. createQuery(): WebGLQuery;
  193. deleteQuery(query: WebGLQuery): void;
  194. beginQuery(target: number, query: WebGLQuery): void;
  195. endQuery(target: number): void;
  196. getQueryParameter(query: WebGLQuery, pname: number): any;
  197. getQuery(target: number, pname: number): any;
  198. MAX_SAMPLES: number;
  199. RGBA8: number;
  200. READ_FRAMEBUFFER: number;
  201. DRAW_FRAMEBUFFER: number;
  202. UNIFORM_BUFFER: number;
  203. HALF_FLOAT_OES: number;
  204. RGBA16F: number;
  205. RGBA32F: number;
  206. R32F: number;
  207. RG32F: number;
  208. RGB32F: number;
  209. RED: number;
  210. RG: number;
  211. UNSIGNED_INT_24_8: number;
  212. DEPTH24_STENCIL8: number;
  213. drawBuffers(buffers: number[]): void;
  214. readBuffer(src: number): void;
  215. readonly COLOR_ATTACHMENT0: number;
  216. readonly COLOR_ATTACHMENT1: number;
  217. readonly COLOR_ATTACHMENT2: number;
  218. readonly COLOR_ATTACHMENT3: number;
  219. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  220. ANY_SAMPLES_PASSED: number;
  221. QUERY_RESULT_AVAILABLE: number;
  222. QUERY_RESULT: number;
  223. }
  224. interface Document {
  225. mozCancelFullScreen(): void;
  226. msCancelFullScreen(): void;
  227. mozFullScreen: boolean;
  228. msIsFullScreen: boolean;
  229. fullscreen: boolean;
  230. mozPointerLockElement: HTMLElement;
  231. msPointerLockElement: HTMLElement;
  232. webkitPointerLockElement: HTMLElement;
  233. }
  234. interface HTMLCanvasElement {
  235. msRequestPointerLock?(): void;
  236. mozRequestPointerLock?(): void;
  237. webkitRequestPointerLock?(): void;
  238. }
  239. interface CanvasRenderingContext2D {
  240. msImageSmoothingEnabled: boolean;
  241. }
  242. interface WebGLBuffer {
  243. references: number;
  244. capacity: number;
  245. is32Bits: boolean;
  246. }
  247. interface WebGLProgram {
  248. transformFeedback?: WebGLTransformFeedback | null;
  249. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  250. }
  251. interface MouseEvent {
  252. mozMovementX: number;
  253. mozMovementY: number;
  254. webkitMovementX: number;
  255. webkitMovementY: number;
  256. msMovementX: number;
  257. msMovementY: number;
  258. }
  259. interface Navigator {
  260. getVRDisplays: () => any;
  261. mozGetVRDevices: (any: any) => any;
  262. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  263. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  264. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  265. webkitGetGamepads(): Gamepad[];
  266. msGetGamepads(): Gamepad[];
  267. webkitGamepads(): Gamepad[];
  268. }
  269. interface HTMLVideoElement {
  270. mozSrcObject: any;
  271. }
  272. interface Screen {
  273. orientation: string;
  274. mozOrientation: string;
  275. }
  276. interface Math {
  277. fround(x: number): number;
  278. imul(a: number, b: number): number;
  279. }
  280. interface GamepadPose {
  281. hasOrientation: boolean;
  282. hasPosition: boolean;
  283. position?: Float32Array;
  284. linearVelocity?: Float32Array;
  285. linearAcceleration?: Float32Array;
  286. orientation?: Float32Array;
  287. angularVelocity?: Float32Array;
  288. angularAcceleration?: Float32Array;
  289. }
  290. interface EXT_disjoint_timer_query {
  291. QUERY_COUNTER_BITS_EXT: number;
  292. TIME_ELAPSED_EXT: number;
  293. TIMESTAMP_EXT: number;
  294. GPU_DISJOINT_EXT: number;
  295. QUERY_RESULT_EXT: number;
  296. QUERY_RESULT_AVAILABLE_EXT: number;
  297. queryCounterEXT(query: WebGLQuery, target: number): void;
  298. createQueryEXT(): WebGLQuery;
  299. beginQueryEXT(target: number, query: WebGLQuery): void;
  300. endQueryEXT(target: number): void;
  301. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  302. deleteQueryEXT(query: WebGLQuery): void;
  303. }
  304. interface WebGLUniformLocation {
  305. _currentState: any;
  306. }
  307. declare module BABYLON {
  308. /**
  309. * Node is the basic class for all scene objects (Mesh, Light Camera).
  310. */
  311. class Node {
  312. /**
  313. * Gets or sets the name of the node
  314. */
  315. name: string;
  316. /**
  317. * Gets or sets the id of the node
  318. */
  319. id: string;
  320. /**
  321. * Gets or sets the unique id of the node
  322. */
  323. uniqueId: number;
  324. /**
  325. * Gets or sets a string used to store user defined state for the node
  326. */
  327. state: string;
  328. /**
  329. * Gets or sets an object used to store user defined information for the node
  330. */
  331. metadata: any;
  332. /**
  333. * Gets or sets a boolean used to define if the node must be serialized
  334. */
  335. doNotSerialize: boolean;
  336. /** @ignore */
  337. _isDisposed: boolean;
  338. /**
  339. * Gets a list of {BABYLON.Animation} associated with the node
  340. */
  341. animations: Animation[];
  342. private _ranges;
  343. /**
  344. * Callback raised when the node is ready to be used
  345. */
  346. onReady: (node: Node) => void;
  347. private _isEnabled;
  348. private _isReady;
  349. /** @ignore */
  350. _currentRenderId: number;
  351. private _parentRenderId;
  352. /** @ignore */
  353. _waitingParentId: Nullable<string>;
  354. private _scene;
  355. /** @ignore */
  356. _cache: any;
  357. private _parentNode;
  358. private _children;
  359. /**
  360. * Gets a boolean indicating if the node has been disposed
  361. * @returns true if the node was disposed
  362. */
  363. isDisposed(): boolean;
  364. /**
  365. * Gets or sets the parent of the node
  366. */
  367. parent: Nullable<Node>;
  368. private _animationPropertiesOverride;
  369. /**
  370. * Gets or sets the animation properties override
  371. */
  372. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  373. /**
  374. * Gets a string idenfifying the name of the class
  375. * @returns "Node" string
  376. */
  377. getClassName(): string;
  378. /**
  379. * An event triggered when the mesh is disposed
  380. * @type {BABYLON.Observable}
  381. */
  382. onDisposeObservable: Observable<Node>;
  383. private _onDisposeObserver;
  384. /**
  385. * Sets a callback that will be raised when the node will be disposed
  386. */
  387. onDispose: () => void;
  388. /**
  389. * Creates a new Node
  390. * @param {string} name - the name and id to be given to this node
  391. * @param {BABYLON.Scene} the scene this node will be added to
  392. */
  393. constructor(name: string, scene?: Nullable<Scene>);
  394. /**
  395. * Gets the scene of the node
  396. * @returns a {BABYLON.Scene}
  397. */
  398. getScene(): Scene;
  399. /**
  400. * Gets the engine of the node
  401. * @returns a {BABYLON.Engine}
  402. */
  403. getEngine(): Engine;
  404. private _behaviors;
  405. /**
  406. * Attach a behavior to the node
  407. * @see http://doc.babylonjs.com/features/behaviour
  408. * @param behavior defines the behavior to attach
  409. * @returns the current Node
  410. */
  411. addBehavior(behavior: Behavior<Node>): Node;
  412. /**
  413. * Remove an attached behavior
  414. * @see http://doc.babylonjs.com/features/behaviour
  415. * @param behavior defines the behavior to attach
  416. * @returns the current Node
  417. */
  418. removeBehavior(behavior: Behavior<Node>): Node;
  419. /**
  420. * Gets the list of attached behaviors
  421. * @see http://doc.babylonjs.com/features/behaviour
  422. */
  423. readonly behaviors: Behavior<Node>[];
  424. /**
  425. * Gets an attached behavior by name
  426. * @param name defines the name of the behavior to look for
  427. * @see http://doc.babylonjs.com/features/behaviour
  428. * @returns null if behavior was not found else the requested behavior
  429. */
  430. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  431. /**
  432. * Returns the world matrix of the node
  433. * @returns a matrix containing the node's world matrix
  434. */
  435. getWorldMatrix(): Matrix;
  436. /** @ignore */
  437. _initCache(): void;
  438. /** @ignore */
  439. updateCache(force?: boolean): void;
  440. /** @ignore */
  441. _updateCache(ignoreParentClass?: boolean): void;
  442. /** @ignore */
  443. _isSynchronized(): boolean;
  444. /** @ignore */
  445. _markSyncedWithParent(): void;
  446. /** @ignore */
  447. isSynchronizedWithParent(): boolean;
  448. /** @ignore */
  449. isSynchronized(updateCache?: boolean): boolean;
  450. /** @ignore */
  451. hasNewParent(update?: boolean): boolean;
  452. /**
  453. * Is this node ready to be used/rendered
  454. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  455. * @return true if the node is ready
  456. */
  457. isReady(completeCheck?: boolean): boolean;
  458. /**
  459. * Is this node enabled?
  460. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  461. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  462. * @return whether this node (and its parent) is enabled
  463. * @see setEnabled
  464. */
  465. isEnabled(checkAncestors?: boolean): boolean;
  466. /**
  467. * Set the enabled state of this node
  468. * @param value defines the new enabled state
  469. * @see isEnabled
  470. */
  471. setEnabled(value: boolean): void;
  472. /**
  473. * Is this node a descendant of the given node?
  474. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  475. * @param ancestor defines the parent node to inspect
  476. * @see parent
  477. * @returns a boolean indicating if this node is a descendant of the given node
  478. */
  479. isDescendantOf(ancestor: Node): boolean;
  480. /** @ignore */
  481. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  482. /**
  483. * Will return all nodes that have this node as ascendant
  484. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  485. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  486. * @return all children nodes of all types
  487. */
  488. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  489. /**
  490. * Get all child-meshes of this node
  491. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  492. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  493. * @returns an array of {BABYLON.AbstractMesh}
  494. */
  495. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  496. /**
  497. * Get all child-transformNodes of this node
  498. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  499. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  500. * @returns an array of {BABYLON.TransformNode}
  501. */
  502. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  503. /**
  504. * Get all direct children of this node
  505. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  506. * @returns an array of {BABYLON.Node}
  507. */
  508. getChildren(predicate?: (node: Node) => boolean): Node[];
  509. /** @ignore */
  510. _setReady(state: boolean): void;
  511. /**
  512. * Get an animation by name
  513. * @param name defines the name of the animation to look for
  514. * @returns null if not found else the requested animation
  515. */
  516. getAnimationByName(name: string): Nullable<Animation>;
  517. /**
  518. * Creates an animation range for this node
  519. * @param name defines the name of the range
  520. * @param from defines the starting key
  521. * @param to defines the end key
  522. */
  523. createAnimationRange(name: string, from: number, to: number): void;
  524. /**
  525. * Delete a specific animation range
  526. * @param name defines the name of the range to delete
  527. * @param deleteFrames defines if animation frames from the range must be deleted as well
  528. */
  529. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  530. /**
  531. * Get an animation range by name
  532. * @param name defines the name of the animation range to look for
  533. * @returns null if not found else the requested animation range
  534. */
  535. getAnimationRange(name: string): Nullable<AnimationRange>;
  536. /**
  537. * Will start the animation sequence
  538. * @param name defines the range frames for animation sequence
  539. * @param loop defines if the animation should loop (false by default)
  540. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  541. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  542. * @returns the object created for this animation. If range does not exist, it will return null
  543. */
  544. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  545. /**
  546. * Serialize animation ranges into a JSON compatible object
  547. * @returns serialization object
  548. */
  549. serializeAnimationRanges(): any;
  550. /**
  551. * Computes the world matrix of the node
  552. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  553. * @returns the world matrix
  554. */
  555. computeWorldMatrix(force?: boolean): Matrix;
  556. /**
  557. * Releases resources associated with this node.
  558. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  559. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  560. */
  561. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  562. /**
  563. * Parse animation range data from a serialization object and store them into a given node
  564. * @param node defines where to store the animation ranges
  565. * @param parsedNode defines the serialization object to read data from
  566. * @param scene defines the hosting scene
  567. */
  568. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  569. }
  570. }
  571. declare module BABYLON {
  572. interface IDisposable {
  573. dispose(): void;
  574. }
  575. interface IActiveMeshCandidateProvider {
  576. getMeshes(scene: Scene): AbstractMesh[];
  577. readonly checksIsEnabled: boolean;
  578. }
  579. /**
  580. * This class is used by the onRenderingGroupObservable
  581. */
  582. class RenderingGroupInfo {
  583. /**
  584. * The Scene that being rendered
  585. */
  586. scene: Scene;
  587. /**
  588. * The camera currently used for the rendering pass
  589. */
  590. camera: Nullable<Camera>;
  591. /**
  592. * The ID of the renderingGroup being processed
  593. */
  594. renderingGroupId: number;
  595. /**
  596. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  597. */
  598. renderStage: number;
  599. /**
  600. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  601. * This stage will be fired no matter what
  602. */
  603. static STAGE_PRECLEAR: number;
  604. /**
  605. * Called before opaque object are rendered.
  606. * This stage will be fired only if there's 3D Opaque content to render
  607. */
  608. static STAGE_PREOPAQUE: number;
  609. /**
  610. * Called after the opaque objects are rendered and before the transparent ones
  611. * This stage will be fired only if there's 3D transparent content to render
  612. */
  613. static STAGE_PRETRANSPARENT: number;
  614. /**
  615. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  616. * This stage will be fired no matter what
  617. */
  618. static STAGE_POSTTRANSPARENT: number;
  619. }
  620. /**
  621. * Represents a scene to be rendered by the engine.
  622. * @see http://doc.babylonjs.com/page.php?p=21911
  623. */
  624. class Scene implements IAnimatable {
  625. private static _FOGMODE_NONE;
  626. private static _FOGMODE_EXP;
  627. private static _FOGMODE_EXP2;
  628. private static _FOGMODE_LINEAR;
  629. private static _uniqueIdCounter;
  630. static MinDeltaTime: number;
  631. static MaxDeltaTime: number;
  632. /** The fog is deactivated */
  633. static readonly FOGMODE_NONE: number;
  634. /** The fog density is following an exponential function */
  635. static readonly FOGMODE_EXP: number;
  636. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  637. static readonly FOGMODE_EXP2: number;
  638. /** The fog density is following a linear function. */
  639. static readonly FOGMODE_LINEAR: number;
  640. autoClear: boolean;
  641. autoClearDepthAndStencil: boolean;
  642. clearColor: Color4;
  643. ambientColor: Color3;
  644. _environmentBRDFTexture: BaseTexture;
  645. protected _environmentTexture: BaseTexture;
  646. /**
  647. * Texture used in all pbr material as the reflection texture.
  648. * As in the majority of the scene they are the same (exception for multi room and so on),
  649. * this is easier to reference from here than from all the materials.
  650. */
  651. /**
  652. * Texture used in all pbr material as the reflection texture.
  653. * As in the majority of the scene they are the same (exception for multi room and so on),
  654. * this is easier to set here than in all the materials.
  655. */
  656. environmentTexture: BaseTexture;
  657. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  658. /**
  659. * Default image processing configuration used either in the rendering
  660. * Forward main pass or through the imageProcessingPostProcess if present.
  661. * As in the majority of the scene they are the same (exception for multi camera),
  662. * this is easier to reference from here than from all the materials and post process.
  663. *
  664. * No setter as we it is a shared configuration, you can set the values instead.
  665. */
  666. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  667. private _forceWireframe;
  668. forceWireframe: boolean;
  669. private _forcePointsCloud;
  670. forcePointsCloud: boolean;
  671. forceShowBoundingBoxes: boolean;
  672. clipPlane: Nullable<Plane>;
  673. animationsEnabled: boolean;
  674. useConstantAnimationDeltaTime: boolean;
  675. constantlyUpdateMeshUnderPointer: boolean;
  676. hoverCursor: string;
  677. defaultCursor: string;
  678. /**
  679. * This is used to call preventDefault() on pointer down
  680. * in order to block unwanted artifacts like system double clicks
  681. */
  682. preventDefaultOnPointerDown: boolean;
  683. metadata: any;
  684. loadingPluginName: string;
  685. private _spritePredicate;
  686. /**
  687. * An event triggered when the scene is disposed.
  688. * @type {BABYLON.Observable}
  689. */
  690. onDisposeObservable: Observable<Scene>;
  691. private _onDisposeObserver;
  692. /** A function to be executed when this scene is disposed. */
  693. onDispose: () => void;
  694. /**
  695. * An event triggered before rendering the scene (right after animations and physics)
  696. * @type {BABYLON.Observable}
  697. */
  698. onBeforeRenderObservable: Observable<Scene>;
  699. private _onBeforeRenderObserver;
  700. /** A function to be executed before rendering this scene */
  701. beforeRender: Nullable<() => void>;
  702. /**
  703. * An event triggered after rendering the scene
  704. * @type {BABYLON.Observable}
  705. */
  706. onAfterRenderObservable: Observable<Scene>;
  707. private _onAfterRenderObserver;
  708. /** A function to be executed after rendering this scene */
  709. afterRender: Nullable<() => void>;
  710. /**
  711. * An event triggered before animating the scene
  712. * @type {BABYLON.Observable}
  713. */
  714. onBeforeAnimationsObservable: Observable<Scene>;
  715. /**
  716. * An event triggered after animations processing
  717. * @type {BABYLON.Observable}
  718. */
  719. onAfterAnimationsObservable: Observable<Scene>;
  720. /**
  721. * An event triggered before draw calls are ready to be sent
  722. * @type {BABYLON.Observable}
  723. */
  724. onBeforeDrawPhaseObservable: Observable<Scene>;
  725. /**
  726. * An event triggered after draw calls have been sent
  727. * @type {BABYLON.Observable}
  728. */
  729. onAfterDrawPhaseObservable: Observable<Scene>;
  730. /**
  731. * An event triggered when physic simulation is about to be run
  732. * @type {BABYLON.Observable}
  733. */
  734. onBeforePhysicsObservable: Observable<Scene>;
  735. /**
  736. * An event triggered when physic simulation has been done
  737. * @type {BABYLON.Observable}
  738. */
  739. onAfterPhysicsObservable: Observable<Scene>;
  740. /**
  741. * An event triggered when the scene is ready
  742. * @type {BABYLON.Observable}
  743. */
  744. onReadyObservable: Observable<Scene>;
  745. /**
  746. * An event triggered before rendering a camera
  747. * @type {BABYLON.Observable}
  748. */
  749. onBeforeCameraRenderObservable: Observable<Camera>;
  750. private _onBeforeCameraRenderObserver;
  751. beforeCameraRender: () => void;
  752. /**
  753. * An event triggered after rendering a camera
  754. * @type {BABYLON.Observable}
  755. */
  756. onAfterCameraRenderObservable: Observable<Camera>;
  757. private _onAfterCameraRenderObserver;
  758. afterCameraRender: () => void;
  759. /**
  760. * An event triggered when active meshes evaluation is about to start
  761. * @type {BABYLON.Observable}
  762. */
  763. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  764. /**
  765. * An event triggered when active meshes evaluation is done
  766. * @type {BABYLON.Observable}
  767. */
  768. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  769. /**
  770. * An event triggered when particles rendering is about to start
  771. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  772. * @type {BABYLON.Observable}
  773. */
  774. onBeforeParticlesRenderingObservable: Observable<Scene>;
  775. /**
  776. * An event triggered when particles rendering is done
  777. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  778. * @type {BABYLON.Observable}
  779. */
  780. onAfterParticlesRenderingObservable: Observable<Scene>;
  781. /**
  782. * An event triggered when sprites rendering is about to start
  783. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  784. * @type {BABYLON.Observable}
  785. */
  786. onBeforeSpritesRenderingObservable: Observable<Scene>;
  787. /**
  788. * An event triggered when sprites rendering is done
  789. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  790. * @type {BABYLON.Observable}
  791. */
  792. onAfterSpritesRenderingObservable: Observable<Scene>;
  793. /**
  794. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  795. * @type {BABYLON.Observable}
  796. */
  797. onDataLoadedObservable: Observable<Scene>;
  798. /**
  799. * An event triggered when a camera is created
  800. * @type {BABYLON.Observable}
  801. */
  802. onNewCameraAddedObservable: Observable<Camera>;
  803. /**
  804. * An event triggered when a camera is removed
  805. * @type {BABYLON.Observable}
  806. */
  807. onCameraRemovedObservable: Observable<Camera>;
  808. /**
  809. * An event triggered when a light is created
  810. * @type {BABYLON.Observable}
  811. */
  812. onNewLightAddedObservable: Observable<Light>;
  813. /**
  814. * An event triggered when a light is removed
  815. * @type {BABYLON.Observable}
  816. */
  817. onLightRemovedObservable: Observable<Light>;
  818. /**
  819. * An event triggered when a geometry is created
  820. * @type {BABYLON.Observable}
  821. */
  822. onNewGeometryAddedObservable: Observable<Geometry>;
  823. /**
  824. * An event triggered when a geometry is removed
  825. * @type {BABYLON.Observable}
  826. */
  827. onGeometryRemovedObservable: Observable<Geometry>;
  828. /**
  829. * An event triggered when a transform node is created
  830. * @type {BABYLON.Observable}
  831. */
  832. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  833. /**
  834. * An event triggered when a transform node is removed
  835. * @type {BABYLON.Observable}
  836. */
  837. onTransformNodeRemovedObservable: Observable<TransformNode>;
  838. /**
  839. * An event triggered when a mesh is created
  840. * @type {BABYLON.Observable}
  841. */
  842. onNewMeshAddedObservable: Observable<AbstractMesh>;
  843. /**
  844. * An event triggered when a mesh is removed
  845. * @type {BABYLON.Observable}
  846. */
  847. onMeshRemovedObservable: Observable<AbstractMesh>;
  848. /**
  849. * An event triggered when render targets are about to be rendered
  850. * Can happen multiple times per frame.
  851. * @type {BABYLON.Observable}
  852. */
  853. OnBeforeRenderTargetsRenderObservable: Observable<Scene>;
  854. /**
  855. * An event triggered when render targets were rendered.
  856. * Can happen multiple times per frame.
  857. * @type {BABYLON.Observable}
  858. */
  859. OnAfterRenderTargetsRenderObservable: Observable<Scene>;
  860. /**
  861. * An event triggered before calculating deterministic simulation step
  862. * @type {BABYLON.Observable}
  863. */
  864. onBeforeStepObservable: Observable<Scene>;
  865. /**
  866. * An event triggered after calculating deterministic simulation step
  867. * @type {BABYLON.Observable}
  868. */
  869. onAfterStepObservable: Observable<Scene>;
  870. /**
  871. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  872. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  873. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  874. */
  875. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  876. animations: Animation[];
  877. private _registeredForLateAnimationBindings;
  878. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  879. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  880. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  881. private _onPointerMove;
  882. private _onPointerDown;
  883. private _onPointerUp;
  884. /** Deprecated. Use onPointerObservable instead */
  885. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  886. /** Deprecated. Use onPointerObservable instead */
  887. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  888. /** Deprecated. Use onPointerObservable instead */
  889. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  890. /** Deprecated. Use onPointerObservable instead */
  891. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  892. private _gamepadManager;
  893. readonly gamepadManager: GamepadManager;
  894. /**
  895. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  896. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  897. */
  898. onPrePointerObservable: Observable<PointerInfoPre>;
  899. /**
  900. * Observable event triggered each time an input event is received from the rendering canvas
  901. */
  902. onPointerObservable: Observable<PointerInfo>;
  903. readonly unTranslatedPointer: Vector2;
  904. /** The distance in pixel that you have to move to prevent some events */
  905. static DragMovementThreshold: number;
  906. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  907. static LongPressDelay: number;
  908. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  909. static DoubleClickDelay: number;
  910. /** If you need to check double click without raising a single click at first click, enable this flag */
  911. static ExclusiveDoubleClickMode: boolean;
  912. private _initClickEvent;
  913. private _initActionManager;
  914. private _delayedSimpleClick;
  915. private _delayedSimpleClickTimeout;
  916. private _previousDelayedSimpleClickTimeout;
  917. private _meshPickProceed;
  918. private _previousButtonPressed;
  919. private _currentPickResult;
  920. private _previousPickResult;
  921. private _totalPointersPressed;
  922. private _doubleClickOccured;
  923. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  924. cameraToUseForPointers: Nullable<Camera>;
  925. private _pointerX;
  926. private _pointerY;
  927. private _unTranslatedPointerX;
  928. private _unTranslatedPointerY;
  929. private _startingPointerPosition;
  930. private _previousStartingPointerPosition;
  931. private _startingPointerTime;
  932. private _previousStartingPointerTime;
  933. private _timeAccumulator;
  934. private _currentStepId;
  935. private _currentInternalStep;
  936. _mirroredCameraPosition: Nullable<Vector3>;
  937. /**
  938. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  939. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  940. */
  941. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  942. /**
  943. * Observable event triggered each time an keyboard event is received from the hosting window
  944. */
  945. onKeyboardObservable: Observable<KeyboardInfo>;
  946. private _onKeyDown;
  947. private _onKeyUp;
  948. private _onCanvasFocusObserver;
  949. private _onCanvasBlurObserver;
  950. /**
  951. * use right-handed coordinate system on this scene.
  952. * @type {boolean}
  953. */
  954. private _useRightHandedSystem;
  955. useRightHandedSystem: boolean;
  956. setStepId(newStepId: number): void;
  957. getStepId(): number;
  958. getInternalStep(): number;
  959. private _fogEnabled;
  960. /**
  961. * is fog enabled on this scene.
  962. */
  963. fogEnabled: boolean;
  964. private _fogMode;
  965. fogMode: number;
  966. fogColor: Color3;
  967. fogDensity: number;
  968. fogStart: number;
  969. fogEnd: number;
  970. /**
  971. * is shadow enabled on this scene.
  972. * @type {boolean}
  973. */
  974. private _shadowsEnabled;
  975. shadowsEnabled: boolean;
  976. /**
  977. * is light enabled on this scene.
  978. * @type {boolean}
  979. */
  980. private _lightsEnabled;
  981. lightsEnabled: boolean;
  982. /**
  983. * All of the lights added to this scene.
  984. * @see BABYLON.Light
  985. * @type {BABYLON.Light[]}
  986. */
  987. lights: Light[];
  988. /** All of the cameras added to this scene. */
  989. cameras: Camera[];
  990. /** All of the active cameras added to this scene. */
  991. activeCameras: Camera[];
  992. /** The current active camera */
  993. activeCamera: Nullable<Camera>;
  994. /**
  995. * All of the tranform nodes added to this scene.
  996. * @see BABYLON.TransformNode
  997. * @type {BABYLON.TransformNode[]}
  998. */
  999. transformNodes: TransformNode[];
  1000. /**
  1001. * All of the (abstract) meshes added to this scene.
  1002. * @see BABYLON.AbstractMesh
  1003. * @type {BABYLON.AbstractMesh[]}
  1004. */
  1005. meshes: AbstractMesh[];
  1006. /**
  1007. * All of the animation groups added to this scene.
  1008. * @see BABYLON.AnimationGroup
  1009. * @type {BABYLON.AnimationGroup[]}
  1010. */
  1011. animationGroups: AnimationGroup[];
  1012. private _geometries;
  1013. materials: Material[];
  1014. multiMaterials: MultiMaterial[];
  1015. private _defaultMaterial;
  1016. /** The default material used on meshes when no material is affected */
  1017. /** The default material used on meshes when no material is affected */
  1018. defaultMaterial: Material;
  1019. private _texturesEnabled;
  1020. texturesEnabled: boolean;
  1021. textures: BaseTexture[];
  1022. particlesEnabled: boolean;
  1023. particleSystems: IParticleSystem[];
  1024. spritesEnabled: boolean;
  1025. spriteManagers: SpriteManager[];
  1026. /**
  1027. * The list of layers (background and foreground) of the scene.
  1028. */
  1029. layers: Layer[];
  1030. /**
  1031. * The list of effect layers (highlights/glow) contained in the scene.
  1032. */
  1033. effectLayers: EffectLayer[];
  1034. private _skeletonsEnabled;
  1035. skeletonsEnabled: boolean;
  1036. skeletons: Skeleton[];
  1037. morphTargetManagers: MorphTargetManager[];
  1038. lensFlaresEnabled: boolean;
  1039. lensFlareSystems: LensFlareSystem[];
  1040. collisionsEnabled: boolean;
  1041. private _workerCollisions;
  1042. collisionCoordinator: ICollisionCoordinator;
  1043. /** Defines the gravity applied to this scene */
  1044. gravity: Vector3;
  1045. postProcesses: PostProcess[];
  1046. postProcessesEnabled: boolean;
  1047. postProcessManager: PostProcessManager;
  1048. private _postProcessRenderPipelineManager;
  1049. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1050. renderTargetsEnabled: boolean;
  1051. dumpNextRenderTargets: boolean;
  1052. customRenderTargets: RenderTargetTexture[];
  1053. useDelayedTextureLoading: boolean;
  1054. importedMeshesFiles: String[];
  1055. probesEnabled: boolean;
  1056. reflectionProbes: ReflectionProbe[];
  1057. database: Database;
  1058. /**
  1059. * This scene's action manager
  1060. * @type {BABYLON.ActionManager}
  1061. */
  1062. actionManager: ActionManager;
  1063. _actionManagers: ActionManager[];
  1064. private _meshesForIntersections;
  1065. proceduralTexturesEnabled: boolean;
  1066. _proceduralTextures: ProceduralTexture[];
  1067. private _mainSoundTrack;
  1068. soundTracks: SoundTrack[];
  1069. private _audioEnabled;
  1070. private _headphone;
  1071. readonly mainSoundTrack: SoundTrack;
  1072. VRHelper: VRExperienceHelper;
  1073. simplificationQueue: SimplificationQueue;
  1074. private _engine;
  1075. private _totalVertices;
  1076. _activeIndices: PerfCounter;
  1077. _activeParticles: PerfCounter;
  1078. _activeBones: PerfCounter;
  1079. private _animationRatio;
  1080. private _animationTimeLast;
  1081. private _animationTime;
  1082. animationTimeScale: number;
  1083. _cachedMaterial: Nullable<Material>;
  1084. _cachedEffect: Nullable<Effect>;
  1085. _cachedVisibility: Nullable<number>;
  1086. private _renderId;
  1087. private _executeWhenReadyTimeoutId;
  1088. private _intermediateRendering;
  1089. private _viewUpdateFlag;
  1090. private _projectionUpdateFlag;
  1091. private _alternateViewUpdateFlag;
  1092. private _alternateProjectionUpdateFlag;
  1093. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1094. private _activeRequests;
  1095. private _pendingData;
  1096. private _isDisposed;
  1097. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1098. private _activeMeshes;
  1099. private _processedMaterials;
  1100. private _renderTargets;
  1101. _activeParticleSystems: SmartArray<IParticleSystem>;
  1102. private _activeSkeletons;
  1103. private _softwareSkinnedMeshes;
  1104. private _renderingManager;
  1105. private _physicsEngine;
  1106. _activeAnimatables: Animatable[];
  1107. private _transformMatrix;
  1108. private _sceneUbo;
  1109. private _alternateSceneUbo;
  1110. private _pickWithRayInverseMatrix;
  1111. private _boundingBoxRenderer;
  1112. private _outlineRenderer;
  1113. private _viewMatrix;
  1114. private _projectionMatrix;
  1115. private _alternateViewMatrix;
  1116. private _alternateProjectionMatrix;
  1117. private _alternateTransformMatrix;
  1118. private _useAlternateCameraConfiguration;
  1119. private _alternateRendering;
  1120. _forcedViewPosition: Nullable<Vector3>;
  1121. readonly _isAlternateRenderingEnabled: boolean;
  1122. private _frustumPlanes;
  1123. readonly frustumPlanes: Plane[];
  1124. requireLightSorting: boolean;
  1125. private _selectionOctree;
  1126. private _pointerOverMesh;
  1127. private _pointerOverSprite;
  1128. private _debugLayer;
  1129. private _depthRenderer;
  1130. private _geometryBufferRenderer;
  1131. /**
  1132. * Gets the current geometry buffer associated to the scene.
  1133. */
  1134. /**
  1135. * Sets the current geometry buffer for the scene.
  1136. */
  1137. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1138. private _pickedDownMesh;
  1139. private _pickedUpMesh;
  1140. private _pickedDownSprite;
  1141. private _externalData;
  1142. private _uid;
  1143. /**
  1144. * @constructor
  1145. * @param {BABYLON.Engine} engine - the engine to be used to render this scene.
  1146. */
  1147. constructor(engine: Engine);
  1148. readonly debugLayer: DebugLayer;
  1149. workerCollisions: boolean;
  1150. readonly selectionOctree: Octree<AbstractMesh>;
  1151. /**
  1152. * The mesh that is currently under the pointer.
  1153. * @return {BABYLON.AbstractMesh} mesh under the pointer/mouse cursor or null if none.
  1154. */
  1155. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1156. /**
  1157. * Current on-screen X position of the pointer
  1158. * @return {number} X position of the pointer
  1159. */
  1160. readonly pointerX: number;
  1161. /**
  1162. * Current on-screen Y position of the pointer
  1163. * @return {number} Y position of the pointer
  1164. */
  1165. readonly pointerY: number;
  1166. getCachedMaterial(): Nullable<Material>;
  1167. getCachedEffect(): Nullable<Effect>;
  1168. getCachedVisibility(): Nullable<number>;
  1169. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1170. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1171. getOutlineRenderer(): OutlineRenderer;
  1172. getEngine(): Engine;
  1173. getTotalVertices(): number;
  1174. readonly totalVerticesPerfCounter: PerfCounter;
  1175. getActiveIndices(): number;
  1176. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1177. getActiveParticles(): number;
  1178. readonly activeParticlesPerfCounter: PerfCounter;
  1179. getActiveBones(): number;
  1180. readonly activeBonesPerfCounter: PerfCounter;
  1181. getInterFramePerfCounter(): number;
  1182. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1183. getLastFrameDuration(): number;
  1184. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1185. getEvaluateActiveMeshesDuration(): number;
  1186. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1187. getActiveMeshes(): SmartArray<AbstractMesh>;
  1188. getRenderTargetsDuration(): number;
  1189. getRenderDuration(): number;
  1190. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1191. getParticlesDuration(): number;
  1192. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1193. getSpritesDuration(): number;
  1194. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1195. getAnimationRatio(): number;
  1196. getRenderId(): number;
  1197. incrementRenderId(): void;
  1198. private _updatePointerPosition(evt);
  1199. private _createUbo();
  1200. private _createAlternateUbo();
  1201. /**
  1202. * Use this method to simulate a pointer move on a mesh
  1203. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1204. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1205. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1206. */
  1207. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1208. private _processPointerMove(pickResult, evt);
  1209. /**
  1210. * Use this method to simulate a pointer down on a mesh
  1211. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1212. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1213. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1214. */
  1215. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1216. private _processPointerDown(pickResult, evt);
  1217. /**
  1218. * Use this method to simulate a pointer up on a mesh
  1219. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1220. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1221. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1222. */
  1223. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1224. private _processPointerUp(pickResult, evt, clickInfo);
  1225. /**
  1226. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1227. * @param attachUp defines if you want to attach events to pointerup
  1228. * @param attachDown defines if you want to attach events to pointerdown
  1229. * @param attachMove defines if you want to attach events to pointermove
  1230. */
  1231. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1232. detachControl(): void;
  1233. /**
  1234. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1235. * Delay loaded resources are not taking in account
  1236. * @return true if all required resources are ready
  1237. */
  1238. isReady(): boolean;
  1239. resetCachedMaterial(): void;
  1240. registerBeforeRender(func: () => void): void;
  1241. unregisterBeforeRender(func: () => void): void;
  1242. registerAfterRender(func: () => void): void;
  1243. unregisterAfterRender(func: () => void): void;
  1244. private _executeOnceBeforeRender(func);
  1245. /**
  1246. * The provided function will run before render once and will be disposed afterwards.
  1247. * A timeout delay can be provided so that the function will be executed in N ms.
  1248. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1249. * @param func The function to be executed.
  1250. * @param timeout optional delay in ms
  1251. */
  1252. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1253. _addPendingData(data: any): void;
  1254. _removePendingData(data: any): void;
  1255. getWaitingItemsCount(): number;
  1256. readonly isLoading: boolean;
  1257. /**
  1258. * Registers a function to be executed when the scene is ready.
  1259. * @param {Function} func - the function to be executed.
  1260. */
  1261. executeWhenReady(func: () => void): void;
  1262. /**
  1263. * Returns a promise that resolves when the scene is ready.
  1264. * @returns A promise that resolves when the scene is ready.
  1265. */
  1266. whenReadyAsync(): Promise<void>;
  1267. _checkIsReady(): void;
  1268. /**
  1269. * Will start the animation sequence of a given target
  1270. * @param target defines the target
  1271. * @param from defines from which frame should animation start
  1272. * @param to defines until which frame should animation run.
  1273. * @param weight defines the weight to apply to the animation (1.0 by default)
  1274. * @param loop defines if the animation loops
  1275. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1276. * @param onAnimationEnd defines the function to be executed when the animation ends
  1277. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1278. * @returns the animatable object created for this animation
  1279. * @see BABYLON.Animatable
  1280. */
  1281. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1282. /**
  1283. * Will start the animation sequence of a given target
  1284. * @param target defines the target
  1285. * @param from defines from which frame should animation start
  1286. * @param to defines until which frame should animation run.
  1287. * @param loop defines if the animation loops
  1288. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1289. * @param onAnimationEnd defines the function to be executed when the animation ends
  1290. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1291. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1292. * @returns the animatable object created for this animation
  1293. * @see BABYLON.Animatable
  1294. */
  1295. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1296. /**
  1297. * Begin a new animation on a given node
  1298. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1299. * @param {BABYLON.Animation[]} defines the list of animations to start
  1300. * @param {number} from defines the initial value
  1301. * @param {number} to defines the final value
  1302. * @param {boolean} loop defines if you want animation to loop (off by default)
  1303. * @param {number} speedRatio defines the speed ratio to apply to all animations
  1304. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1305. * @returns the list of created animatables
  1306. */
  1307. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1308. /**
  1309. * Begin a new animation on a given node and its hierarchy
  1310. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1311. * @param {boolean} directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1312. * @param {BABYLON.Animation[]} defines the list of animations to start
  1313. * @param {number} from defines the initial value
  1314. * @param {number} to defines the final value
  1315. * @param {boolean} loop defines if you want animation to loop (off by default)
  1316. * @param {number} speedRatio defines the speed ratio to apply to all animations
  1317. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1318. * @returns the list of animatables created for all nodes
  1319. */
  1320. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1321. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1322. /**
  1323. * Gets all animatables associated with a given target
  1324. * @param target defines the target to look animatables for
  1325. * @returns an array of Animatables
  1326. */
  1327. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1328. readonly animatables: Animatable[];
  1329. /**
  1330. * Will stop the animation of the given target
  1331. * @param target - the target
  1332. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1333. * @see beginAnimation
  1334. */
  1335. stopAnimation(target: any, animationName?: string): void;
  1336. /**
  1337. * Stops and removes all animations that have been applied to the scene
  1338. */
  1339. stopAllAnimations(): void;
  1340. private _animate();
  1341. /** @ignore */
  1342. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation): void;
  1343. private _processLateAnimationBindings();
  1344. _switchToAlternateCameraConfiguration(active: boolean): void;
  1345. getViewMatrix(): Matrix;
  1346. getProjectionMatrix(): Matrix;
  1347. getTransformMatrix(): Matrix;
  1348. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1349. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1350. getSceneUniformBuffer(): UniformBuffer;
  1351. getUniqueId(): number;
  1352. addMesh(newMesh: AbstractMesh): void;
  1353. removeMesh(toRemove: AbstractMesh): number;
  1354. addTransformNode(newTransformNode: TransformNode): void;
  1355. removeTransformNode(toRemove: TransformNode): number;
  1356. removeSkeleton(toRemove: Skeleton): number;
  1357. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1358. removeLight(toRemove: Light): number;
  1359. removeCamera(toRemove: Camera): number;
  1360. removeParticleSystem(toRemove: IParticleSystem): number;
  1361. removeAnimation(toRemove: Animation): number;
  1362. removeMultiMaterial(toRemove: MultiMaterial): number;
  1363. removeMaterial(toRemove: Material): number;
  1364. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1365. removeActionManager(toRemove: ActionManager): number;
  1366. addLight(newLight: Light): void;
  1367. sortLightsByPriority(): void;
  1368. addCamera(newCamera: Camera): void;
  1369. addSkeleton(newSkeleton: Skeleton): void;
  1370. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1371. addAnimation(newAnimation: Animation): void;
  1372. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1373. addMaterial(newMaterial: Material): void;
  1374. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1375. addGeometry(newGeometrie: Geometry): void;
  1376. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1377. addActionManager(newActionManager: ActionManager): void;
  1378. /**
  1379. * Switch active camera
  1380. * @param {Camera} newCamera - new active camera
  1381. * @param {boolean} attachControl - call attachControl for the new active camera (default: true)
  1382. */
  1383. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1384. /**
  1385. * sets the active camera of the scene using its ID
  1386. * @param {string} id - the camera's ID
  1387. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1388. * @see activeCamera
  1389. */
  1390. setActiveCameraByID(id: string): Nullable<Camera>;
  1391. /**
  1392. * sets the active camera of the scene using its name
  1393. * @param {string} name - the camera's name
  1394. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1395. * @see activeCamera
  1396. */
  1397. setActiveCameraByName(name: string): Nullable<Camera>;
  1398. /**
  1399. * get an animation group using its name
  1400. * @param {string} the material's name
  1401. * @return {BABYLON.AnimationGroup|null} the animation group or null if none found.
  1402. */
  1403. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1404. /**
  1405. * get a material using its id
  1406. * @param {string} the material's ID
  1407. * @return {BABYLON.Material|null} the material or null if none found.
  1408. */
  1409. getMaterialByID(id: string): Nullable<Material>;
  1410. /**
  1411. * get a material using its name
  1412. * @param {string} the material's name
  1413. * @return {BABYLON.Material|null} the material or null if none found.
  1414. */
  1415. getMaterialByName(name: string): Nullable<Material>;
  1416. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  1417. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  1418. getCameraByID(id: string): Nullable<Camera>;
  1419. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1420. /**
  1421. * get a camera using its name
  1422. * @param {string} the camera's name
  1423. * @return {BABYLON.Camera|null} the camera or null if none found.
  1424. */
  1425. getCameraByName(name: string): Nullable<Camera>;
  1426. /**
  1427. * get a bone using its id
  1428. * @param {string} the bone's id
  1429. * @return {BABYLON.Bone|null} the bone or null if not found
  1430. */
  1431. getBoneByID(id: string): Nullable<Bone>;
  1432. /**
  1433. * get a bone using its id
  1434. * @param {string} the bone's name
  1435. * @return {BABYLON.Bone|null} the bone or null if not found
  1436. */
  1437. getBoneByName(name: string): Nullable<Bone>;
  1438. /**
  1439. * get a light node using its name
  1440. * @param {string} the light's name
  1441. * @return {BABYLON.Light|null} the light or null if none found.
  1442. */
  1443. getLightByName(name: string): Nullable<Light>;
  1444. /**
  1445. * get a light node using its ID
  1446. * @param {string} the light's id
  1447. * @return {BABYLON.Light|null} the light or null if none found.
  1448. */
  1449. getLightByID(id: string): Nullable<Light>;
  1450. /**
  1451. * get a light node using its scene-generated unique ID
  1452. * @param {number} the light's unique id
  1453. * @return {BABYLON.Light|null} the light or null if none found.
  1454. */
  1455. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  1456. /**
  1457. * get a particle system by id
  1458. * @param id {number} the particle system id
  1459. * @return {BABYLON.IParticleSystem|null} the corresponding system or null if none found.
  1460. */
  1461. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  1462. /**
  1463. * get a geometry using its ID
  1464. * @param {string} the geometry's id
  1465. * @return {BABYLON.Geometry|null} the geometry or null if none found.
  1466. */
  1467. getGeometryByID(id: string): Nullable<Geometry>;
  1468. /**
  1469. * add a new geometry to this scene.
  1470. * @param {BABYLON.Geometry} geometry - the geometry to be added to the scene.
  1471. * @param {boolean} [force] - force addition, even if a geometry with this ID already exists
  1472. * @return {boolean} was the geometry added or not
  1473. */
  1474. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  1475. /**
  1476. * Removes an existing geometry
  1477. * @param {BABYLON.Geometry} geometry - the geometry to be removed from the scene.
  1478. * @return {boolean} was the geometry removed or not
  1479. */
  1480. removeGeometry(geometry: Geometry): boolean;
  1481. getGeometries(): Geometry[];
  1482. /**
  1483. * Get the first added mesh found of a given ID
  1484. * @param {string} id - the id to search for
  1485. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1486. */
  1487. getMeshByID(id: string): Nullable<AbstractMesh>;
  1488. getMeshesByID(id: string): Array<AbstractMesh>;
  1489. /**
  1490. * Get the first added transform node found of a given ID
  1491. * @param {string} id - the id to search for
  1492. * @return {BABYLON.TransformNode|null} the transform node found or null if not found at all.
  1493. */
  1494. getTransformNodeByID(id: string): Nullable<TransformNode>;
  1495. getTransformNodesByID(id: string): Array<TransformNode>;
  1496. /**
  1497. * Get a mesh with its auto-generated unique id
  1498. * @param {number} uniqueId - the unique id to search for
  1499. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1500. */
  1501. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  1502. /**
  1503. * Get a the last added mesh found of a given ID
  1504. * @param {string} id - the id to search for
  1505. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1506. */
  1507. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  1508. /**
  1509. * Get a the last added node (Mesh, Camera, Light) found of a given ID
  1510. * @param {string} id - the id to search for
  1511. * @return {BABYLON.Node|null} the node found or null if not found at all.
  1512. */
  1513. getLastEntryByID(id: string): Nullable<Node>;
  1514. getNodeByID(id: string): Nullable<Node>;
  1515. getNodeByName(name: string): Nullable<Node>;
  1516. getMeshByName(name: string): Nullable<AbstractMesh>;
  1517. getTransformNodeByName(name: string): Nullable<TransformNode>;
  1518. getSoundByName(name: string): Nullable<Sound>;
  1519. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  1520. getSkeletonById(id: string): Nullable<Skeleton>;
  1521. getSkeletonByName(name: string): Nullable<Skeleton>;
  1522. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  1523. isActiveMesh(mesh: AbstractMesh): boolean;
  1524. /**
  1525. * Return a the first highlight layer of the scene with a given name.
  1526. * @param name The name of the highlight layer to look for.
  1527. * @return The highlight layer if found otherwise null.
  1528. */
  1529. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  1530. /**
  1531. * Return a the first highlight layer of the scene with a given name.
  1532. * @param name The name of the highlight layer to look for.
  1533. * @return The highlight layer if found otherwise null.
  1534. */
  1535. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  1536. /**
  1537. * Return a unique id as a string which can serve as an identifier for the scene
  1538. */
  1539. readonly uid: string;
  1540. /**
  1541. * Add an externaly attached data from its key.
  1542. * This method call will fail and return false, if such key already exists.
  1543. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  1544. * @param key the unique key that identifies the data
  1545. * @param data the data object to associate to the key for this Engine instance
  1546. * @return true if no such key were already present and the data was added successfully, false otherwise
  1547. */
  1548. addExternalData<T>(key: string, data: T): boolean;
  1549. /**
  1550. * Get an externaly attached data from its key
  1551. * @param key the unique key that identifies the data
  1552. * @return the associated data, if present (can be null), or undefined if not present
  1553. */
  1554. getExternalData<T>(key: string): Nullable<T>;
  1555. /**
  1556. * Get an externaly attached data from its key, create it using a factory if it's not already present
  1557. * @param key the unique key that identifies the data
  1558. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  1559. * @return the associated data, can be null if the factory returned null.
  1560. */
  1561. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  1562. /**
  1563. * Remove an externaly attached data from the Engine instance
  1564. * @param key the unique key that identifies the data
  1565. * @return true if the data was successfully removed, false if it doesn't exist
  1566. */
  1567. removeExternalData(key: string): boolean;
  1568. private _evaluateSubMesh(subMesh, mesh);
  1569. /**
  1570. * Clear the processed materials smart array preventing retention point in material dispose.
  1571. */
  1572. freeProcessedMaterials(): void;
  1573. /**
  1574. * Clear the active meshes smart array preventing retention point in mesh dispose.
  1575. */
  1576. freeActiveMeshes(): void;
  1577. /**
  1578. * Clear the info related to rendering groups preventing retention points during dispose.
  1579. */
  1580. freeRenderingGroups(): void;
  1581. _isInIntermediateRendering(): boolean;
  1582. private _activeMeshCandidateProvider;
  1583. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  1584. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  1585. private _activeMeshesFrozen;
  1586. /**
  1587. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  1588. */
  1589. freezeActiveMeshes(): Scene;
  1590. /**
  1591. * Use this function to restart evaluating active meshes on every frame
  1592. */
  1593. unfreezeActiveMeshes(): this;
  1594. private _evaluateActiveMeshes();
  1595. private _activeMesh(sourceMesh, mesh);
  1596. updateTransformMatrix(force?: boolean): void;
  1597. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  1598. private _renderForCamera(camera, rigParent?);
  1599. private _processSubCameras(camera);
  1600. private _checkIntersections();
  1601. render(): void;
  1602. private _updateAudioParameters();
  1603. audioEnabled: boolean;
  1604. private _disableAudio();
  1605. private _enableAudio();
  1606. headphone: boolean;
  1607. private _switchAudioModeForHeadphones();
  1608. private _switchAudioModeForNormalSpeakers();
  1609. /**
  1610. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  1611. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  1612. * @returns the created depth renderer
  1613. */
  1614. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  1615. /**
  1616. * Disables a depth renderer for a given camera
  1617. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  1618. */
  1619. disableDepthRenderer(camera?: Nullable<Camera>): void;
  1620. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  1621. disableGeometryBufferRenderer(): void;
  1622. freezeMaterials(): void;
  1623. unfreezeMaterials(): void;
  1624. dispose(): void;
  1625. readonly isDisposed: boolean;
  1626. disposeSounds(): void;
  1627. /**
  1628. * Get the world extend vectors with an optional filter
  1629. *
  1630. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  1631. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  1632. */
  1633. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  1634. min: Vector3;
  1635. max: Vector3;
  1636. };
  1637. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  1638. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  1639. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  1640. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  1641. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  1642. private _internalPick(rayFunction, predicate?, fastCheck?);
  1643. private _internalMultiPick(rayFunction, predicate?);
  1644. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  1645. private _tempPickingRay;
  1646. /** Launch a ray to try to pick a mesh in the scene
  1647. * @param x position on screen
  1648. * @param y position on screen
  1649. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  1650. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1651. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1652. */
  1653. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  1654. /** Launch a ray to try to pick a sprite in the scene
  1655. * @param x position on screen
  1656. * @param y position on screen
  1657. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  1658. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1659. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1660. */
  1661. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  1662. private _cachedRayForTransform;
  1663. /** Use the given ray to pick a mesh in the scene
  1664. * @param ray The ray to use to pick meshes
  1665. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  1666. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1667. */
  1668. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  1669. /**
  1670. * Launch a ray to try to pick a mesh in the scene
  1671. * @param x X position on screen
  1672. * @param y Y position on screen
  1673. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  1674. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1675. */
  1676. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  1677. /**
  1678. * Launch a ray to try to pick a mesh in the scene
  1679. * @param ray Ray to use
  1680. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  1681. */
  1682. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  1683. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  1684. getPointerOverMesh(): Nullable<AbstractMesh>;
  1685. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  1686. getPointerOverSprite(): Nullable<Sprite>;
  1687. getPhysicsEngine(): Nullable<PhysicsEngine>;
  1688. /**
  1689. * Enables physics to the current scene
  1690. * @param {BABYLON.Vector3} [gravity] - the scene's gravity for the physics engine
  1691. * @param {BABYLON.IPhysicsEnginePlugin} [plugin] - The physics engine to be used. defaults to OimoJS.
  1692. * @return {boolean} was the physics engine initialized
  1693. */
  1694. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  1695. disablePhysicsEngine(): void;
  1696. isPhysicsEnabled(): boolean;
  1697. deleteCompoundImpostor(compound: any): void;
  1698. _rebuildGeometries(): void;
  1699. _rebuildTextures(): void;
  1700. /**
  1701. * Creates a default light for the scene.
  1702. * @param replace Whether to replace the existing lights in the scene.
  1703. */
  1704. createDefaultLight(replace?: boolean): void;
  1705. /**
  1706. * Creates a default camera for the scene.
  1707. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  1708. * @param replace Whether to replace the existing active camera in the scene.
  1709. * @param attachCameraControls Whether to attach camera controls to the canvas.
  1710. */
  1711. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  1712. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  1713. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number): Nullable<Mesh>;
  1714. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  1715. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  1716. private _getByTags(list, tagsQuery, forEach?);
  1717. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  1718. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  1719. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  1720. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  1721. /**
  1722. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  1723. * This allowed control for front to back rendering or reversly depending of the special needs.
  1724. *
  1725. * @param renderingGroupId The rendering group id corresponding to its index
  1726. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  1727. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  1728. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  1729. */
  1730. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  1731. /**
  1732. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  1733. *
  1734. * @param renderingGroupId The rendering group id corresponding to its index
  1735. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  1736. * @param depth Automatically clears depth between groups if true and autoClear is true.
  1737. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  1738. */
  1739. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  1740. /**
  1741. * Will flag all materials as dirty to trigger new shader compilation
  1742. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  1743. */
  1744. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  1745. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useDatabase?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  1746. /** @ignore */
  1747. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  1748. }
  1749. }
  1750. declare module BABYLON {
  1751. type Nullable<T> = T | null;
  1752. type float = number;
  1753. type double = number;
  1754. type int = number;
  1755. type FloatArray = number[] | Float32Array;
  1756. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  1757. }
  1758. declare module BABYLON {
  1759. class Action {
  1760. triggerOptions: any;
  1761. trigger: number;
  1762. _actionManager: ActionManager;
  1763. private _nextActiveAction;
  1764. private _child;
  1765. private _condition?;
  1766. private _triggerParameter;
  1767. onBeforeExecuteObservable: Observable<Action>;
  1768. constructor(triggerOptions: any, condition?: Condition);
  1769. _prepare(): void;
  1770. getTriggerParameter(): any;
  1771. _executeCurrent(evt?: ActionEvent): void;
  1772. execute(evt?: ActionEvent): void;
  1773. skipToNextActiveAction(): void;
  1774. then(action: Action): Action;
  1775. _getProperty(propertyPath: string): string;
  1776. _getEffectiveTarget(target: any, propertyPath: string): any;
  1777. serialize(parent: any): any;
  1778. protected _serialize(serializedAction: any, parent?: any): any;
  1779. static _SerializeValueAsString: (value: any) => string;
  1780. static _GetTargetProperty: (target: Scene | Node) => {
  1781. name: string;
  1782. targetType: string;
  1783. value: string;
  1784. };
  1785. }
  1786. }
  1787. declare module BABYLON {
  1788. /**
  1789. * ActionEvent is the event beint sent when an action is triggered.
  1790. */
  1791. class ActionEvent {
  1792. source: any;
  1793. pointerX: number;
  1794. pointerY: number;
  1795. meshUnderPointer: Nullable<AbstractMesh>;
  1796. sourceEvent: any;
  1797. additionalData: any;
  1798. /**
  1799. * @param source The mesh or sprite that triggered the action.
  1800. * @param pointerX The X mouse cursor position at the time of the event
  1801. * @param pointerY The Y mouse cursor position at the time of the event
  1802. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  1803. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  1804. */
  1805. constructor(source: any, pointerX: number, pointerY: number, meshUnderPointer: Nullable<AbstractMesh>, sourceEvent?: any, additionalData?: any);
  1806. /**
  1807. * Helper function to auto-create an ActionEvent from a source mesh.
  1808. * @param source The source mesh that triggered the event
  1809. * @param evt {Event} The original (browser) event
  1810. */
  1811. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  1812. /**
  1813. * Helper function to auto-create an ActionEvent from a source mesh.
  1814. * @param source The source sprite that triggered the event
  1815. * @param scene Scene associated with the sprite
  1816. * @param evt {Event} The original (browser) event
  1817. */
  1818. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  1819. /**
  1820. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  1821. * @param scene the scene where the event occurred
  1822. * @param evt {Event} The original (browser) event
  1823. */
  1824. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  1825. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  1826. }
  1827. /**
  1828. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  1829. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  1830. */
  1831. class ActionManager {
  1832. private static _NothingTrigger;
  1833. private static _OnPickTrigger;
  1834. private static _OnLeftPickTrigger;
  1835. private static _OnRightPickTrigger;
  1836. private static _OnCenterPickTrigger;
  1837. private static _OnPickDownTrigger;
  1838. private static _OnDoublePickTrigger;
  1839. private static _OnPickUpTrigger;
  1840. private static _OnLongPressTrigger;
  1841. private static _OnPointerOverTrigger;
  1842. private static _OnPointerOutTrigger;
  1843. private static _OnEveryFrameTrigger;
  1844. private static _OnIntersectionEnterTrigger;
  1845. private static _OnIntersectionExitTrigger;
  1846. private static _OnKeyDownTrigger;
  1847. private static _OnKeyUpTrigger;
  1848. private static _OnPickOutTrigger;
  1849. static readonly NothingTrigger: number;
  1850. static readonly OnPickTrigger: number;
  1851. static readonly OnLeftPickTrigger: number;
  1852. static readonly OnRightPickTrigger: number;
  1853. static readonly OnCenterPickTrigger: number;
  1854. static readonly OnPickDownTrigger: number;
  1855. static readonly OnDoublePickTrigger: number;
  1856. static readonly OnPickUpTrigger: number;
  1857. static readonly OnPickOutTrigger: number;
  1858. static readonly OnLongPressTrigger: number;
  1859. static readonly OnPointerOverTrigger: number;
  1860. static readonly OnPointerOutTrigger: number;
  1861. static readonly OnEveryFrameTrigger: number;
  1862. static readonly OnIntersectionEnterTrigger: number;
  1863. static readonly OnIntersectionExitTrigger: number;
  1864. static readonly OnKeyDownTrigger: number;
  1865. static readonly OnKeyUpTrigger: number;
  1866. static Triggers: {
  1867. [key: string]: number;
  1868. };
  1869. actions: Action[];
  1870. hoverCursor: string;
  1871. private _scene;
  1872. constructor(scene: Scene);
  1873. dispose(): void;
  1874. getScene(): Scene;
  1875. /**
  1876. * Does this action manager handles actions of any of the given triggers
  1877. * @param {number[]} triggers - the triggers to be tested
  1878. * @return {boolean} whether one (or more) of the triggers is handeled
  1879. */
  1880. hasSpecificTriggers(triggers: number[]): boolean;
  1881. /**
  1882. * Does this action manager handles actions of a given trigger
  1883. * @param {number} trigger - the trigger to be tested
  1884. * @return {boolean} whether the trigger is handeled
  1885. */
  1886. hasSpecificTrigger(trigger: number): boolean;
  1887. /**
  1888. * Does this action manager has pointer triggers
  1889. * @return {boolean} whether or not it has pointer triggers
  1890. */
  1891. readonly hasPointerTriggers: boolean;
  1892. /**
  1893. * Does this action manager has pick triggers
  1894. * @return {boolean} whether or not it has pick triggers
  1895. */
  1896. readonly hasPickTriggers: boolean;
  1897. /**
  1898. * Does exist one action manager with at least one trigger
  1899. * @return {boolean} whether or not it exists one action manager with one trigger
  1900. **/
  1901. static readonly HasTriggers: boolean;
  1902. /**
  1903. * Does exist one action manager with at least one pick trigger
  1904. * @return {boolean} whether or not it exists one action manager with one pick trigger
  1905. **/
  1906. static readonly HasPickTriggers: boolean;
  1907. /**
  1908. * Does exist one action manager that handles actions of a given trigger
  1909. * @param {number} trigger - the trigger to be tested
  1910. * @return {boolean} whether the trigger is handeled by at least one action manager
  1911. **/
  1912. static HasSpecificTrigger(trigger: number): boolean;
  1913. /**
  1914. * Registers an action to this action manager
  1915. * @param {BABYLON.Action} action - the action to be registered
  1916. * @return {BABYLON.Action} the action amended (prepared) after registration
  1917. */
  1918. registerAction(action: Action): Nullable<Action>;
  1919. /**
  1920. * Unregisters an action to this action manager
  1921. * @param action The action to be unregistered
  1922. * @return whether the action has been unregistered
  1923. */
  1924. unregisterAction(action: Action): Boolean;
  1925. /**
  1926. * Process a specific trigger
  1927. * @param {number} trigger - the trigger to process
  1928. * @param evt {BABYLON.ActionEvent} the event details to be processed
  1929. */
  1930. processTrigger(trigger: number, evt?: ActionEvent): void;
  1931. _getEffectiveTarget(target: any, propertyPath: string): any;
  1932. _getProperty(propertyPath: string): string;
  1933. serialize(name: string): any;
  1934. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  1935. static GetTriggerName(trigger: number): string;
  1936. }
  1937. }
  1938. declare module BABYLON {
  1939. class Condition {
  1940. _actionManager: ActionManager;
  1941. _evaluationId: number;
  1942. _currentResult: boolean;
  1943. constructor(actionManager: ActionManager);
  1944. isValid(): boolean;
  1945. _getProperty(propertyPath: string): string;
  1946. _getEffectiveTarget(target: any, propertyPath: string): any;
  1947. serialize(): any;
  1948. protected _serialize(serializedCondition: any): any;
  1949. }
  1950. class ValueCondition extends Condition {
  1951. propertyPath: string;
  1952. value: any;
  1953. operator: number;
  1954. private static _IsEqual;
  1955. private static _IsDifferent;
  1956. private static _IsGreater;
  1957. private static _IsLesser;
  1958. static readonly IsEqual: number;
  1959. static readonly IsDifferent: number;
  1960. static readonly IsGreater: number;
  1961. static readonly IsLesser: number;
  1962. _actionManager: ActionManager;
  1963. private _target;
  1964. private _effectiveTarget;
  1965. private _property;
  1966. constructor(actionManager: ActionManager, target: any, propertyPath: string, value: any, operator?: number);
  1967. isValid(): boolean;
  1968. serialize(): any;
  1969. static GetOperatorName(operator: number): string;
  1970. }
  1971. class PredicateCondition extends Condition {
  1972. predicate: () => boolean;
  1973. _actionManager: ActionManager;
  1974. constructor(actionManager: ActionManager, predicate: () => boolean);
  1975. isValid(): boolean;
  1976. }
  1977. class StateCondition extends Condition {
  1978. value: string;
  1979. _actionManager: ActionManager;
  1980. private _target;
  1981. constructor(actionManager: ActionManager, target: any, value: string);
  1982. isValid(): boolean;
  1983. serialize(): any;
  1984. }
  1985. }
  1986. declare module BABYLON {
  1987. class SwitchBooleanAction extends Action {
  1988. propertyPath: string;
  1989. private _target;
  1990. private _effectiveTarget;
  1991. private _property;
  1992. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  1993. _prepare(): void;
  1994. execute(): void;
  1995. serialize(parent: any): any;
  1996. }
  1997. class SetStateAction extends Action {
  1998. value: string;
  1999. private _target;
  2000. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  2001. execute(): void;
  2002. serialize(parent: any): any;
  2003. }
  2004. class SetValueAction extends Action {
  2005. propertyPath: string;
  2006. value: any;
  2007. private _target;
  2008. private _effectiveTarget;
  2009. private _property;
  2010. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  2011. _prepare(): void;
  2012. execute(): void;
  2013. serialize(parent: any): any;
  2014. }
  2015. class IncrementValueAction extends Action {
  2016. propertyPath: string;
  2017. value: any;
  2018. private _target;
  2019. private _effectiveTarget;
  2020. private _property;
  2021. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  2022. _prepare(): void;
  2023. execute(): void;
  2024. serialize(parent: any): any;
  2025. }
  2026. class PlayAnimationAction extends Action {
  2027. from: number;
  2028. to: number;
  2029. loop: boolean | undefined;
  2030. private _target;
  2031. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  2032. _prepare(): void;
  2033. execute(): void;
  2034. serialize(parent: any): any;
  2035. }
  2036. class StopAnimationAction extends Action {
  2037. private _target;
  2038. constructor(triggerOptions: any, target: any, condition?: Condition);
  2039. _prepare(): void;
  2040. execute(): void;
  2041. serialize(parent: any): any;
  2042. }
  2043. class DoNothingAction extends Action {
  2044. constructor(triggerOptions?: any, condition?: Condition);
  2045. execute(): void;
  2046. serialize(parent: any): any;
  2047. }
  2048. class CombineAction extends Action {
  2049. children: Action[];
  2050. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  2051. _prepare(): void;
  2052. execute(evt: ActionEvent): void;
  2053. serialize(parent: any): any;
  2054. }
  2055. class ExecuteCodeAction extends Action {
  2056. func: (evt: ActionEvent) => void;
  2057. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  2058. execute(evt: ActionEvent): void;
  2059. }
  2060. class SetParentAction extends Action {
  2061. private _parent;
  2062. private _target;
  2063. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  2064. _prepare(): void;
  2065. execute(): void;
  2066. serialize(parent: any): any;
  2067. }
  2068. class PlaySoundAction extends Action {
  2069. private _sound;
  2070. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  2071. _prepare(): void;
  2072. execute(): void;
  2073. serialize(parent: any): any;
  2074. }
  2075. class StopSoundAction extends Action {
  2076. private _sound;
  2077. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  2078. _prepare(): void;
  2079. execute(): void;
  2080. serialize(parent: any): any;
  2081. }
  2082. }
  2083. declare module BABYLON {
  2084. class InterpolateValueAction extends Action {
  2085. propertyPath: string;
  2086. value: any;
  2087. duration: number;
  2088. stopOtherAnimations: boolean | undefined;
  2089. onInterpolationDone: (() => void) | undefined;
  2090. private _target;
  2091. private _effectiveTarget;
  2092. private _property;
  2093. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  2094. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  2095. _prepare(): void;
  2096. execute(): void;
  2097. serialize(parent: any): any;
  2098. }
  2099. }
  2100. declare module BABYLON {
  2101. class Animatable {
  2102. target: any;
  2103. fromFrame: number;
  2104. toFrame: number;
  2105. loopAnimation: boolean;
  2106. onAnimationEnd: (() => void) | null | undefined;
  2107. private _localDelayOffset;
  2108. private _pausedDelay;
  2109. private _runtimeAnimations;
  2110. private _paused;
  2111. private _scene;
  2112. private _speedRatio;
  2113. private _weight;
  2114. animationStarted: boolean;
  2115. /**
  2116. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2117. */
  2118. weight: number;
  2119. /**
  2120. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2121. */
  2122. speedRatio: number;
  2123. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  2124. getAnimations(): RuntimeAnimation[];
  2125. appendAnimations(target: any, animations: Animation[]): void;
  2126. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  2127. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  2128. reset(): void;
  2129. enableBlending(blendingSpeed: number): void;
  2130. disableBlending(): void;
  2131. goToFrame(frame: number): void;
  2132. pause(): void;
  2133. restart(): void;
  2134. stop(animationName?: string): void;
  2135. _animate(delay: number): boolean;
  2136. }
  2137. }
  2138. declare module BABYLON {
  2139. class AnimationRange {
  2140. name: string;
  2141. from: number;
  2142. to: number;
  2143. constructor(name: string, from: number, to: number);
  2144. clone(): AnimationRange;
  2145. }
  2146. /**
  2147. * Composed of a frame, and an action function
  2148. */
  2149. class AnimationEvent {
  2150. frame: number;
  2151. action: () => void;
  2152. onlyOnce: boolean | undefined;
  2153. isDone: boolean;
  2154. constructor(frame: number, action: () => void, onlyOnce?: boolean | undefined);
  2155. }
  2156. class PathCursor {
  2157. private path;
  2158. private _onchange;
  2159. value: number;
  2160. animations: Animation[];
  2161. constructor(path: Path2);
  2162. getPoint(): Vector3;
  2163. moveAhead(step?: number): PathCursor;
  2164. moveBack(step?: number): PathCursor;
  2165. move(step: number): PathCursor;
  2166. private ensureLimits();
  2167. private raiseOnChange();
  2168. onchange(f: (cursor: PathCursor) => void): PathCursor;
  2169. }
  2170. interface IAnimationKey {
  2171. frame: number;
  2172. value: any;
  2173. inTangent?: any;
  2174. outTangent?: any;
  2175. interpolation?: AnimationKeyInterpolation;
  2176. }
  2177. enum AnimationKeyInterpolation {
  2178. /**
  2179. * Do not interpolate between keys and use the start key value only. Tangents are ignored.
  2180. */
  2181. STEP = 1,
  2182. }
  2183. class Animation {
  2184. name: string;
  2185. targetProperty: string;
  2186. framePerSecond: number;
  2187. dataType: number;
  2188. loopMode: number | undefined;
  2189. enableBlending: boolean | undefined;
  2190. static AllowMatricesInterpolation: boolean;
  2191. private _keys;
  2192. private _easingFunction;
  2193. _runtimeAnimations: RuntimeAnimation[];
  2194. private _events;
  2195. targetPropertyPath: string[];
  2196. blendingSpeed: number;
  2197. private _ranges;
  2198. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  2199. /**
  2200. * Sets up an animation.
  2201. * @param property the property to animate
  2202. * @param animationType the animation type to apply
  2203. * @param easingFunction the easing function used in the animation
  2204. * @returns The created animation
  2205. */
  2206. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  2207. /**
  2208. * Create and start an animation on a node
  2209. * @param {string} name defines the name of the global animation that will be run on all nodes
  2210. * @param {BABYLON.Node} node defines the root node where the animation will take place
  2211. * @param {string} targetProperty defines property to animate
  2212. * @param {number} framePerSecond defines the number of frame per second yo use
  2213. * @param {number} totalFrame defines the number of frames in total
  2214. * @param {any} from defines the initial value
  2215. * @param {any} to defines the final value
  2216. * @param {number} loopMode defines which loop mode you want to use (off by default)
  2217. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  2218. * @param onAnimationEnd defines the callback to call when animation end
  2219. * @returns the animatable created for this animation
  2220. */
  2221. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  2222. /**
  2223. * Create and start an animation on a node and its descendants
  2224. * @param {string} name defines the name of the global animation that will be run on all nodes
  2225. * @param {BABYLON.Node} node defines the root node where the animation will take place
  2226. * @param {boolean} directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  2227. * @param {string} targetProperty defines property to animate
  2228. * @param {number} framePerSecond defines the number of frame per second yo use
  2229. * @param {number} totalFrame defines the number of frames in total
  2230. * @param {any} from defines the initial value
  2231. * @param {any} to defines the final value
  2232. * @param {number} loopMode defines which loop mode you want to use (off by default)
  2233. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  2234. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  2235. * @returns the list of animatables created for all nodes
  2236. * @example https://www.babylonjs-playground.com/#MH0VLI
  2237. */
  2238. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  2239. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  2240. /**
  2241. * Transition property of the Camera to the target Value.
  2242. * @param property The property to transition
  2243. * @param targetValue The target Value of the property
  2244. * @param host The object where the property to animate belongs
  2245. * @param scene Scene used to run the animation
  2246. * @param frameRate Framerate (in frame/s) to use
  2247. * @param transition The transition type we want to use
  2248. * @param duration The duration of the animation, in milliseconds
  2249. * @param onAnimationEnd Call back trigger at the end of the animation.
  2250. */
  2251. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  2252. /**
  2253. * Return the array of runtime animations currently using this animation
  2254. */
  2255. readonly runtimeAnimations: RuntimeAnimation[];
  2256. readonly hasRunningRuntimeAnimations: boolean;
  2257. constructor(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number | undefined, enableBlending?: boolean | undefined);
  2258. /**
  2259. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  2260. */
  2261. toString(fullDetails?: boolean): string;
  2262. /**
  2263. * Add an event to this animation.
  2264. */
  2265. addEvent(event: AnimationEvent): void;
  2266. /**
  2267. * Remove all events found at the given frame
  2268. * @param frame
  2269. */
  2270. removeEvents(frame: number): void;
  2271. getEvents(): AnimationEvent[];
  2272. createRange(name: string, from: number, to: number): void;
  2273. deleteRange(name: string, deleteFrames?: boolean): void;
  2274. getRange(name: string): Nullable<AnimationRange>;
  2275. getKeys(): Array<IAnimationKey>;
  2276. getHighestFrame(): number;
  2277. getEasingFunction(): IEasingFunction;
  2278. setEasingFunction(easingFunction: EasingFunction): void;
  2279. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  2280. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  2281. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  2282. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  2283. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  2284. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  2285. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  2286. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  2287. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  2288. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  2289. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  2290. clone(): Animation;
  2291. setKeys(values: Array<IAnimationKey>): void;
  2292. serialize(): any;
  2293. private static _ANIMATIONTYPE_FLOAT;
  2294. private static _ANIMATIONTYPE_VECTOR3;
  2295. private static _ANIMATIONTYPE_QUATERNION;
  2296. private static _ANIMATIONTYPE_MATRIX;
  2297. private static _ANIMATIONTYPE_COLOR3;
  2298. private static _ANIMATIONTYPE_VECTOR2;
  2299. private static _ANIMATIONTYPE_SIZE;
  2300. private static _ANIMATIONLOOPMODE_RELATIVE;
  2301. private static _ANIMATIONLOOPMODE_CYCLE;
  2302. private static _ANIMATIONLOOPMODE_CONSTANT;
  2303. static readonly ANIMATIONTYPE_FLOAT: number;
  2304. static readonly ANIMATIONTYPE_VECTOR3: number;
  2305. static readonly ANIMATIONTYPE_VECTOR2: number;
  2306. static readonly ANIMATIONTYPE_SIZE: number;
  2307. static readonly ANIMATIONTYPE_QUATERNION: number;
  2308. static readonly ANIMATIONTYPE_MATRIX: number;
  2309. static readonly ANIMATIONTYPE_COLOR3: number;
  2310. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  2311. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  2312. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  2313. static Parse(parsedAnimation: any): Animation;
  2314. static AppendSerializedAnimations(source: IAnimatable, destination: any): any;
  2315. }
  2316. }
  2317. declare module BABYLON {
  2318. /**
  2319. * This class defines the direct association between an animation and a target
  2320. */
  2321. class TargetedAnimation {
  2322. animation: Animation;
  2323. target: any;
  2324. }
  2325. /**
  2326. * Use this class to create coordinated animations on multiple targets
  2327. */
  2328. class AnimationGroup implements IDisposable {
  2329. name: string;
  2330. private _scene;
  2331. private _targetedAnimations;
  2332. private _animatables;
  2333. private _from;
  2334. private _to;
  2335. private _isStarted;
  2336. private _speedRatio;
  2337. onAnimationEndObservable: Observable<TargetedAnimation>;
  2338. /**
  2339. * Define if the animations are started
  2340. */
  2341. readonly isStarted: boolean;
  2342. /**
  2343. * Gets or sets the speed ratio to use for all animations
  2344. */
  2345. /**
  2346. * Gets or sets the speed ratio to use for all animations
  2347. */
  2348. speedRatio: number;
  2349. /**
  2350. * Gets the targeted animations for this animation group
  2351. */
  2352. readonly targetedAnimations: Array<TargetedAnimation>;
  2353. /**
  2354. * returning the list of animatables controlled by this animation group.
  2355. */
  2356. readonly animatables: Array<Animatable>;
  2357. constructor(name: string, scene?: Nullable<Scene>);
  2358. /**
  2359. * Add an animation (with its target) in the group
  2360. * @param animation defines the animation we want to add
  2361. * @param target defines the target of the animation
  2362. * @returns the {BABYLON.TargetedAnimation} object
  2363. */
  2364. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  2365. /**
  2366. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  2367. * It can add constant keys at begin or end
  2368. * @param beginFrame defines the new begin frame for all animations. It can't be bigger than the smallest begin frame of all animations
  2369. * @param endFrame defines the new end frame for all animations. It can't be smaller than the largest end frame of all animations
  2370. */
  2371. normalize(beginFrame?: number, endFrame?: number): AnimationGroup;
  2372. /**
  2373. * Start all animations on given targets
  2374. * @param loop defines if animations must loop
  2375. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  2376. */
  2377. start(loop?: boolean, speedRatio?: number): AnimationGroup;
  2378. /**
  2379. * Pause all animations
  2380. */
  2381. pause(): AnimationGroup;
  2382. /**
  2383. * Play all animations to initial state
  2384. * This function will start() the animations if they were not started or will restart() them if they were paused
  2385. * @param loop defines if animations must loop
  2386. */
  2387. play(loop?: boolean): AnimationGroup;
  2388. /**
  2389. * Reset all animations to initial state
  2390. */
  2391. reset(): AnimationGroup;
  2392. /**
  2393. * Restart animations from key 0
  2394. */
  2395. restart(): AnimationGroup;
  2396. /**
  2397. * Stop all animations
  2398. */
  2399. stop(): AnimationGroup;
  2400. /**
  2401. * Goes to a specific frame in this animation group
  2402. *
  2403. * @param frame the frame number to go to
  2404. * @return the animationGroup
  2405. */
  2406. goToFrame(frame: number): AnimationGroup;
  2407. /**
  2408. * Dispose all associated resources
  2409. */
  2410. dispose(): void;
  2411. }
  2412. }
  2413. declare module BABYLON {
  2414. /**
  2415. * Class used to override all child animations of a given target
  2416. */
  2417. class AnimationPropertiesOverride {
  2418. /**
  2419. * Gets or sets a value indicating if animation blending must be used
  2420. */
  2421. enableBlending: boolean;
  2422. /**
  2423. * Gets or sets the blending speed to use when enableBlending is true
  2424. */
  2425. blendingSpeed: number;
  2426. /**
  2427. * Gets or sets the default loop mode to use
  2428. */
  2429. loopMode: number;
  2430. }
  2431. }
  2432. declare module BABYLON {
  2433. interface IEasingFunction {
  2434. ease(gradient: number): number;
  2435. }
  2436. class EasingFunction implements IEasingFunction {
  2437. private static _EASINGMODE_EASEIN;
  2438. private static _EASINGMODE_EASEOUT;
  2439. private static _EASINGMODE_EASEINOUT;
  2440. static readonly EASINGMODE_EASEIN: number;
  2441. static readonly EASINGMODE_EASEOUT: number;
  2442. static readonly EASINGMODE_EASEINOUT: number;
  2443. private _easingMode;
  2444. setEasingMode(easingMode: number): void;
  2445. getEasingMode(): number;
  2446. easeInCore(gradient: number): number;
  2447. ease(gradient: number): number;
  2448. }
  2449. class CircleEase extends EasingFunction implements IEasingFunction {
  2450. easeInCore(gradient: number): number;
  2451. }
  2452. class BackEase extends EasingFunction implements IEasingFunction {
  2453. amplitude: number;
  2454. constructor(amplitude?: number);
  2455. easeInCore(gradient: number): number;
  2456. }
  2457. class BounceEase extends EasingFunction implements IEasingFunction {
  2458. bounces: number;
  2459. bounciness: number;
  2460. constructor(bounces?: number, bounciness?: number);
  2461. easeInCore(gradient: number): number;
  2462. }
  2463. class CubicEase extends EasingFunction implements IEasingFunction {
  2464. easeInCore(gradient: number): number;
  2465. }
  2466. class ElasticEase extends EasingFunction implements IEasingFunction {
  2467. oscillations: number;
  2468. springiness: number;
  2469. constructor(oscillations?: number, springiness?: number);
  2470. easeInCore(gradient: number): number;
  2471. }
  2472. class ExponentialEase extends EasingFunction implements IEasingFunction {
  2473. exponent: number;
  2474. constructor(exponent?: number);
  2475. easeInCore(gradient: number): number;
  2476. }
  2477. class PowerEase extends EasingFunction implements IEasingFunction {
  2478. power: number;
  2479. constructor(power?: number);
  2480. easeInCore(gradient: number): number;
  2481. }
  2482. class QuadraticEase extends EasingFunction implements IEasingFunction {
  2483. easeInCore(gradient: number): number;
  2484. }
  2485. class QuarticEase extends EasingFunction implements IEasingFunction {
  2486. easeInCore(gradient: number): number;
  2487. }
  2488. class QuinticEase extends EasingFunction implements IEasingFunction {
  2489. easeInCore(gradient: number): number;
  2490. }
  2491. class SineEase extends EasingFunction implements IEasingFunction {
  2492. easeInCore(gradient: number): number;
  2493. }
  2494. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  2495. x1: number;
  2496. y1: number;
  2497. x2: number;
  2498. y2: number;
  2499. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  2500. easeInCore(gradient: number): number;
  2501. }
  2502. }
  2503. declare module BABYLON {
  2504. class RuntimeAnimation {
  2505. currentFrame: number;
  2506. private _animation;
  2507. private _target;
  2508. private _originalValue;
  2509. private _originalBlendValue;
  2510. private _offsetsCache;
  2511. private _highLimitsCache;
  2512. private _stopped;
  2513. private _blendingFactor;
  2514. private _scene;
  2515. private _currentValue;
  2516. private _activeTarget;
  2517. private _targetPath;
  2518. private _weight;
  2519. /**
  2520. * Gets the weight of the runtime animation
  2521. */
  2522. readonly weight: number;
  2523. /**
  2524. * Gets the original value of the runtime animation
  2525. */
  2526. readonly originalValue: any;
  2527. /**
  2528. * Gets the current value of the runtime animation
  2529. */
  2530. readonly currentValue: any;
  2531. /**
  2532. * Gets the path where to store the animated value in the target
  2533. */
  2534. readonly targetPath: string;
  2535. /**
  2536. * Gets the actual target of the runtime animation
  2537. */
  2538. readonly target: any;
  2539. /**
  2540. * Create a new RuntimeAnimation object
  2541. * @param target defines the target of the animation
  2542. * @param animation defines the source {BABYLON.Animation} object
  2543. * @param scene defines the hosting scene
  2544. */
  2545. constructor(target: any, animation: Animation, scene: Scene);
  2546. readonly animation: Animation;
  2547. reset(): void;
  2548. isStopped(): boolean;
  2549. dispose(): void;
  2550. private _getKeyValue(value);
  2551. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  2552. /**
  2553. * Affect the interpolated value to the target
  2554. * @param currentValue defines the value computed by the animation
  2555. * @param weight defines the weight to apply to this value
  2556. */
  2557. setValue(currentValue: any, weight?: number): void;
  2558. private _getCorrectLoopMode();
  2559. /**
  2560. * Move the current animation to a given frame
  2561. * @param frame defines the frame to move to
  2562. */
  2563. goToFrame(frame: number): void;
  2564. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  2565. private _ratioOffset;
  2566. private _previousDelay;
  2567. private _previousRatio;
  2568. /**
  2569. * Execute the current animation
  2570. * @param delay defines the delay to add to the current frame
  2571. * @param from defines the lower bound of the animation range
  2572. * @param to defines the upper bound of the animation range
  2573. * @param loop defines if the current animation must loop
  2574. * @param speedRatio defines the current speed ratio
  2575. * @param weight defines the weight of the animation (default is -1 so no weight)
  2576. * @returns a boolean indicating if the animation has ended
  2577. */
  2578. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  2579. }
  2580. }
  2581. declare module BABYLON {
  2582. class Analyser {
  2583. SMOOTHING: number;
  2584. FFT_SIZE: number;
  2585. BARGRAPHAMPLITUDE: number;
  2586. DEBUGCANVASPOS: {
  2587. x: number;
  2588. y: number;
  2589. };
  2590. DEBUGCANVASSIZE: {
  2591. width: number;
  2592. height: number;
  2593. };
  2594. private _byteFreqs;
  2595. private _byteTime;
  2596. private _floatFreqs;
  2597. private _webAudioAnalyser;
  2598. private _debugCanvas;
  2599. private _debugCanvasContext;
  2600. private _scene;
  2601. private _registerFunc;
  2602. private _audioEngine;
  2603. constructor(scene: Scene);
  2604. getFrequencyBinCount(): number;
  2605. getByteFrequencyData(): Uint8Array;
  2606. getByteTimeDomainData(): Uint8Array;
  2607. getFloatFrequencyData(): Uint8Array;
  2608. drawDebugCanvas(): void;
  2609. stopDebugCanvas(): void;
  2610. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  2611. dispose(): void;
  2612. }
  2613. }
  2614. declare module BABYLON {
  2615. class AudioEngine {
  2616. private _audioContext;
  2617. private _audioContextInitialized;
  2618. canUseWebAudio: boolean;
  2619. masterGain: GainNode;
  2620. private _connectedAnalyser;
  2621. WarnedWebAudioUnsupported: boolean;
  2622. unlocked: boolean;
  2623. onAudioUnlocked: () => any;
  2624. isMP3supported: boolean;
  2625. isOGGsupported: boolean;
  2626. readonly audioContext: Nullable<AudioContext>;
  2627. constructor();
  2628. private _unlockiOSaudio();
  2629. private _initializeAudioContext();
  2630. dispose(): void;
  2631. getGlobalVolume(): number;
  2632. setGlobalVolume(newVolume: number): void;
  2633. connectToAnalyser(analyser: Analyser): void;
  2634. }
  2635. }
  2636. declare module BABYLON {
  2637. class Sound {
  2638. name: string;
  2639. autoplay: boolean;
  2640. loop: boolean;
  2641. useCustomAttenuation: boolean;
  2642. soundTrackId: number;
  2643. spatialSound: boolean;
  2644. refDistance: number;
  2645. rolloffFactor: number;
  2646. maxDistance: number;
  2647. distanceModel: string;
  2648. private _panningModel;
  2649. onended: () => any;
  2650. private _playbackRate;
  2651. private _streaming;
  2652. private _startTime;
  2653. private _startOffset;
  2654. private _position;
  2655. private _localDirection;
  2656. private _volume;
  2657. private _isReadyToPlay;
  2658. isPlaying: boolean;
  2659. isPaused: boolean;
  2660. private _isDirectional;
  2661. private _readyToPlayCallback;
  2662. private _audioBuffer;
  2663. private _soundSource;
  2664. private _streamingSource;
  2665. private _soundPanner;
  2666. private _soundGain;
  2667. private _inputAudioNode;
  2668. private _ouputAudioNode;
  2669. private _coneInnerAngle;
  2670. private _coneOuterAngle;
  2671. private _coneOuterGain;
  2672. private _scene;
  2673. private _connectedMesh;
  2674. private _customAttenuationFunction;
  2675. private _registerFunc;
  2676. private _isOutputConnected;
  2677. private _htmlAudioElement;
  2678. private _urlType;
  2679. /**
  2680. * Create a sound and attach it to a scene
  2681. * @param name Name of your sound
  2682. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  2683. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  2684. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  2685. */
  2686. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  2687. dispose(): void;
  2688. isReady(): boolean;
  2689. private _soundLoaded(audioData);
  2690. setAudioBuffer(audioBuffer: AudioBuffer): void;
  2691. updateOptions(options: any): void;
  2692. private _createSpatialParameters();
  2693. private _updateSpatialParameters();
  2694. switchPanningModelToHRTF(): void;
  2695. switchPanningModelToEqualPower(): void;
  2696. private _switchPanningModel();
  2697. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  2698. /**
  2699. * Transform this sound into a directional source
  2700. * @param coneInnerAngle Size of the inner cone in degree
  2701. * @param coneOuterAngle Size of the outer cone in degree
  2702. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  2703. */
  2704. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  2705. setPosition(newPosition: Vector3): void;
  2706. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  2707. private _updateDirection();
  2708. updateDistanceFromListener(): void;
  2709. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  2710. /**
  2711. * Play the sound
  2712. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  2713. * @param offset (optional) Start the sound setting it at a specific time
  2714. */
  2715. play(time?: number, offset?: number): void;
  2716. private _onended();
  2717. /**
  2718. * Stop the sound
  2719. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  2720. */
  2721. stop(time?: number): void;
  2722. pause(): void;
  2723. setVolume(newVolume: number, time?: number): void;
  2724. setPlaybackRate(newPlaybackRate: number): void;
  2725. getVolume(): number;
  2726. attachToMesh(meshToConnectTo: AbstractMesh): void;
  2727. detachFromMesh(): void;
  2728. private _onRegisterAfterWorldMatrixUpdate(node);
  2729. clone(): Nullable<Sound>;
  2730. getAudioBuffer(): AudioBuffer | null;
  2731. serialize(): any;
  2732. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  2733. }
  2734. }
  2735. declare module BABYLON {
  2736. class SoundTrack {
  2737. private _outputAudioNode;
  2738. private _scene;
  2739. id: number;
  2740. soundCollection: Array<Sound>;
  2741. private _isMainTrack;
  2742. private _connectedAnalyser;
  2743. private _options;
  2744. private _isInitialized;
  2745. constructor(scene: Scene, options?: any);
  2746. private _initializeSoundTrackAudioGraph();
  2747. dispose(): void;
  2748. AddSound(sound: Sound): void;
  2749. RemoveSound(sound: Sound): void;
  2750. setVolume(newVolume: number): void;
  2751. switchPanningModelToHRTF(): void;
  2752. switchPanningModelToEqualPower(): void;
  2753. connectToAnalyser(analyser: Analyser): void;
  2754. }
  2755. }
  2756. declare module BABYLON {
  2757. interface Behavior<T extends Node> {
  2758. name: string;
  2759. init(): void;
  2760. attach(node: T): void;
  2761. detach(): void;
  2762. }
  2763. }
  2764. declare module BABYLON {
  2765. class Bone extends Node {
  2766. name: string;
  2767. private static _tmpVecs;
  2768. private static _tmpQuat;
  2769. private static _tmpMats;
  2770. children: Bone[];
  2771. animations: Animation[];
  2772. length: number;
  2773. _index: Nullable<number>;
  2774. private _skeleton;
  2775. private _localMatrix;
  2776. private _restPose;
  2777. private _baseMatrix;
  2778. private _worldTransform;
  2779. private _absoluteTransform;
  2780. private _invertedAbsoluteTransform;
  2781. private _parent;
  2782. private _scaleMatrix;
  2783. private _scaleVector;
  2784. private _negateScaleChildren;
  2785. private _scalingDeterminant;
  2786. _matrix: Matrix;
  2787. constructor(name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  2788. getSkeleton(): Skeleton;
  2789. getParent(): Nullable<Bone>;
  2790. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  2791. getLocalMatrix(): Matrix;
  2792. getBaseMatrix(): Matrix;
  2793. getRestPose(): Matrix;
  2794. returnToRest(): void;
  2795. getWorldMatrix(): Matrix;
  2796. getInvertedAbsoluteTransform(): Matrix;
  2797. getAbsoluteTransform(): Matrix;
  2798. position: Vector3;
  2799. rotation: Vector3;
  2800. rotationQuaternion: Quaternion;
  2801. scaling: Vector3;
  2802. /**
  2803. * Gets the animation properties override
  2804. */
  2805. readonly animationPropertiesOverride: AnimationPropertiesOverride;
  2806. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean): void;
  2807. _updateDifferenceMatrix(rootMatrix?: Matrix): void;
  2808. markAsDirty(): void;
  2809. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  2810. /**
  2811. * Translate the bone in local or world space.
  2812. * @param vec The amount to translate the bone.
  2813. * @param space The space that the translation is in.
  2814. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2815. */
  2816. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2817. /**
  2818. * Set the postion of the bone in local or world space.
  2819. * @param position The position to set the bone.
  2820. * @param space The space that the position is in.
  2821. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2822. */
  2823. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2824. /**
  2825. * Set the absolute postion of the bone (world space).
  2826. * @param position The position to set the bone.
  2827. * @param mesh The mesh that this bone is attached to.
  2828. */
  2829. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  2830. /**
  2831. * Set the scale of the bone on the x, y and z axes.
  2832. * @param x The scale of the bone on the x axis.
  2833. * @param x The scale of the bone on the y axis.
  2834. * @param z The scale of the bone on the z axis.
  2835. * @param scaleChildren Set this to true if children of the bone should be scaled.
  2836. */
  2837. setScale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  2838. /**
  2839. * Scale the bone on the x, y and z axes.
  2840. * @param x The amount to scale the bone on the x axis.
  2841. * @param x The amount to scale the bone on the y axis.
  2842. * @param z The amount to scale the bone on the z axis.
  2843. * @param scaleChildren Set this to true if children of the bone should be scaled.
  2844. */
  2845. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  2846. /**
  2847. * Set the yaw, pitch, and roll of the bone in local or world space.
  2848. * @param yaw The rotation of the bone on the y axis.
  2849. * @param pitch The rotation of the bone on the x axis.
  2850. * @param roll The rotation of the bone on the z axis.
  2851. * @param space The space that the axes of rotation are in.
  2852. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2853. */
  2854. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  2855. /**
  2856. * Rotate the bone on an axis in local or world space.
  2857. * @param axis The axis to rotate the bone on.
  2858. * @param amount The amount to rotate the bone.
  2859. * @param space The space that the axis is in.
  2860. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2861. */
  2862. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  2863. /**
  2864. * Set the rotation of the bone to a particular axis angle in local or world space.
  2865. * @param axis The axis to rotate the bone on.
  2866. * @param angle The angle that the bone should be rotated to.
  2867. * @param space The space that the axis is in.
  2868. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2869. */
  2870. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  2871. /**
  2872. * Set the euler rotation of the bone in local of world space.
  2873. * @param rotation The euler rotation that the bone should be set to.
  2874. * @param space The space that the rotation is in.
  2875. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2876. */
  2877. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2878. /**
  2879. * Set the quaternion rotation of the bone in local of world space.
  2880. * @param quat The quaternion rotation that the bone should be set to.
  2881. * @param space The space that the rotation is in.
  2882. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2883. */
  2884. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  2885. /**
  2886. * Set the rotation matrix of the bone in local of world space.
  2887. * @param rotMat The rotation matrix that the bone should be set to.
  2888. * @param space The space that the rotation is in.
  2889. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2890. */
  2891. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  2892. private _rotateWithMatrix(rmat, space?, mesh?);
  2893. private _getNegativeRotationToRef(rotMatInv, space?, mesh?);
  2894. /**
  2895. * Get the scale of the bone
  2896. * @returns the scale of the bone
  2897. */
  2898. getScale(): Vector3;
  2899. /**
  2900. * Copy the scale of the bone to a vector3.
  2901. * @param result The vector3 to copy the scale to
  2902. */
  2903. getScaleToRef(result: Vector3): void;
  2904. /**
  2905. * Get the position of the bone in local or world space.
  2906. * @param space The space that the returned position is in.
  2907. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2908. * @returns The position of the bone
  2909. */
  2910. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  2911. /**
  2912. * Copy the position of the bone to a vector3 in local or world space.
  2913. * @param space The space that the returned position is in.
  2914. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2915. * @param result The vector3 to copy the position to.
  2916. */
  2917. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  2918. /**
  2919. * Get the absolute position of the bone (world space).
  2920. * @param mesh The mesh that this bone is attached to.
  2921. * @returns The absolute position of the bone
  2922. */
  2923. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  2924. /**
  2925. * Copy the absolute position of the bone (world space) to the result param.
  2926. * @param mesh The mesh that this bone is attached to.
  2927. * @param result The vector3 to copy the absolute position to.
  2928. */
  2929. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  2930. /**
  2931. * Compute the absolute transforms of this bone and its children.
  2932. */
  2933. computeAbsoluteTransforms(): void;
  2934. private _syncScaleVector();
  2935. /**
  2936. * Get the world direction from an axis that is in the local space of the bone.
  2937. * @param localAxis The local direction that is used to compute the world direction.
  2938. * @param mesh The mesh that this bone is attached to.
  2939. * @returns The world direction
  2940. */
  2941. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2942. /**
  2943. * Copy the world direction to a vector3 from an axis that is in the local space of the bone.
  2944. * @param localAxis The local direction that is used to compute the world direction.
  2945. * @param mesh The mesh that this bone is attached to.
  2946. * @param result The vector3 that the world direction will be copied to.
  2947. */
  2948. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2949. /**
  2950. * Get the euler rotation of the bone in local or world space.
  2951. * @param space The space that the rotation should be in.
  2952. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2953. * @returns The euler rotation
  2954. */
  2955. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  2956. /**
  2957. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space.
  2958. * @param space The space that the rotation should be in.
  2959. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2960. * @param result The vector3 that the rotation should be copied to.
  2961. */
  2962. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2963. /**
  2964. * Get the quaternion rotation of the bone in either local or world space.
  2965. * @param space The space that the rotation should be in.
  2966. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2967. * @returns The quaternion rotation
  2968. */
  2969. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  2970. /**
  2971. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space.
  2972. * @param space The space that the rotation should be in.
  2973. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2974. * @param result The quaternion that the rotation should be copied to.
  2975. */
  2976. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  2977. /**
  2978. * Get the rotation matrix of the bone in local or world space.
  2979. * @param space The space that the rotation should be in.
  2980. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2981. * @returns The rotation matrix
  2982. */
  2983. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  2984. /**
  2985. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space.
  2986. * @param space The space that the rotation should be in.
  2987. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2988. * @param result The quaternion that the rotation should be copied to.
  2989. */
  2990. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  2991. /**
  2992. * Get the world position of a point that is in the local space of the bone.
  2993. * @param position The local position
  2994. * @param mesh The mesh that this bone is attached to.
  2995. * @returns The world position
  2996. */
  2997. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2998. /**
  2999. * Get the world position of a point that is in the local space of the bone and copy it to the result param.
  3000. * @param position The local position
  3001. * @param mesh The mesh that this bone is attached to.
  3002. * @param result The vector3 that the world position should be copied to.
  3003. */
  3004. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  3005. /**
  3006. * Get the local position of a point that is in world space.
  3007. * @param position The world position
  3008. * @param mesh The mesh that this bone is attached to.
  3009. * @returns The local position
  3010. */
  3011. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  3012. /**
  3013. * Get the local position of a point that is in world space and copy it to the result param.
  3014. * @param position The world position
  3015. * @param mesh The mesh that this bone is attached to.
  3016. * @param result The vector3 that the local position should be copied to.
  3017. */
  3018. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  3019. }
  3020. }
  3021. declare module BABYLON {
  3022. class BoneIKController {
  3023. private static _tmpVecs;
  3024. private static _tmpQuat;
  3025. private static _tmpMats;
  3026. targetMesh: AbstractMesh;
  3027. poleTargetMesh: AbstractMesh;
  3028. poleTargetBone: Nullable<Bone>;
  3029. targetPosition: Vector3;
  3030. poleTargetPosition: Vector3;
  3031. poleTargetLocalOffset: Vector3;
  3032. poleAngle: number;
  3033. mesh: AbstractMesh;
  3034. slerpAmount: number;
  3035. private _bone1Quat;
  3036. private _bone1Mat;
  3037. private _bone2Ang;
  3038. private _bone1;
  3039. private _bone2;
  3040. private _bone1Length;
  3041. private _bone2Length;
  3042. private _maxAngle;
  3043. private _maxReach;
  3044. private _rightHandedSystem;
  3045. private _bendAxis;
  3046. private _slerping;
  3047. private _adjustRoll;
  3048. maxAngle: number;
  3049. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  3050. targetMesh?: AbstractMesh;
  3051. poleTargetMesh?: AbstractMesh;
  3052. poleTargetBone?: Bone;
  3053. poleTargetLocalOffset?: Vector3;
  3054. poleAngle?: number;
  3055. bendAxis?: Vector3;
  3056. maxAngle?: number;
  3057. slerpAmount?: number;
  3058. });
  3059. private _setMaxAngle(ang);
  3060. update(): void;
  3061. }
  3062. }
  3063. declare module BABYLON {
  3064. class BoneLookController {
  3065. private static _tmpVecs;
  3066. private static _tmpQuat;
  3067. private static _tmpMats;
  3068. /**
  3069. * The target Vector3 that the bone will look at.
  3070. */
  3071. target: Vector3;
  3072. /**
  3073. * The mesh that the bone is attached to.
  3074. */
  3075. mesh: AbstractMesh;
  3076. /**
  3077. * The bone that will be looking to the target.
  3078. */
  3079. bone: Bone;
  3080. /**
  3081. * The up axis of the coordinate system that is used when the bone is rotated.
  3082. */
  3083. upAxis: Vector3;
  3084. /**
  3085. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  3086. */
  3087. upAxisSpace: Space;
  3088. /**
  3089. * Used to make an adjustment to the yaw of the bone.
  3090. */
  3091. adjustYaw: number;
  3092. /**
  3093. * Used to make an adjustment to the pitch of the bone.
  3094. */
  3095. adjustPitch: number;
  3096. /**
  3097. * Used to make an adjustment to the roll of the bone.
  3098. */
  3099. adjustRoll: number;
  3100. /**
  3101. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp).
  3102. */
  3103. slerpAmount: number;
  3104. private _minYaw;
  3105. private _maxYaw;
  3106. private _minPitch;
  3107. private _maxPitch;
  3108. private _minYawSin;
  3109. private _minYawCos;
  3110. private _maxYawSin;
  3111. private _maxYawCos;
  3112. private _midYawConstraint;
  3113. private _minPitchTan;
  3114. private _maxPitchTan;
  3115. private _boneQuat;
  3116. private _slerping;
  3117. private _transformYawPitch;
  3118. private _transformYawPitchInv;
  3119. private _firstFrameSkipped;
  3120. private _yawRange;
  3121. private _fowardAxis;
  3122. /**
  3123. * Get/set the minimum yaw angle that the bone can look to.
  3124. */
  3125. minYaw: number;
  3126. /**
  3127. * Get/set the maximum yaw angle that the bone can look to.
  3128. */
  3129. maxYaw: number;
  3130. /**
  3131. * Get/set the minimum pitch angle that the bone can look to.
  3132. */
  3133. minPitch: number;
  3134. /**
  3135. * Get/set the maximum pitch angle that the bone can look to.
  3136. */
  3137. maxPitch: number;
  3138. /**
  3139. * Create a BoneLookController
  3140. * @param mesh the mesh that the bone belongs to
  3141. * @param bone the bone that will be looking to the target
  3142. * @param target the target Vector3 to look at
  3143. * @param settings optional settings:
  3144. * - maxYaw: the maximum angle the bone will yaw to
  3145. * - minYaw: the minimum angle the bone will yaw to
  3146. * - maxPitch: the maximum angle the bone will pitch to
  3147. * - minPitch: the minimum angle the bone will yaw to
  3148. * - slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  3149. * - upAxis: the up axis of the coordinate system
  3150. * - upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  3151. * - yawAxis: set yawAxis if the bone does not yaw on the y axis
  3152. * - pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  3153. * - adjustYaw: used to make an adjustment to the yaw of the bone
  3154. * - adjustPitch: used to make an adjustment to the pitch of the bone
  3155. * - adjustRoll: used to make an adjustment to the roll of the bone
  3156. **/
  3157. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  3158. maxYaw?: number;
  3159. minYaw?: number;
  3160. maxPitch?: number;
  3161. minPitch?: number;
  3162. slerpAmount?: number;
  3163. upAxis?: Vector3;
  3164. upAxisSpace?: Space;
  3165. yawAxis?: Vector3;
  3166. pitchAxis?: Vector3;
  3167. adjustYaw?: number;
  3168. adjustPitch?: number;
  3169. adjustRoll?: number;
  3170. });
  3171. /**
  3172. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender()).
  3173. */
  3174. update(): void;
  3175. private _getAngleDiff(ang1, ang2);
  3176. private _getAngleBetween(ang1, ang2);
  3177. private _isAngleBetween(ang, ang1, ang2);
  3178. }
  3179. }
  3180. declare module BABYLON {
  3181. class Skeleton implements IAnimatable {
  3182. name: string;
  3183. id: string;
  3184. bones: Bone[];
  3185. dimensionsAtRest: Vector3;
  3186. needInitialSkinMatrix: boolean;
  3187. animations: Array<Animation>;
  3188. private _scene;
  3189. private _isDirty;
  3190. private _transformMatrices;
  3191. private _meshesWithPoseMatrix;
  3192. private _animatables;
  3193. private _identity;
  3194. private _synchronizedWithMesh;
  3195. private _ranges;
  3196. private _lastAbsoluteTransformsUpdateId;
  3197. /**
  3198. * Specifies if the skeleton should be serialized.
  3199. */
  3200. doNotSerialize: boolean;
  3201. /**
  3202. * Gets or sets the animation properties override
  3203. */
  3204. animationPropertiesOverride: AnimationPropertiesOverride;
  3205. /**
  3206. * An event triggered before computing the skeleton's matrices
  3207. * @type {BABYLON.Observable}
  3208. */
  3209. onBeforeComputeObservable: Observable<Skeleton>;
  3210. constructor(name: string, id: string, scene: Scene);
  3211. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  3212. getScene(): Scene;
  3213. /**
  3214. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3215. */
  3216. toString(fullDetails?: boolean): string;
  3217. /**
  3218. * Get bone's index searching by name
  3219. * @param {string} name is bone's name to search for
  3220. * @return {number} Indice of the bone. Returns -1 if not found
  3221. */
  3222. getBoneIndexByName(name: string): number;
  3223. createAnimationRange(name: string, from: number, to: number): void;
  3224. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  3225. getAnimationRange(name: string): Nullable<AnimationRange>;
  3226. /**
  3227. * Returns as an Array, all AnimationRanges defined on this skeleton
  3228. */
  3229. getAnimationRanges(): Nullable<AnimationRange>[];
  3230. /**
  3231. * note: This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  3232. */
  3233. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  3234. returnToRest(): void;
  3235. private _getHighestAnimationFrame();
  3236. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  3237. _markAsDirty(): void;
  3238. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  3239. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  3240. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  3241. prepare(): void;
  3242. getAnimatables(): IAnimatable[];
  3243. clone(name: string, id: string): Skeleton;
  3244. enableBlending(blendingSpeed?: number): void;
  3245. dispose(): void;
  3246. serialize(): any;
  3247. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  3248. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  3249. getPoseMatrix(): Nullable<Matrix>;
  3250. sortBones(): void;
  3251. private _sortBones(index, bones, visited);
  3252. }
  3253. }
  3254. declare module BABYLON {
  3255. class ArcRotateCamera extends TargetCamera {
  3256. alpha: number;
  3257. beta: number;
  3258. radius: number;
  3259. protected _target: Vector3;
  3260. protected _targetHost: Nullable<AbstractMesh>;
  3261. target: Vector3;
  3262. inertialAlphaOffset: number;
  3263. inertialBetaOffset: number;
  3264. inertialRadiusOffset: number;
  3265. lowerAlphaLimit: Nullable<number>;
  3266. upperAlphaLimit: Nullable<number>;
  3267. lowerBetaLimit: number;
  3268. upperBetaLimit: number;
  3269. lowerRadiusLimit: Nullable<number>;
  3270. upperRadiusLimit: Nullable<number>;
  3271. inertialPanningX: number;
  3272. inertialPanningY: number;
  3273. pinchToPanMaxDistance: number;
  3274. panningDistanceLimit: Nullable<number>;
  3275. panningOriginTarget: Vector3;
  3276. panningInertia: number;
  3277. angularSensibilityX: number;
  3278. angularSensibilityY: number;
  3279. pinchPrecision: number;
  3280. pinchDeltaPercentage: number;
  3281. panningSensibility: number;
  3282. keysUp: number[];
  3283. keysDown: number[];
  3284. keysLeft: number[];
  3285. keysRight: number[];
  3286. wheelPrecision: number;
  3287. wheelDeltaPercentage: number;
  3288. zoomOnFactor: number;
  3289. targetScreenOffset: Vector2;
  3290. allowUpsideDown: boolean;
  3291. _viewMatrix: Matrix;
  3292. _useCtrlForPanning: boolean;
  3293. _panningMouseButton: number;
  3294. inputs: ArcRotateCameraInputsManager;
  3295. _reset: () => void;
  3296. panningAxis: Vector3;
  3297. protected _localDirection: Vector3;
  3298. protected _transformedDirection: Vector3;
  3299. private _bouncingBehavior;
  3300. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  3301. useBouncingBehavior: boolean;
  3302. private _framingBehavior;
  3303. readonly framingBehavior: Nullable<FramingBehavior>;
  3304. useFramingBehavior: boolean;
  3305. private _autoRotationBehavior;
  3306. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  3307. useAutoRotationBehavior: boolean;
  3308. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  3309. onCollide: (collidedMesh: AbstractMesh) => void;
  3310. checkCollisions: boolean;
  3311. collisionRadius: Vector3;
  3312. protected _collider: Collider;
  3313. protected _previousPosition: Vector3;
  3314. protected _collisionVelocity: Vector3;
  3315. protected _newPosition: Vector3;
  3316. protected _previousAlpha: number;
  3317. protected _previousBeta: number;
  3318. protected _previousRadius: number;
  3319. protected _collisionTriggered: boolean;
  3320. protected _targetBoundingCenter: Nullable<Vector3>;
  3321. private _computationVector;
  3322. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
  3323. _initCache(): void;
  3324. _updateCache(ignoreParentClass?: boolean): void;
  3325. protected _getTargetPosition(): Vector3;
  3326. /**
  3327. * Store current camera state (fov, position, etc..)
  3328. */
  3329. private _storedAlpha;
  3330. private _storedBeta;
  3331. private _storedRadius;
  3332. private _storedTarget;
  3333. storeState(): Camera;
  3334. /**
  3335. * Restored camera state. You must call storeState() first
  3336. */
  3337. _restoreStateValues(): boolean;
  3338. _isSynchronizedViewMatrix(): boolean;
  3339. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  3340. detachControl(element: HTMLElement): void;
  3341. _checkInputs(): void;
  3342. protected _checkLimits(): void;
  3343. rebuildAnglesAndRadius(): void;
  3344. setPosition(position: Vector3): void;
  3345. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  3346. _getViewMatrix(): Matrix;
  3347. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  3348. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  3349. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  3350. min: Vector3;
  3351. max: Vector3;
  3352. distance: number;
  3353. }, doNotUpdateMaxZ?: boolean): void;
  3354. /**
  3355. * @override
  3356. * Override Camera.createRigCamera
  3357. */
  3358. createRigCamera(name: string, cameraIndex: number): Camera;
  3359. /**
  3360. * @override
  3361. * Override Camera._updateRigCameras
  3362. */
  3363. _updateRigCameras(): void;
  3364. dispose(): void;
  3365. getClassName(): string;
  3366. }
  3367. }
  3368. declare module BABYLON {
  3369. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  3370. constructor(camera: ArcRotateCamera);
  3371. addMouseWheel(): ArcRotateCameraInputsManager;
  3372. addPointers(): ArcRotateCameraInputsManager;
  3373. addKeyboard(): ArcRotateCameraInputsManager;
  3374. addGamepad(): ArcRotateCameraInputsManager;
  3375. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  3376. }
  3377. }
  3378. declare module BABYLON {
  3379. class Camera extends Node {
  3380. inputs: CameraInputsManager<Camera>;
  3381. private static _PERSPECTIVE_CAMERA;
  3382. private static _ORTHOGRAPHIC_CAMERA;
  3383. private static _FOVMODE_VERTICAL_FIXED;
  3384. private static _FOVMODE_HORIZONTAL_FIXED;
  3385. private static _RIG_MODE_NONE;
  3386. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  3387. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  3388. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  3389. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  3390. private static _RIG_MODE_VR;
  3391. private static _RIG_MODE_WEBVR;
  3392. static readonly PERSPECTIVE_CAMERA: number;
  3393. static readonly ORTHOGRAPHIC_CAMERA: number;
  3394. /**
  3395. * This is the default FOV mode for perspective cameras.
  3396. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  3397. *
  3398. */
  3399. static readonly FOVMODE_VERTICAL_FIXED: number;
  3400. /**
  3401. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  3402. *
  3403. */
  3404. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  3405. static readonly RIG_MODE_NONE: number;
  3406. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  3407. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  3408. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  3409. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  3410. static readonly RIG_MODE_VR: number;
  3411. static readonly RIG_MODE_WEBVR: number;
  3412. static ForceAttachControlToAlwaysPreventDefault: boolean;
  3413. static UseAlternateWebVRRendering: boolean;
  3414. position: Vector3;
  3415. /**
  3416. * The vector the camera should consider as up.
  3417. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  3418. */
  3419. upVector: Vector3;
  3420. orthoLeft: Nullable<number>;
  3421. orthoRight: Nullable<number>;
  3422. orthoBottom: Nullable<number>;
  3423. orthoTop: Nullable<number>;
  3424. /**
  3425. * FOV is set in Radians. (default is 0.8)
  3426. */
  3427. fov: number;
  3428. minZ: number;
  3429. maxZ: number;
  3430. inertia: number;
  3431. mode: number;
  3432. isIntermediate: boolean;
  3433. viewport: Viewport;
  3434. /**
  3435. * Restricts the camera to viewing objects with the same layerMask.
  3436. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  3437. */
  3438. layerMask: number;
  3439. /**
  3440. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  3441. */
  3442. fovMode: number;
  3443. cameraRigMode: number;
  3444. interaxialDistance: number;
  3445. isStereoscopicSideBySide: boolean;
  3446. _cameraRigParams: any;
  3447. _rigCameras: Camera[];
  3448. _rigPostProcess: Nullable<PostProcess>;
  3449. protected _webvrViewMatrix: Matrix;
  3450. _skipRendering: boolean;
  3451. _alternateCamera: Camera;
  3452. customRenderTargets: RenderTargetTexture[];
  3453. onViewMatrixChangedObservable: Observable<Camera>;
  3454. onProjectionMatrixChangedObservable: Observable<Camera>;
  3455. onAfterCheckInputsObservable: Observable<Camera>;
  3456. onRestoreStateObservable: Observable<Camera>;
  3457. private _computedViewMatrix;
  3458. _projectionMatrix: Matrix;
  3459. private _doNotComputeProjectionMatrix;
  3460. private _worldMatrix;
  3461. _postProcesses: Nullable<PostProcess>[];
  3462. private _transformMatrix;
  3463. _activeMeshes: SmartArray<AbstractMesh>;
  3464. private _globalPosition;
  3465. private _frustumPlanes;
  3466. private _refreshFrustumPlanes;
  3467. constructor(name: string, position: Vector3, scene: Scene);
  3468. private _storedFov;
  3469. private _stateStored;
  3470. /**
  3471. * Store current camera state (fov, position, etc..)
  3472. */
  3473. storeState(): Camera;
  3474. /**
  3475. * Restores the camera state values if it has been stored. You must call storeState() first
  3476. */
  3477. protected _restoreStateValues(): boolean;
  3478. /**
  3479. * Restored camera state. You must call storeState() first
  3480. */
  3481. restoreState(): boolean;
  3482. getClassName(): string;
  3483. /**
  3484. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3485. */
  3486. toString(fullDetails?: boolean): string;
  3487. readonly globalPosition: Vector3;
  3488. getActiveMeshes(): SmartArray<AbstractMesh>;
  3489. isActiveMesh(mesh: Mesh): boolean;
  3490. _initCache(): void;
  3491. _updateCache(ignoreParentClass?: boolean): void;
  3492. _isSynchronized(): boolean;
  3493. _isSynchronizedViewMatrix(): boolean;
  3494. _isSynchronizedProjectionMatrix(): boolean;
  3495. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3496. detachControl(element: HTMLElement): void;
  3497. update(): void;
  3498. _checkInputs(): void;
  3499. readonly rigCameras: Camera[];
  3500. readonly rigPostProcess: Nullable<PostProcess>;
  3501. /**
  3502. * Internal, gets the first post proces.
  3503. * @returns the first post process to be run on this camera.
  3504. */
  3505. _getFirstPostProcess(): Nullable<PostProcess>;
  3506. private _cascadePostProcessesToRigCams();
  3507. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  3508. detachPostProcess(postProcess: PostProcess): void;
  3509. getWorldMatrix(): Matrix;
  3510. _getViewMatrix(): Matrix;
  3511. getViewMatrix(force?: boolean): Matrix;
  3512. freezeProjectionMatrix(projection?: Matrix): void;
  3513. unfreezeProjectionMatrix(): void;
  3514. getProjectionMatrix(force?: boolean): Matrix;
  3515. getTranformationMatrix(): Matrix;
  3516. private updateFrustumPlanes();
  3517. isInFrustum(target: ICullable): boolean;
  3518. isCompletelyInFrustum(target: ICullable): boolean;
  3519. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  3520. /**
  3521. * Releases resources associated with this node.
  3522. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  3523. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  3524. */
  3525. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  3526. readonly leftCamera: Nullable<FreeCamera>;
  3527. readonly rightCamera: Nullable<FreeCamera>;
  3528. getLeftTarget(): Nullable<Vector3>;
  3529. getRightTarget(): Nullable<Vector3>;
  3530. setCameraRigMode(mode: number, rigParams: any): void;
  3531. private _getVRProjectionMatrix();
  3532. protected _updateCameraRotationMatrix(): void;
  3533. protected _updateWebVRCameraRotationMatrix(): void;
  3534. /**
  3535. * This function MUST be overwritten by the different WebVR cameras available.
  3536. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  3537. */
  3538. protected _getWebVRProjectionMatrix(): Matrix;
  3539. /**
  3540. * This function MUST be overwritten by the different WebVR cameras available.
  3541. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  3542. */
  3543. protected _getWebVRViewMatrix(): Matrix;
  3544. setCameraRigParameter(name: string, value: any): void;
  3545. /**
  3546. * needs to be overridden by children so sub has required properties to be copied
  3547. */
  3548. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  3549. /**
  3550. * May need to be overridden by children
  3551. */
  3552. _updateRigCameras(): void;
  3553. _setupInputs(): void;
  3554. serialize(): any;
  3555. clone(name: string): Camera;
  3556. getDirection(localAxis: Vector3): Vector3;
  3557. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  3558. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  3559. computeWorldMatrix(): Matrix;
  3560. static Parse(parsedCamera: any, scene: Scene): Camera;
  3561. }
  3562. }
  3563. declare module BABYLON {
  3564. var CameraInputTypes: {};
  3565. interface ICameraInput<TCamera extends Camera> {
  3566. camera: Nullable<TCamera>;
  3567. getClassName(): string;
  3568. getSimpleName(): string;
  3569. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  3570. detachControl: (element: Nullable<HTMLElement>) => void;
  3571. checkInputs?: () => void;
  3572. }
  3573. interface CameraInputsMap<TCamera extends Camera> {
  3574. [name: string]: ICameraInput<TCamera>;
  3575. [idx: number]: ICameraInput<TCamera>;
  3576. }
  3577. class CameraInputsManager<TCamera extends Camera> {
  3578. attached: CameraInputsMap<TCamera>;
  3579. attachedElement: Nullable<HTMLElement>;
  3580. noPreventDefault: boolean;
  3581. camera: TCamera;
  3582. checkInputs: () => void;
  3583. constructor(camera: TCamera);
  3584. /**
  3585. * Add an input method to a camera.
  3586. * builtin inputs example: camera.inputs.addGamepad();
  3587. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  3588. * @param input camera input method
  3589. */
  3590. add(input: ICameraInput<TCamera>): void;
  3591. /**
  3592. * Remove a specific input method from a camera
  3593. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  3594. * @param inputToRemove camera input method
  3595. */
  3596. remove(inputToRemove: ICameraInput<TCamera>): void;
  3597. removeByType(inputType: string): void;
  3598. private _addCheckInputs(fn);
  3599. attachInput(input: ICameraInput<TCamera>): void;
  3600. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  3601. detachElement(element: HTMLElement, disconnect?: boolean): void;
  3602. rebuildInputCheck(): void;
  3603. /**
  3604. * Remove all attached input methods from a camera
  3605. */
  3606. clear(): void;
  3607. serialize(serializedCamera: any): void;
  3608. parse(parsedCamera: any): void;
  3609. }
  3610. }
  3611. declare module BABYLON {
  3612. /**
  3613. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  3614. * being tilted forward or back and left or right.
  3615. */
  3616. class DeviceOrientationCamera extends FreeCamera {
  3617. private _initialQuaternion;
  3618. private _quaternionCache;
  3619. /**
  3620. * Creates a new device orientation camera. @see DeviceOrientationCamera
  3621. * @param name The name of the camera
  3622. * @param position The start position camera
  3623. * @param scene The scene the camera belongs to
  3624. */
  3625. constructor(name: string, position: Vector3, scene: Scene);
  3626. /**
  3627. * Gets the current instance class name ("DeviceOrientationCamera").
  3628. * This helps avoiding instanceof at run time.
  3629. * @returns the class name
  3630. */
  3631. getClassName(): string;
  3632. /**
  3633. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  3634. */
  3635. _checkInputs(): void;
  3636. /**
  3637. * Reset the camera to its default orientation on the specified axis only.
  3638. * @param axis The axis to reset
  3639. */
  3640. resetToCurrentRotation(axis?: Axis): void;
  3641. }
  3642. }
  3643. declare module BABYLON {
  3644. class FollowCamera extends TargetCamera {
  3645. radius: number;
  3646. rotationOffset: number;
  3647. heightOffset: number;
  3648. cameraAcceleration: number;
  3649. maxCameraSpeed: number;
  3650. lockedTarget: Nullable<AbstractMesh>;
  3651. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  3652. private getRadians(degrees);
  3653. private follow(cameraTarget);
  3654. _checkInputs(): void;
  3655. getClassName(): string;
  3656. }
  3657. class ArcFollowCamera extends TargetCamera {
  3658. alpha: number;
  3659. beta: number;
  3660. radius: number;
  3661. target: Nullable<AbstractMesh>;
  3662. private _cartesianCoordinates;
  3663. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  3664. private follow();
  3665. _checkInputs(): void;
  3666. getClassName(): string;
  3667. }
  3668. }
  3669. declare module BABYLON {
  3670. class FreeCamera extends TargetCamera {
  3671. ellipsoid: Vector3;
  3672. ellipsoidOffset: Vector3;
  3673. checkCollisions: boolean;
  3674. applyGravity: boolean;
  3675. inputs: FreeCameraInputsManager;
  3676. /**
  3677. * Gets the input sensibility for a mouse input. (default is 2000.0)
  3678. * Higher values reduce sensitivity.
  3679. */
  3680. /**
  3681. * Sets the input sensibility for a mouse input. (default is 2000.0)
  3682. * Higher values reduce sensitivity.
  3683. */
  3684. angularSensibility: number;
  3685. keysUp: number[];
  3686. keysDown: number[];
  3687. keysLeft: number[];
  3688. keysRight: number[];
  3689. onCollide: (collidedMesh: AbstractMesh) => void;
  3690. private _collider;
  3691. private _needMoveForGravity;
  3692. private _oldPosition;
  3693. private _diffPosition;
  3694. private _newPosition;
  3695. _localDirection: Vector3;
  3696. _transformedDirection: Vector3;
  3697. constructor(name: string, position: Vector3, scene: Scene);
  3698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3699. detachControl(element: HTMLElement): void;
  3700. private _collisionMask;
  3701. collisionMask: number;
  3702. _collideWithWorld(displacement: Vector3): void;
  3703. private _onCollisionPositionChange;
  3704. _checkInputs(): void;
  3705. _decideIfNeedsToMove(): boolean;
  3706. _updatePosition(): void;
  3707. dispose(): void;
  3708. getClassName(): string;
  3709. }
  3710. }
  3711. declare module BABYLON {
  3712. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  3713. constructor(camera: FreeCamera);
  3714. addKeyboard(): FreeCameraInputsManager;
  3715. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  3716. addGamepad(): FreeCameraInputsManager;
  3717. addDeviceOrientation(): FreeCameraInputsManager;
  3718. addTouch(): FreeCameraInputsManager;
  3719. addVirtualJoystick(): FreeCameraInputsManager;
  3720. }
  3721. }
  3722. declare module BABYLON {
  3723. class GamepadCamera extends UniversalCamera {
  3724. gamepadAngularSensibility: number;
  3725. gamepadMoveSensibility: number;
  3726. constructor(name: string, position: Vector3, scene: Scene);
  3727. getClassName(): string;
  3728. }
  3729. }
  3730. declare module BABYLON {
  3731. class AnaglyphFreeCamera extends FreeCamera {
  3732. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3733. getClassName(): string;
  3734. }
  3735. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  3736. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  3737. getClassName(): string;
  3738. }
  3739. class AnaglyphGamepadCamera extends GamepadCamera {
  3740. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3741. getClassName(): string;
  3742. }
  3743. class AnaglyphUniversalCamera extends UniversalCamera {
  3744. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3745. getClassName(): string;
  3746. }
  3747. class StereoscopicFreeCamera extends FreeCamera {
  3748. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3749. getClassName(): string;
  3750. }
  3751. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  3752. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3753. getClassName(): string;
  3754. }
  3755. class StereoscopicGamepadCamera extends GamepadCamera {
  3756. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3757. getClassName(): string;
  3758. }
  3759. class StereoscopicUniversalCamera extends UniversalCamera {
  3760. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3761. getClassName(): string;
  3762. }
  3763. }
  3764. declare module BABYLON {
  3765. class TargetCamera extends Camera {
  3766. cameraDirection: Vector3;
  3767. cameraRotation: Vector2;
  3768. rotation: Vector3;
  3769. rotationQuaternion: Quaternion;
  3770. speed: number;
  3771. noRotationConstraint: boolean;
  3772. lockedTarget: any;
  3773. _currentTarget: Vector3;
  3774. _viewMatrix: Matrix;
  3775. _camMatrix: Matrix;
  3776. _cameraTransformMatrix: Matrix;
  3777. _cameraRotationMatrix: Matrix;
  3778. private _rigCamTransformMatrix;
  3779. _referencePoint: Vector3;
  3780. private _currentUpVector;
  3781. _transformedReferencePoint: Vector3;
  3782. _lookAtTemp: Matrix;
  3783. _tempMatrix: Matrix;
  3784. _reset: () => void;
  3785. constructor(name: string, position: Vector3, scene: Scene);
  3786. getFrontPosition(distance: number): Vector3;
  3787. _getLockedTargetPosition(): Nullable<Vector3>;
  3788. /**
  3789. * Store current camera state (fov, position, etc..)
  3790. */
  3791. private _storedPosition;
  3792. private _storedRotation;
  3793. private _storedRotationQuaternion;
  3794. storeState(): Camera;
  3795. /**
  3796. * Restored camera state. You must call storeState() first
  3797. */
  3798. _restoreStateValues(): boolean;
  3799. _initCache(): void;
  3800. _updateCache(ignoreParentClass?: boolean): void;
  3801. _isSynchronizedViewMatrix(): boolean;
  3802. _computeLocalCameraSpeed(): number;
  3803. setTarget(target: Vector3): void;
  3804. /**
  3805. * Return the current target position of the camera. This value is expressed in local space.
  3806. */
  3807. getTarget(): Vector3;
  3808. _decideIfNeedsToMove(): boolean;
  3809. _updatePosition(): void;
  3810. _checkInputs(): void;
  3811. protected _updateCameraRotationMatrix(): void;
  3812. _getViewMatrix(): Matrix;
  3813. /**
  3814. * @override
  3815. * Override Camera.createRigCamera
  3816. */
  3817. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  3818. /**
  3819. * @override
  3820. * Override Camera._updateRigCameras
  3821. */
  3822. _updateRigCameras(): void;
  3823. private _getRigCamPosition(halfSpace, result);
  3824. getClassName(): string;
  3825. }
  3826. }
  3827. declare module BABYLON {
  3828. class TouchCamera extends FreeCamera {
  3829. touchAngularSensibility: number;
  3830. touchMoveSensibility: number;
  3831. constructor(name: string, position: Vector3, scene: Scene);
  3832. getClassName(): string;
  3833. _setupInputs(): void;
  3834. }
  3835. }
  3836. declare module BABYLON {
  3837. class UniversalCamera extends TouchCamera {
  3838. gamepadAngularSensibility: number;
  3839. gamepadMoveSensibility: number;
  3840. constructor(name: string, position: Vector3, scene: Scene);
  3841. getClassName(): string;
  3842. }
  3843. }
  3844. declare module BABYLON {
  3845. class VirtualJoysticksCamera extends FreeCamera {
  3846. constructor(name: string, position: Vector3, scene: Scene);
  3847. getClassName(): string;
  3848. }
  3849. }
  3850. declare module BABYLON {
  3851. class Collider {
  3852. /** Define if a collision was found */
  3853. collisionFound: boolean;
  3854. /**
  3855. * Define last intersection point in local space
  3856. */
  3857. intersectionPoint: Vector3;
  3858. /**
  3859. * Define last collided mesh
  3860. */
  3861. collidedMesh: Nullable<AbstractMesh>;
  3862. private _collisionPoint;
  3863. private _planeIntersectionPoint;
  3864. private _tempVector;
  3865. private _tempVector2;
  3866. private _tempVector3;
  3867. private _tempVector4;
  3868. private _edge;
  3869. private _baseToVertex;
  3870. private _destinationPoint;
  3871. private _slidePlaneNormal;
  3872. private _displacementVector;
  3873. _radius: Vector3;
  3874. _retry: number;
  3875. private _velocity;
  3876. private _basePoint;
  3877. private _epsilon;
  3878. _velocityWorldLength: number;
  3879. _basePointWorld: Vector3;
  3880. private _velocityWorld;
  3881. private _normalizedVelocity;
  3882. _initialVelocity: Vector3;
  3883. _initialPosition: Vector3;
  3884. private _nearestDistance;
  3885. private _collisionMask;
  3886. collisionMask: number;
  3887. /**
  3888. * Gets the plane normal used to compute the sliding response (in local space)
  3889. */
  3890. readonly slidePlaneNormal: Vector3;
  3891. _initialize(source: Vector3, dir: Vector3, e: number): void;
  3892. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  3893. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  3894. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  3895. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  3896. _getResponse(pos: Vector3, vel: Vector3): void;
  3897. }
  3898. }
  3899. declare module BABYLON {
  3900. var CollisionWorker: string;
  3901. interface ICollisionCoordinator {
  3902. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  3903. init(scene: Scene): void;
  3904. destroy(): void;
  3905. onMeshAdded(mesh: AbstractMesh): void;
  3906. onMeshUpdated(mesh: AbstractMesh): void;
  3907. onMeshRemoved(mesh: AbstractMesh): void;
  3908. onGeometryAdded(geometry: Geometry): void;
  3909. onGeometryUpdated(geometry: Geometry): void;
  3910. onGeometryDeleted(geometry: Geometry): void;
  3911. }
  3912. interface SerializedMesh {
  3913. id: string;
  3914. name: string;
  3915. uniqueId: number;
  3916. geometryId: Nullable<string>;
  3917. sphereCenter: Array<number>;
  3918. sphereRadius: number;
  3919. boxMinimum: Array<number>;
  3920. boxMaximum: Array<number>;
  3921. worldMatrixFromCache: any;
  3922. subMeshes: Array<SerializedSubMesh>;
  3923. checkCollisions: boolean;
  3924. }
  3925. interface SerializedSubMesh {
  3926. position: number;
  3927. verticesStart: number;
  3928. verticesCount: number;
  3929. indexStart: number;
  3930. indexCount: number;
  3931. hasMaterial: boolean;
  3932. sphereCenter: Array<number>;
  3933. sphereRadius: number;
  3934. boxMinimum: Array<number>;
  3935. boxMaximum: Array<number>;
  3936. }
  3937. /**
  3938. * Interface describing the value associated with a geometry
  3939. */
  3940. interface SerializedGeometry {
  3941. /**
  3942. * Defines the unique ID of the geometry
  3943. */
  3944. id: string;
  3945. /**
  3946. * Defines the array containing the positions
  3947. */
  3948. positions: Float32Array;
  3949. /**
  3950. * Defines the array containing the indices
  3951. */
  3952. indices: Uint32Array;
  3953. /**
  3954. * Defines the array containing the normals
  3955. */
  3956. normals: Float32Array;
  3957. }
  3958. interface BabylonMessage {
  3959. taskType: WorkerTaskType;
  3960. payload: InitPayload | CollidePayload | UpdatePayload;
  3961. }
  3962. interface SerializedColliderToWorker {
  3963. position: Array<number>;
  3964. velocity: Array<number>;
  3965. radius: Array<number>;
  3966. }
  3967. enum WorkerTaskType {
  3968. INIT = 0,
  3969. UPDATE = 1,
  3970. COLLIDE = 2,
  3971. }
  3972. interface WorkerReply {
  3973. error: WorkerReplyType;
  3974. taskType: WorkerTaskType;
  3975. payload?: any;
  3976. }
  3977. interface CollisionReplyPayload {
  3978. newPosition: Array<number>;
  3979. collisionId: number;
  3980. collidedMeshUniqueId: number;
  3981. }
  3982. interface InitPayload {
  3983. }
  3984. interface CollidePayload {
  3985. collisionId: number;
  3986. collider: SerializedColliderToWorker;
  3987. maximumRetry: number;
  3988. excludedMeshUniqueId: Nullable<number>;
  3989. }
  3990. interface UpdatePayload {
  3991. updatedMeshes: {
  3992. [n: number]: SerializedMesh;
  3993. };
  3994. updatedGeometries: {
  3995. [s: string]: SerializedGeometry;
  3996. };
  3997. removedMeshes: Array<number>;
  3998. removedGeometries: Array<string>;
  3999. }
  4000. enum WorkerReplyType {
  4001. SUCCESS = 0,
  4002. UNKNOWN_ERROR = 1,
  4003. }
  4004. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  4005. private _scene;
  4006. private _scaledPosition;
  4007. private _scaledVelocity;
  4008. private _collisionsCallbackArray;
  4009. private _init;
  4010. private _runningUpdated;
  4011. private _worker;
  4012. private _addUpdateMeshesList;
  4013. private _addUpdateGeometriesList;
  4014. private _toRemoveMeshesArray;
  4015. private _toRemoveGeometryArray;
  4016. constructor();
  4017. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  4018. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  4019. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4020. init(scene: Scene): void;
  4021. destroy(): void;
  4022. onMeshAdded(mesh: AbstractMesh): void;
  4023. onMeshUpdated: (transformNode: TransformNode) => void;
  4024. onMeshRemoved(mesh: AbstractMesh): void;
  4025. onGeometryAdded(geometry: Geometry): void;
  4026. onGeometryUpdated: (geometry: Geometry) => void;
  4027. onGeometryDeleted(geometry: Geometry): void;
  4028. private _afterRender;
  4029. private _onMessageFromWorker;
  4030. }
  4031. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  4032. private _scene;
  4033. private _scaledPosition;
  4034. private _scaledVelocity;
  4035. private _finalPosition;
  4036. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4037. init(scene: Scene): void;
  4038. destroy(): void;
  4039. onMeshAdded(mesh: AbstractMesh): void;
  4040. onMeshUpdated(mesh: AbstractMesh): void;
  4041. onMeshRemoved(mesh: AbstractMesh): void;
  4042. onGeometryAdded(geometry: Geometry): void;
  4043. onGeometryUpdated(geometry: Geometry): void;
  4044. onGeometryDeleted(geometry: Geometry): void;
  4045. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  4046. }
  4047. }
  4048. declare function importScripts(...urls: string[]): void;
  4049. declare const safePostMessage: any;
  4050. declare module BABYLON {
  4051. var WorkerIncluded: boolean;
  4052. class CollisionCache {
  4053. private _meshes;
  4054. private _geometries;
  4055. getMeshes(): {
  4056. [n: number]: SerializedMesh;
  4057. };
  4058. getGeometries(): {
  4059. [s: number]: SerializedGeometry;
  4060. };
  4061. getMesh(id: any): SerializedMesh;
  4062. addMesh(mesh: SerializedMesh): void;
  4063. removeMesh(uniqueId: number): void;
  4064. getGeometry(id: string): SerializedGeometry;
  4065. addGeometry(geometry: SerializedGeometry): void;
  4066. removeGeometry(id: string): void;
  4067. }
  4068. class CollideWorker {
  4069. collider: Collider;
  4070. private _collisionCache;
  4071. private finalPosition;
  4072. private collisionsScalingMatrix;
  4073. private collisionTranformationMatrix;
  4074. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  4075. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  4076. private checkCollision(mesh);
  4077. private processCollisionsForSubMeshes(transformMatrix, mesh);
  4078. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  4079. private checkSubmeshCollision(subMesh);
  4080. }
  4081. interface ICollisionDetector {
  4082. onInit(payload: InitPayload): void;
  4083. onUpdate(payload: UpdatePayload): void;
  4084. onCollision(payload: CollidePayload): void;
  4085. }
  4086. class CollisionDetectorTransferable implements ICollisionDetector {
  4087. private _collisionCache;
  4088. onInit(payload: InitPayload): void;
  4089. onUpdate(payload: UpdatePayload): void;
  4090. onCollision(payload: CollidePayload): void;
  4091. }
  4092. }
  4093. declare module BABYLON {
  4094. class IntersectionInfo {
  4095. bu: Nullable<number>;
  4096. bv: Nullable<number>;
  4097. distance: number;
  4098. faceId: number;
  4099. subMeshId: number;
  4100. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  4101. }
  4102. class PickingInfo {
  4103. hit: boolean;
  4104. distance: number;
  4105. pickedPoint: Nullable<Vector3>;
  4106. pickedMesh: Nullable<AbstractMesh>;
  4107. bu: number;
  4108. bv: number;
  4109. faceId: number;
  4110. subMeshId: number;
  4111. pickedSprite: Nullable<Sprite>;
  4112. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  4113. getTextureCoordinates(): Nullable<Vector2>;
  4114. }
  4115. }
  4116. declare module BABYLON {
  4117. class DebugLayer {
  4118. private _scene;
  4119. static InspectorURL: string;
  4120. private _inspector;
  4121. private BJSINSPECTOR;
  4122. constructor(scene: Scene);
  4123. /** Creates the inspector window. */
  4124. private _createInspector(config?);
  4125. isVisible(): boolean;
  4126. hide(): void;
  4127. show(config?: {
  4128. popup?: boolean;
  4129. initialTab?: number;
  4130. parentElement?: HTMLElement;
  4131. newColors?: {
  4132. backgroundColor?: string;
  4133. backgroundColorLighter?: string;
  4134. backgroundColorLighter2?: string;
  4135. backgroundColorLighter3?: string;
  4136. color?: string;
  4137. colorTop?: string;
  4138. colorBot?: string;
  4139. };
  4140. }): void;
  4141. }
  4142. }
  4143. declare module BABYLON {
  4144. class Debug {
  4145. static AxesViewer: {
  4146. new (scene: Scene, scaleLines?: number): {
  4147. _xline: Vector3[];
  4148. _yline: Vector3[];
  4149. _zline: Vector3[];
  4150. _xmesh: Nullable<LinesMesh>;
  4151. _ymesh: Nullable<LinesMesh>;
  4152. _zmesh: Nullable<LinesMesh>;
  4153. scene: Nullable<Scene>;
  4154. scaleLines: number;
  4155. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  4156. dispose(): void;
  4157. };
  4158. };
  4159. static BoneAxesViewer: {
  4160. new (scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number): {
  4161. mesh: Nullable<Mesh>;
  4162. bone: Nullable<Bone>;
  4163. pos: Vector3;
  4164. xaxis: Vector3;
  4165. yaxis: Vector3;
  4166. zaxis: Vector3;
  4167. update(): void;
  4168. dispose(): void;
  4169. _xline: Vector3[];
  4170. _yline: Vector3[];
  4171. _zline: Vector3[];
  4172. _xmesh: Nullable<LinesMesh>;
  4173. _ymesh: Nullable<LinesMesh>;
  4174. _zmesh: Nullable<LinesMesh>;
  4175. scene: Nullable<Scene>;
  4176. scaleLines: number;
  4177. };
  4178. };
  4179. static PhysicsViewer: {
  4180. new (scene: Scene): {
  4181. _impostors: Nullable<PhysicsImpostor>[];
  4182. _meshes: Nullable<AbstractMesh>[];
  4183. _scene: Nullable<Scene>;
  4184. _numMeshes: number;
  4185. _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  4186. _renderFunction: () => void;
  4187. _debugBoxMesh: Mesh;
  4188. _debugSphereMesh: Mesh;
  4189. _debugMaterial: StandardMaterial;
  4190. _updateDebugMeshes(): void;
  4191. showImpostor(impostor: PhysicsImpostor): void;
  4192. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  4193. _getDebugMaterial(scene: Scene): Material;
  4194. _getDebugBoxMesh(scene: Scene): AbstractMesh;
  4195. _getDebugSphereMesh(scene: Scene): AbstractMesh;
  4196. _getDebugMesh(impostor: PhysicsImpostor, scene: Scene): Nullable<AbstractMesh>;
  4197. dispose(): void;
  4198. };
  4199. };
  4200. static SkeletonViewer: {
  4201. new (skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number): {
  4202. color: Color3;
  4203. _scene: Scene;
  4204. _debugLines: Vector3[][];
  4205. _debugMesh: Nullable<LinesMesh>;
  4206. _isEnabled: boolean;
  4207. _renderFunction: () => void;
  4208. skeleton: Skeleton;
  4209. mesh: AbstractMesh;
  4210. autoUpdateBonesMatrices: boolean;
  4211. renderingGroupId: number;
  4212. isEnabled: boolean;
  4213. _getBonePosition(position: Vector3, bone: Bone, meshMat: Matrix, x?: number, y?: number, z?: number): void;
  4214. _getLinesForBonesWithLength(bones: Bone[], meshMat: Matrix): void;
  4215. _getLinesForBonesNoLength(bones: Bone[], meshMat: Matrix): void;
  4216. update(): void;
  4217. dispose(): void;
  4218. };
  4219. };
  4220. }
  4221. }
  4222. declare module BABYLON {
  4223. class RayHelper {
  4224. ray: Nullable<Ray>;
  4225. private _renderPoints;
  4226. private _renderLine;
  4227. private _renderFunction;
  4228. private _scene;
  4229. private _updateToMeshFunction;
  4230. private _attachedToMesh;
  4231. private _meshSpaceDirection;
  4232. private _meshSpaceOrigin;
  4233. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  4234. constructor(ray: Ray);
  4235. show(scene: Scene, color: Color3): void;
  4236. hide(): void;
  4237. private _render();
  4238. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  4239. detachFromMesh(): void;
  4240. private _updateToMesh();
  4241. dispose(): void;
  4242. }
  4243. }
  4244. declare module BABYLON {
  4245. class BoundingBox implements ICullable {
  4246. minimum: Vector3;
  4247. maximum: Vector3;
  4248. vectors: Vector3[];
  4249. center: Vector3;
  4250. centerWorld: Vector3;
  4251. extendSize: Vector3;
  4252. extendSizeWorld: Vector3;
  4253. directions: Vector3[];
  4254. vectorsWorld: Vector3[];
  4255. minimumWorld: Vector3;
  4256. maximumWorld: Vector3;
  4257. private _worldMatrix;
  4258. constructor(minimum: Vector3, maximum: Vector3);
  4259. getWorldMatrix(): Matrix;
  4260. setWorldMatrix(matrix: Matrix): BoundingBox;
  4261. _update(world: Matrix): void;
  4262. isInFrustum(frustumPlanes: Plane[]): boolean;
  4263. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  4264. intersectsPoint(point: Vector3): boolean;
  4265. intersectsSphere(sphere: BoundingSphere): boolean;
  4266. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  4267. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  4268. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  4269. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  4270. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  4271. }
  4272. }
  4273. declare module BABYLON {
  4274. interface ICullable {
  4275. isInFrustum(frustumPlanes: Plane[]): boolean;
  4276. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  4277. }
  4278. class BoundingInfo implements ICullable {
  4279. minimum: Vector3;
  4280. maximum: Vector3;
  4281. boundingBox: BoundingBox;
  4282. boundingSphere: BoundingSphere;
  4283. private _isLocked;
  4284. constructor(minimum: Vector3, maximum: Vector3);
  4285. isLocked: boolean;
  4286. update(world: Matrix): void;
  4287. /**
  4288. * Recreate the bounding info to be centered around a specific point given a specific extend.
  4289. * @param center New center of the bounding info
  4290. * @param extend New extend of the bounding info
  4291. */
  4292. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  4293. isInFrustum(frustumPlanes: Plane[]): boolean;
  4294. /**
  4295. * Gets the world distance between the min and max points of the bounding box
  4296. */
  4297. readonly diagonalLength: number;
  4298. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  4299. _checkCollision(collider: Collider): boolean;
  4300. intersectsPoint(point: Vector3): boolean;
  4301. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  4302. }
  4303. }
  4304. declare module BABYLON {
  4305. class BoundingSphere {
  4306. minimum: Vector3;
  4307. maximum: Vector3;
  4308. center: Vector3;
  4309. radius: number;
  4310. centerWorld: Vector3;
  4311. radiusWorld: number;
  4312. private _tempRadiusVector;
  4313. constructor(minimum: Vector3, maximum: Vector3);
  4314. _update(world: Matrix): void;
  4315. isInFrustum(frustumPlanes: Plane[]): boolean;
  4316. intersectsPoint(point: Vector3): boolean;
  4317. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  4318. }
  4319. }
  4320. declare module BABYLON {
  4321. class Ray {
  4322. origin: Vector3;
  4323. direction: Vector3;
  4324. length: number;
  4325. private _edge1;
  4326. private _edge2;
  4327. private _pvec;
  4328. private _tvec;
  4329. private _qvec;
  4330. private _tmpRay;
  4331. constructor(origin: Vector3, direction: Vector3, length?: number);
  4332. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  4333. intersectsBox(box: BoundingBox): boolean;
  4334. intersectsSphere(sphere: BoundingSphere): boolean;
  4335. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  4336. intersectsPlane(plane: Plane): Nullable<number>;
  4337. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  4338. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  4339. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  4340. private static smallnum;
  4341. private static rayl;
  4342. /**
  4343. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  4344. * @param sega the first point of the segment to test the intersection against
  4345. * @param segb the second point of the segment to test the intersection against
  4346. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  4347. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  4348. */
  4349. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  4350. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  4351. static Zero(): Ray;
  4352. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  4353. /**
  4354. * 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
  4355. * transformed to the given world matrix.
  4356. * @param origin The origin point
  4357. * @param end The end point
  4358. * @param world a matrix to transform the ray to. Default is the identity matrix.
  4359. */
  4360. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  4361. static Transform(ray: Ray, matrix: Matrix): Ray;
  4362. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  4363. }
  4364. }
  4365. declare module BABYLON {
  4366. class InstancingAttributeInfo {
  4367. /**
  4368. * Index/offset of the attribute in the vertex shader
  4369. */
  4370. index: number;
  4371. /**
  4372. * size of the attribute, 1, 2, 3 or 4
  4373. */
  4374. attributeSize: number;
  4375. /**
  4376. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  4377. * default is FLOAT
  4378. */
  4379. attribyteType: number;
  4380. /**
  4381. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  4382. */
  4383. normalized: boolean;
  4384. /**
  4385. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  4386. */
  4387. offset: number;
  4388. /**
  4389. * Name of the GLSL attribute, for debugging purpose only
  4390. */
  4391. attributeName: string;
  4392. }
  4393. /**
  4394. * Define options used to create a render target texture
  4395. */
  4396. class RenderTargetCreationOptions {
  4397. /**
  4398. * Specifies is mipmaps must be generated
  4399. */
  4400. generateMipMaps?: boolean;
  4401. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4402. generateDepthBuffer?: boolean;
  4403. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4404. generateStencilBuffer?: boolean;
  4405. /** Defines texture type (int by default) */
  4406. type?: number;
  4407. /** Defines sampling mode (trilinear by default) */
  4408. samplingMode?: number;
  4409. /** Defines format (RGBA by default) */
  4410. format?: number;
  4411. }
  4412. /**
  4413. * Define options used to create a depth texture
  4414. */
  4415. class DepthTextureCreationOptions {
  4416. /** Specifies whether or not a stencil should be allocated in the texture */
  4417. generateStencil?: boolean;
  4418. /** Specifies whether or not bilinear filtering is enable on the texture */
  4419. bilinearFiltering?: boolean;
  4420. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  4421. comparisonFunction?: number;
  4422. /** Specifies if the created texture is a cube texture */
  4423. isCube?: boolean;
  4424. }
  4425. /**
  4426. * Regroup several parameters relative to the browser in use
  4427. */
  4428. class EngineCapabilities {
  4429. /** The maximum textures image */
  4430. maxTexturesImageUnits: number;
  4431. maxVertexTextureImageUnits: number;
  4432. maxCombinedTexturesImageUnits: number;
  4433. /** The maximum texture size */
  4434. maxTextureSize: number;
  4435. maxCubemapTextureSize: number;
  4436. maxRenderTextureSize: number;
  4437. maxVertexAttribs: number;
  4438. maxVaryingVectors: number;
  4439. maxVertexUniformVectors: number;
  4440. maxFragmentUniformVectors: number;
  4441. standardDerivatives: boolean;
  4442. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  4443. pvrtc: any;
  4444. etc1: any;
  4445. etc2: any;
  4446. astc: any;
  4447. textureFloat: boolean;
  4448. vertexArrayObject: boolean;
  4449. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  4450. maxAnisotropy: number;
  4451. instancedArrays: boolean;
  4452. uintIndices: boolean;
  4453. highPrecisionShaderSupported: boolean;
  4454. fragmentDepthSupported: boolean;
  4455. textureFloatLinearFiltering: boolean;
  4456. textureFloatRender: boolean;
  4457. textureHalfFloat: boolean;
  4458. textureHalfFloatLinearFiltering: boolean;
  4459. textureHalfFloatRender: boolean;
  4460. textureLOD: boolean;
  4461. drawBuffersExtension: boolean;
  4462. depthTextureExtension: boolean;
  4463. colorBufferFloat: boolean;
  4464. timerQuery: EXT_disjoint_timer_query;
  4465. canUseTimestampForTimerQuery: boolean;
  4466. }
  4467. interface EngineOptions extends WebGLContextAttributes {
  4468. limitDeviceRatio?: number;
  4469. autoEnableWebVR?: boolean;
  4470. disableWebGL2Support?: boolean;
  4471. audioEngine?: boolean;
  4472. deterministicLockstep?: boolean;
  4473. lockstepMaxSteps?: number;
  4474. doNotHandleContextLost?: boolean;
  4475. }
  4476. interface IDisplayChangedEventArgs {
  4477. vrDisplay: Nullable<any>;
  4478. vrSupported: boolean;
  4479. }
  4480. /**
  4481. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
  4482. */
  4483. class Engine {
  4484. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  4485. static ExceptionList: ({
  4486. key: string;
  4487. capture: string;
  4488. captureConstraint: number;
  4489. targets: string[];
  4490. } | {
  4491. key: string;
  4492. capture: null;
  4493. captureConstraint: null;
  4494. targets: string[];
  4495. })[];
  4496. static Instances: Engine[];
  4497. static readonly LastCreatedEngine: Nullable<Engine>;
  4498. static readonly LastCreatedScene: Nullable<Scene>;
  4499. /**
  4500. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  4501. */
  4502. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  4503. private static _ALPHA_DISABLE;
  4504. private static _ALPHA_ADD;
  4505. private static _ALPHA_COMBINE;
  4506. private static _ALPHA_SUBTRACT;
  4507. private static _ALPHA_MULTIPLY;
  4508. private static _ALPHA_MAXIMIZED;
  4509. private static _ALPHA_ONEONE;
  4510. private static _ALPHA_PREMULTIPLIED;
  4511. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  4512. private static _ALPHA_INTERPOLATE;
  4513. private static _ALPHA_SCREENMODE;
  4514. private static _DELAYLOADSTATE_NONE;
  4515. private static _DELAYLOADSTATE_LOADED;
  4516. private static _DELAYLOADSTATE_LOADING;
  4517. private static _DELAYLOADSTATE_NOTLOADED;
  4518. private static _TEXTUREFORMAT_ALPHA;
  4519. private static _TEXTUREFORMAT_LUMINANCE;
  4520. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  4521. private static _TEXTUREFORMAT_RGB;
  4522. private static _TEXTUREFORMAT_RGBA;
  4523. private static _TEXTUREFORMAT_R32F;
  4524. private static _TEXTUREFORMAT_RG32F;
  4525. private static _TEXTUREFORMAT_RGB32F;
  4526. private static _TEXTUREFORMAT_RGBA32F;
  4527. private static _TEXTURETYPE_UNSIGNED_INT;
  4528. private static _TEXTURETYPE_FLOAT;
  4529. private static _TEXTURETYPE_HALF_FLOAT;
  4530. private static _NEVER;
  4531. private static _ALWAYS;
  4532. private static _LESS;
  4533. private static _EQUAL;
  4534. private static _LEQUAL;
  4535. private static _GREATER;
  4536. private static _GEQUAL;
  4537. private static _NOTEQUAL;
  4538. static readonly NEVER: number;
  4539. static readonly ALWAYS: number;
  4540. static readonly LESS: number;
  4541. static readonly EQUAL: number;
  4542. static readonly LEQUAL: number;
  4543. static readonly GREATER: number;
  4544. static readonly GEQUAL: number;
  4545. static readonly NOTEQUAL: number;
  4546. private static _KEEP;
  4547. private static _REPLACE;
  4548. private static _INCR;
  4549. private static _DECR;
  4550. private static _INVERT;
  4551. private static _INCR_WRAP;
  4552. private static _DECR_WRAP;
  4553. static readonly KEEP: number;
  4554. static readonly REPLACE: number;
  4555. static readonly INCR: number;
  4556. static readonly DECR: number;
  4557. static readonly INVERT: number;
  4558. static readonly INCR_WRAP: number;
  4559. static readonly DECR_WRAP: number;
  4560. static readonly ALPHA_DISABLE: number;
  4561. static readonly ALPHA_ONEONE: number;
  4562. static readonly ALPHA_ADD: number;
  4563. static readonly ALPHA_COMBINE: number;
  4564. static readonly ALPHA_SUBTRACT: number;
  4565. static readonly ALPHA_MULTIPLY: number;
  4566. static readonly ALPHA_MAXIMIZED: number;
  4567. static readonly ALPHA_PREMULTIPLIED: number;
  4568. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4569. static readonly ALPHA_INTERPOLATE: number;
  4570. static readonly ALPHA_SCREENMODE: number;
  4571. static readonly DELAYLOADSTATE_NONE: number;
  4572. static readonly DELAYLOADSTATE_LOADED: number;
  4573. static readonly DELAYLOADSTATE_LOADING: number;
  4574. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4575. static readonly TEXTUREFORMAT_ALPHA: number;
  4576. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4577. /**
  4578. * R32F
  4579. */
  4580. static readonly TEXTUREFORMAT_R32F: number;
  4581. /**
  4582. * RG32F
  4583. */
  4584. static readonly TEXTUREFORMAT_RG32F: number;
  4585. /**
  4586. * RGB32F
  4587. */
  4588. static readonly TEXTUREFORMAT_RGB32F: number;
  4589. /**
  4590. * RGBA32F
  4591. */
  4592. static readonly TEXTUREFORMAT_RGBA32F: number;
  4593. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4594. static readonly TEXTUREFORMAT_RGB: number;
  4595. static readonly TEXTUREFORMAT_RGBA: number;
  4596. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4597. static readonly TEXTURETYPE_FLOAT: number;
  4598. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4599. private static _SCALEMODE_FLOOR;
  4600. private static _SCALEMODE_NEAREST;
  4601. private static _SCALEMODE_CEILING;
  4602. static readonly SCALEMODE_FLOOR: number;
  4603. static readonly SCALEMODE_NEAREST: number;
  4604. static readonly SCALEMODE_CEILING: number;
  4605. static readonly Version: string;
  4606. static CollisionsEpsilon: number;
  4607. static CodeRepository: string;
  4608. static ShadersRepository: string;
  4609. forcePOTTextures: boolean;
  4610. isFullscreen: boolean;
  4611. isPointerLock: boolean;
  4612. cullBackFaces: boolean;
  4613. renderEvenInBackground: boolean;
  4614. preventCacheWipeBetweenFrames: boolean;
  4615. enableOfflineSupport: boolean;
  4616. scenes: Scene[];
  4617. postProcesses: PostProcess[];
  4618. /**
  4619. * Observable event triggered each time the rendering canvas is resized
  4620. */
  4621. onResizeObservable: Observable<Engine>;
  4622. /**
  4623. * Observable event triggered each time the canvas loses focus
  4624. */
  4625. onCanvasBlurObservable: Observable<Engine>;
  4626. /**
  4627. * Observable event triggered each time the canvas gains focus
  4628. */
  4629. onCanvasFocusObservable: Observable<Engine>;
  4630. /**
  4631. * Observable event triggered each time the canvas receives pointerout event
  4632. */
  4633. onCanvasPointerOutObservable: Observable<PointerEvent>;
  4634. /**
  4635. * Observable event triggered before each texture is initialized
  4636. */
  4637. onBeforeTextureInitObservable: Observable<Texture>;
  4638. private _vrDisplay;
  4639. private _vrSupported;
  4640. private _oldSize;
  4641. private _oldHardwareScaleFactor;
  4642. private _vrExclusivePointerMode;
  4643. private _webVRInitPromise;
  4644. readonly isInVRExclusivePointerMode: boolean;
  4645. disableUniformBuffers: boolean;
  4646. _uniformBuffers: UniformBuffer[];
  4647. readonly supportsUniformBuffers: boolean;
  4648. /**
  4649. * Observable raised when the engine begins a new frame
  4650. */
  4651. onBeginFrameObservable: Observable<Engine>;
  4652. /**
  4653. * Observable raised when the engine ends the current frame
  4654. */
  4655. onEndFrameObservable: Observable<Engine>;
  4656. /**
  4657. * Observable raised when the engine is about to compile a shader
  4658. */
  4659. onBeforeShaderCompilationObservable: Observable<Engine>;
  4660. /**
  4661. * Observable raised when the engine has jsut compiled a shader
  4662. */
  4663. onAfterShaderCompilationObservable: Observable<Engine>;
  4664. private _gl;
  4665. private _renderingCanvas;
  4666. private _windowIsBackground;
  4667. private _webGLVersion;
  4668. readonly needPOTTextures: boolean;
  4669. private _badOS;
  4670. readonly badOS: boolean;
  4671. private _badDesktopOS;
  4672. readonly badDesktopOS: boolean;
  4673. /**
  4674. * Gets or sets a value indicating if we want to disable texture binding optmization.
  4675. * This could be required on some buggy drivers which wants to have textures bound in a progressive order
  4676. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is.
  4677. */
  4678. disableTextureBindingOptimization: boolean;
  4679. static audioEngine: AudioEngine;
  4680. private _onFocus;
  4681. private _onBlur;
  4682. private _onCanvasPointerOut;
  4683. private _onCanvasBlur;
  4684. private _onCanvasFocus;
  4685. private _onFullscreenChange;
  4686. private _onPointerLockChange;
  4687. private _onVRDisplayPointerRestricted;
  4688. private _onVRDisplayPointerUnrestricted;
  4689. private _onVrDisplayConnect;
  4690. private _onVrDisplayDisconnect;
  4691. private _onVrDisplayPresentChange;
  4692. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  4693. onVRRequestPresentComplete: Observable<boolean>;
  4694. onVRRequestPresentStart: Observable<Engine>;
  4695. private _hardwareScalingLevel;
  4696. protected _caps: EngineCapabilities;
  4697. private _pointerLockRequested;
  4698. private _isStencilEnable;
  4699. private _colorWrite;
  4700. private _loadingScreen;
  4701. _drawCalls: PerfCounter;
  4702. _textureCollisions: PerfCounter;
  4703. private _glVersion;
  4704. private _glRenderer;
  4705. private _glVendor;
  4706. private _videoTextureSupported;
  4707. private _renderingQueueLaunched;
  4708. private _activeRenderLoops;
  4709. private _deterministicLockstep;
  4710. private _lockstepMaxSteps;
  4711. onContextLostObservable: Observable<Engine>;
  4712. onContextRestoredObservable: Observable<Engine>;
  4713. private _onContextLost;
  4714. private _onContextRestored;
  4715. private _contextWasLost;
  4716. private _doNotHandleContextLost;
  4717. private _performanceMonitor;
  4718. private _fps;
  4719. private _deltaTime;
  4720. /**
  4721. * Turn this value on if you want to pause FPS computation when in background
  4722. */
  4723. disablePerformanceMonitorInBackground: boolean;
  4724. readonly performanceMonitor: PerformanceMonitor;
  4725. protected _depthCullingState: _DepthCullingState;
  4726. protected _stencilState: _StencilState;
  4727. protected _alphaState: _AlphaState;
  4728. protected _alphaMode: number;
  4729. private _internalTexturesCache;
  4730. protected _activeChannel: number;
  4731. private _currentTextureChannel;
  4732. protected _boundTexturesCache: {
  4733. [key: string]: Nullable<InternalTexture>;
  4734. };
  4735. protected _currentEffect: Nullable<Effect>;
  4736. protected _currentProgram: Nullable<WebGLProgram>;
  4737. private _compiledEffects;
  4738. private _vertexAttribArraysEnabled;
  4739. protected _cachedViewport: Nullable<Viewport>;
  4740. private _cachedVertexArrayObject;
  4741. protected _cachedVertexBuffers: any;
  4742. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  4743. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  4744. protected _currentRenderTarget: Nullable<InternalTexture>;
  4745. private _uintIndicesCurrentlySet;
  4746. private _currentBoundBuffer;
  4747. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  4748. private _currentBufferPointers;
  4749. private _currentInstanceLocations;
  4750. private _currentInstanceBuffers;
  4751. private _textureUnits;
  4752. private _firstBoundInternalTextureTracker;
  4753. private _lastBoundInternalTextureTracker;
  4754. private _workingCanvas;
  4755. private _workingContext;
  4756. private _rescalePostProcess;
  4757. private _dummyFramebuffer;
  4758. private _externalData;
  4759. private _bindedRenderFunction;
  4760. private _vaoRecordInProgress;
  4761. private _mustWipeVertexAttributes;
  4762. private _emptyTexture;
  4763. private _emptyCubeTexture;
  4764. private _emptyTexture3D;
  4765. private _frameHandler;
  4766. private _nextFreeTextureSlots;
  4767. private _maxSimultaneousTextures;
  4768. private _activeRequests;
  4769. private _texturesSupported;
  4770. private _textureFormatInUse;
  4771. readonly texturesSupported: Array<string>;
  4772. readonly textureFormatInUse: Nullable<string>;
  4773. readonly currentViewport: Nullable<Viewport>;
  4774. readonly emptyTexture: InternalTexture;
  4775. readonly emptyTexture3D: InternalTexture;
  4776. readonly emptyCubeTexture: InternalTexture;
  4777. /**
  4778. * @constructor
  4779. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  4780. * @param antialias defines enable antialiasing (default: false)
  4781. * @param options defines further options to be sent to the getContext() function
  4782. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  4783. */
  4784. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  4785. private _rebuildInternalTextures();
  4786. private _rebuildEffects();
  4787. private _rebuildBuffers();
  4788. private _initGLContext();
  4789. readonly webGLVersion: number;
  4790. /**
  4791. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  4792. */
  4793. readonly isStencilEnable: boolean;
  4794. private _prepareWorkingCanvas();
  4795. resetTextureCache(): void;
  4796. isDeterministicLockStep(): boolean;
  4797. getLockstepMaxSteps(): number;
  4798. getGlInfo(): {
  4799. vendor: string;
  4800. renderer: string;
  4801. version: string;
  4802. };
  4803. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  4804. getRenderWidth(useScreen?: boolean): number;
  4805. getRenderHeight(useScreen?: boolean): number;
  4806. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  4807. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  4808. setHardwareScalingLevel(level: number): void;
  4809. getHardwareScalingLevel(): number;
  4810. getLoadedTexturesCache(): InternalTexture[];
  4811. getCaps(): EngineCapabilities;
  4812. /** The number of draw calls submitted last frame */
  4813. readonly drawCalls: number;
  4814. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  4815. getDepthFunction(): Nullable<number>;
  4816. setDepthFunction(depthFunc: number): void;
  4817. setDepthFunctionToGreater(): void;
  4818. setDepthFunctionToGreaterOrEqual(): void;
  4819. setDepthFunctionToLess(): void;
  4820. setDepthFunctionToLessOrEqual(): void;
  4821. getStencilBuffer(): boolean;
  4822. setStencilBuffer(enable: boolean): void;
  4823. getStencilMask(): number;
  4824. setStencilMask(mask: number): void;
  4825. getStencilFunction(): number;
  4826. getStencilFunctionReference(): number;
  4827. getStencilFunctionMask(): number;
  4828. setStencilFunction(stencilFunc: number): void;
  4829. setStencilFunctionReference(reference: number): void;
  4830. setStencilFunctionMask(mask: number): void;
  4831. getStencilOperationFail(): number;
  4832. getStencilOperationDepthFail(): number;
  4833. getStencilOperationPass(): number;
  4834. setStencilOperationFail(operation: number): void;
  4835. setStencilOperationDepthFail(operation: number): void;
  4836. setStencilOperationPass(operation: number): void;
  4837. setDitheringState(value: boolean): void;
  4838. setRasterizerState(value: boolean): void;
  4839. /**
  4840. * stop executing a render loop function and remove it from the execution array
  4841. * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
  4842. */
  4843. stopRenderLoop(renderFunction?: () => void): void;
  4844. _renderLoop(): void;
  4845. /**
  4846. * Register and execute a render loop. The engine can have more than one render function.
  4847. * @param {Function} renderFunction - the function to continuously execute starting the next render loop.
  4848. * @example
  4849. * engine.runRenderLoop(function () {
  4850. * scene.render()
  4851. * })
  4852. */
  4853. runRenderLoop(renderFunction: () => void): void;
  4854. /**
  4855. * Toggle full screen mode.
  4856. * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
  4857. * @param {any} options - an options object to be sent to the requestFullscreen function
  4858. */
  4859. switchFullscreen(requestPointerLock: boolean): void;
  4860. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  4861. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  4862. /**
  4863. * Set the WebGL's viewport
  4864. * @param {BABYLON.Viewport} viewport - the viewport element to be used.
  4865. * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
  4866. * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
  4867. */
  4868. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  4869. /**
  4870. * Directly set the WebGL Viewport
  4871. * The x, y, width & height are directly passed to the WebGL call
  4872. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state.
  4873. */
  4874. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  4875. beginFrame(): void;
  4876. endFrame(): void;
  4877. /**
  4878. * resize the view according to the canvas' size.
  4879. * @example
  4880. * window.addEventListener("resize", function () {
  4881. * engine.resize();
  4882. * });
  4883. */
  4884. resize(): void;
  4885. /**
  4886. * force a specific size of the canvas
  4887. * @param {number} width - the new canvas' width
  4888. * @param {number} height - the new canvas' height
  4889. */
  4890. setSize(width: number, height: number): void;
  4891. isVRDevicePresent(): boolean;
  4892. getVRDevice(): any;
  4893. /**
  4894. * Initializes a webVR display and starts listening to display change events.
  4895. * The onVRDisplayChangedObservable will be notified upon these changes.
  4896. * @returns The onVRDisplayChangedObservable.
  4897. */
  4898. initWebVR(): Observable<IDisplayChangedEventArgs>;
  4899. /**
  4900. * Initializes a webVR display and starts listening to display change events.
  4901. * The onVRDisplayChangedObservable will be notified upon these changes.
  4902. * @returns A promise containing a VRDisplay and if vr is supported.
  4903. */
  4904. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  4905. enableVR(): void;
  4906. disableVR(): void;
  4907. private _onVRFullScreenTriggered;
  4908. private _getVRDisplaysAsync();
  4909. /**
  4910. * Binds the frame buffer to the specified texture.
  4911. * @param texture The texture to render to or null for the default canvas
  4912. * @param faceIndex The face of the texture to render to in case of cube texture
  4913. * @param requiredWidth The width of the target to render to
  4914. * @param requiredHeight The height of the target to render to
  4915. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  4916. * @param depthStencilTexture The depth stencil texture to use to render
  4917. */
  4918. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  4919. private bindUnboundFramebuffer(framebuffer);
  4920. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4921. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4922. generateMipMapsForCubemap(texture: InternalTexture): void;
  4923. flushFramebuffer(): void;
  4924. restoreDefaultFramebuffer(): void;
  4925. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  4926. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  4927. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  4928. private _resetVertexBufferBinding();
  4929. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4930. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4931. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  4932. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  4933. private _resetIndexBufferBinding();
  4934. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  4935. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  4936. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  4937. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  4938. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  4939. private bindIndexBuffer(buffer);
  4940. private bindBuffer(buffer, target);
  4941. updateArrayBuffer(data: Float32Array): void;
  4942. private vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  4943. private _bindIndexBufferWithCache(indexBuffer);
  4944. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  4945. recordVertexArrayObject(vertexBuffers: {
  4946. [key: string]: VertexBuffer;
  4947. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  4948. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  4949. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  4950. private _unbindVertexArrayObject();
  4951. bindBuffers(vertexBuffers: {
  4952. [key: string]: Nullable<VertexBuffer>;
  4953. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  4954. unbindInstanceAttributes(): void;
  4955. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  4956. _releaseBuffer(buffer: WebGLBuffer): boolean;
  4957. createInstancesBuffer(capacity: number): WebGLBuffer;
  4958. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  4959. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  4960. applyStates(): void;
  4961. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  4962. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4963. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4964. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  4965. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4966. private _drawMode(fillMode);
  4967. _releaseEffect(effect: Effect): void;
  4968. _deleteProgram(program: WebGLProgram): void;
  4969. /**
  4970. * @param baseName The base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  4971. * @param samplers An array of string used to represent textures
  4972. */
  4973. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  4974. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  4975. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  4976. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  4977. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  4978. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  4979. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  4980. enableEffect(effect: Nullable<Effect>): void;
  4981. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4982. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4983. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4984. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4985. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4986. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4987. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4988. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4989. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4990. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4991. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4992. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4993. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  4994. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  4995. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  4996. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  4997. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  4998. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  4999. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  5000. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  5001. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  5002. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  5003. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  5004. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  5005. /**
  5006. * Sets a Color4 on a uniform variable
  5007. * @param uniform defines the uniform location
  5008. * @param color4 defines the value to be set
  5009. */
  5010. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  5011. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  5012. setZOffset(value: number): void;
  5013. getZOffset(): number;
  5014. setDepthBuffer(enable: boolean): void;
  5015. getDepthWrite(): boolean;
  5016. setDepthWrite(enable: boolean): void;
  5017. setColorWrite(enable: boolean): void;
  5018. getColorWrite(): boolean;
  5019. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  5020. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  5021. getAlphaMode(): number;
  5022. wipeCaches(bruteForce?: boolean): void;
  5023. /**
  5024. * Set the compressed texture format to use, based on the formats you have, and the formats
  5025. * supported by the hardware / browser.
  5026. *
  5027. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  5028. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  5029. * to API arguments needed to compressed textures. This puts the burden on the container
  5030. * generator to house the arcane code for determining these for current & future formats.
  5031. *
  5032. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  5033. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  5034. *
  5035. * Note: The result of this call is not taken into account when a texture is base64.
  5036. *
  5037. * @param {Array<string>} formatsAvailable- The list of those format families you have created
  5038. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  5039. *
  5040. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  5041. * @returns The extension selected.
  5042. */
  5043. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  5044. _createTexture(): WebGLTexture;
  5045. /**
  5046. * Usually called from BABYLON.Texture.ts. Passed information to create a WebGLTexture.
  5047. * @param {string} urlArg- This contains one of the following:
  5048. * 1. A conventional http URL, e.g. 'http://...' or 'file://...'
  5049. * 2. A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  5050. * 3. An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  5051. *
  5052. * @param {boolean} noMipmap- When true, no mipmaps shall be generated. Ignored for compressed textures. They must be in the file.
  5053. * @param {boolean} invertY- When true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file.
  5054. * @param {Scene} scene- Needed for loading to the correct scene.
  5055. * @param {number} samplingMode- Mode with should be used sample / access the texture. Default: TRILINEAR
  5056. * @param {callback} onLoad- Optional callback to be called upon successful completion.
  5057. * @param {callback} onError- Optional callback to be called upon failure.
  5058. * @param {ArrayBuffer | HTMLImageElement} buffer- A source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
  5059. * @param {WebGLTexture} fallback- An internal argument in case the function must be called again, due to etc1 not having alpha capabilities.
  5060. * @param {number} format- Internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures.
  5061. *
  5062. * @returns {WebGLTexture} for assignment back into BABYLON.Texture
  5063. */
  5064. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  5065. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  5066. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  5067. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  5068. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  5069. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  5070. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  5071. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  5072. /**
  5073. * Updates a depth texture Comparison Mode and Function.
  5074. * If the comparison Function is equal to 0, the mode will be set to none.
  5075. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  5076. * @param texture The texture to set the comparison function for
  5077. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  5078. */
  5079. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  5080. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  5081. /**
  5082. * Creates a depth stencil texture.
  5083. * This is only available in WebGL 2 or with the depth texture extension available.
  5084. * @param size The size of face edge in the texture.
  5085. * @param options The options defining the texture.
  5086. * @returns The texture
  5087. */
  5088. createDepthStencilTexture(size: number | {
  5089. width: number;
  5090. height: number;
  5091. }, options: DepthTextureCreationOptions): InternalTexture;
  5092. /**
  5093. * Creates a depth stencil texture.
  5094. * This is only available in WebGL 2 or with the depth texture extension available.
  5095. * @param size The size of face edge in the texture.
  5096. * @param options The options defining the texture.
  5097. * @returns The texture
  5098. */
  5099. private _createDepthStencilTexture(size, options);
  5100. /**
  5101. * Creates a depth stencil cube texture.
  5102. * This is only available in WebGL 2.
  5103. * @param size The size of face edge in the cube texture.
  5104. * @param options The options defining the cube texture.
  5105. * @returns The cube texture
  5106. */
  5107. private _createDepthStencilCubeTexture(size, options);
  5108. /**
  5109. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  5110. * @param renderTarget The render target to set the frame buffer for
  5111. */
  5112. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  5113. createRenderTargetTexture(size: number | {
  5114. width: number;
  5115. height: number;
  5116. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  5117. createMultipleRenderTarget(size: any, options: any): InternalTexture[];
  5118. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  5119. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  5120. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  5121. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  5122. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  5123. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  5124. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, scale: number, offset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any): InternalTexture;
  5125. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any): InternalTexture;
  5126. private setCubeMapTextureParams(gl, loadMipmap);
  5127. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  5128. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  5129. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, samplingMode?: number, invertY?: boolean): InternalTexture;
  5130. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  5131. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  5132. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  5133. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  5134. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  5135. _releaseFramebufferObjects(texture: InternalTexture): void;
  5136. _releaseTexture(texture: InternalTexture): void;
  5137. private setProgram(program);
  5138. private _boundUniforms;
  5139. bindSamplers(effect: Effect): void;
  5140. private _moveBoundTextureOnTop(internalTexture);
  5141. private _getCorrectTextureChannel(channel, internalTexture);
  5142. private _linkTrackers(previous, next);
  5143. private _removeDesignatedSlot(internalTexture);
  5144. private _activateCurrentTexture();
  5145. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean): void;
  5146. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  5147. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  5148. /**
  5149. * Binds the output of the passed in post process to the texture channel specified
  5150. * @param channel The channel the texture should be bound to
  5151. * @param postProcess The post process which's output should be bound
  5152. */
  5153. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  5154. unbindAllTextures(): void;
  5155. /**
  5156. * Sets a texture to the according uniform.
  5157. * @param channel The texture channel
  5158. * @param uniform The uniform to set
  5159. * @param texture The texture to apply
  5160. */
  5161. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  5162. /**
  5163. * Sets a depth stencil texture from a render target to the according uniform.
  5164. * @param channel The texture channel
  5165. * @param uniform The uniform to set
  5166. * @param texture The render target texture containing the depth stencil texture to apply
  5167. */
  5168. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  5169. private _bindSamplerUniformToChannel(sourceSlot, destination);
  5170. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  5171. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  5172. _setAnisotropicLevel(key: number, texture: BaseTexture): void;
  5173. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  5174. /**
  5175. * Add an externaly attached data from its key.
  5176. * This method call will fail and return false, if such key already exists.
  5177. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  5178. * @param key the unique key that identifies the data
  5179. * @param data the data object to associate to the key for this Engine instance
  5180. * @return true if no such key were already present and the data was added successfully, false otherwise
  5181. */
  5182. addExternalData<T>(key: string, data: T): boolean;
  5183. /**
  5184. * Get an externaly attached data from its key
  5185. * @param key the unique key that identifies the data
  5186. * @return the associated data, if present (can be null), or undefined if not present
  5187. */
  5188. getExternalData<T>(key: string): T;
  5189. /**
  5190. * Get an externaly attached data from its key, create it using a factory if it's not already present
  5191. * @param key the unique key that identifies the data
  5192. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  5193. * @return the associated data, can be null if the factory returned null.
  5194. */
  5195. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  5196. /**
  5197. * Remove an externaly attached data from the Engine instance
  5198. * @param key the unique key that identifies the data
  5199. * @return true if the data was successfully removed, false if it doesn't exist
  5200. */
  5201. removeExternalData(key: string): boolean;
  5202. unbindAllAttributes(): void;
  5203. releaseEffects(): void;
  5204. dispose(): void;
  5205. displayLoadingUI(): void;
  5206. hideLoadingUI(): void;
  5207. loadingScreen: ILoadingScreen;
  5208. loadingUIText: string;
  5209. loadingUIBackgroundColor: string;
  5210. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  5211. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  5212. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  5213. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  5214. getError(): number;
  5215. getFps(): number;
  5216. getDeltaTime(): number;
  5217. private _measureFps();
  5218. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  5219. private _canRenderToFloatFramebuffer();
  5220. private _canRenderToHalfFloatFramebuffer();
  5221. private _canRenderToFramebuffer(type);
  5222. _getWebGLTextureType(type: number): number;
  5223. private _getInternalFormat(format);
  5224. /** @ignore */
  5225. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  5226. _getRGBAMultiSampleBufferFormat(type: number): number;
  5227. createQuery(): WebGLQuery;
  5228. deleteQuery(query: WebGLQuery): Engine;
  5229. isQueryResultAvailable(query: WebGLQuery): boolean;
  5230. getQueryResult(query: WebGLQuery): number;
  5231. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  5232. endOcclusionQuery(algorithmType: number): Engine;
  5233. private _createTimeQuery();
  5234. private _deleteTimeQuery(query);
  5235. private _getTimeQueryResult(query);
  5236. private _getTimeQueryAvailability(query);
  5237. private _currentNonTimestampToken;
  5238. startTimeQuery(): Nullable<_TimeToken>;
  5239. endTimeQuery(token: _TimeToken): int;
  5240. private getGlAlgorithmType(algorithmType);
  5241. createTransformFeedback(): WebGLTransformFeedback;
  5242. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  5243. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  5244. beginTransformFeedback(usePoints?: boolean): void;
  5245. endTransformFeedback(): void;
  5246. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  5247. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  5248. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, database?: Database, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  5249. /** @ignore */
  5250. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  5251. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  5252. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  5253. static isSupported(): boolean;
  5254. }
  5255. }
  5256. declare module BABYLON {
  5257. class NullEngineOptions {
  5258. renderWidth: number;
  5259. renderHeight: number;
  5260. textureSize: number;
  5261. deterministicLockstep: boolean;
  5262. lockstepMaxSteps: number;
  5263. }
  5264. /**
  5265. * The null engine class provides support for headless version of babylon.js.
  5266. * This can be used in server side scenario or for testing purposes
  5267. */
  5268. class NullEngine extends Engine {
  5269. private _options;
  5270. isDeterministicLockStep(): boolean;
  5271. getLockstepMaxSteps(): number;
  5272. getHardwareScalingLevel(): number;
  5273. constructor(options?: NullEngineOptions);
  5274. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  5275. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  5276. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  5277. getRenderWidth(useScreen?: boolean): number;
  5278. getRenderHeight(useScreen?: boolean): number;
  5279. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  5280. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  5281. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  5282. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  5283. bindSamplers(effect: Effect): void;
  5284. enableEffect(effect: Effect): void;
  5285. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  5286. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  5287. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  5288. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  5289. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  5290. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  5291. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  5292. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  5293. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  5294. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  5295. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  5296. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  5297. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  5298. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  5299. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  5300. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  5301. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  5302. setFloat(uniform: WebGLUniformLocation, value: number): void;
  5303. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  5304. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  5305. setBool(uniform: WebGLUniformLocation, bool: number): void;
  5306. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  5307. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  5308. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  5309. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  5310. bindBuffers(vertexBuffers: {
  5311. [key: string]: VertexBuffer;
  5312. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  5313. wipeCaches(bruteForce?: boolean): void;
  5314. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  5315. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  5316. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  5317. _createTexture(): WebGLTexture;
  5318. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  5319. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  5320. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  5321. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  5322. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  5323. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  5324. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  5325. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  5326. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  5327. _bindTexture(channel: number, texture: InternalTexture): void;
  5328. _releaseBuffer(buffer: WebGLBuffer): boolean;
  5329. }
  5330. }
  5331. interface WebGLRenderingContext {
  5332. readonly RASTERIZER_DISCARD: number;
  5333. readonly DEPTH_COMPONENT24: number;
  5334. readonly TEXTURE_3D: number;
  5335. readonly TEXTURE_2D_ARRAY: number;
  5336. readonly TEXTURE_COMPARE_FUNC: number;
  5337. readonly TEXTURE_COMPARE_MODE: number;
  5338. readonly COMPARE_REF_TO_TEXTURE: number;
  5339. readonly TEXTURE_WRAP_R: number;
  5340. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  5341. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  5342. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void;
  5343. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  5344. readonly TRANSFORM_FEEDBACK: number;
  5345. readonly INTERLEAVED_ATTRIBS: number;
  5346. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  5347. createTransformFeedback(): WebGLTransformFeedback;
  5348. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  5349. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  5350. beginTransformFeedback(primitiveMode: number): void;
  5351. endTransformFeedback(): void;
  5352. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  5353. }
  5354. interface ImageBitmap {
  5355. readonly width: number;
  5356. readonly height: number;
  5357. close(): void;
  5358. }
  5359. interface WebGLQuery extends WebGLObject {
  5360. }
  5361. declare var WebGLQuery: {
  5362. prototype: WebGLQuery;
  5363. new (): WebGLQuery;
  5364. };
  5365. interface WebGLSampler extends WebGLObject {
  5366. }
  5367. declare var WebGLSampler: {
  5368. prototype: WebGLSampler;
  5369. new (): WebGLSampler;
  5370. };
  5371. interface WebGLSync extends WebGLObject {
  5372. }
  5373. declare var WebGLSync: {
  5374. prototype: WebGLSync;
  5375. new (): WebGLSync;
  5376. };
  5377. interface WebGLTransformFeedback extends WebGLObject {
  5378. }
  5379. declare var WebGLTransformFeedback: {
  5380. prototype: WebGLTransformFeedback;
  5381. new (): WebGLTransformFeedback;
  5382. };
  5383. interface WebGLVertexArrayObject extends WebGLObject {
  5384. }
  5385. declare var WebGLVertexArrayObject: {
  5386. prototype: WebGLVertexArrayObject;
  5387. new (): WebGLVertexArrayObject;
  5388. };
  5389. declare module BABYLON {
  5390. class KeyboardEventTypes {
  5391. static _KEYDOWN: number;
  5392. static _KEYUP: number;
  5393. static readonly KEYDOWN: number;
  5394. static readonly KEYUP: number;
  5395. }
  5396. class KeyboardInfo {
  5397. type: number;
  5398. event: KeyboardEvent;
  5399. constructor(type: number, event: KeyboardEvent);
  5400. }
  5401. /**
  5402. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  5403. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  5404. */
  5405. class KeyboardInfoPre extends KeyboardInfo {
  5406. constructor(type: number, event: KeyboardEvent);
  5407. skipOnPointerObservable: boolean;
  5408. }
  5409. }
  5410. declare module BABYLON {
  5411. class PointerEventTypes {
  5412. static _POINTERDOWN: number;
  5413. static _POINTERUP: number;
  5414. static _POINTERMOVE: number;
  5415. static _POINTERWHEEL: number;
  5416. static _POINTERPICK: number;
  5417. static _POINTERTAP: number;
  5418. static _POINTERDOUBLETAP: number;
  5419. static readonly POINTERDOWN: number;
  5420. static readonly POINTERUP: number;
  5421. static readonly POINTERMOVE: number;
  5422. static readonly POINTERWHEEL: number;
  5423. static readonly POINTERPICK: number;
  5424. static readonly POINTERTAP: number;
  5425. static readonly POINTERDOUBLETAP: number;
  5426. }
  5427. class PointerInfoBase {
  5428. type: number;
  5429. event: PointerEvent | MouseWheelEvent;
  5430. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  5431. }
  5432. /**
  5433. * This class is used to store pointer related info for the onPrePointerObservable event.
  5434. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  5435. */
  5436. class PointerInfoPre extends PointerInfoBase {
  5437. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  5438. localPosition: Vector2;
  5439. skipOnPointerObservable: boolean;
  5440. }
  5441. /**
  5442. * This type contains all the data related to a pointer event in Babylon.js.
  5443. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  5444. */
  5445. class PointerInfo extends PointerInfoBase {
  5446. pickInfo: Nullable<PickingInfo>;
  5447. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  5448. }
  5449. }
  5450. declare module BABYLON {
  5451. class StickValues {
  5452. x: number;
  5453. y: number;
  5454. constructor(x: number, y: number);
  5455. }
  5456. interface GamepadButtonChanges {
  5457. changed: boolean;
  5458. pressChanged: boolean;
  5459. touchChanged: boolean;
  5460. valueChanged: boolean;
  5461. }
  5462. class Gamepad {
  5463. id: string;
  5464. index: number;
  5465. browserGamepad: any;
  5466. type: number;
  5467. private _leftStick;
  5468. private _rightStick;
  5469. _isConnected: boolean;
  5470. private _leftStickAxisX;
  5471. private _leftStickAxisY;
  5472. private _rightStickAxisX;
  5473. private _rightStickAxisY;
  5474. private _onleftstickchanged;
  5475. private _onrightstickchanged;
  5476. static GAMEPAD: number;
  5477. static GENERIC: number;
  5478. static XBOX: number;
  5479. static POSE_ENABLED: number;
  5480. protected _invertLeftStickY: boolean;
  5481. readonly isConnected: boolean;
  5482. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  5483. onleftstickchanged(callback: (values: StickValues) => void): void;
  5484. onrightstickchanged(callback: (values: StickValues) => void): void;
  5485. leftStick: StickValues;
  5486. rightStick: StickValues;
  5487. update(): void;
  5488. dispose(): void;
  5489. }
  5490. class GenericPad extends Gamepad {
  5491. private _buttons;
  5492. private _onbuttondown;
  5493. private _onbuttonup;
  5494. onButtonDownObservable: Observable<number>;
  5495. onButtonUpObservable: Observable<number>;
  5496. onbuttondown(callback: (buttonPressed: number) => void): void;
  5497. onbuttonup(callback: (buttonReleased: number) => void): void;
  5498. constructor(id: string, index: number, browserGamepad: any);
  5499. private _setButtonValue(newValue, currentValue, buttonIndex);
  5500. update(): void;
  5501. dispose(): void;
  5502. }
  5503. }
  5504. declare module BABYLON {
  5505. class GamepadManager {
  5506. private _scene;
  5507. private _babylonGamepads;
  5508. private _oneGamepadConnected;
  5509. _isMonitoring: boolean;
  5510. private _gamepadEventSupported;
  5511. private _gamepadSupport;
  5512. onGamepadConnectedObservable: Observable<Gamepad>;
  5513. onGamepadDisconnectedObservable: Observable<Gamepad>;
  5514. private _onGamepadConnectedEvent;
  5515. private _onGamepadDisconnectedEvent;
  5516. constructor(_scene?: Scene | undefined);
  5517. readonly gamepads: Gamepad[];
  5518. getGamepadByType(type?: number): Nullable<Gamepad>;
  5519. dispose(): void;
  5520. private _addNewGamepad(gamepad);
  5521. private _startMonitoringGamepads();
  5522. private _stopMonitoringGamepads();
  5523. _checkGamepadsStatus(): void;
  5524. private _updateGamepadObjects();
  5525. }
  5526. }
  5527. declare module BABYLON {
  5528. enum Xbox360Button {
  5529. A = 0,
  5530. B = 1,
  5531. X = 2,
  5532. Y = 3,
  5533. Start = 4,
  5534. Back = 5,
  5535. LB = 6,
  5536. RB = 7,
  5537. LeftStick = 8,
  5538. RightStick = 9,
  5539. }
  5540. enum Xbox360Dpad {
  5541. Up = 0,
  5542. Down = 1,
  5543. Left = 2,
  5544. Right = 3,
  5545. }
  5546. class Xbox360Pad extends Gamepad {
  5547. private _leftTrigger;
  5548. private _rightTrigger;
  5549. private _onlefttriggerchanged;
  5550. private _onrighttriggerchanged;
  5551. private _onbuttondown;
  5552. private _onbuttonup;
  5553. private _ondpaddown;
  5554. private _ondpadup;
  5555. onButtonDownObservable: Observable<Xbox360Button>;
  5556. onButtonUpObservable: Observable<Xbox360Button>;
  5557. onPadDownObservable: Observable<Xbox360Dpad>;
  5558. onPadUpObservable: Observable<Xbox360Dpad>;
  5559. private _buttonA;
  5560. private _buttonB;
  5561. private _buttonX;
  5562. private _buttonY;
  5563. private _buttonBack;
  5564. private _buttonStart;
  5565. private _buttonLB;
  5566. private _buttonRB;
  5567. private _buttonLeftStick;
  5568. private _buttonRightStick;
  5569. private _dPadUp;
  5570. private _dPadDown;
  5571. private _dPadLeft;
  5572. private _dPadRight;
  5573. private _isXboxOnePad;
  5574. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  5575. onlefttriggerchanged(callback: (value: number) => void): void;
  5576. onrighttriggerchanged(callback: (value: number) => void): void;
  5577. leftTrigger: number;
  5578. rightTrigger: number;
  5579. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  5580. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  5581. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  5582. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  5583. private _setButtonValue(newValue, currentValue, buttonType);
  5584. private _setDPadValue(newValue, currentValue, buttonType);
  5585. buttonA: number;
  5586. buttonB: number;
  5587. buttonX: number;
  5588. buttonY: number;
  5589. buttonStart: number;
  5590. buttonBack: number;
  5591. buttonLB: number;
  5592. buttonRB: number;
  5593. buttonLeftStick: number;
  5594. buttonRightStick: number;
  5595. dPadUp: number;
  5596. dPadDown: number;
  5597. dPadLeft: number;
  5598. dPadRight: number;
  5599. update(): void;
  5600. dispose(): void;
  5601. }
  5602. }
  5603. declare module BABYLON {
  5604. /**
  5605. * Represents the different options available during the creation of
  5606. * a Environment helper.
  5607. *
  5608. * This can control the default ground, skybox and image processing setup of your scene.
  5609. */
  5610. interface IEnvironmentHelperOptions {
  5611. /**
  5612. * Specifies wether or not to create a ground.
  5613. * True by default.
  5614. */
  5615. createGround: boolean;
  5616. /**
  5617. * Specifies the ground size.
  5618. * 15 by default.
  5619. */
  5620. groundSize: number;
  5621. /**
  5622. * The texture used on the ground for the main color.
  5623. * Comes from the BabylonJS CDN by default.
  5624. *
  5625. * Remarks: Can be either a texture or a url.
  5626. */
  5627. groundTexture: string | BaseTexture;
  5628. /**
  5629. * The color mixed in the ground texture by default.
  5630. * BabylonJS clearColor by default.
  5631. */
  5632. groundColor: Color3;
  5633. /**
  5634. * Specifies the ground opacity.
  5635. * 1 by default.
  5636. */
  5637. groundOpacity: number;
  5638. /**
  5639. * Enables the ground to receive shadows.
  5640. * True by default.
  5641. */
  5642. enableGroundShadow: boolean;
  5643. /**
  5644. * Helps preventing the shadow to be fully black on the ground.
  5645. * 0.5 by default.
  5646. */
  5647. groundShadowLevel: number;
  5648. /**
  5649. * Creates a mirror texture attach to the ground.
  5650. * false by default.
  5651. */
  5652. enableGroundMirror: boolean;
  5653. /**
  5654. * Specifies the ground mirror size ratio.
  5655. * 0.3 by default as the default kernel is 64.
  5656. */
  5657. groundMirrorSizeRatio: number;
  5658. /**
  5659. * Specifies the ground mirror blur kernel size.
  5660. * 64 by default.
  5661. */
  5662. groundMirrorBlurKernel: number;
  5663. /**
  5664. * Specifies the ground mirror visibility amount.
  5665. * 1 by default
  5666. */
  5667. groundMirrorAmount: number;
  5668. /**
  5669. * Specifies the ground mirror reflectance weight.
  5670. * This uses the standard weight of the background material to setup the fresnel effect
  5671. * of the mirror.
  5672. * 1 by default.
  5673. */
  5674. groundMirrorFresnelWeight: number;
  5675. /**
  5676. * Specifies the ground mirror Falloff distance.
  5677. * This can helps reducing the size of the reflection.
  5678. * 0 by Default.
  5679. */
  5680. groundMirrorFallOffDistance: number;
  5681. /**
  5682. * Specifies the ground mirror texture type.
  5683. * Unsigned Int by Default.
  5684. */
  5685. groundMirrorTextureType: number;
  5686. /**
  5687. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  5688. * the shown objects.
  5689. */
  5690. groundYBias: number;
  5691. /**
  5692. * Specifies wether or not to create a skybox.
  5693. * True by default.
  5694. */
  5695. createSkybox: boolean;
  5696. /**
  5697. * Specifies the skybox size.
  5698. * 20 by default.
  5699. */
  5700. skyboxSize: number;
  5701. /**
  5702. * The texture used on the skybox for the main color.
  5703. * Comes from the BabylonJS CDN by default.
  5704. *
  5705. * Remarks: Can be either a texture or a url.
  5706. */
  5707. skyboxTexture: string | BaseTexture;
  5708. /**
  5709. * The color mixed in the skybox texture by default.
  5710. * BabylonJS clearColor by default.
  5711. */
  5712. skyboxColor: Color3;
  5713. /**
  5714. * The background rotation around the Y axis of the scene.
  5715. * This helps aligning the key lights of your scene with the background.
  5716. * 0 by default.
  5717. */
  5718. backgroundYRotation: number;
  5719. /**
  5720. * Compute automatically the size of the elements to best fit with the scene.
  5721. */
  5722. sizeAuto: boolean;
  5723. /**
  5724. * Default position of the rootMesh if autoSize is not true.
  5725. */
  5726. rootPosition: Vector3;
  5727. /**
  5728. * Sets up the image processing in the scene.
  5729. * true by default.
  5730. */
  5731. setupImageProcessing: boolean;
  5732. /**
  5733. * The texture used as your environment texture in the scene.
  5734. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  5735. *
  5736. * Remarks: Can be either a texture or a url.
  5737. */
  5738. environmentTexture: string | BaseTexture;
  5739. /**
  5740. * The value of the exposure to apply to the scene.
  5741. * 0.6 by default if setupImageProcessing is true.
  5742. */
  5743. cameraExposure: number;
  5744. /**
  5745. * The value of the contrast to apply to the scene.
  5746. * 1.6 by default if setupImageProcessing is true.
  5747. */
  5748. cameraContrast: number;
  5749. /**
  5750. * Specifies wether or not tonemapping should be enabled in the scene.
  5751. * true by default if setupImageProcessing is true.
  5752. */
  5753. toneMappingEnabled: boolean;
  5754. }
  5755. /**
  5756. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  5757. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  5758. * It also helps with the default setup of your imageProcessing configuration.
  5759. */
  5760. class EnvironmentHelper {
  5761. /**
  5762. * Default ground texture URL.
  5763. */
  5764. private static _groundTextureCDNUrl;
  5765. /**
  5766. * Default skybox texture URL.
  5767. */
  5768. private static _skyboxTextureCDNUrl;
  5769. /**
  5770. * Default environment texture URL.
  5771. */
  5772. private static _environmentTextureCDNUrl;
  5773. /**
  5774. * Creates the default options for the helper.
  5775. */
  5776. private static _getDefaultOptions();
  5777. private _rootMesh;
  5778. /**
  5779. * Gets the root mesh created by the helper.
  5780. */
  5781. readonly rootMesh: Mesh;
  5782. private _skybox;
  5783. /**
  5784. * Gets the skybox created by the helper.
  5785. */
  5786. readonly skybox: Nullable<Mesh>;
  5787. private _skyboxTexture;
  5788. /**
  5789. * Gets the skybox texture created by the helper.
  5790. */
  5791. readonly skyboxTexture: Nullable<BaseTexture>;
  5792. private _skyboxMaterial;
  5793. /**
  5794. * Gets the skybox material created by the helper.
  5795. */
  5796. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  5797. private _ground;
  5798. /**
  5799. * Gets the ground mesh created by the helper.
  5800. */
  5801. readonly ground: Nullable<Mesh>;
  5802. private _groundTexture;
  5803. /**
  5804. * Gets the ground texture created by the helper.
  5805. */
  5806. readonly groundTexture: Nullable<BaseTexture>;
  5807. private _groundMirror;
  5808. /**
  5809. * Gets the ground mirror created by the helper.
  5810. */
  5811. readonly groundMirror: Nullable<MirrorTexture>;
  5812. /**
  5813. * Gets the ground mirror render list to helps pushing the meshes
  5814. * you wish in the ground reflection.
  5815. */
  5816. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  5817. private _groundMaterial;
  5818. /**
  5819. * Gets the ground material created by the helper.
  5820. */
  5821. readonly groundMaterial: Nullable<BackgroundMaterial>;
  5822. /**
  5823. * Stores the creation options.
  5824. */
  5825. private readonly _scene;
  5826. private _options;
  5827. /**
  5828. * This observable will be notified with any error during the creation of the environment,
  5829. * mainly texture creation errors.
  5830. */
  5831. onErrorObservable: Observable<{
  5832. message?: string;
  5833. exception?: any;
  5834. }>;
  5835. /**
  5836. * constructor
  5837. * @param options
  5838. * @param scene The scene to add the material to
  5839. */
  5840. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  5841. /**
  5842. * Updates the background according to the new options
  5843. * @param options
  5844. */
  5845. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  5846. /**
  5847. * Sets the primary color of all the available elements.
  5848. * @param color
  5849. */
  5850. setMainColor(color: Color3): void;
  5851. /**
  5852. * Setup the image processing according to the specified options.
  5853. */
  5854. private _setupImageProcessing();
  5855. /**
  5856. * Setup the environment texture according to the specified options.
  5857. */
  5858. private _setupEnvironmentTexture();
  5859. /**
  5860. * Setup the background according to the specified options.
  5861. */
  5862. private _setupBackground();
  5863. /**
  5864. * Get the scene sizes according to the setup.
  5865. */
  5866. private _getSceneSize();
  5867. /**
  5868. * Setup the ground according to the specified options.
  5869. */
  5870. private _setupGround(sceneSize);
  5871. /**
  5872. * Setup the ground material according to the specified options.
  5873. */
  5874. private _setupGroundMaterial();
  5875. /**
  5876. * Setup the ground diffuse texture according to the specified options.
  5877. */
  5878. private _setupGroundDiffuseTexture();
  5879. /**
  5880. * Setup the ground mirror texture according to the specified options.
  5881. */
  5882. private _setupGroundMirrorTexture(sceneSize);
  5883. /**
  5884. * Setup the ground to receive the mirror texture.
  5885. */
  5886. private _setupMirrorInGroundMaterial();
  5887. /**
  5888. * Setup the skybox according to the specified options.
  5889. */
  5890. private _setupSkybox(sceneSize);
  5891. /**
  5892. * Setup the skybox material according to the specified options.
  5893. */
  5894. private _setupSkyboxMaterial();
  5895. /**
  5896. * Setup the skybox reflection texture according to the specified options.
  5897. */
  5898. private _setupSkyboxReflectionTexture();
  5899. private _errorHandler;
  5900. /**
  5901. * Dispose all the elements created by the Helper.
  5902. */
  5903. dispose(): void;
  5904. }
  5905. }
  5906. declare module BABYLON {
  5907. /**
  5908. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  5909. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  5910. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  5911. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  5912. */
  5913. class VideoDome extends Node {
  5914. /**
  5915. * The video texture being displayed on the sphere
  5916. */
  5917. protected _videoTexture: VideoTexture;
  5918. /**
  5919. * The skybox material
  5920. */
  5921. protected _material: BackgroundMaterial;
  5922. /**
  5923. * The surface used for the skybox
  5924. */
  5925. protected _mesh: Mesh;
  5926. /**
  5927. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  5928. * Also see the options.resolution property.
  5929. */
  5930. fovMultiplier: number;
  5931. /**
  5932. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  5933. * @param name Element's name, child elements will append suffixes for their own names.
  5934. * @param urlsOrVideo
  5935. * @param options An object containing optional or exposed sub element properties:
  5936. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  5937. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  5938. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  5939. * @param options **loop=true** Automatically loop video on end.
  5940. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  5941. */
  5942. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  5943. resolution?: number;
  5944. clickToPlay?: boolean;
  5945. autoPlay?: boolean;
  5946. loop?: boolean;
  5947. size?: number;
  5948. }, scene: Scene);
  5949. /**
  5950. * Releases resources associated with this node.
  5951. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5952. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5953. */
  5954. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5955. }
  5956. }
  5957. declare module BABYLON {
  5958. /**
  5959. * This class can be used to get instrumentation data from a Babylon engine
  5960. */
  5961. class EngineInstrumentation implements IDisposable {
  5962. engine: Engine;
  5963. private _captureGPUFrameTime;
  5964. private _gpuFrameTimeToken;
  5965. private _gpuFrameTime;
  5966. private _captureShaderCompilationTime;
  5967. private _shaderCompilationTime;
  5968. private _onBeginFrameObserver;
  5969. private _onEndFrameObserver;
  5970. private _onBeforeShaderCompilationObserver;
  5971. private _onAfterShaderCompilationObserver;
  5972. /**
  5973. * Gets the perf counter used for GPU frame time
  5974. */
  5975. readonly gpuFrameTimeCounter: PerfCounter;
  5976. /**
  5977. * Gets the GPU frame time capture status
  5978. */
  5979. /**
  5980. * Enable or disable the GPU frame time capture
  5981. */
  5982. captureGPUFrameTime: boolean;
  5983. /**
  5984. * Gets the perf counter used for shader compilation time
  5985. */
  5986. readonly shaderCompilationTimeCounter: PerfCounter;
  5987. /**
  5988. * Gets the shader compilation time capture status
  5989. */
  5990. /**
  5991. * Enable or disable the shader compilation time capture
  5992. */
  5993. captureShaderCompilationTime: boolean;
  5994. constructor(engine: Engine);
  5995. dispose(): void;
  5996. }
  5997. }
  5998. declare module BABYLON {
  5999. /**
  6000. * This class can be used to get instrumentation data from a Babylon engine
  6001. */
  6002. class SceneInstrumentation implements IDisposable {
  6003. scene: Scene;
  6004. private _captureActiveMeshesEvaluationTime;
  6005. private _activeMeshesEvaluationTime;
  6006. private _captureRenderTargetsRenderTime;
  6007. private _renderTargetsRenderTime;
  6008. private _captureFrameTime;
  6009. private _frameTime;
  6010. private _captureRenderTime;
  6011. private _renderTime;
  6012. private _captureInterFrameTime;
  6013. private _interFrameTime;
  6014. private _captureParticlesRenderTime;
  6015. private _particlesRenderTime;
  6016. private _captureSpritesRenderTime;
  6017. private _spritesRenderTime;
  6018. private _capturePhysicsTime;
  6019. private _physicsTime;
  6020. private _captureAnimationsTime;
  6021. private _animationsTime;
  6022. private _onBeforeActiveMeshesEvaluationObserver;
  6023. private _onAfterActiveMeshesEvaluationObserver;
  6024. private _onBeforeRenderTargetsRenderObserver;
  6025. private _onAfterRenderTargetsRenderObserver;
  6026. private _onAfterRenderObserver;
  6027. private _onBeforeDrawPhaseObserver;
  6028. private _onAfterDrawPhaseObserver;
  6029. private _onBeforeAnimationsObserver;
  6030. private _onBeforeParticlesRenderingObserver;
  6031. private _onAfterParticlesRenderingObserver;
  6032. private _onBeforeSpritesRenderingObserver;
  6033. private _onAfterSpritesRenderingObserver;
  6034. private _onBeforePhysicsObserver;
  6035. private _onAfterPhysicsObserver;
  6036. private _onAfterAnimationsObserver;
  6037. /**
  6038. * Gets the perf counter used for active meshes evaluation time
  6039. */
  6040. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  6041. /**
  6042. * Gets the active meshes evaluation time capture status
  6043. */
  6044. /**
  6045. * Enable or disable the active meshes evaluation time capture
  6046. */
  6047. captureActiveMeshesEvaluationTime: boolean;
  6048. /**
  6049. * Gets the perf counter used for render targets render time
  6050. */
  6051. readonly renderTargetsRenderTimeCounter: PerfCounter;
  6052. /**
  6053. * Gets the render targets render time capture status
  6054. */
  6055. /**
  6056. * Enable or disable the render targets render time capture
  6057. */
  6058. captureRenderTargetsRenderTime: boolean;
  6059. /**
  6060. * Gets the perf counter used for particles render time
  6061. */
  6062. readonly particlesRenderTimeCounter: PerfCounter;
  6063. /**
  6064. * Gets the particles render time capture status
  6065. */
  6066. /**
  6067. * Enable or disable the particles render time capture
  6068. */
  6069. captureParticlesRenderTime: boolean;
  6070. /**
  6071. * Gets the perf counter used for sprites render time
  6072. */
  6073. readonly spritesRenderTimeCounter: PerfCounter;
  6074. /**
  6075. * Gets the sprites render time capture status
  6076. */
  6077. /**
  6078. * Enable or disable the sprites render time capture
  6079. */
  6080. captureSpritesRenderTime: boolean;
  6081. /**
  6082. * Gets the perf counter used for physics time
  6083. */
  6084. readonly physicsTimeCounter: PerfCounter;
  6085. /**
  6086. * Gets the physics time capture status
  6087. */
  6088. /**
  6089. * Enable or disable the physics time capture
  6090. */
  6091. capturePhysicsTime: boolean;
  6092. /**
  6093. * Gets the perf counter used for animations time
  6094. */
  6095. readonly animationsTimeCounter: PerfCounter;
  6096. /**
  6097. * Gets the animations time capture status
  6098. */
  6099. /**
  6100. * Enable or disable the animations time capture
  6101. */
  6102. captureAnimationsTime: boolean;
  6103. /**
  6104. * Gets the perf counter used for frame time capture
  6105. */
  6106. readonly frameTimeCounter: PerfCounter;
  6107. /**
  6108. * Gets the frame time capture status
  6109. */
  6110. /**
  6111. * Enable or disable the frame time capture
  6112. */
  6113. captureFrameTime: boolean;
  6114. /**
  6115. * Gets the perf counter used for inter-frames time capture
  6116. */
  6117. readonly interFrameTimeCounter: PerfCounter;
  6118. /**
  6119. * Gets the inter-frames time capture status
  6120. */
  6121. /**
  6122. * Enable or disable the inter-frames time capture
  6123. */
  6124. captureInterFrameTime: boolean;
  6125. /**
  6126. * Gets the perf counter used for render time capture
  6127. */
  6128. readonly renderTimeCounter: PerfCounter;
  6129. /**
  6130. * Gets the render time capture status
  6131. */
  6132. /**
  6133. * Enable or disable the render time capture
  6134. */
  6135. captureRenderTime: boolean;
  6136. /**
  6137. * Gets the perf counter used for draw calls
  6138. */
  6139. readonly drawCallsCounter: PerfCounter;
  6140. /**
  6141. * Gets the perf counter used for texture collisions
  6142. */
  6143. readonly textureCollisionsCounter: PerfCounter;
  6144. constructor(scene: Scene);
  6145. dispose(): void;
  6146. }
  6147. }
  6148. declare module BABYLON {
  6149. class _TimeToken {
  6150. _startTimeQuery: Nullable<WebGLQuery>;
  6151. _endTimeQuery: Nullable<WebGLQuery>;
  6152. _timeElapsedQuery: Nullable<WebGLQuery>;
  6153. _timeElapsedQueryEnded: boolean;
  6154. }
  6155. }
  6156. declare module BABYLON {
  6157. /**
  6158. * Effect layer options. This helps customizing the behaviour
  6159. * of the effect layer.
  6160. */
  6161. interface IEffectLayerOptions {
  6162. /**
  6163. * Multiplication factor apply to the canvas size to compute the render target size
  6164. * used to generated the objects (the smaller the faster).
  6165. */
  6166. mainTextureRatio: number;
  6167. /**
  6168. * Enforces a fixed size texture to ensure effect stability across devices.
  6169. */
  6170. mainTextureFixedSize?: number;
  6171. /**
  6172. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  6173. */
  6174. alphaBlendingMode: number;
  6175. /**
  6176. * The camera attached to the layer.
  6177. */
  6178. camera: Nullable<Camera>;
  6179. }
  6180. /**
  6181. * The effect layer Helps adding post process effect blended with the main pass.
  6182. *
  6183. * This can be for instance use to generate glow or higlight effects on the scene.
  6184. *
  6185. * The effect layer class can not be used directly and is intented to inherited from to be
  6186. * customized per effects.
  6187. */
  6188. abstract class EffectLayer {
  6189. /** The Friendly of the effect in the scene */
  6190. name: string;
  6191. private _vertexBuffers;
  6192. private _indexBuffer;
  6193. private _cachedDefines;
  6194. private _effectLayerMapGenerationEffect;
  6195. private _effectLayerOptions;
  6196. private _mergeEffect;
  6197. protected _scene: Scene;
  6198. protected _engine: Engine;
  6199. protected _maxSize: number;
  6200. protected _mainTextureDesiredSize: ISize;
  6201. protected _mainTexture: RenderTargetTexture;
  6202. protected _shouldRender: boolean;
  6203. protected _postProcesses: PostProcess[];
  6204. protected _textures: BaseTexture[];
  6205. protected _emissiveTextureAndColor: {
  6206. texture: Nullable<BaseTexture>;
  6207. color: Color4;
  6208. };
  6209. /**
  6210. * The clear color of the texture used to generate the glow map.
  6211. */
  6212. neutralColor: Color4;
  6213. /**
  6214. * Specifies wether the highlight layer is enabled or not.
  6215. */
  6216. isEnabled: boolean;
  6217. /**
  6218. * Gets the camera attached to the layer.
  6219. */
  6220. readonly camera: Nullable<Camera>;
  6221. /**
  6222. * An event triggered when the effect layer has been disposed.
  6223. */
  6224. onDisposeObservable: Observable<EffectLayer>;
  6225. /**
  6226. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  6227. */
  6228. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  6229. /**
  6230. * An event triggered when the generated texture is being merged in the scene.
  6231. */
  6232. onBeforeComposeObservable: Observable<EffectLayer>;
  6233. /**
  6234. * An event triggered when the generated texture has been merged in the scene.
  6235. */
  6236. onAfterComposeObservable: Observable<EffectLayer>;
  6237. /**
  6238. * An event triggered when the efffect layer changes its size.
  6239. */
  6240. onSizeChangedObservable: Observable<EffectLayer>;
  6241. /**
  6242. * Instantiates a new effect Layer and references it in the scene.
  6243. * @param name The name of the layer
  6244. * @param scene The scene to use the layer in
  6245. */
  6246. constructor(
  6247. /** The Friendly of the effect in the scene */
  6248. name: string, scene: Scene);
  6249. /**
  6250. * Get the effect name of the layer.
  6251. * @return The effect name
  6252. */
  6253. abstract getEffectName(): string;
  6254. /**
  6255. * Checks for the readiness of the element composing the layer.
  6256. * @param subMesh the mesh to check for
  6257. * @param useInstances specify wether or not to use instances to render the mesh
  6258. * @return true if ready otherwise, false
  6259. */
  6260. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  6261. /**
  6262. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  6263. * @returns true if the effect requires stencil during the main canvas render pass.
  6264. */
  6265. abstract needStencil(): boolean;
  6266. /**
  6267. * Create the merge effect. This is the shader use to blit the information back
  6268. * to the main canvas at the end of the scene rendering.
  6269. * @returns The effect containing the shader used to merge the effect on the main canvas
  6270. */
  6271. protected abstract _createMergeEffect(): Effect;
  6272. /**
  6273. * Creates the render target textures and post processes used in the effect layer.
  6274. */
  6275. protected abstract _createTextureAndPostProcesses(): void;
  6276. /**
  6277. * Implementation specific of rendering the generating effect on the main canvas.
  6278. * @param effect The effect used to render through
  6279. */
  6280. protected abstract _internalRender(effect: Effect): void;
  6281. /**
  6282. * Sets the required values for both the emissive texture and and the main color.
  6283. */
  6284. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  6285. /**
  6286. * Free any resources and references associated to a mesh.
  6287. * Internal use
  6288. * @param mesh The mesh to free.
  6289. */
  6290. abstract _disposeMesh(mesh: Mesh): void;
  6291. /**
  6292. * Initializes the effect layer with the required options.
  6293. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  6294. */
  6295. protected _init(options: Partial<IEffectLayerOptions>): void;
  6296. /**
  6297. * Generates the index buffer of the full screen quad blending to the main canvas.
  6298. */
  6299. private _generateIndexBuffer();
  6300. /**
  6301. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  6302. */
  6303. private _genrateVertexBuffer();
  6304. /**
  6305. * Sets the main texture desired size which is the closest power of two
  6306. * of the engine canvas size.
  6307. */
  6308. private _setMainTextureSize();
  6309. /**
  6310. * Creates the main texture for the effect layer.
  6311. */
  6312. protected _createMainTexture(): void;
  6313. /**
  6314. * Checks for the readiness of the element composing the layer.
  6315. * @param subMesh the mesh to check for
  6316. * @param useInstances specify wether or not to use instances to render the mesh
  6317. * @param emissiveTexture the associated emissive texture used to generate the glow
  6318. * @return true if ready otherwise, false
  6319. */
  6320. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  6321. /**
  6322. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  6323. */
  6324. render(): void;
  6325. /**
  6326. * Determine if a given mesh will be used in the current effect.
  6327. * @param mesh mesh to test
  6328. * @returns true if the mesh will be used
  6329. */
  6330. hasMesh(mesh: AbstractMesh): boolean;
  6331. /**
  6332. * Returns true if the layer contains information to display, otherwise false.
  6333. * @returns true if the glow layer should be rendered
  6334. */
  6335. shouldRender(): boolean;
  6336. /**
  6337. * Returns true if the mesh should render, otherwise false.
  6338. * @param mesh The mesh to render
  6339. * @returns true if it should render otherwise false
  6340. */
  6341. protected _shouldRenderMesh(mesh: Mesh): boolean;
  6342. /**
  6343. * Returns true if the mesh should render, otherwise false.
  6344. * @param mesh The mesh to render
  6345. * @returns true if it should render otherwise false
  6346. */
  6347. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  6348. /**
  6349. * Renders the submesh passed in parameter to the generation map.
  6350. */
  6351. protected _renderSubMesh(subMesh: SubMesh): void;
  6352. /**
  6353. * Rebuild the required buffers.
  6354. * @ignore Internal use only.
  6355. */
  6356. _rebuild(): void;
  6357. /**
  6358. * Dispose only the render target textures and post process.
  6359. */
  6360. private _disposeTextureAndPostProcesses();
  6361. /**
  6362. * Dispose the highlight layer and free resources.
  6363. */
  6364. dispose(): void;
  6365. }
  6366. }
  6367. declare module BABYLON {
  6368. /**
  6369. * Glow layer options. This helps customizing the behaviour
  6370. * of the glow layer.
  6371. */
  6372. interface IGlowLayerOptions {
  6373. /**
  6374. * Multiplication factor apply to the canvas size to compute the render target size
  6375. * used to generated the glowing objects (the smaller the faster).
  6376. */
  6377. mainTextureRatio: number;
  6378. /**
  6379. * Enforces a fixed size texture to ensure resize independant blur.
  6380. */
  6381. mainTextureFixedSize?: number;
  6382. /**
  6383. * How big is the kernel of the blur texture.
  6384. */
  6385. blurKernelSize: number;
  6386. /**
  6387. * The camera attached to the layer.
  6388. */
  6389. camera: Nullable<Camera>;
  6390. /**
  6391. * Enable MSAA by chosing the number of samples.
  6392. */
  6393. mainTextureSamples?: number;
  6394. }
  6395. /**
  6396. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  6397. *
  6398. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  6399. * glowy meshes to your scene.
  6400. *
  6401. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  6402. */
  6403. class GlowLayer extends EffectLayer {
  6404. name: string;
  6405. /**
  6406. * Effect Name of the layer.
  6407. */
  6408. static readonly EffectName: string;
  6409. /**
  6410. * The default blur kernel size used for the glow.
  6411. */
  6412. static DefaultBlurKernelSize: number;
  6413. /**
  6414. * The default texture size ratio used for the glow.
  6415. */
  6416. static DefaultTextureRatio: number;
  6417. /**
  6418. * Gets the kernel size of the blur.
  6419. */
  6420. /**
  6421. * Sets the kernel size of the blur.
  6422. */
  6423. blurKernelSize: number;
  6424. /**
  6425. * Gets the glow intensity.
  6426. */
  6427. /**
  6428. * Sets the glow intensity.
  6429. */
  6430. intensity: number;
  6431. private _options;
  6432. private _intensity;
  6433. private _horizontalBlurPostprocess1;
  6434. private _verticalBlurPostprocess1;
  6435. private _horizontalBlurPostprocess2;
  6436. private _verticalBlurPostprocess2;
  6437. private _blurTexture1;
  6438. private _blurTexture2;
  6439. private _postProcesses1;
  6440. private _postProcesses2;
  6441. private _includedOnlyMeshes;
  6442. private _excludedMeshes;
  6443. /**
  6444. * Callback used to let the user override the color selection on a per mesh basis
  6445. */
  6446. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  6447. /**
  6448. * Callback used to let the user override the texture selection on a per mesh basis
  6449. */
  6450. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  6451. /**
  6452. * Instantiates a new glow Layer and references it to the scene.
  6453. * @param name The name of the layer
  6454. * @param scene The scene to use the layer in
  6455. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  6456. */
  6457. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  6458. /**
  6459. * Get the effect name of the layer.
  6460. * @return The effect name
  6461. */
  6462. getEffectName(): string;
  6463. /**
  6464. * Create the merge effect. This is the shader use to blit the information back
  6465. * to the main canvas at the end of the scene rendering.
  6466. */
  6467. protected _createMergeEffect(): Effect;
  6468. /**
  6469. * Creates the render target textures and post processes used in the glow layer.
  6470. */
  6471. protected _createTextureAndPostProcesses(): void;
  6472. /**
  6473. * Checks for the readiness of the element composing the layer.
  6474. * @param subMesh the mesh to check for
  6475. * @param useInstances specify wether or not to use instances to render the mesh
  6476. * @param emissiveTexture the associated emissive texture used to generate the glow
  6477. * @return true if ready otherwise, false
  6478. */
  6479. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  6480. /**
  6481. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  6482. */
  6483. needStencil(): boolean;
  6484. /**
  6485. * Implementation specific of rendering the generating effect on the main canvas.
  6486. * @param effect The effect used to render through
  6487. */
  6488. protected _internalRender(effect: Effect): void;
  6489. /**
  6490. * Sets the required values for both the emissive texture and and the main color.
  6491. */
  6492. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  6493. /**
  6494. * Returns true if the mesh should render, otherwise false.
  6495. * @param mesh The mesh to render
  6496. * @returns true if it should render otherwise false
  6497. */
  6498. protected _shouldRenderMesh(mesh: Mesh): boolean;
  6499. /**
  6500. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  6501. * @param mesh The mesh to exclude from the glow layer
  6502. */
  6503. addExcludedMesh(mesh: Mesh): void;
  6504. /**
  6505. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  6506. * @param mesh The mesh to remove
  6507. */
  6508. removeExcludedMesh(mesh: Mesh): void;
  6509. /**
  6510. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  6511. * @param mesh The mesh to include in the glow layer
  6512. */
  6513. addIncludedOnlyMesh(mesh: Mesh): void;
  6514. /**
  6515. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  6516. * @param mesh The mesh to remove
  6517. */
  6518. removeIncludedOnlyMesh(mesh: Mesh): void;
  6519. /**
  6520. * Determine if a given mesh will be used in the glow layer
  6521. * @param mesh The mesh to test
  6522. * @returns true if the mesh will be highlighted by the current glow layer
  6523. */
  6524. hasMesh(mesh: AbstractMesh): boolean;
  6525. /**
  6526. * Free any resources and references associated to a mesh.
  6527. * Internal use
  6528. * @param mesh The mesh to free.
  6529. */
  6530. _disposeMesh(mesh: Mesh): void;
  6531. }
  6532. }
  6533. declare module BABYLON {
  6534. /**
  6535. * Highlight layer options. This helps customizing the behaviour
  6536. * of the highlight layer.
  6537. */
  6538. interface IHighlightLayerOptions {
  6539. /**
  6540. * Multiplication factor apply to the canvas size to compute the render target size
  6541. * used to generated the glowing objects (the smaller the faster).
  6542. */
  6543. mainTextureRatio: number;
  6544. /**
  6545. * Enforces a fixed size texture to ensure resize independant blur.
  6546. */
  6547. mainTextureFixedSize?: number;
  6548. /**
  6549. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  6550. * of the picture to blur (the smaller the faster).
  6551. */
  6552. blurTextureSizeRatio: number;
  6553. /**
  6554. * How big in texel of the blur texture is the vertical blur.
  6555. */
  6556. blurVerticalSize: number;
  6557. /**
  6558. * How big in texel of the blur texture is the horizontal blur.
  6559. */
  6560. blurHorizontalSize: number;
  6561. /**
  6562. * Alpha blending mode used to apply the blur. Default is combine.
  6563. */
  6564. alphaBlendingMode: number;
  6565. /**
  6566. * The camera attached to the layer.
  6567. */
  6568. camera: Nullable<Camera>;
  6569. /**
  6570. * Should we display highlight as a solid stroke?
  6571. */
  6572. isStroke?: boolean;
  6573. }
  6574. /**
  6575. * The highlight layer Helps adding a glow effect around a mesh.
  6576. *
  6577. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  6578. * glowy meshes to your scene.
  6579. *
  6580. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  6581. */
  6582. class HighlightLayer extends EffectLayer {
  6583. name: string;
  6584. /**
  6585. * Effect Name of the highlight layer.
  6586. */
  6587. static readonly EffectName: string;
  6588. /**
  6589. * The neutral color used during the preparation of the glow effect.
  6590. * This is black by default as the blend operation is a blend operation.
  6591. */
  6592. static NeutralColor: Color4;
  6593. /**
  6594. * Stencil value used for glowing meshes.
  6595. */
  6596. static GlowingMeshStencilReference: number;
  6597. /**
  6598. * Stencil value used for the other meshes in the scene.
  6599. */
  6600. static NormalMeshStencilReference: number;
  6601. /**
  6602. * Specifies whether or not the inner glow is ACTIVE in the layer.
  6603. */
  6604. innerGlow: boolean;
  6605. /**
  6606. * Specifies whether or not the outer glow is ACTIVE in the layer.
  6607. */
  6608. outerGlow: boolean;
  6609. /**
  6610. * Gets the horizontal size of the blur.
  6611. */
  6612. /**
  6613. * Specifies the horizontal size of the blur.
  6614. */
  6615. blurHorizontalSize: number;
  6616. /**
  6617. * Gets the vertical size of the blur.
  6618. */
  6619. /**
  6620. * Specifies the vertical size of the blur.
  6621. */
  6622. blurVerticalSize: number;
  6623. /**
  6624. * An event triggered when the highlight layer is being blurred.
  6625. */
  6626. onBeforeBlurObservable: Observable<HighlightLayer>;
  6627. /**
  6628. * An event triggered when the highlight layer has been blurred.
  6629. */
  6630. onAfterBlurObservable: Observable<HighlightLayer>;
  6631. private _instanceGlowingMeshStencilReference;
  6632. private _options;
  6633. private _downSamplePostprocess;
  6634. private _horizontalBlurPostprocess;
  6635. private _verticalBlurPostprocess;
  6636. private _blurTexture;
  6637. private _meshes;
  6638. private _excludedMeshes;
  6639. /**
  6640. * Instantiates a new highlight Layer and references it to the scene..
  6641. * @param name The name of the layer
  6642. * @param scene The scene to use the layer in
  6643. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  6644. */
  6645. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  6646. /**
  6647. * Get the effect name of the layer.
  6648. * @return The effect name
  6649. */
  6650. getEffectName(): string;
  6651. /**
  6652. * Create the merge effect. This is the shader use to blit the information back
  6653. * to the main canvas at the end of the scene rendering.
  6654. */
  6655. protected _createMergeEffect(): Effect;
  6656. /**
  6657. * Creates the render target textures and post processes used in the highlight layer.
  6658. */
  6659. protected _createTextureAndPostProcesses(): void;
  6660. /**
  6661. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  6662. */
  6663. needStencil(): boolean;
  6664. /**
  6665. * Checks for the readiness of the element composing the layer.
  6666. * @param subMesh the mesh to check for
  6667. * @param useInstances specify wether or not to use instances to render the mesh
  6668. * @param emissiveTexture the associated emissive texture used to generate the glow
  6669. * @return true if ready otherwise, false
  6670. */
  6671. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  6672. /**
  6673. * Implementation specific of rendering the generating effect on the main canvas.
  6674. * @param effect The effect used to render through
  6675. */
  6676. protected _internalRender(effect: Effect): void;
  6677. /**
  6678. * Returns true if the layer contains information to display, otherwise false.
  6679. */
  6680. shouldRender(): boolean;
  6681. /**
  6682. * Returns true if the mesh should render, otherwise false.
  6683. * @param mesh The mesh to render
  6684. * @returns true if it should render otherwise false
  6685. */
  6686. protected _shouldRenderMesh(mesh: Mesh): boolean;
  6687. /**
  6688. * Sets the required values for both the emissive texture and and the main color.
  6689. */
  6690. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  6691. /**
  6692. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  6693. * @param mesh The mesh to exclude from the highlight layer
  6694. */
  6695. addExcludedMesh(mesh: Mesh): void;
  6696. /**
  6697. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  6698. * @param mesh The mesh to highlight
  6699. */
  6700. removeExcludedMesh(mesh: Mesh): void;
  6701. /**
  6702. * Determine if a given mesh will be highlighted by the current HighlightLayer
  6703. * @param mesh mesh to test
  6704. * @returns true if the mesh will be highlighted by the current HighlightLayer
  6705. */
  6706. hasMesh(mesh: AbstractMesh): boolean;
  6707. /**
  6708. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  6709. * @param mesh The mesh to highlight
  6710. * @param color The color of the highlight
  6711. * @param glowEmissiveOnly Extract the glow from the emissive texture
  6712. */
  6713. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  6714. /**
  6715. * Remove a mesh from the highlight layer in order to make it stop glowing.
  6716. * @param mesh The mesh to highlight
  6717. */
  6718. removeMesh(mesh: Mesh): void;
  6719. /**
  6720. * Force the stencil to the normal expected value for none glowing parts
  6721. */
  6722. private _defaultStencilReference(mesh);
  6723. /**
  6724. * Free any resources and references associated to a mesh.
  6725. * Internal use
  6726. * @param mesh The mesh to free.
  6727. */
  6728. _disposeMesh(mesh: Mesh): void;
  6729. /**
  6730. * Dispose the highlight layer and free resources.
  6731. */
  6732. dispose(): void;
  6733. }
  6734. }
  6735. declare module BABYLON {
  6736. class Layer {
  6737. name: string;
  6738. texture: Nullable<Texture>;
  6739. isBackground: boolean;
  6740. color: Color4;
  6741. scale: Vector2;
  6742. offset: Vector2;
  6743. alphaBlendingMode: number;
  6744. alphaTest: boolean;
  6745. layerMask: number;
  6746. private _scene;
  6747. private _vertexBuffers;
  6748. private _indexBuffer;
  6749. private _effect;
  6750. private _alphaTestEffect;
  6751. /**
  6752. * An event triggered when the layer is disposed.
  6753. * @type {BABYLON.Observable}
  6754. */
  6755. onDisposeObservable: Observable<Layer>;
  6756. private _onDisposeObserver;
  6757. onDispose: () => void;
  6758. /**
  6759. * An event triggered before rendering the scene
  6760. * @type {BABYLON.Observable}
  6761. */
  6762. onBeforeRenderObservable: Observable<Layer>;
  6763. private _onBeforeRenderObserver;
  6764. onBeforeRender: () => void;
  6765. /**
  6766. * An event triggered after rendering the scene
  6767. * @type {BABYLON.Observable}
  6768. */
  6769. onAfterRenderObservable: Observable<Layer>;
  6770. private _onAfterRenderObserver;
  6771. onAfterRender: () => void;
  6772. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  6773. private _createIndexBuffer();
  6774. _rebuild(): void;
  6775. render(): void;
  6776. dispose(): void;
  6777. }
  6778. }
  6779. declare module BABYLON {
  6780. class LensFlare {
  6781. size: number;
  6782. position: number;
  6783. color: Color3;
  6784. texture: Nullable<Texture>;
  6785. alphaMode: number;
  6786. private _system;
  6787. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  6788. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  6789. dispose(): void;
  6790. }
  6791. }
  6792. declare module BABYLON {
  6793. class LensFlareSystem {
  6794. name: string;
  6795. lensFlares: LensFlare[];
  6796. borderLimit: number;
  6797. viewportBorder: number;
  6798. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  6799. layerMask: number;
  6800. id: string;
  6801. private _scene;
  6802. private _emitter;
  6803. private _vertexBuffers;
  6804. private _indexBuffer;
  6805. private _effect;
  6806. private _positionX;
  6807. private _positionY;
  6808. private _isEnabled;
  6809. constructor(name: string, emitter: any, scene: Scene);
  6810. isEnabled: boolean;
  6811. getScene(): Scene;
  6812. getEmitter(): any;
  6813. setEmitter(newEmitter: any): void;
  6814. getEmitterPosition(): Vector3;
  6815. computeEffectivePosition(globalViewport: Viewport): boolean;
  6816. _isVisible(): boolean;
  6817. render(): boolean;
  6818. dispose(): void;
  6819. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  6820. serialize(): any;
  6821. }
  6822. }
  6823. declare module BABYLON {
  6824. /**
  6825. * A directional light is defined by a direction (what a surprise!).
  6826. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  6827. * An example of a directional light is when a distance planet is lit by the apparently parallel lines of light from its sun. Light in a downward direction will light the top of an object.
  6828. * Documentation: https://doc.babylonjs.com/babylon101/lights
  6829. */
  6830. class DirectionalLight extends ShadowLight {
  6831. private _shadowFrustumSize;
  6832. /**
  6833. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  6834. */
  6835. /**
  6836. * Specifies a fix frustum size for the shadow generation.
  6837. */
  6838. shadowFrustumSize: number;
  6839. private _shadowOrthoScale;
  6840. /**
  6841. * Gets the shadow projection scale against the optimal computed one.
  6842. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  6843. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  6844. */
  6845. /**
  6846. * Sets the shadow projection scale against the optimal computed one.
  6847. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  6848. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  6849. */
  6850. shadowOrthoScale: number;
  6851. /**
  6852. * Automatically compute the projection matrix to best fit (including all the casters)
  6853. * on each frame.
  6854. */
  6855. autoUpdateExtends: boolean;
  6856. private _orthoLeft;
  6857. private _orthoRight;
  6858. private _orthoTop;
  6859. private _orthoBottom;
  6860. /**
  6861. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  6862. * The directional light is emitted from everywhere in the given direction.
  6863. * It can cast shawdows.
  6864. * Documentation : http://doc.babylonjs.com/tutorials/lights
  6865. * @param name The friendly name of the light
  6866. * @param direction The direction of the light
  6867. * @param scene The scene the light belongs to
  6868. */
  6869. constructor(name: string, direction: Vector3, scene: Scene);
  6870. /**
  6871. * Returns the string "DirectionalLight".
  6872. * @return The class name
  6873. */
  6874. getClassName(): string;
  6875. /**
  6876. * Returns the integer 1.
  6877. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  6878. */
  6879. getTypeID(): number;
  6880. /**
  6881. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  6882. * Returns the DirectionalLight Shadow projection matrix.
  6883. */
  6884. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  6885. /**
  6886. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  6887. * Returns the DirectionalLight Shadow projection matrix.
  6888. */
  6889. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  6890. /**
  6891. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  6892. * Returns the DirectionalLight Shadow projection matrix.
  6893. */
  6894. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  6895. protected _buildUniformLayout(): void;
  6896. /**
  6897. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  6898. * @param effect The effect to update
  6899. * @param lightIndex The index of the light in the effect to update
  6900. * @returns The directional light
  6901. */
  6902. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  6903. /**
  6904. * Gets the minZ used for shadow according to both the scene and the light.
  6905. *
  6906. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  6907. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  6908. * @param activeCamera The camera we are returning the min for
  6909. * @returns the depth min z
  6910. */
  6911. getDepthMinZ(activeCamera: Camera): number;
  6912. /**
  6913. * Gets the maxZ used for shadow according to both the scene and the light.
  6914. *
  6915. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  6916. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  6917. * @param activeCamera The camera we are returning the max for
  6918. * @returns the depth max z
  6919. */
  6920. getDepthMaxZ(activeCamera: Camera): number;
  6921. }
  6922. }
  6923. declare module BABYLON {
  6924. /**
  6925. * The HemisphericLight simulates the ambient environment light,
  6926. * so the passed direction is the light reflection direction, not the incoming direction.
  6927. */
  6928. class HemisphericLight extends Light {
  6929. /**
  6930. * The groundColor is the light in the opposite direction to the one specified during creation.
  6931. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  6932. */
  6933. groundColor: Color3;
  6934. /**
  6935. * The light reflection direction, not the incoming direction.
  6936. */
  6937. direction: Vector3;
  6938. private _worldMatrix;
  6939. /**
  6940. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  6941. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  6942. * The HemisphericLight can't cast shadows.
  6943. * Documentation : http://doc.babylonjs.com/tutorials/lights
  6944. * @param name The friendly name of the light
  6945. * @param direction The direction of the light reflection
  6946. * @param scene The scene the light belongs to
  6947. */
  6948. constructor(name: string, direction: Vector3, scene: Scene);
  6949. protected _buildUniformLayout(): void;
  6950. /**
  6951. * Returns the string "HemisphericLight".
  6952. * @return The class name
  6953. */
  6954. getClassName(): string;
  6955. /**
  6956. * Sets the HemisphericLight direction towards the passed target (Vector3).
  6957. * Returns the updated direction.
  6958. * @param target The target the direction should point to
  6959. * @return The computed direction
  6960. */
  6961. setDirectionToTarget(target: Vector3): Vector3;
  6962. /**
  6963. * Returns the shadow generator associated to the light.
  6964. * @returns Always null for hemispheric lights because it does not support shadows.
  6965. */
  6966. getShadowGenerator(): Nullable<ShadowGenerator>;
  6967. /**
  6968. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  6969. * @param effect The effect to update
  6970. * @param lightIndex The index of the light in the effect to update
  6971. * @returns The hemispheric light
  6972. */
  6973. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  6974. /**
  6975. * @ignore internal use only.
  6976. */
  6977. _getWorldMatrix(): Matrix;
  6978. /**
  6979. * Returns the integer 3.
  6980. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  6981. */
  6982. getTypeID(): number;
  6983. }
  6984. }
  6985. declare module BABYLON {
  6986. /**
  6987. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  6988. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  6989. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  6990. */
  6991. abstract class Light extends Node {
  6992. private static _LIGHTMAP_DEFAULT;
  6993. private static _LIGHTMAP_SPECULAR;
  6994. private static _LIGHTMAP_SHADOWSONLY;
  6995. /**
  6996. * If every light affecting the material is in this lightmapMode,
  6997. * material.lightmapTexture adds or multiplies
  6998. * (depends on material.useLightmapAsShadowmap)
  6999. * after every other light calculations.
  7000. */
  7001. static readonly LIGHTMAP_DEFAULT: number;
  7002. /**
  7003. * material.lightmapTexture as only diffuse lighting from this light
  7004. * adds only specular lighting from this light
  7005. * adds dynamic shadows
  7006. */
  7007. static readonly LIGHTMAP_SPECULAR: number;
  7008. /**
  7009. * material.lightmapTexture as only lighting
  7010. * no light calculation from this light
  7011. * only adds dynamic shadows from this light
  7012. */
  7013. static readonly LIGHTMAP_SHADOWSONLY: number;
  7014. private static _INTENSITYMODE_AUTOMATIC;
  7015. private static _INTENSITYMODE_LUMINOUSPOWER;
  7016. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  7017. private static _INTENSITYMODE_ILLUMINANCE;
  7018. private static _INTENSITYMODE_LUMINANCE;
  7019. /**
  7020. * Each light type uses the default quantity according to its type:
  7021. * point/spot lights use luminous intensity
  7022. * directional lights use illuminance
  7023. */
  7024. static readonly INTENSITYMODE_AUTOMATIC: number;
  7025. /**
  7026. * lumen (lm)
  7027. */
  7028. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  7029. /**
  7030. * candela (lm/sr)
  7031. */
  7032. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  7033. /**
  7034. * lux (lm/m^2)
  7035. */
  7036. static readonly INTENSITYMODE_ILLUMINANCE: number;
  7037. /**
  7038. * nit (cd/m^2)
  7039. */
  7040. static readonly INTENSITYMODE_LUMINANCE: number;
  7041. private static _LIGHTTYPEID_POINTLIGHT;
  7042. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  7043. private static _LIGHTTYPEID_SPOTLIGHT;
  7044. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  7045. /**
  7046. * Light type const id of the point light.
  7047. */
  7048. static readonly LIGHTTYPEID_POINTLIGHT: number;
  7049. /**
  7050. * Light type const id of the directional light.
  7051. */
  7052. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  7053. /**
  7054. * Light type const id of the spot light.
  7055. */
  7056. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  7057. /**
  7058. * Light type const id of the hemispheric light.
  7059. */
  7060. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  7061. /**
  7062. * Diffuse gives the basic color to an object.
  7063. */
  7064. diffuse: Color3;
  7065. /**
  7066. * Specular produces a highlight color on an object.
  7067. * Note: This is note affecting PBR materials.
  7068. */
  7069. specular: Color3;
  7070. /**
  7071. * Strength of the light.
  7072. * Note: By default it is define in the framework own unit.
  7073. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  7074. */
  7075. intensity: number;
  7076. /**
  7077. * Defines how far from the source the light is impacting in scene units.
  7078. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  7079. */
  7080. range: number;
  7081. /**
  7082. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  7083. * of light.
  7084. */
  7085. private _photometricScale;
  7086. private _intensityMode;
  7087. /**
  7088. * Gets the photometric scale used to interpret the intensity.
  7089. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  7090. */
  7091. /**
  7092. * Sets the photometric scale used to interpret the intensity.
  7093. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  7094. */
  7095. intensityMode: number;
  7096. private _radius;
  7097. /**
  7098. * Gets the light radius used by PBR Materials to simulate soft area lights.
  7099. */
  7100. /**
  7101. * sets the light radius used by PBR Materials to simulate soft area lights.
  7102. */
  7103. radius: number;
  7104. private _renderPriority;
  7105. /**
  7106. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  7107. * exceeding the number allowed of the materials.
  7108. */
  7109. renderPriority: number;
  7110. /**
  7111. * Defines wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  7112. * the current shadow generator.
  7113. */
  7114. shadowEnabled: boolean;
  7115. private _includedOnlyMeshes;
  7116. /**
  7117. * Gets the only meshes impacted by this light.
  7118. */
  7119. /**
  7120. * Sets the only meshes impacted by this light.
  7121. */
  7122. includedOnlyMeshes: AbstractMesh[];
  7123. private _excludedMeshes;
  7124. /**
  7125. * Gets the meshes not impacted by this light.
  7126. */
  7127. /**
  7128. * Sets the meshes not impacted by this light.
  7129. */
  7130. excludedMeshes: AbstractMesh[];
  7131. private _excludeWithLayerMask;
  7132. /**
  7133. * Gets the layer id use to find what meshes are not impacted by the light.
  7134. * Inactive if 0
  7135. */
  7136. /**
  7137. * Sets the layer id use to find what meshes are not impacted by the light.
  7138. * Inactive if 0
  7139. */
  7140. excludeWithLayerMask: number;
  7141. private _includeOnlyWithLayerMask;
  7142. /**
  7143. * Gets the layer id use to find what meshes are impacted by the light.
  7144. * Inactive if 0
  7145. */
  7146. /**
  7147. * Sets the layer id use to find what meshes are impacted by the light.
  7148. * Inactive if 0
  7149. */
  7150. includeOnlyWithLayerMask: number;
  7151. private _lightmapMode;
  7152. /**
  7153. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  7154. */
  7155. /**
  7156. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  7157. */
  7158. lightmapMode: number;
  7159. private _parentedWorldMatrix;
  7160. /**
  7161. * Shadow generator associted to the light.
  7162. * Internal use only.
  7163. */
  7164. _shadowGenerator: Nullable<IShadowGenerator>;
  7165. /**
  7166. * @ignore Internal use only.
  7167. */
  7168. _excludedMeshesIds: string[];
  7169. /**
  7170. * @ignore Internal use only.
  7171. */
  7172. _includedOnlyMeshesIds: string[];
  7173. /**
  7174. * The current light unifom buffer.
  7175. * @ignore Internal use only.
  7176. */
  7177. _uniformBuffer: UniformBuffer;
  7178. /**
  7179. * Creates a Light object in the scene.
  7180. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7181. * @param name The firendly name of the light
  7182. * @param scene The scene the light belongs too
  7183. */
  7184. constructor(name: string, scene: Scene);
  7185. protected abstract _buildUniformLayout(): void;
  7186. /**
  7187. * Sets the passed Effect "effect" with the Light information.
  7188. * @param effect The effect to update
  7189. * @param lightIndex The index of the light in the effect to update
  7190. * @returns The light
  7191. */
  7192. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  7193. /**
  7194. * @ignore internal use only.
  7195. */
  7196. abstract _getWorldMatrix(): Matrix;
  7197. /**
  7198. * Returns the string "Light".
  7199. * @returns the class name
  7200. */
  7201. getClassName(): string;
  7202. /**
  7203. * Converts the light information to a readable string for debug purpose.
  7204. * @param fullDetails Supports for multiple levels of logging within scene loading
  7205. * @returns the human readable light info
  7206. */
  7207. toString(fullDetails?: boolean): string;
  7208. /**
  7209. * Set the enabled state of this node.
  7210. * @param value - the new enabled state
  7211. * @see isEnabled
  7212. */
  7213. setEnabled(value: boolean): void;
  7214. /**
  7215. * Returns the Light associated shadow generator if any.
  7216. * @return the associated shadow generator.
  7217. */
  7218. getShadowGenerator(): Nullable<IShadowGenerator>;
  7219. /**
  7220. * Returns a Vector3, the absolute light position in the World.
  7221. * @returns the world space position of the light
  7222. */
  7223. getAbsolutePosition(): Vector3;
  7224. /**
  7225. * Specifies if the light will affect the passed mesh.
  7226. * @param mesh The mesh to test against the light
  7227. * @return true the mesh is affected otherwise, false.
  7228. */
  7229. canAffectMesh(mesh: AbstractMesh): boolean;
  7230. /**
  7231. * Computes and Returns the light World matrix.
  7232. * @returns the world matrix
  7233. */
  7234. getWorldMatrix(): Matrix;
  7235. /**
  7236. * Sort function to order lights for rendering.
  7237. * @param a First Light object to compare to second.
  7238. * @param b Second Light object to compare first.
  7239. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  7240. */
  7241. static CompareLightsPriority(a: Light, b: Light): number;
  7242. /**
  7243. * Releases resources associated with this node.
  7244. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7245. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7246. */
  7247. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7248. /**
  7249. * Returns the light type ID (integer).
  7250. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7251. */
  7252. getTypeID(): number;
  7253. /**
  7254. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  7255. * @returns the scaled intensity in intensity mode unit
  7256. */
  7257. getScaledIntensity(): number;
  7258. /**
  7259. * Returns a new Light object, named "name", from the current one.
  7260. * @param name The name of the cloned light
  7261. * @returns the new created light
  7262. */
  7263. clone(name: string): Nullable<Light>;
  7264. /**
  7265. * Serializes the current light into a Serialization object.
  7266. * @returns the serialized object.
  7267. */
  7268. serialize(): any;
  7269. /**
  7270. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  7271. * This new light is named "name" and added to the passed scene.
  7272. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  7273. * @param name The friendly name of the light
  7274. * @param scene The scene the new light will belong to
  7275. * @returns the constructor function
  7276. */
  7277. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  7278. /**
  7279. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  7280. * @param parsedLight The JSON representation of the light
  7281. * @param scene The scene to create the parsed light in
  7282. * @returns the created light after parsing
  7283. */
  7284. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  7285. private _hookArrayForExcluded(array);
  7286. private _hookArrayForIncludedOnly(array);
  7287. private _resyncMeshes();
  7288. /**
  7289. * Forces the meshes to update their light related information in their rendering used effects
  7290. * @ignore Internal Use Only
  7291. */
  7292. _markMeshesAsLightDirty(): void;
  7293. /**
  7294. * Recomputes the cached photometric scale if needed.
  7295. */
  7296. private _computePhotometricScale();
  7297. /**
  7298. * Returns the Photometric Scale according to the light type and intensity mode.
  7299. */
  7300. private _getPhotometricScale();
  7301. /**
  7302. * Reorder the light in the scene according to their defined priority.
  7303. * @ignore Internal Use Only
  7304. */
  7305. _reorderLightsInScene(): void;
  7306. }
  7307. }
  7308. declare module BABYLON {
  7309. /**
  7310. * A point light is a light defined by an unique point in world space.
  7311. * The light is emitted in every direction from this point.
  7312. * A good example of a point light is a standard light bulb.
  7313. * Documentation: https://doc.babylonjs.com/babylon101/lights
  7314. */
  7315. class PointLight extends ShadowLight {
  7316. private _shadowAngle;
  7317. /**
  7318. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7319. * This specifies what angle the shadow will use to be created.
  7320. *
  7321. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  7322. */
  7323. /**
  7324. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7325. * This specifies what angle the shadow will use to be created.
  7326. *
  7327. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  7328. */
  7329. shadowAngle: number;
  7330. /**
  7331. * Gets the direction if it has been set.
  7332. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7333. */
  7334. /**
  7335. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7336. */
  7337. direction: Vector3;
  7338. /**
  7339. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  7340. * A PointLight emits the light in every direction.
  7341. * It can cast shadows.
  7342. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  7343. * ```javascript
  7344. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  7345. * ```
  7346. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7347. * @param name The light friendly name
  7348. * @param position The position of the point light in the scene
  7349. * @param scene The scene the lights belongs to
  7350. */
  7351. constructor(name: string, position: Vector3, scene: Scene);
  7352. /**
  7353. * Returns the string "PointLight"
  7354. * @returns the class name
  7355. */
  7356. getClassName(): string;
  7357. /**
  7358. * Returns the integer 0.
  7359. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7360. */
  7361. getTypeID(): number;
  7362. /**
  7363. * Specifies wether or not the shadowmap should be a cube texture.
  7364. * @returns true if the shadowmap needs to be a cube texture.
  7365. */
  7366. needCube(): boolean;
  7367. /**
  7368. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  7369. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7370. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7371. */
  7372. getShadowDirection(faceIndex?: number): Vector3;
  7373. /**
  7374. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  7375. * - fov = PI / 2
  7376. * - aspect ratio : 1.0
  7377. * - z-near and far equal to the active camera minZ and maxZ.
  7378. * Returns the PointLight.
  7379. */
  7380. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7381. protected _buildUniformLayout(): void;
  7382. /**
  7383. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  7384. * @param effect The effect to update
  7385. * @param lightIndex The index of the light in the effect to update
  7386. * @returns The point light
  7387. */
  7388. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  7389. }
  7390. }
  7391. declare module BABYLON {
  7392. /**
  7393. * Interface describing all the common properties and methods a shadow light needs to implement.
  7394. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  7395. * as well as binding the different shadow properties to the effects.
  7396. */
  7397. interface IShadowLight extends Light {
  7398. /**
  7399. * The light id in the scene (used in scene.findLighById for instance)
  7400. */
  7401. id: string;
  7402. /**
  7403. * The position the shdow will be casted from.
  7404. */
  7405. position: Vector3;
  7406. /**
  7407. * In 2d mode (needCube being false), the direction used to cast the shadow.
  7408. */
  7409. direction: Vector3;
  7410. /**
  7411. * The transformed position. Position of the light in world space taking parenting in account.
  7412. */
  7413. transformedPosition: Vector3;
  7414. /**
  7415. * The transformed direction. Direction of the light in world space taking parenting in account.
  7416. */
  7417. transformedDirection: Vector3;
  7418. /**
  7419. * The friendly name of the light in the scene.
  7420. */
  7421. name: string;
  7422. /**
  7423. * Defines the shadow projection clipping minimum z value.
  7424. */
  7425. shadowMinZ: number;
  7426. /**
  7427. * Defines the shadow projection clipping maximum z value.
  7428. */
  7429. shadowMaxZ: number;
  7430. /**
  7431. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  7432. * @returns true if the information has been computed, false if it does not need to (no parenting)
  7433. */
  7434. computeTransformedInformation(): boolean;
  7435. /**
  7436. * Gets the scene the light belongs to.
  7437. * @returns The scene
  7438. */
  7439. getScene(): Scene;
  7440. /**
  7441. * Callback defining a custom Projection Matrix Builder.
  7442. * This can be used to override the default projection matrix computation.
  7443. */
  7444. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  7445. /**
  7446. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  7447. * @param matrix The materix to updated with the projection information
  7448. * @param viewMatrix The transform matrix of the light
  7449. * @param renderList The list of mesh to render in the map
  7450. * @returns The current light
  7451. */
  7452. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  7453. /**
  7454. * Gets the current depth scale used in ESM.
  7455. * @returns The scale
  7456. */
  7457. getDepthScale(): number;
  7458. /**
  7459. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  7460. * @returns true if a cube texture needs to be use
  7461. */
  7462. needCube(): boolean;
  7463. /**
  7464. * Detects if the projection matrix requires to be recomputed this frame.
  7465. * @returns true if it requires to be recomputed otherwise, false.
  7466. */
  7467. needProjectionMatrixCompute(): boolean;
  7468. /**
  7469. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  7470. */
  7471. forceProjectionMatrixCompute(): void;
  7472. /**
  7473. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  7474. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7475. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7476. */
  7477. getShadowDirection(faceIndex?: number): Vector3;
  7478. /**
  7479. * Gets the minZ used for shadow according to both the scene and the light.
  7480. * @param activeCamera The camera we are returning the min for
  7481. * @returns the depth min z
  7482. */
  7483. getDepthMinZ(activeCamera: Camera): number;
  7484. /**
  7485. * Gets the maxZ used for shadow according to both the scene and the light.
  7486. * @param activeCamera The camera we are returning the max for
  7487. * @returns the depth max z
  7488. */
  7489. getDepthMaxZ(activeCamera: Camera): number;
  7490. }
  7491. /**
  7492. * Base implementation of @see IShadowLight
  7493. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  7494. */
  7495. abstract class ShadowLight extends Light implements IShadowLight {
  7496. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7497. protected _position: Vector3;
  7498. protected _setPosition(value: Vector3): void;
  7499. /**
  7500. * Sets the position the shadow will be casted from. Also use as the light position for both
  7501. * point and spot lights.
  7502. */
  7503. /**
  7504. * Sets the position the shadow will be casted from. Also use as the light position for both
  7505. * point and spot lights.
  7506. */
  7507. position: Vector3;
  7508. protected _direction: Vector3;
  7509. protected _setDirection(value: Vector3): void;
  7510. /**
  7511. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  7512. * Also use as the light direction on spot and directional lights.
  7513. */
  7514. /**
  7515. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  7516. * Also use as the light direction on spot and directional lights.
  7517. */
  7518. direction: Vector3;
  7519. private _shadowMinZ;
  7520. /**
  7521. * Gets the shadow projection clipping minimum z value.
  7522. */
  7523. /**
  7524. * Sets the shadow projection clipping minimum z value.
  7525. */
  7526. shadowMinZ: number;
  7527. private _shadowMaxZ;
  7528. /**
  7529. * Sets the shadow projection clipping maximum z value.
  7530. */
  7531. /**
  7532. * Gets the shadow projection clipping maximum z value.
  7533. */
  7534. shadowMaxZ: number;
  7535. /**
  7536. * Callback defining a custom Projection Matrix Builder.
  7537. * This can be used to override the default projection matrix computation.
  7538. */
  7539. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  7540. /**
  7541. * The transformed position. Position of the light in world space taking parenting in account.
  7542. */
  7543. transformedPosition: Vector3;
  7544. /**
  7545. * The transformed direction. Direction of the light in world space taking parenting in account.
  7546. */
  7547. transformedDirection: Vector3;
  7548. private _worldMatrix;
  7549. private _needProjectionMatrixCompute;
  7550. /**
  7551. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  7552. * @returns true if the information has been computed, false if it does not need to (no parenting)
  7553. */
  7554. computeTransformedInformation(): boolean;
  7555. /**
  7556. * Return the depth scale used for the shadow map.
  7557. * @returns the depth scale.
  7558. */
  7559. getDepthScale(): number;
  7560. /**
  7561. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  7562. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7563. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7564. */
  7565. getShadowDirection(faceIndex?: number): Vector3;
  7566. /**
  7567. * Returns the ShadowLight absolute position in the World.
  7568. * @returns the position vector in world space
  7569. */
  7570. getAbsolutePosition(): Vector3;
  7571. /**
  7572. * Sets the ShadowLight direction toward the passed target.
  7573. * @param target The point tot target in local space
  7574. * @returns the updated ShadowLight direction
  7575. */
  7576. setDirectionToTarget(target: Vector3): Vector3;
  7577. /**
  7578. * Returns the light rotation in euler definition.
  7579. * @returns the x y z rotation in local space.
  7580. */
  7581. getRotation(): Vector3;
  7582. /**
  7583. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  7584. * @returns true if a cube texture needs to be use
  7585. */
  7586. needCube(): boolean;
  7587. /**
  7588. * Detects if the projection matrix requires to be recomputed this frame.
  7589. * @returns true if it requires to be recomputed otherwise, false.
  7590. */
  7591. needProjectionMatrixCompute(): boolean;
  7592. /**
  7593. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  7594. */
  7595. forceProjectionMatrixCompute(): void;
  7596. /**
  7597. * Get the world matrix of the sahdow lights.
  7598. * @ignore Internal Use Only
  7599. */
  7600. _getWorldMatrix(): Matrix;
  7601. /**
  7602. * Gets the minZ used for shadow according to both the scene and the light.
  7603. * @param activeCamera The camera we are returning the min for
  7604. * @returns the depth min z
  7605. */
  7606. getDepthMinZ(activeCamera: Camera): number;
  7607. /**
  7608. * Gets the maxZ used for shadow according to both the scene and the light.
  7609. * @param activeCamera The camera we are returning the max for
  7610. * @returns the depth max z
  7611. */
  7612. getDepthMaxZ(activeCamera: Camera): number;
  7613. /**
  7614. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  7615. * @param matrix The materix to updated with the projection information
  7616. * @param viewMatrix The transform matrix of the light
  7617. * @param renderList The list of mesh to render in the map
  7618. * @returns The current light
  7619. */
  7620. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  7621. }
  7622. }
  7623. declare module BABYLON {
  7624. /**
  7625. * A spot light is defined by a position, a direction, an angle, and an exponent.
  7626. * These values define a cone of light starting from the position, emitting toward the direction.
  7627. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  7628. * and the exponent defines the speed of the decay of the light with distance (reach).
  7629. * Documentation: https://doc.babylonjs.com/babylon101/lights
  7630. */
  7631. class SpotLight extends ShadowLight {
  7632. private _angle;
  7633. /**
  7634. * Gets the cone angle of the spot light in Radians.
  7635. */
  7636. /**
  7637. * Sets the cone angle of the spot light in Radians.
  7638. */
  7639. angle: number;
  7640. private _shadowAngleScale;
  7641. /**
  7642. * Allows scaling the angle of the light for shadow generation only.
  7643. */
  7644. /**
  7645. * Allows scaling the angle of the light for shadow generation only.
  7646. */
  7647. shadowAngleScale: number;
  7648. /**
  7649. * The light decay speed with the distance from the emission spot.
  7650. */
  7651. exponent: number;
  7652. private _projectionTextureMatrix;
  7653. /**
  7654. * Allows reading the projecton texture
  7655. */
  7656. readonly projectionTextureMatrix: Matrix;
  7657. protected _projectionTextureLightNear: number;
  7658. /**
  7659. * Gets the near clip of the Spotlight for texture projection.
  7660. */
  7661. /**
  7662. * Sets the near clip of the Spotlight for texture projection.
  7663. */
  7664. projectionTextureLightNear: number;
  7665. protected _projectionTextureLightFar: number;
  7666. /**
  7667. * Gets the far clip of the Spotlight for texture projection.
  7668. */
  7669. /**
  7670. * Sets the far clip of the Spotlight for texture projection.
  7671. */
  7672. projectionTextureLightFar: number;
  7673. protected _projectionTextureUpDirection: Vector3;
  7674. /**
  7675. * Gets the Up vector of the Spotlight for texture projection.
  7676. */
  7677. /**
  7678. * Sets the Up vector of the Spotlight for texture projection.
  7679. */
  7680. projectionTextureUpDirection: Vector3;
  7681. private _projectionTexture;
  7682. /**
  7683. * Gets the projection texture of the light.
  7684. */
  7685. /**
  7686. * Sets the projection texture of the light.
  7687. */
  7688. projectionTexture: Nullable<BaseTexture>;
  7689. private _projectionTextureViewLightDirty;
  7690. private _projectionTextureProjectionLightDirty;
  7691. private _projectionTextureDirty;
  7692. private _projectionTextureViewTargetVector;
  7693. private _projectionTextureViewLightMatrix;
  7694. private _projectionTextureProjectionLightMatrix;
  7695. private _projectionTextureScalingMatrix;
  7696. /**
  7697. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  7698. * It can cast shadows.
  7699. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7700. * @param name The light friendly name
  7701. * @param position The position of the spot light in the scene
  7702. * @param direction The direction of the light in the scene
  7703. * @param angle The cone angle of the light in Radians
  7704. * @param exponent The light decay speed with the distance from the emission spot
  7705. * @param scene The scene the lights belongs to
  7706. */
  7707. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  7708. /**
  7709. * Returns the string "SpotLight".
  7710. * @returns the class name
  7711. */
  7712. getClassName(): string;
  7713. /**
  7714. * Returns the integer 2.
  7715. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7716. */
  7717. getTypeID(): number;
  7718. /**
  7719. * Overrides the direction setter to recompute the projection texture view light Matrix.
  7720. */
  7721. protected _setDirection(value: Vector3): void;
  7722. /**
  7723. * Overrides the position setter to recompute the projection texture view light Matrix.
  7724. */
  7725. protected _setPosition(value: Vector3): void;
  7726. /**
  7727. * Sets the passed matrix "matrix" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.
  7728. * Returns the SpotLight.
  7729. */
  7730. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7731. protected _computeProjectionTextureViewLightMatrix(): void;
  7732. protected _computeProjectionTextureProjectionLightMatrix(): void;
  7733. /**
  7734. * Main function for light texture projection matrix computing.
  7735. */
  7736. protected _computeProjectionTextureMatrix(): void;
  7737. protected _buildUniformLayout(): void;
  7738. /**
  7739. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  7740. * @param effect The effect to update
  7741. * @param lightIndex The index of the light in the effect to update
  7742. * @returns The spot light
  7743. */
  7744. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  7745. /**
  7746. * Disposes the light and the associated resources.
  7747. */
  7748. dispose(): void;
  7749. }
  7750. }
  7751. declare module BABYLON {
  7752. interface ILoadingScreen {
  7753. displayLoadingUI: () => void;
  7754. hideLoadingUI: () => void;
  7755. loadingUIBackgroundColor: string;
  7756. loadingUIText: string;
  7757. }
  7758. class DefaultLoadingScreen implements ILoadingScreen {
  7759. private _renderingCanvas;
  7760. private _loadingText;
  7761. private _loadingDivBackgroundColor;
  7762. private _loadingDiv;
  7763. private _loadingTextDiv;
  7764. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  7765. displayLoadingUI(): void;
  7766. hideLoadingUI(): void;
  7767. loadingUIText: string;
  7768. loadingUIBackgroundColor: string;
  7769. private _resizeLoadingUI;
  7770. }
  7771. }
  7772. declare module BABYLON {
  7773. class SceneLoaderProgressEvent {
  7774. readonly lengthComputable: boolean;
  7775. readonly loaded: number;
  7776. readonly total: number;
  7777. constructor(lengthComputable: boolean, loaded: number, total: number);
  7778. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  7779. }
  7780. interface ISceneLoaderPluginExtensions {
  7781. [extension: string]: {
  7782. isBinary: boolean;
  7783. };
  7784. }
  7785. interface ISceneLoaderPluginFactory {
  7786. name: string;
  7787. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  7788. canDirectLoad?: (data: string) => boolean;
  7789. }
  7790. interface ISceneLoaderPlugin {
  7791. /**
  7792. * The friendly name of this plugin.
  7793. */
  7794. name: string;
  7795. /**
  7796. * The file extensions supported by this plugin.
  7797. */
  7798. extensions: string | ISceneLoaderPluginExtensions;
  7799. /**
  7800. * Import meshes into a scene.
  7801. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  7802. * @param scene The scene to import into
  7803. * @param data The data to import
  7804. * @param rootUrl The root url for scene and resources
  7805. * @param meshes The meshes array to import into
  7806. * @param particleSystems The particle systems array to import into
  7807. * @param skeletons The skeletons array to import into
  7808. * @param onError The callback when import fails
  7809. * @returns True if successful or false otherwise
  7810. */
  7811. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  7812. /**
  7813. * Load into a scene.
  7814. * @param scene The scene to load into
  7815. * @param data The data to import
  7816. * @param rootUrl The root url for scene and resources
  7817. * @param onError The callback when import fails
  7818. * @returns true if successful or false otherwise
  7819. */
  7820. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  7821. /**
  7822. * The callback that returns true if the data can be directly loaded.
  7823. */
  7824. canDirectLoad?: (data: string) => boolean;
  7825. /**
  7826. * The callback that allows custom handling of the root url based on the response url.
  7827. */
  7828. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  7829. /**
  7830. * Load into an asset container.
  7831. * @param scene The scene to load into
  7832. * @param data The data to import
  7833. * @param rootUrl The root url for scene and resources
  7834. * @param onError The callback when import fails
  7835. * @returns The loaded asset container
  7836. */
  7837. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  7838. }
  7839. interface ISceneLoaderPluginAsync {
  7840. /**
  7841. * The friendly name of this plugin.
  7842. */
  7843. name: string;
  7844. /**
  7845. * The file extensions supported by this plugin.
  7846. */
  7847. extensions: string | ISceneLoaderPluginExtensions;
  7848. /**
  7849. * Import meshes into a scene.
  7850. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  7851. * @param scene The scene to import into
  7852. * @param data The data to import
  7853. * @param rootUrl The root url for scene and resources
  7854. * @param onProgress The callback when the load progresses
  7855. * @returns The loaded meshes, particle systems, and skeletons
  7856. */
  7857. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  7858. meshes: AbstractMesh[];
  7859. particleSystems: ParticleSystem[];
  7860. skeletons: Skeleton[];
  7861. }>;
  7862. /**
  7863. * Load into a scene.
  7864. * @param scene The scene to load into
  7865. * @param data The data to import
  7866. * @param rootUrl The root url for scene and resources
  7867. * @param onProgress The callback when the load progresses
  7868. * @returns Nothing
  7869. */
  7870. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  7871. /**
  7872. * The callback that returns true if the data can be directly loaded.
  7873. */
  7874. canDirectLoad?: (data: string) => boolean;
  7875. /**
  7876. * The callback that allows custom handling of the root url based on the response url.
  7877. */
  7878. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  7879. /**
  7880. * Load into an asset container.
  7881. * @param scene The scene to load into
  7882. * @param data The data to import
  7883. * @param rootUrl The root url for scene and resources
  7884. * @param onProgress The callback when the load progresses
  7885. * @returns The loaded asset container
  7886. */
  7887. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  7888. }
  7889. class SceneLoader {
  7890. private static _ForceFullSceneLoadingForIncremental;
  7891. private static _ShowLoadingScreen;
  7892. private static _CleanBoneMatrixWeights;
  7893. static readonly NO_LOGGING: number;
  7894. static readonly MINIMAL_LOGGING: number;
  7895. static readonly SUMMARY_LOGGING: number;
  7896. static readonly DETAILED_LOGGING: number;
  7897. private static _loggingLevel;
  7898. static ForceFullSceneLoadingForIncremental: boolean;
  7899. static ShowLoadingScreen: boolean;
  7900. static loggingLevel: number;
  7901. static CleanBoneMatrixWeights: boolean;
  7902. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  7903. private static _registeredPlugins;
  7904. private static _getDefaultPlugin();
  7905. private static _getPluginForExtension(extension);
  7906. private static _getPluginForDirectLoad(data);
  7907. private static _getPluginForFilename(sceneFilename);
  7908. private static _getDirectLoad(sceneFilename);
  7909. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  7910. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  7911. static IsPluginForExtensionAvailable(extension: string): boolean;
  7912. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  7913. /**
  7914. * Import meshes into a scene
  7915. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  7916. * @param rootUrl a string that defines the root url for scene and resources
  7917. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7918. * @param scene the instance of BABYLON.Scene to append to
  7919. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  7920. * @param onProgress a callback with a progress event for each file being loaded
  7921. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  7922. * @param pluginExtension the extension used to determine the plugin
  7923. * @returns The loaded plugin
  7924. */
  7925. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  7926. /**
  7927. * Import meshes into a scene
  7928. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  7929. * @param rootUrl a string that defines the root url for scene and resources
  7930. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7931. * @param scene the instance of BABYLON.Scene to append to
  7932. * @param onProgress a callback with a progress event for each file being loaded
  7933. * @param pluginExtension the extension used to determine the plugin
  7934. * @returns The loaded list of imported meshes, particleSystems, and skeletons
  7935. */
  7936. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  7937. meshes: AbstractMesh[];
  7938. particleSystems: ParticleSystem[];
  7939. skeletons: Skeleton[];
  7940. }>;
  7941. /**
  7942. * Load a scene
  7943. * @param rootUrl a string that defines the root url for scene and resources
  7944. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7945. * @param engine is the instance of BABYLON.Engine to use to create the scene
  7946. * @param onSuccess a callback with the scene when import succeeds
  7947. * @param onProgress a callback with a progress event for each file being loaded
  7948. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  7949. * @param pluginExtension the extension used to determine the plugin
  7950. * @returns The loaded plugin
  7951. */
  7952. static Load(rootUrl: string, sceneFilename: any, engine: Engine, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  7953. /**
  7954. * Load a scene
  7955. * @param rootUrl a string that defines the root url for scene and resources
  7956. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7957. * @param engine is the instance of BABYLON.Engine to use to create the scene
  7958. * @param onProgress a callback with a progress event for each file being loaded
  7959. * @param pluginExtension the extension used to determine the plugin
  7960. * @returns The loaded scene
  7961. */
  7962. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  7963. /**
  7964. * Append a scene
  7965. * @param rootUrl a string that defines the root url for scene and resources
  7966. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7967. * @param scene is the instance of BABYLON.Scene to append to
  7968. * @param onSuccess a callback with the scene when import succeeds
  7969. * @param onProgress a callback with a progress event for each file being loaded
  7970. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  7971. * @param pluginExtension the extension used to determine the plugin
  7972. * @returns The loaded plugin
  7973. */
  7974. static Append(rootUrl: string, sceneFilename: any, scene: Scene, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  7975. /**
  7976. * Append a scene
  7977. * @param rootUrl a string that defines the root url for scene and resources
  7978. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7979. * @param scene is the instance of BABYLON.Scene to append to
  7980. * @param onProgress a callback with a progress event for each file being loaded
  7981. * @param pluginExtension the extension used to determine the plugin
  7982. * @returns The given scene
  7983. */
  7984. static AppendAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  7985. /**
  7986. * Load a scene into an asset container
  7987. * @param rootUrl a string that defines the root url for scene and resources
  7988. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7989. * @param scene is the instance of BABYLON.Scene to append to
  7990. * @param onSuccess a callback with the scene when import succeeds
  7991. * @param onProgress a callback with a progress event for each file being loaded
  7992. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  7993. * @param pluginExtension the extension used to determine the plugin
  7994. * @returns The loaded plugin
  7995. */
  7996. static LoadAssetContainer(rootUrl: string, sceneFilename: any, scene: Scene, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  7997. /**
  7998. * Load a scene into an asset container
  7999. * @param rootUrl a string that defines the root url for scene and resources
  8000. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8001. * @param scene is the instance of BABYLON.Scene to append to
  8002. * @param onProgress a callback with a progress event for each file being loaded
  8003. * @param pluginExtension the extension used to determine the plugin
  8004. * @returns The loaded asset container
  8005. */
  8006. static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  8007. }
  8008. }
  8009. declare module BABYLON {
  8010. class Scalar {
  8011. /**
  8012. * Two pi constants convenient for computation.
  8013. */
  8014. static TwoPi: number;
  8015. /**
  8016. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  8017. */
  8018. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  8019. /**
  8020. * Returns a string : the upper case translation of the number i to hexadecimal.
  8021. */
  8022. static ToHex(i: number): string;
  8023. /**
  8024. * Returns -1 if value is negative and +1 is value is positive.
  8025. * Returns the value itself if it's equal to zero.
  8026. */
  8027. static Sign(value: number): number;
  8028. /**
  8029. * Returns the value itself if it's between min and max.
  8030. * Returns min if the value is lower than min.
  8031. * Returns max if the value is greater than max.
  8032. */
  8033. static Clamp(value: number, min?: number, max?: number): number;
  8034. /**
  8035. * Returns the log2 of value.
  8036. */
  8037. static Log2(value: number): number;
  8038. /**
  8039. * Loops the value, so that it is never larger than length and never smaller than 0.
  8040. *
  8041. * This is similar to the modulo operator but it works with floating point numbers.
  8042. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  8043. * With t = 5 and length = 2.5, the result would be 0.0.
  8044. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  8045. */
  8046. static Repeat(value: number, length: number): number;
  8047. /**
  8048. * Normalize the value between 0.0 and 1.0 using min and max values
  8049. */
  8050. static Normalize(value: number, min: number, max: number): number;
  8051. /**
  8052. * Denormalize the value from 0.0 and 1.0 using min and max values
  8053. */
  8054. static Denormalize(normalized: number, min: number, max: number): number;
  8055. /**
  8056. * Calculates the shortest difference between two given angles given in degrees.
  8057. */
  8058. static DeltaAngle(current: number, target: number): number;
  8059. /**
  8060. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  8061. *
  8062. * The returned value will move back and forth between 0 and length
  8063. */
  8064. static PingPong(tx: number, length: number): number;
  8065. /**
  8066. * Interpolates between min and max with smoothing at the limits.
  8067. *
  8068. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  8069. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  8070. */
  8071. static SmoothStep(from: number, to: number, tx: number): number;
  8072. /**
  8073. * Moves a value current towards target.
  8074. *
  8075. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  8076. * Negative values of maxDelta pushes the value away from target.
  8077. */
  8078. static MoveTowards(current: number, target: number, maxDelta: number): number;
  8079. /**
  8080. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  8081. *
  8082. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  8083. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  8084. */
  8085. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  8086. /**
  8087. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  8088. */
  8089. static Lerp(start: number, end: number, amount: number): number;
  8090. /**
  8091. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  8092. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  8093. */
  8094. static LerpAngle(start: number, end: number, amount: number): number;
  8095. /**
  8096. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  8097. */
  8098. static InverseLerp(a: number, b: number, value: number): number;
  8099. /**
  8100. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  8101. */
  8102. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  8103. /**
  8104. * Returns a random float number between and min and max values
  8105. */
  8106. static RandomRange(min: number, max: number): number;
  8107. /**
  8108. * This function returns percentage of a number in a given range.
  8109. *
  8110. * RangeToPercent(40,20,60) will return 0.5 (50%)
  8111. * RangeToPercent(34,0,100) will return 0.34 (34%)
  8112. */
  8113. static RangeToPercent(number: number, min: number, max: number): number;
  8114. /**
  8115. * This function returns number that corresponds to the percentage in a given range.
  8116. *
  8117. * PercentToRange(0.34,0,100) will return 34.
  8118. */
  8119. static PercentToRange(percent: number, min: number, max: number): number;
  8120. /**
  8121. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  8122. * @param angle The angle to normalize in radian.
  8123. * @return The converted angle.
  8124. */
  8125. static NormalizeRadians(angle: number): number;
  8126. }
  8127. }
  8128. declare module BABYLON {
  8129. const ToGammaSpace: number;
  8130. const ToLinearSpace = 2.2;
  8131. const Epsilon = 0.001;
  8132. /**
  8133. * Class used to hold a RBG color
  8134. */
  8135. class Color3 {
  8136. /**
  8137. * Defines the red component (between 0 and 1, default is 0)
  8138. */
  8139. r: number;
  8140. /**
  8141. * Defines the green component (between 0 and 1, default is 0)
  8142. */
  8143. g: number;
  8144. /**
  8145. * Defines the blue component (between 0 and 1, default is 0)
  8146. */
  8147. b: number;
  8148. /**
  8149. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  8150. * @param r defines the red component (between 0 and 1, default is 0)
  8151. * @param g defines the green component (between 0 and 1, default is 0)
  8152. * @param b defines the blue component (between 0 and 1, default is 0)
  8153. */
  8154. constructor(
  8155. /**
  8156. * Defines the red component (between 0 and 1, default is 0)
  8157. */
  8158. r?: number,
  8159. /**
  8160. * Defines the green component (between 0 and 1, default is 0)
  8161. */
  8162. g?: number,
  8163. /**
  8164. * Defines the blue component (between 0 and 1, default is 0)
  8165. */
  8166. b?: number);
  8167. /**
  8168. * Creates a string with the Color3 current values
  8169. * @returns the string representation of the Color3 object
  8170. */
  8171. toString(): string;
  8172. /**
  8173. * Returns the string "Color3"
  8174. * @returns "Color3"
  8175. */
  8176. getClassName(): string;
  8177. /**
  8178. * Compute the Color3 hash code
  8179. * @returns an unique number that can be used to hash Color3 objects
  8180. */
  8181. getHashCode(): number;
  8182. /**
  8183. * Stores in the passed array from the passed starting index the red, green, blue values as successive elements
  8184. * @param array defines the array where to store the r,g,b components
  8185. * @param index defines an optional index in the target array to define where to start storing values
  8186. * @returns the current Color3 object
  8187. */
  8188. toArray(array: FloatArray, index?: number): Color3;
  8189. /**
  8190. * Returns a new {BABYLON.Color4} object from the current Color3 and the passed alpha
  8191. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  8192. * @returns a new {BABYLON.Color4} object
  8193. */
  8194. toColor4(alpha?: number): Color4;
  8195. /**
  8196. * Returns a new array populated with 3 numeric elements : red, green and blue values
  8197. * @returns the new array
  8198. */
  8199. asArray(): number[];
  8200. /**
  8201. * Returns the luminance value
  8202. * @returns a float value
  8203. */
  8204. toLuminance(): number;
  8205. /**
  8206. * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object
  8207. * @param otherColor defines the second operand
  8208. * @returns the new Color3 object
  8209. */
  8210. multiply(otherColor: Color3): Color3;
  8211. /**
  8212. * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result"
  8213. * @param otherColor defines the second operand
  8214. * @param result defines the Color3 object where to store the result
  8215. * @returns the current Color3
  8216. */
  8217. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  8218. /**
  8219. * Determines equality between Color3 objects
  8220. * @param otherColor defines the second operand
  8221. * @returns true if the rgb values are equal to the passed ones
  8222. */
  8223. equals(otherColor: Color3): boolean;
  8224. /**
  8225. * Determines equality between the current Color3 object and a set of r,b,g values
  8226. * @param r defines the red component to check
  8227. * @param g defines the green component to check
  8228. * @param b defines the blue component to check
  8229. * @returns true if the rgb values are equal to the passed ones
  8230. */
  8231. equalsFloats(r: number, g: number, b: number): boolean;
  8232. /**
  8233. * Multiplies in place each rgb value by scale
  8234. * @param scale defines the scaling factor
  8235. * @returns the updated Color3
  8236. */
  8237. scale(scale: number): Color3;
  8238. /**
  8239. * Multiplies the rgb values by scale and stores the result into "result"
  8240. * @param scale defines the scaling factor
  8241. * @param result defines the Color3 object where to store the result
  8242. * @returns the unmodified current Color3
  8243. */
  8244. scaleToRef(scale: number, result: Color3): Color3;
  8245. /**
  8246. * Scale the current Color3 values by a factor and add the result to a given Color3
  8247. * @param scale defines the scale factor
  8248. * @param result defines color to store the result into
  8249. * @returns the unmodified current Color3
  8250. */
  8251. scaleAndAddToRef(scale: number, result: Color3): Color3;
  8252. /**
  8253. * Clamps the rgb values by the min and max values and stores the result into "result"
  8254. * @param min defines minimum clamping value (default is 0)
  8255. * @param max defines maximum clamping value (default is 1)
  8256. * @param result defines color to store the result into
  8257. * @returns the original Color3
  8258. */
  8259. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  8260. /**
  8261. * Creates a new Color3 set with the added values of the current Color3 and of the passed one
  8262. * @param otherColor defines the second operand
  8263. * @returns the new Color3
  8264. */
  8265. add(otherColor: Color3): Color3;
  8266. /**
  8267. * Stores the result of the addition of the current Color3 and passed one rgb values into "result"
  8268. * @param otherColor defines the second operand
  8269. * @param result defines Color3 object to store the result into
  8270. * @returns the unmodified current Color3
  8271. */
  8272. addToRef(otherColor: Color3, result: Color3): Color3;
  8273. /**
  8274. * Returns a new Color3 set with the subtracted values of the passed one from the current Color3
  8275. * @param otherColor defines the second operand
  8276. * @returns the new Color3
  8277. */
  8278. subtract(otherColor: Color3): Color3;
  8279. /**
  8280. * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result"
  8281. * @param otherColor defines the second operand
  8282. * @param result defines Color3 object to store the result into
  8283. * @returns the unmodified current Color3
  8284. */
  8285. subtractToRef(otherColor: Color3, result: Color3): Color3;
  8286. /**
  8287. * Copy the current object
  8288. * @returns a new Color3 copied the current one
  8289. */
  8290. clone(): Color3;
  8291. /**
  8292. * Copies the rgb values from the source in the current Color3
  8293. * @param source defines the source Color3 object
  8294. * @returns the updated Color3 object
  8295. */
  8296. copyFrom(source: Color3): Color3;
  8297. /**
  8298. * Updates the Color3 rgb values from the passed floats
  8299. * @param r defines the red component to read from
  8300. * @param g defines the green component to read from
  8301. * @param b defines the blue component to read from
  8302. * @returns the current Color3 object
  8303. */
  8304. copyFromFloats(r: number, g: number, b: number): Color3;
  8305. /**
  8306. * Updates the Color3 rgb values from the passed floats
  8307. * @param r defines the red component to read from
  8308. * @param g defines the green component to read from
  8309. * @param b defines the blue component to read from
  8310. * @returns the current Color3 object
  8311. */
  8312. set(r: number, g: number, b: number): Color3;
  8313. /**
  8314. * Compute the Color3 hexadecimal code as a string
  8315. * @returns a string containing the hexadecimal representation of the Color3 object
  8316. */
  8317. toHexString(): string;
  8318. /**
  8319. * Computes a new Color3 converted from the current one to linear space
  8320. * @returns a new Color3 object
  8321. */
  8322. toLinearSpace(): Color3;
  8323. /**
  8324. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  8325. * @param convertedColor defines the Color3 object where to store the linear space version
  8326. * @returns the unmodified Color3
  8327. */
  8328. toLinearSpaceToRef(convertedColor: Color3): Color3;
  8329. /**
  8330. * Computes a new Color3 converted from the current one to gamma space
  8331. * @returns a new Color3 object
  8332. */
  8333. toGammaSpace(): Color3;
  8334. /**
  8335. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  8336. * @param convertedColor defines the Color3 object where to store the gamma space version
  8337. * @returns the unmodified Color3
  8338. */
  8339. toGammaSpaceToRef(convertedColor: Color3): Color3;
  8340. /**
  8341. * Creates a new Color3 from the string containing valid hexadecimal values
  8342. * @param hex defines a string containing valid hexadecimal values
  8343. * @returns a new Color3 object
  8344. */
  8345. static FromHexString(hex: string): Color3;
  8346. /**
  8347. * Creates a new Vector3 from the starting index of the passed array
  8348. * @param array defines the source array
  8349. * @param offset defines an offset in the source array
  8350. * @returns a new Color3 object
  8351. */
  8352. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  8353. /**
  8354. * Creates a new Color3 from integer values (< 256)
  8355. * @param r defines the red component to read from (value between 0 and 255)
  8356. * @param g defines the green component to read from (value between 0 and 255)
  8357. * @param b defines the blue component to read from (value between 0 and 255)
  8358. * @returns a new Color3 object
  8359. */
  8360. static FromInts(r: number, g: number, b: number): Color3;
  8361. /**
  8362. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  8363. * @param start defines the start Color3 value
  8364. * @param end defines the end Color3 value
  8365. * @param amount defines the gradient value between start and end
  8366. * @returns a new Color3 object
  8367. */
  8368. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  8369. /**
  8370. * Returns a Color3 value containing a red color
  8371. * @returns a new Color3 object
  8372. */
  8373. static Red(): Color3;
  8374. /**
  8375. * Returns a Color3 value containing a green color
  8376. * @returns a new Color3 object
  8377. */
  8378. static Green(): Color3;
  8379. /**
  8380. * Returns a Color3 value containing a blue color
  8381. * @returns a new Color3 object
  8382. */
  8383. static Blue(): Color3;
  8384. /**
  8385. * Returns a Color3 value containing a black color
  8386. * @returns a new Color3 object
  8387. */
  8388. static Black(): Color3;
  8389. /**
  8390. * Returns a Color3 value containing a white color
  8391. * @returns a new Color3 object
  8392. */
  8393. static White(): Color3;
  8394. /**
  8395. * Returns a Color3 value containing a purple color
  8396. * @returns a new Color3 object
  8397. */
  8398. static Purple(): Color3;
  8399. /**
  8400. * Returns a Color3 value containing a magenta color
  8401. * @returns a new Color3 object
  8402. */
  8403. static Magenta(): Color3;
  8404. /**
  8405. * Returns a Color3 value containing a yellow color
  8406. * @returns a new Color3 object
  8407. */
  8408. static Yellow(): Color3;
  8409. /**
  8410. * Returns a Color3 value containing a gray color
  8411. * @returns a new Color3 object
  8412. */
  8413. static Gray(): Color3;
  8414. /**
  8415. * Returns a Color3 value containing a teal color
  8416. * @returns a new Color3 object
  8417. */
  8418. static Teal(): Color3;
  8419. /**
  8420. * Returns a Color3 value containing a random color
  8421. * @returns a new Color3 object
  8422. */
  8423. static Random(): Color3;
  8424. }
  8425. /**
  8426. * Class used to hold a RBGA color
  8427. */
  8428. class Color4 {
  8429. /**
  8430. * Defines the red component (between 0 and 1, default is 0)
  8431. */
  8432. r: number;
  8433. /**
  8434. * Defines the green component (between 0 and 1, default is 0)
  8435. */
  8436. g: number;
  8437. /**
  8438. * Defines the blue component (between 0 and 1, default is 0)
  8439. */
  8440. b: number;
  8441. /**
  8442. * Defines the alpha component (between 0 and 1, default is 1)
  8443. */
  8444. a: number;
  8445. /**
  8446. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  8447. * @param r defines the red component (between 0 and 1, default is 0)
  8448. * @param g defines the green component (between 0 and 1, default is 0)
  8449. * @param b defines the blue component (between 0 and 1, default is 0)
  8450. * @param a defines the alpha component (between 0 and 1, default is 1)
  8451. */
  8452. constructor(
  8453. /**
  8454. * Defines the red component (between 0 and 1, default is 0)
  8455. */
  8456. r?: number,
  8457. /**
  8458. * Defines the green component (between 0 and 1, default is 0)
  8459. */
  8460. g?: number,
  8461. /**
  8462. * Defines the blue component (between 0 and 1, default is 0)
  8463. */
  8464. b?: number,
  8465. /**
  8466. * Defines the alpha component (between 0 and 1, default is 1)
  8467. */
  8468. a?: number);
  8469. /**
  8470. * Adds in place the passed Color4 values to the current Color4 object
  8471. * @param right defines the second operand
  8472. * @returns the current updated Color4 object
  8473. */
  8474. addInPlace(right: Color4): Color4;
  8475. /**
  8476. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  8477. * @returns the new array
  8478. */
  8479. asArray(): number[];
  8480. /**
  8481. * Stores from the starting index in the passed array the Color4 successive values
  8482. * @param array defines the array where to store the r,g,b components
  8483. * @param index defines an optional index in the target array to define where to start storing values
  8484. * @returns the current Color4 object
  8485. */
  8486. toArray(array: number[], index?: number): Color4;
  8487. /**
  8488. * Creates a new Color4 set with the added values of the current Color4 and of the passed one
  8489. * @param right defines the second operand
  8490. * @returns a new Color4 object
  8491. */
  8492. add(right: Color4): Color4;
  8493. /**
  8494. * Creates a new Color4 set with the subtracted values of the passed one from the current Color4
  8495. * @param right defines the second operand
  8496. * @returns a new Color4 object
  8497. */
  8498. subtract(right: Color4): Color4;
  8499. /**
  8500. * Subtracts the passed ones from the current Color4 values and stores the results in "result"
  8501. * @param right defines the second operand
  8502. * @param result defines the Color4 object where to store the result
  8503. * @returns the current Color4 object
  8504. */
  8505. subtractToRef(right: Color4, result: Color4): Color4;
  8506. /**
  8507. * Creates a new Color4 with the current Color4 values multiplied by scale
  8508. * @param scale defines the scaling factor to apply
  8509. * @returns a new Color4 object
  8510. */
  8511. scale(scale: number): Color4;
  8512. /**
  8513. * Multiplies the current Color4 values by scale and stores the result in "result"
  8514. * @param scale defines the scaling factor to apply
  8515. * @param result defines the Color4 object where to store the result
  8516. * @returns the current unmodified Color4
  8517. */
  8518. scaleToRef(scale: number, result: Color4): Color4;
  8519. /**
  8520. * Scale the current Color4 values by a factor and add the result to a given Color4
  8521. * @param scale defines the scale factor
  8522. * @param result defines the Color4 object where to store the result
  8523. * @returns the unmodified current Color4
  8524. */
  8525. scaleAndAddToRef(scale: number, result: Color4): Color4;
  8526. /**
  8527. * Clamps the rgb values by the min and max values and stores the result into "result"
  8528. * @param min defines minimum clamping value (default is 0)
  8529. * @param max defines maximum clamping value (default is 1)
  8530. * @param result defines color to store the result into.
  8531. * @returns the cuurent Color4
  8532. */
  8533. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  8534. /**
  8535. * Multipy an Color4 value by another and return a new Color4 object
  8536. * @param color defines the Color4 value to multiply by
  8537. * @returns a new Color4 object
  8538. */
  8539. multiply(color: Color4): Color4;
  8540. /**
  8541. * Multipy a Color4 value by another and push the result in a reference value
  8542. * @param color defines the Color4 value to multiply by
  8543. * @param result defines the Color4 to fill the result in
  8544. * @returns the result Color4
  8545. */
  8546. multiplyToRef(color: Color4, result: Color4): Color4;
  8547. /**
  8548. * Creates a string with the Color4 current values
  8549. * @returns the string representation of the Color4 object
  8550. */
  8551. toString(): string;
  8552. /**
  8553. * Returns the string "Color4"
  8554. * @returns "Color4"
  8555. */
  8556. getClassName(): string;
  8557. /**
  8558. * Compute the Color4 hash code
  8559. * @returns an unique number that can be used to hash Color4 objects
  8560. */
  8561. getHashCode(): number;
  8562. /**
  8563. * Creates a new Color4 copied from the current one
  8564. * @returns a new Color4 object
  8565. */
  8566. clone(): Color4;
  8567. /**
  8568. * Copies the passed Color4 values into the current one
  8569. * @param source defines the source Color4 object
  8570. * @returns the current updated Color4 object
  8571. */
  8572. copyFrom(source: Color4): Color4;
  8573. /**
  8574. * Copies the passed float values into the current one
  8575. * @param r defines the red component to read from
  8576. * @param g defines the green component to read from
  8577. * @param b defines the blue component to read from
  8578. * @param a defines the alpha component to read from
  8579. * @returns the current updated Color4 object
  8580. */
  8581. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  8582. /**
  8583. * Copies the passed float values into the current one
  8584. * @param r defines the red component to read from
  8585. * @param g defines the green component to read from
  8586. * @param b defines the blue component to read from
  8587. * @param a defines the alpha component to read from
  8588. * @returns the current updated Color4 object
  8589. */
  8590. set(r: number, g: number, b: number, a: number): Color4;
  8591. /**
  8592. * Compute the Color4 hexadecimal code as a string
  8593. * @returns a string containing the hexadecimal representation of the Color4 object
  8594. */
  8595. toHexString(): string;
  8596. /**
  8597. * Computes a new Color4 converted from the current one to linear space
  8598. * @returns a new Color4 object
  8599. */
  8600. toLinearSpace(): Color4;
  8601. /**
  8602. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  8603. * @param convertedColor defines the Color4 object where to store the linear space version
  8604. * @returns the unmodified Color4
  8605. */
  8606. toLinearSpaceToRef(convertedColor: Color4): Color4;
  8607. /**
  8608. * Computes a new Color4 converted from the current one to gamma space
  8609. * @returns a new Color4 object
  8610. */
  8611. toGammaSpace(): Color4;
  8612. /**
  8613. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  8614. * @param convertedColor defines the Color4 object where to store the gamma space version
  8615. * @returns the unmodified Color4
  8616. */
  8617. toGammaSpaceToRef(convertedColor: Color4): Color4;
  8618. /**
  8619. * Creates a new Color4 from the string containing valid hexadecimal values
  8620. * @param hex defines a string containing valid hexadecimal values
  8621. * @returns a new Color4 object
  8622. */
  8623. static FromHexString(hex: string): Color4;
  8624. /**
  8625. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  8626. * @param left defines the start value
  8627. * @param right defines the end value
  8628. * @param amount defines the gradient factor
  8629. * @returns a new Color4 object
  8630. */
  8631. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  8632. /**
  8633. * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  8634. * @param left defines the start value
  8635. * @param right defines the end value
  8636. * @param amount defines the gradient factor
  8637. * @param result defines the Color4 object where to store data
  8638. */
  8639. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  8640. /**
  8641. * Creates a new Color4 from the starting index element of the passed array
  8642. * @param array defines the source array to read from
  8643. * @param offset defines the offset in the source array
  8644. * @returns a new Color4 object
  8645. */
  8646. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  8647. /**
  8648. * Creates a new Color3 from integer values (< 256)
  8649. * @param r defines the red component to read from (value between 0 and 255)
  8650. * @param g defines the green component to read from (value between 0 and 255)
  8651. * @param b defines the blue component to read from (value between 0 and 255)
  8652. * @param a defines the alpha component to read from (value between 0 and 255)
  8653. * @returns a new Color3 object
  8654. */
  8655. static FromInts(r: number, g: number, b: number, a: number): Color4;
  8656. /**
  8657. * Check the content of a given array and convert it to an array containing RGBA data
  8658. * If the original array was already containing count * 4 values then it is returned directly
  8659. * @param colors defines the array to check
  8660. * @param count defines the number of RGBA data to expect
  8661. * @returns an array containing count * 4 values (RGBA)
  8662. */
  8663. static CheckColors4(colors: number[], count: number): number[];
  8664. }
  8665. class Vector2 {
  8666. x: number;
  8667. y: number;
  8668. /**
  8669. * Creates a new Vector2 from the passed x and y coordinates.
  8670. */
  8671. constructor(x: number, y: number);
  8672. /**
  8673. * Returns a string with the Vector2 coordinates.
  8674. */
  8675. toString(): string;
  8676. /**
  8677. * Returns the string "Vector2"
  8678. */
  8679. getClassName(): string;
  8680. /**
  8681. * Returns the Vector2 hash code as a number.
  8682. */
  8683. getHashCode(): number;
  8684. /**
  8685. * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index.
  8686. * Returns the Vector2.
  8687. */
  8688. toArray(array: FloatArray, index?: number): Vector2;
  8689. /**
  8690. * Returns a new array with 2 elements : the Vector2 coordinates.
  8691. */
  8692. asArray(): number[];
  8693. /**
  8694. * Sets the Vector2 coordinates with the passed Vector2 coordinates.
  8695. * Returns the updated Vector2.
  8696. */
  8697. copyFrom(source: Vector2): Vector2;
  8698. /**
  8699. * Sets the Vector2 coordinates with the passed floats.
  8700. * Returns the updated Vector2.
  8701. */
  8702. copyFromFloats(x: number, y: number): Vector2;
  8703. /**
  8704. * Sets the Vector2 coordinates with the passed floats.
  8705. * Returns the updated Vector2.
  8706. */
  8707. set(x: number, y: number): Vector2;
  8708. /**
  8709. * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates.
  8710. */
  8711. add(otherVector: Vector2): Vector2;
  8712. /**
  8713. * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates.
  8714. * Returns the Vector2.
  8715. */
  8716. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  8717. /**
  8718. * Set the Vector2 coordinates by adding the passed Vector2 coordinates.
  8719. * Returns the updated Vector2.
  8720. */
  8721. addInPlace(otherVector: Vector2): Vector2;
  8722. /**
  8723. * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates.
  8724. */
  8725. addVector3(otherVector: Vector3): Vector2;
  8726. /**
  8727. * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2.
  8728. */
  8729. subtract(otherVector: Vector2): Vector2;
  8730. /**
  8731. * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates.
  8732. * Returns the Vector2.
  8733. */
  8734. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  8735. /**
  8736. * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates.
  8737. * Returns the updated Vector2.
  8738. */
  8739. subtractInPlace(otherVector: Vector2): Vector2;
  8740. /**
  8741. * Multiplies in place the current Vector2 coordinates by the passed ones.
  8742. * Returns the updated Vector2.
  8743. */
  8744. multiplyInPlace(otherVector: Vector2): Vector2;
  8745. /**
  8746. * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates.
  8747. */
  8748. multiply(otherVector: Vector2): Vector2;
  8749. /**
  8750. * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates.
  8751. * Returns the Vector2.
  8752. */
  8753. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  8754. /**
  8755. * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats.
  8756. */
  8757. multiplyByFloats(x: number, y: number): Vector2;
  8758. /**
  8759. * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates.
  8760. */
  8761. divide(otherVector: Vector2): Vector2;
  8762. /**
  8763. * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates.
  8764. * Returns the Vector2.
  8765. */
  8766. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  8767. /**
  8768. * Divides the current Vector3 coordinates by the passed ones.
  8769. * Returns the updated Vector3.
  8770. */
  8771. divideInPlace(otherVector: Vector2): Vector2;
  8772. /**
  8773. * Returns a new Vector2 with current Vector2 negated coordinates.
  8774. */
  8775. negate(): Vector2;
  8776. /**
  8777. * Multiply the Vector2 coordinates by scale.
  8778. * Returns the updated Vector2.
  8779. */
  8780. scaleInPlace(scale: number): Vector2;
  8781. /**
  8782. * Returns a new Vector2 scaled by "scale" from the current Vector2.
  8783. */
  8784. scale(scale: number): Vector2;
  8785. /**
  8786. * Scale the current Vector2 values by a factor to a given Vector2
  8787. * @param scale defines the scale factor
  8788. * @param result defines the Vector2 object where to store the result
  8789. * @returns the unmodified current Vector2
  8790. */
  8791. scaleToRef(scale: number, result: Vector2): Vector2;
  8792. /**
  8793. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  8794. * @param scale defines the scale factor
  8795. * @param result defines the Vector2 object where to store the result
  8796. * @returns the unmodified current Vector2
  8797. */
  8798. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  8799. /**
  8800. * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones.
  8801. */
  8802. equals(otherVector: Vector2): boolean;
  8803. /**
  8804. * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon.
  8805. */
  8806. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  8807. /**
  8808. * Returns the vector length (float).
  8809. */
  8810. length(): number;
  8811. /**
  8812. * Returns the vector squared length (float);
  8813. */
  8814. lengthSquared(): number;
  8815. /**
  8816. * Normalize the vector.
  8817. * Returns the updated Vector2.
  8818. */
  8819. normalize(): Vector2;
  8820. /**
  8821. * Returns a new Vector2 copied from the Vector2.
  8822. */
  8823. clone(): Vector2;
  8824. /**
  8825. * Returns a new Vector2(0, 0)
  8826. */
  8827. static Zero(): Vector2;
  8828. /**
  8829. * Returns a new Vector2(1, 1)
  8830. */
  8831. static One(): Vector2;
  8832. /**
  8833. * Returns a new Vector2 set from the passed index element of the passed array.
  8834. */
  8835. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  8836. /**
  8837. * Sets "result" from the passed index element of the passed array.
  8838. */
  8839. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  8840. /**
  8841. * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2.
  8842. */
  8843. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  8844. /**
  8845. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  8846. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  8847. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate.
  8848. */
  8849. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  8850. /**
  8851. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2".
  8852. */
  8853. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  8854. /**
  8855. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  8856. */
  8857. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  8858. /**
  8859. * Returns the dot product (float) of the vector "left" and the vector "right".
  8860. */
  8861. static Dot(left: Vector2, right: Vector2): number;
  8862. /**
  8863. * Returns a new Vector2 equal to the normalized passed vector.
  8864. */
  8865. static Normalize(vector: Vector2): Vector2;
  8866. /**
  8867. * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors.
  8868. */
  8869. static Minimize(left: Vector2, right: Vector2): Vector2;
  8870. /**
  8871. * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors.
  8872. */
  8873. static Maximize(left: Vector2, right: Vector2): Vector2;
  8874. /**
  8875. * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix.
  8876. */
  8877. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  8878. /**
  8879. * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates.
  8880. */
  8881. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  8882. /**
  8883. * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  8884. */
  8885. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  8886. /**
  8887. * Returns the distance (float) between the vectors "value1" and "value2".
  8888. */
  8889. static Distance(value1: Vector2, value2: Vector2): number;
  8890. /**
  8891. * Returns the squared distance (float) between the vectors "value1" and "value2".
  8892. */
  8893. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  8894. /**
  8895. * Returns a new Vecto2 located at the center of the vectors "value1" and "value2".
  8896. */
  8897. static Center(value1: Vector2, value2: Vector2): Vector2;
  8898. /**
  8899. * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  8900. */
  8901. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  8902. }
  8903. /**
  8904. * Classed used to store (x,y,z) vector representation
  8905. * A Vector3 is the main object used in 3D geometry
  8906. * It can represent etiher the coordinates of a point the space, either a direction
  8907. * Reminder: Babylon.js uses a left handed forward facing system
  8908. */
  8909. class Vector3 {
  8910. /**
  8911. * Defines the first coordinates (on X axis)
  8912. */
  8913. x: number;
  8914. /**
  8915. * Defines the second coordinates (on Y axis)
  8916. */
  8917. y: number;
  8918. /**
  8919. * Defines the third coordinates (on Z axis)
  8920. */
  8921. z: number;
  8922. /**
  8923. * Creates a new Vector3 object from the passed x, y, z (floats) coordinates.
  8924. * @param x defines the first coordinates (on X axis)
  8925. * @param y defines the second coordinates (on Y axis)
  8926. * @param z defines the third coordinates (on Z axis)
  8927. */
  8928. constructor(
  8929. /**
  8930. * Defines the first coordinates (on X axis)
  8931. */
  8932. x: number,
  8933. /**
  8934. * Defines the second coordinates (on Y axis)
  8935. */
  8936. y: number,
  8937. /**
  8938. * Defines the third coordinates (on Z axis)
  8939. */
  8940. z: number);
  8941. /**
  8942. * Creates a string representation of the Vector3
  8943. * @returns a string with the Vector3 coordinates.
  8944. */
  8945. toString(): string;
  8946. /**
  8947. * Gets the class name
  8948. * @returns the string "Vector3"
  8949. */
  8950. getClassName(): string;
  8951. /**
  8952. * Creates the Vector3 hash code
  8953. * @returns a number which tends to be unique between Vector3 instances
  8954. */
  8955. getHashCode(): number;
  8956. /**
  8957. * Creates an array containing three elements : the coordinates of the Vector3
  8958. * @returns a new array of numbers
  8959. */
  8960. asArray(): number[];
  8961. /**
  8962. * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3
  8963. * @param array defines the destination array
  8964. * @param index defines the offset in the destination array
  8965. * @returns the current Vector3
  8966. */
  8967. toArray(array: FloatArray, index?: number): Vector3;
  8968. /**
  8969. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  8970. * @returns a new Quaternion object, computed from the Vector3 coordinates
  8971. */
  8972. toQuaternion(): Quaternion;
  8973. /**
  8974. * Adds the passed vector to the current Vector3
  8975. * @param otherVector defines the second operand
  8976. * @returns the current updated Vector3
  8977. */
  8978. addInPlace(otherVector: Vector3): Vector3;
  8979. /**
  8980. * Gets a new Vector3, result of the addition the current Vector3 and the passed vector
  8981. * @param otherVector defines the second operand
  8982. * @returns the resulting Vector3
  8983. */
  8984. add(otherVector: Vector3): Vector3;
  8985. /**
  8986. * Adds the current Vector3 to the passed one and stores the result in the vector "result"
  8987. * @param otherVector defines the second operand
  8988. * @param result defines the Vector3 object where to store the result
  8989. * @returns the current Vector3
  8990. */
  8991. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  8992. /**
  8993. * Subtract the passed vector from the current Vector3
  8994. * @param otherVector defines the second operand
  8995. * @returns the current updated Vector3
  8996. */
  8997. subtractInPlace(otherVector: Vector3): Vector3;
  8998. /**
  8999. * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3
  9000. * @param otherVector defines the second operand
  9001. * @returns the resulting Vector3
  9002. */
  9003. subtract(otherVector: Vector3): Vector3;
  9004. /**
  9005. * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result".
  9006. * @param otherVector defines the second operand
  9007. * @param result defines the Vector3 object where to store the result
  9008. * @returns the current Vector3
  9009. */
  9010. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  9011. /**
  9012. * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates
  9013. * @param x defines the x coordinate of the operand
  9014. * @param y defines the y coordinate of the operand
  9015. * @param z defines the z coordinate of the operand
  9016. * @returns the resulting Vector3
  9017. */
  9018. subtractFromFloats(x: number, y: number, z: number): Vector3;
  9019. /**
  9020. * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result
  9021. * @param x defines the x coordinate of the operand
  9022. * @param y defines the y coordinate of the operand
  9023. * @param z defines the z coordinate of the operand
  9024. * @param result defines the Vector3 object where to store the result
  9025. * @returns the current Vector3
  9026. */
  9027. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  9028. /**
  9029. * Gets a new Vector3 set with the current Vector3 negated coordinates
  9030. * @returns a new Vector3
  9031. */
  9032. negate(): Vector3;
  9033. /**
  9034. * Multiplies the Vector3 coordinates by the float "scale"
  9035. * @param scale defines the multiplier factor
  9036. * @returns the current updated Vector3
  9037. */
  9038. scaleInPlace(scale: number): Vector3;
  9039. /**
  9040. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  9041. * @param scale defines the multiplier factor
  9042. * @returns a new Vector3
  9043. */
  9044. scale(scale: number): Vector3;
  9045. /**
  9046. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates
  9047. * @param scale defines the multiplier factor
  9048. * @param result defines the Vector3 object where to store the result
  9049. * @returns the current Vector3
  9050. */
  9051. scaleToRef(scale: number, result: Vector3): Vector3;
  9052. /**
  9053. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  9054. * @param scale defines the scale factor
  9055. * @param result defines the Vector3 object where to store the result
  9056. * @returns the unmodified current Vector3
  9057. */
  9058. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  9059. /**
  9060. * Returns true if the current Vector3 and the passed vector coordinates are strictly equal
  9061. * @param otherVector defines the second operand
  9062. * @returns true if both vectors are equals
  9063. */
  9064. equals(otherVector: Vector3): boolean;
  9065. /**
  9066. * Returns true if the current Vector3 and the passed vector coordinates are distant less than epsilon
  9067. * @param otherVector defines the second operand
  9068. * @param epsilon defines the minimal distance to define values as equals
  9069. * @returns true if both vectors are distant less than epsilon
  9070. */
  9071. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  9072. /**
  9073. * Returns true if the current Vector3 coordinates equals the passed floats
  9074. * @param x defines the x coordinate of the operand
  9075. * @param y defines the y coordinate of the operand
  9076. * @param z defines the z coordinate of the operand
  9077. * @returns true if both vectors are equals
  9078. */
  9079. equalsToFloats(x: number, y: number, z: number): boolean;
  9080. /**
  9081. * Multiplies the current Vector3 coordinates by the passed ones
  9082. * @param otherVector defines the second operand
  9083. * @returns the current updated Vector3
  9084. */
  9085. multiplyInPlace(otherVector: Vector3): Vector3;
  9086. /**
  9087. * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector
  9088. * @param otherVector defines the second operand
  9089. * @returns the new Vector3
  9090. */
  9091. multiply(otherVector: Vector3): Vector3;
  9092. /**
  9093. * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result"
  9094. * @param otherVector defines the second operand
  9095. * @param result defines the Vector3 object where to store the result
  9096. * @returns the current Vector3
  9097. */
  9098. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  9099. /**
  9100. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the passed floats
  9101. * @param x defines the x coordinate of the operand
  9102. * @param y defines the y coordinate of the operand
  9103. * @param z defines the z coordinate of the operand
  9104. * @returns the new Vector3
  9105. */
  9106. multiplyByFloats(x: number, y: number, z: number): Vector3;
  9107. /**
  9108. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the passed ones
  9109. * @param otherVector defines the second operand
  9110. * @returns the new Vector3
  9111. */
  9112. divide(otherVector: Vector3): Vector3;
  9113. /**
  9114. * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result"
  9115. * @param otherVector defines the second operand
  9116. * @param result defines the Vector3 object where to store the result
  9117. * @returns the current Vector3
  9118. */
  9119. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  9120. /**
  9121. * Divides the current Vector3 coordinates by the passed ones.
  9122. * @param otherVector defines the second operand
  9123. * @returns the current updated Vector3
  9124. */
  9125. divideInPlace(otherVector: Vector3): Vector3;
  9126. /**
  9127. * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones
  9128. * @param other defines the second operand
  9129. * @returns the current updated Vector3
  9130. */
  9131. minimizeInPlace(other: Vector3): Vector3;
  9132. /**
  9133. * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones.
  9134. * @param other defines the second operand
  9135. * @returns the current updated Vector3
  9136. */
  9137. maximizeInPlace(other: Vector3): Vector3;
  9138. /**
  9139. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  9140. */
  9141. readonly isNonUniform: boolean;
  9142. /**
  9143. * Gets the length of the Vector3
  9144. * @returns the length of the Vecto3
  9145. */
  9146. length(): number;
  9147. /**
  9148. * Gets the squared length of the Vector3
  9149. * @returns squared length of the Vector3
  9150. */
  9151. lengthSquared(): number;
  9152. /**
  9153. * Normalize the current Vector3.
  9154. * Please note that this is an in place operation.
  9155. * @returns the current updated Vector3
  9156. */
  9157. normalize(): Vector3;
  9158. /**
  9159. * Normalize the current Vector3 to a new vector
  9160. * @returns the new Vector3
  9161. */
  9162. normalizeToNew(): Vector3;
  9163. /**
  9164. * Normalize the current Vector3 to the reference
  9165. * @param reference define the Vector3 to update
  9166. * @returns the updated Vector3
  9167. */
  9168. normalizeToRef(reference: Vector3): Vector3;
  9169. /**
  9170. * Creates a new Vector3 copied from the current Vector3
  9171. * @returns the new Vector3
  9172. */
  9173. clone(): Vector3;
  9174. /**
  9175. * Copies the passed vector coordinates to the current Vector3 ones
  9176. * @param source defines the source Vector3
  9177. * @returns the current updated Vector3
  9178. */
  9179. copyFrom(source: Vector3): Vector3;
  9180. /**
  9181. * Copies the passed floats to the current Vector3 coordinates
  9182. * @param x defines the x coordinate of the operand
  9183. * @param y defines the y coordinate of the operand
  9184. * @param z defines the z coordinate of the operand
  9185. * @returns the current updated Vector3
  9186. */
  9187. copyFromFloats(x: number, y: number, z: number): Vector3;
  9188. /**
  9189. * Copies the passed floats to the current Vector3 coordinates
  9190. * @param x defines the x coordinate of the operand
  9191. * @param y defines the y coordinate of the operand
  9192. * @param z defines the z coordinate of the operand
  9193. * @returns the current updated Vector3
  9194. */
  9195. set(x: number, y: number, z: number): Vector3;
  9196. /**
  9197. * Get the clip factor between two vectors
  9198. * @param vector0 defines the first operand
  9199. * @param vector1 defines the second operand
  9200. * @param axis defines the axis to use
  9201. * @param size defines the size along the axis
  9202. * @returns the clip factor
  9203. */
  9204. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  9205. /**
  9206. * Get angle between two vectors
  9207. * @param vector0 angle between vector0 and vector1
  9208. * @param vector1 angle between vector0 and vector1
  9209. * @param normal direction of the normal
  9210. * @return the angle between vector0 and vector1
  9211. */
  9212. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  9213. /**
  9214. * Returns a new Vector3 set from the index "offset" of the passed array
  9215. * @param array defines the source array
  9216. * @param offset defines the offset in the source array
  9217. * @returns the new Vector3
  9218. */
  9219. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  9220. /**
  9221. * Returns a new Vector3 set from the index "offset" of the passed Float32Array
  9222. * This function is deprecated. Use FromArray instead
  9223. * @param array defines the source array
  9224. * @param offset defines the offset in the source array
  9225. * @returns the new Vector3
  9226. */
  9227. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  9228. /**
  9229. * Sets the passed vector "result" with the element values from the index "offset" of the passed array
  9230. * @param array defines the source array
  9231. * @param offset defines the offset in the source array
  9232. * @param result defines the Vector3 where to store the result
  9233. */
  9234. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  9235. /**
  9236. * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array
  9237. * This function is deprecated. Use FromArrayToRef instead.
  9238. * @param array defines the source array
  9239. * @param offset defines the offset in the source array
  9240. * @param result defines the Vector3 where to store the result
  9241. */
  9242. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  9243. /**
  9244. * Sets the passed vector "result" with the passed floats.
  9245. * @param x defines the x coordinate of the source
  9246. * @param y defines the y coordinate of the source
  9247. * @param z defines the z coordinate of the source
  9248. * @param result defines the Vector3 where to store the result
  9249. */
  9250. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  9251. /**
  9252. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  9253. * @returns a new empty Vector3
  9254. */
  9255. static Zero(): Vector3;
  9256. /**
  9257. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  9258. * @returns a new unit Vector3
  9259. */
  9260. static One(): Vector3;
  9261. /**
  9262. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  9263. * @returns a new up Vector3
  9264. */
  9265. static Up(): Vector3;
  9266. /**
  9267. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  9268. * @returns a new forward Vector3
  9269. */
  9270. static Forward(): Vector3;
  9271. /**
  9272. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  9273. * @returns a new right Vector3
  9274. */
  9275. static Right(): Vector3;
  9276. /**
  9277. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  9278. * @returns a new left Vector3
  9279. */
  9280. static Left(): Vector3;
  9281. /**
  9282. * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector.
  9283. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  9284. * @param vector defines the Vector3 to transform
  9285. * @param transformation defines the transformation matrix
  9286. * @returns the transformed Vector3
  9287. */
  9288. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  9289. /**
  9290. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector
  9291. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  9292. * @param vector defines the Vector3 to transform
  9293. * @param transformation defines the transformation matrix
  9294. * @param result defines the Vector3 where to store the result
  9295. */
  9296. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  9297. /**
  9298. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z)
  9299. * This method computes tranformed coordinates only, not transformed direction vectors
  9300. * @param x define the x coordinate of the source vector
  9301. * @param y define the y coordinate of the source vector
  9302. * @param z define the z coordinate of the source vector
  9303. * @param transformation defines the transformation matrix
  9304. * @param result defines the Vector3 where to store the result
  9305. */
  9306. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  9307. /**
  9308. * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector
  9309. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  9310. * @param vector defines the Vector3 to transform
  9311. * @param transformation defines the transformation matrix
  9312. * @returns the new Vector3
  9313. */
  9314. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  9315. /**
  9316. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector
  9317. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  9318. * @param vector defines the Vector3 to transform
  9319. * @param transformation defines the transformation matrix
  9320. * @param result defines the Vector3 where to store the result
  9321. */
  9322. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  9323. /**
  9324. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z)
  9325. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  9326. * @param x define the x coordinate of the source vector
  9327. * @param y define the y coordinate of the source vector
  9328. * @param z define the z coordinate of the source vector
  9329. * @param transformation defines the transformation matrix
  9330. * @param result defines the Vector3 where to store the result
  9331. */
  9332. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  9333. /**
  9334. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  9335. * @param value1 defines the first control point
  9336. * @param value2 defines the second control point
  9337. * @param value3 defines the third control point
  9338. * @param value4 defines the fourth control point
  9339. * @param amount defines the amount on the spline to use
  9340. * @returns the new Vector3
  9341. */
  9342. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  9343. /**
  9344. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  9345. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  9346. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  9347. * @param value defines the current value
  9348. * @param min defines the lower range value
  9349. * @param max defines the upper range value
  9350. * @returns the new Vector3
  9351. */
  9352. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  9353. /**
  9354. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  9355. * @param value1 defines the first control point
  9356. * @param tangent1 defines the first tangent vector
  9357. * @param value2 defines the second control point
  9358. * @param tangent2 defines the second tangent vector
  9359. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  9360. * @returns the new Vector3
  9361. */
  9362. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  9363. /**
  9364. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  9365. * @param start defines the start value
  9366. * @param end defines the end value
  9367. * @param amount max defines amount between both (between 0 and 1)
  9368. * @returns the new Vector3
  9369. */
  9370. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  9371. /**
  9372. * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  9373. * @param start defines the start value
  9374. * @param end defines the end value
  9375. * @param amount max defines amount between both (between 0 and 1)
  9376. * @param result defines the Vector3 where to store the result
  9377. */
  9378. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  9379. /**
  9380. * Returns the dot product (float) between the vectors "left" and "right"
  9381. * @param left defines the left operand
  9382. * @param right defines the right operand
  9383. * @returns the dot product
  9384. */
  9385. static Dot(left: Vector3, right: Vector3): number;
  9386. /**
  9387. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  9388. * The cross product is then orthogonal to both "left" and "right"
  9389. * @param left defines the left operand
  9390. * @param right defines the right operand
  9391. * @returns the cross product
  9392. */
  9393. static Cross(left: Vector3, right: Vector3): Vector3;
  9394. /**
  9395. * Sets the passed vector "result" with the cross product of "left" and "right"
  9396. * The cross product is then orthogonal to both "left" and "right"
  9397. * @param left defines the left operand
  9398. * @param right defines the right operand
  9399. * @param result defines the Vector3 where to store the result
  9400. */
  9401. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  9402. /**
  9403. * Returns a new Vector3 as the normalization of the passed vector
  9404. * @param vector defines the Vector3 to normalize
  9405. * @returns the new Vector3
  9406. */
  9407. static Normalize(vector: Vector3): Vector3;
  9408. /**
  9409. * Sets the passed vector "result" with the normalization of the passed first vector
  9410. * @param vector defines the Vector3 to normalize
  9411. * @param result defines the Vector3 where to store the result
  9412. */
  9413. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  9414. private static _viewportMatrixCache;
  9415. /**
  9416. * Project a Vector3 onto screen space
  9417. * @param vector defines the Vector3 to project
  9418. * @param world defines the world matrix to use
  9419. * @param transform defines the transform (view x projection) matrix to use
  9420. * @param viewport defines the screen viewport to use
  9421. * @returns the new Vector3
  9422. */
  9423. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  9424. /**
  9425. * Unproject from screen space to object space
  9426. * @param source defines the screen space Vector3 to use
  9427. * @param viewportWidth defines the current width of the viewport
  9428. * @param viewportHeight defines the current height of the viewport
  9429. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9430. * @param transform defines the transform (view x projection) matrix to use
  9431. * @returns the new Vector3
  9432. */
  9433. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  9434. /**
  9435. * Unproject from screen space to object space
  9436. * @param source defines the screen space Vector3 to use
  9437. * @param viewportWidth defines the current width of the viewport
  9438. * @param viewportHeight defines the current height of the viewport
  9439. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9440. * @param view defines the view matrix to use
  9441. * @param projection defines the projection matrix to use
  9442. * @returns the new Vector3
  9443. */
  9444. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  9445. /**
  9446. * Unproject from screen space to object space
  9447. * @param source defines the screen space Vector3 to use
  9448. * @param viewportWidth defines the current width of the viewport
  9449. * @param viewportHeight defines the current height of the viewport
  9450. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9451. * @param view defines the view matrix to use
  9452. * @param projection defines the projection matrix to use
  9453. * @param result defines the Vector3 where to store the result
  9454. */
  9455. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  9456. /**
  9457. * Unproject from screen space to object space
  9458. * @param sourceX defines the screen space x coordinate to use
  9459. * @param sourceY defines the screen space y coordinate to use
  9460. * @param sourceZ defines the screen space z coordinate to use
  9461. * @param viewportWidth defines the current width of the viewport
  9462. * @param viewportHeight defines the current height of the viewport
  9463. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9464. * @param view defines the view matrix to use
  9465. * @param projection defines the projection matrix to use
  9466. * @param result defines the Vector3 where to store the result
  9467. */
  9468. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  9469. /**
  9470. * Gets the minimal coordinate values between two Vector3
  9471. * @param left defines the first operand
  9472. * @param right defines the second operand
  9473. * @returns the new Vector3
  9474. */
  9475. static Minimize(left: Vector3, right: Vector3): Vector3;
  9476. /**
  9477. * Gets the maximal coordinate values between two Vector3
  9478. * @param left defines the first operand
  9479. * @param right defines the second operand
  9480. * @returns the new Vector3
  9481. */
  9482. static Maximize(left: Vector3, right: Vector3): Vector3;
  9483. /**
  9484. * Returns the distance between the vectors "value1" and "value2"
  9485. * @param value1 defines the first operand
  9486. * @param value2 defines the second operand
  9487. * @returns the distance
  9488. */
  9489. static Distance(value1: Vector3, value2: Vector3): number;
  9490. /**
  9491. * Returns the squared distance between the vectors "value1" and "value2"
  9492. * @param value1 defines the first operand
  9493. * @param value2 defines the second operand
  9494. * @returns the squared distance
  9495. */
  9496. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  9497. /**
  9498. * Returns a new Vector3 located at the center between "value1" and "value2"
  9499. * @param value1 defines the first operand
  9500. * @param value2 defines the second operand
  9501. * @returns the new Vector3
  9502. */
  9503. static Center(value1: Vector3, value2: Vector3): Vector3;
  9504. /**
  9505. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  9506. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  9507. * to something in order to rotate it from its local system to the given target system
  9508. * Note: axis1, axis2 and axis3 are normalized during this operation
  9509. * @param axis1 defines the first axis
  9510. * @param axis2 defines the second axis
  9511. * @param axis3 defines the third axis
  9512. * @returns a new Vector3
  9513. */
  9514. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  9515. /**
  9516. * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3
  9517. * @param axis1 defines the first axis
  9518. * @param axis2 defines the second axis
  9519. * @param axis3 defines the third axis
  9520. * @param ref defines the Vector3 where to store the result
  9521. */
  9522. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  9523. }
  9524. class Vector4 {
  9525. x: number;
  9526. y: number;
  9527. z: number;
  9528. w: number;
  9529. /**
  9530. * Creates a Vector4 object from the passed floats.
  9531. */
  9532. constructor(x: number, y: number, z: number, w: number);
  9533. /**
  9534. * Returns the string with the Vector4 coordinates.
  9535. */
  9536. toString(): string;
  9537. /**
  9538. * Returns the string "Vector4".
  9539. */
  9540. getClassName(): string;
  9541. /**
  9542. * Returns the Vector4 hash code.
  9543. */
  9544. getHashCode(): number;
  9545. /**
  9546. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  9547. */
  9548. asArray(): number[];
  9549. /**
  9550. * Populates the passed array from the passed index with the Vector4 coordinates.
  9551. * Returns the Vector4.
  9552. */
  9553. toArray(array: FloatArray, index?: number): Vector4;
  9554. /**
  9555. * Adds the passed vector to the current Vector4.
  9556. * Returns the updated Vector4.
  9557. */
  9558. addInPlace(otherVector: Vector4): Vector4;
  9559. /**
  9560. * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one.
  9561. */
  9562. add(otherVector: Vector4): Vector4;
  9563. /**
  9564. * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one.
  9565. * Returns the current Vector4.
  9566. */
  9567. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  9568. /**
  9569. * Subtract in place the passed vector from the current Vector4.
  9570. * Returns the updated Vector4.
  9571. */
  9572. subtractInPlace(otherVector: Vector4): Vector4;
  9573. /**
  9574. * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4.
  9575. */
  9576. subtract(otherVector: Vector4): Vector4;
  9577. /**
  9578. * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4.
  9579. * Returns the current Vector4.
  9580. */
  9581. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  9582. /**
  9583. * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  9584. */
  9585. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  9586. /**
  9587. * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  9588. * Returns the current Vector4.
  9589. */
  9590. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  9591. /**
  9592. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  9593. */
  9594. negate(): Vector4;
  9595. /**
  9596. * Multiplies the current Vector4 coordinates by scale (float).
  9597. * Returns the updated Vector4.
  9598. */
  9599. scaleInPlace(scale: number): Vector4;
  9600. /**
  9601. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  9602. */
  9603. scale(scale: number): Vector4;
  9604. /**
  9605. * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float).
  9606. * Returns the current Vector4.
  9607. */
  9608. scaleToRef(scale: number, result: Vector4): Vector4;
  9609. /**
  9610. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  9611. * @param scale defines the scale factor
  9612. * @param result defines the Vector4 object where to store the result
  9613. * @returns the unmodified current Vector4
  9614. */
  9615. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  9616. /**
  9617. * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones.
  9618. */
  9619. equals(otherVector: Vector4): boolean;
  9620. /**
  9621. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones.
  9622. */
  9623. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  9624. /**
  9625. * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates.
  9626. */
  9627. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  9628. /**
  9629. * Multiplies in place the current Vector4 by the passed one.
  9630. * Returns the updated Vector4.
  9631. */
  9632. multiplyInPlace(otherVector: Vector4): Vector4;
  9633. /**
  9634. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one.
  9635. */
  9636. multiply(otherVector: Vector4): Vector4;
  9637. /**
  9638. * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one.
  9639. * Returns the current Vector4.
  9640. */
  9641. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  9642. /**
  9643. * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates.
  9644. */
  9645. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  9646. /**
  9647. * Returns a new Vector4 set with the division result of the current Vector4 by the passed one.
  9648. */
  9649. divide(otherVector: Vector4): Vector4;
  9650. /**
  9651. * Updates the passed vector "result" with the division result of the current Vector4 by the passed one.
  9652. * Returns the current Vector4.
  9653. */
  9654. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  9655. /**
  9656. * Divides the current Vector3 coordinates by the passed ones.
  9657. * @returns the updated Vector3.
  9658. */
  9659. divideInPlace(otherVector: Vector4): Vector4;
  9660. /**
  9661. * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones
  9662. * @param other defines the second operand
  9663. * @returns the current updated Vector4
  9664. */
  9665. minimizeInPlace(other: Vector4): Vector4;
  9666. /**
  9667. * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones
  9668. * @param other defines the second operand
  9669. * @returns the current updated Vector4
  9670. */
  9671. maximizeInPlace(other: Vector4): Vector4;
  9672. /**
  9673. * Returns the Vector4 length (float).
  9674. */
  9675. length(): number;
  9676. /**
  9677. * Returns the Vector4 squared length (float).
  9678. */
  9679. lengthSquared(): number;
  9680. /**
  9681. * Normalizes in place the Vector4.
  9682. * Returns the updated Vector4.
  9683. */
  9684. normalize(): Vector4;
  9685. /**
  9686. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  9687. */
  9688. toVector3(): Vector3;
  9689. /**
  9690. * Returns a new Vector4 copied from the current one.
  9691. */
  9692. clone(): Vector4;
  9693. /**
  9694. * Updates the current Vector4 with the passed one coordinates.
  9695. * Returns the updated Vector4.
  9696. */
  9697. copyFrom(source: Vector4): Vector4;
  9698. /**
  9699. * Updates the current Vector4 coordinates with the passed floats.
  9700. * Returns the updated Vector4.
  9701. */
  9702. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  9703. /**
  9704. * Updates the current Vector4 coordinates with the passed floats.
  9705. * Returns the updated Vector4.
  9706. */
  9707. set(x: number, y: number, z: number, w: number): Vector4;
  9708. /**
  9709. * Returns a new Vector4 set from the starting index of the passed array.
  9710. */
  9711. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  9712. /**
  9713. * Updates the passed vector "result" from the starting index of the passed array.
  9714. */
  9715. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  9716. /**
  9717. * Updates the passed vector "result" from the starting index of the passed Float32Array.
  9718. */
  9719. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  9720. /**
  9721. * Updates the passed vector "result" coordinates from the passed floats.
  9722. */
  9723. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  9724. /**
  9725. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  9726. */
  9727. static Zero(): Vector4;
  9728. /**
  9729. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  9730. */
  9731. static One(): Vector4;
  9732. /**
  9733. * Returns a new normalized Vector4 from the passed one.
  9734. */
  9735. static Normalize(vector: Vector4): Vector4;
  9736. /**
  9737. * Updates the passed vector "result" from the normalization of the passed one.
  9738. */
  9739. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  9740. static Minimize(left: Vector4, right: Vector4): Vector4;
  9741. static Maximize(left: Vector4, right: Vector4): Vector4;
  9742. /**
  9743. * Returns the distance (float) between the vectors "value1" and "value2".
  9744. */
  9745. static Distance(value1: Vector4, value2: Vector4): number;
  9746. /**
  9747. * Returns the squared distance (float) between the vectors "value1" and "value2".
  9748. */
  9749. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  9750. /**
  9751. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  9752. */
  9753. static Center(value1: Vector4, value2: Vector4): Vector4;
  9754. /**
  9755. * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector.
  9756. * This methods computes transformed normalized direction vectors only.
  9757. */
  9758. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  9759. /**
  9760. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector.
  9761. * This methods computes transformed normalized direction vectors only.
  9762. */
  9763. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  9764. /**
  9765. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w).
  9766. * This methods computes transformed normalized direction vectors only.
  9767. */
  9768. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  9769. }
  9770. interface ISize {
  9771. width: number;
  9772. height: number;
  9773. }
  9774. class Size implements ISize {
  9775. width: number;
  9776. height: number;
  9777. /**
  9778. * Creates a Size object from the passed width and height (floats).
  9779. */
  9780. constructor(width: number, height: number);
  9781. toString(): string;
  9782. /**
  9783. * Returns the string "Size"
  9784. */
  9785. getClassName(): string;
  9786. /**
  9787. * Returns the Size hash code.
  9788. */
  9789. getHashCode(): number;
  9790. /**
  9791. * Updates the current size from the passed one.
  9792. * Returns the updated Size.
  9793. */
  9794. copyFrom(src: Size): void;
  9795. /**
  9796. * Updates in place the current Size from the passed floats.
  9797. * Returns the updated Size.
  9798. */
  9799. copyFromFloats(width: number, height: number): Size;
  9800. /**
  9801. * Updates in place the current Size from the passed floats.
  9802. * Returns the updated Size.
  9803. */
  9804. set(width: number, height: number): Size;
  9805. /**
  9806. * Returns a new Size set with the multiplication result of the current Size and the passed floats.
  9807. */
  9808. multiplyByFloats(w: number, h: number): Size;
  9809. /**
  9810. * Returns a new Size copied from the passed one.
  9811. */
  9812. clone(): Size;
  9813. /**
  9814. * Boolean : True if the current Size and the passed one width and height are strictly equal.
  9815. */
  9816. equals(other: Size): boolean;
  9817. /**
  9818. * Returns the surface of the Size : width * height (float).
  9819. */
  9820. readonly surface: number;
  9821. /**
  9822. * Returns a new Size set to (0.0, 0.0)
  9823. */
  9824. static Zero(): Size;
  9825. /**
  9826. * Returns a new Size set as the addition result of the current Size and the passed one.
  9827. */
  9828. add(otherSize: Size): Size;
  9829. /**
  9830. * Returns a new Size set as the subtraction result of the passed one from the current Size.
  9831. */
  9832. subtract(otherSize: Size): Size;
  9833. /**
  9834. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  9835. */
  9836. static Lerp(start: Size, end: Size, amount: number): Size;
  9837. }
  9838. class Quaternion {
  9839. x: number;
  9840. y: number;
  9841. z: number;
  9842. w: number;
  9843. /**
  9844. * Creates a new Quaternion from the passed floats.
  9845. */
  9846. constructor(x?: number, y?: number, z?: number, w?: number);
  9847. /**
  9848. * Returns a string with the Quaternion coordinates.
  9849. */
  9850. toString(): string;
  9851. /**
  9852. * Returns the string "Quaternion".
  9853. */
  9854. getClassName(): string;
  9855. /**
  9856. * Returns the Quaternion hash code.
  9857. */
  9858. getHashCode(): number;
  9859. /**
  9860. * Returns a new array populated with 4 elements : the Quaternion coordinates.
  9861. */
  9862. asArray(): number[];
  9863. /**
  9864. * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal.
  9865. */
  9866. equals(otherQuaternion: Quaternion): boolean;
  9867. /**
  9868. * Returns a new Quaternion copied from the current one.
  9869. */
  9870. clone(): Quaternion;
  9871. /**
  9872. * Updates the current Quaternion from the passed one coordinates.
  9873. * Returns the updated Quaterion.
  9874. */
  9875. copyFrom(other: Quaternion): Quaternion;
  9876. /**
  9877. * Updates the current Quaternion from the passed float coordinates.
  9878. * Returns the updated Quaterion.
  9879. */
  9880. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  9881. /**
  9882. * Updates the current Quaternion from the passed float coordinates.
  9883. * Returns the updated Quaterion.
  9884. */
  9885. set(x: number, y: number, z: number, w: number): Quaternion;
  9886. /**
  9887. * Returns a new Quaternion as the addition result of the passed one and the current Quaternion.
  9888. */
  9889. add(other: Quaternion): Quaternion;
  9890. /**
  9891. * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion.
  9892. */
  9893. subtract(other: Quaternion): Quaternion;
  9894. /**
  9895. * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale".
  9896. */
  9897. scale(value: number): Quaternion;
  9898. /**
  9899. * Scale the current Quaternion values by a factor to a given Quaternion
  9900. * @param scale defines the scale factor
  9901. * @param result defines the Quaternion object where to store the result
  9902. * @returns the unmodified current Quaternion
  9903. */
  9904. scaleToRef(scale: number, result: Quaternion): Quaternion;
  9905. /**
  9906. * Scale the current Quaternion values by a factor and add the result to a given Quaternion
  9907. * @param scale defines the scale factor
  9908. * @param result defines the Quaternion object where to store the result
  9909. * @returns the unmodified current Quaternion
  9910. */
  9911. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  9912. /**
  9913. * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1".
  9914. */
  9915. multiply(q1: Quaternion): Quaternion;
  9916. /**
  9917. * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1".
  9918. * Returns the current Quaternion.
  9919. */
  9920. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  9921. /**
  9922. * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1".
  9923. * Returns the updated Quaternion.
  9924. */
  9925. multiplyInPlace(q1: Quaternion): Quaternion;
  9926. /**
  9927. * Sets the passed "ref" with the conjugation of the current Quaternion.
  9928. * Returns the current Quaternion.
  9929. */
  9930. conjugateToRef(ref: Quaternion): Quaternion;
  9931. /**
  9932. * Conjugates in place the current Quaternion.
  9933. * Returns the updated Quaternion.
  9934. */
  9935. conjugateInPlace(): Quaternion;
  9936. /**
  9937. * Returns a new Quaternion as the conjugate of the current Quaternion.
  9938. */
  9939. conjugate(): Quaternion;
  9940. /**
  9941. * Returns the Quaternion length (float).
  9942. */
  9943. length(): number;
  9944. /**
  9945. * Normalize in place the current Quaternion.
  9946. * Returns the updated Quaternion.
  9947. */
  9948. normalize(): Quaternion;
  9949. /**
  9950. * Returns a new Vector3 set with the Euler angles translated from the current Quaternion
  9951. * @param order is a reserved parameter and is ignore for now
  9952. * @returns the new Vector3
  9953. */
  9954. toEulerAngles(order?: string): Vector3;
  9955. /**
  9956. * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion
  9957. * @param result defines the vector which will be filled with the Euler angles
  9958. * @param order is a reserved parameter and is ignore for now
  9959. * @returns the current Quaternion
  9960. */
  9961. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  9962. /**
  9963. * Updates the passed rotation matrix with the current Quaternion values.
  9964. * Returns the current Quaternion.
  9965. */
  9966. toRotationMatrix(result: Matrix): Quaternion;
  9967. /**
  9968. * Updates the current Quaternion from the passed rotation matrix values.
  9969. * Returns the updated Quaternion.
  9970. */
  9971. fromRotationMatrix(matrix: Matrix): Quaternion;
  9972. /**
  9973. * Returns a new Quaternion set from the passed rotation matrix values.
  9974. */
  9975. static FromRotationMatrix(matrix: Matrix): Quaternion;
  9976. /**
  9977. * Updates the passed quaternion "result" with the passed rotation matrix values.
  9978. */
  9979. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  9980. /**
  9981. * Returns a new Quaternion set to (0.0, 0.0, 0.0).
  9982. */
  9983. static Zero(): Quaternion;
  9984. /**
  9985. * Returns a new Quaternion as the inverted current Quaternion.
  9986. */
  9987. static Inverse(q: Quaternion): Quaternion;
  9988. /**
  9989. * Returns the identity Quaternion.
  9990. */
  9991. static Identity(): Quaternion;
  9992. static IsIdentity(quaternion: Quaternion): boolean;
  9993. /**
  9994. * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float).
  9995. */
  9996. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  9997. /**
  9998. * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float).
  9999. */
  10000. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  10001. /**
  10002. * Retuns a new Quaternion set from the starting index of the passed array.
  10003. */
  10004. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  10005. /**
  10006. * Returns a new Quaternion set from the passed Euler float angles (y, x, z).
  10007. */
  10008. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  10009. /**
  10010. * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z).
  10011. */
  10012. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  10013. /**
  10014. * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation
  10015. */
  10016. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  10017. /**
  10018. * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation
  10019. */
  10020. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  10021. /**
  10022. * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  10023. * cf to Vector3.RotationFromAxis() documentation.
  10024. * Note : axis1, axis2 and axis3 are normalized during this operation.
  10025. */
  10026. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion;
  10027. /**
  10028. * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  10029. * cf to Vector3.RotationFromAxis() documentation.
  10030. * Note : axis1, axis2 and axis3 are normalized during this operation.
  10031. */
  10032. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  10033. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  10034. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  10035. /**
  10036. * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2".
  10037. */
  10038. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  10039. }
  10040. class Matrix {
  10041. private static _tempQuaternion;
  10042. private static _xAxis;
  10043. private static _yAxis;
  10044. private static _zAxis;
  10045. private static _updateFlagSeed;
  10046. private static _identityReadOnly;
  10047. private _isIdentity;
  10048. private _isIdentityDirty;
  10049. updateFlag: number;
  10050. m: Float32Array;
  10051. _markAsUpdated(): void;
  10052. constructor();
  10053. /**
  10054. * Boolean : True is the matrix is the identity matrix
  10055. */
  10056. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  10057. /**
  10058. * Returns the matrix determinant (float).
  10059. */
  10060. determinant(): number;
  10061. /**
  10062. * Returns the matrix underlying array.
  10063. */
  10064. toArray(): Float32Array;
  10065. /**
  10066. * Returns the matrix underlying array.
  10067. */
  10068. asArray(): Float32Array;
  10069. /**
  10070. * Inverts in place the Matrix.
  10071. * Returns the Matrix inverted.
  10072. */
  10073. invert(): Matrix;
  10074. /**
  10075. * Sets all the matrix elements to zero.
  10076. * Returns the Matrix.
  10077. */
  10078. reset(): Matrix;
  10079. /**
  10080. * Returns a new Matrix as the addition result of the current Matrix and the passed one.
  10081. */
  10082. add(other: Matrix): Matrix;
  10083. /**
  10084. * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one.
  10085. * Returns the Matrix.
  10086. */
  10087. addToRef(other: Matrix, result: Matrix): Matrix;
  10088. /**
  10089. * Adds in place the passed matrix to the current Matrix.
  10090. * Returns the updated Matrix.
  10091. */
  10092. addToSelf(other: Matrix): Matrix;
  10093. /**
  10094. * Sets the passed matrix with the current inverted Matrix.
  10095. * Returns the unmodified current Matrix.
  10096. */
  10097. invertToRef(other: Matrix): Matrix;
  10098. /**
  10099. * Inserts the translation vector (using 3 x floats) in the current Matrix.
  10100. * Returns the updated Matrix.
  10101. */
  10102. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  10103. /**
  10104. * Inserts the translation vector in the current Matrix.
  10105. * Returns the updated Matrix.
  10106. */
  10107. setTranslation(vector3: Vector3): Matrix;
  10108. /**
  10109. * Returns a new Vector3 as the extracted translation from the Matrix.
  10110. */
  10111. getTranslation(): Vector3;
  10112. /**
  10113. * Fill a Vector3 with the extracted translation from the Matrix.
  10114. */
  10115. getTranslationToRef(result: Vector3): Matrix;
  10116. /**
  10117. * Remove rotation and scaling part from the Matrix.
  10118. * Returns the updated Matrix.
  10119. */
  10120. removeRotationAndScaling(): Matrix;
  10121. /**
  10122. * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one.
  10123. */
  10124. multiply(other: Matrix): Matrix;
  10125. /**
  10126. * Updates the current Matrix from the passed one values.
  10127. * Returns the updated Matrix.
  10128. */
  10129. copyFrom(other: Matrix): Matrix;
  10130. /**
  10131. * Populates the passed array from the starting index with the Matrix values.
  10132. * Returns the Matrix.
  10133. */
  10134. copyToArray(array: Float32Array, offset?: number): Matrix;
  10135. /**
  10136. * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one.
  10137. */
  10138. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  10139. /**
  10140. * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one.
  10141. */
  10142. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  10143. /**
  10144. * Boolean : True is the current Matrix and the passed one values are strictly equal.
  10145. */
  10146. equals(value: Matrix): boolean;
  10147. /**
  10148. * Returns a new Matrix from the current Matrix.
  10149. */
  10150. clone(): Matrix;
  10151. /**
  10152. * Returns the string "Matrix"
  10153. */
  10154. getClassName(): string;
  10155. /**
  10156. * Returns the Matrix hash code.
  10157. */
  10158. getHashCode(): number;
  10159. /**
  10160. * Decomposes the current Matrix into :
  10161. * - a scale vector3 passed as a reference to update,
  10162. * - a rotation quaternion passed as a reference to update,
  10163. * - a translation vector3 passed as a reference to update.
  10164. * Returns the true if operation was successful.
  10165. */
  10166. decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean;
  10167. /**
  10168. * Returns the index-th row of the current matrix as a new Vector4.
  10169. */
  10170. getRow(index: number): Nullable<Vector4>;
  10171. /**
  10172. * Sets the index-th row of the current matrix with the passed Vector4 values.
  10173. * Returns the updated Matrix.
  10174. */
  10175. setRow(index: number, row: Vector4): Matrix;
  10176. /**
  10177. * Compute the transpose of the matrix.
  10178. * Returns a new Matrix.
  10179. */
  10180. transpose(): Matrix;
  10181. /**
  10182. * Compute the transpose of the matrix.
  10183. * Returns the current matrix.
  10184. */
  10185. transposeToRef(result: Matrix): Matrix;
  10186. /**
  10187. * Sets the index-th row of the current matrix with the passed 4 x float values.
  10188. * Returns the updated Matrix.
  10189. */
  10190. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  10191. /**
  10192. * Compute a new Matrix set with the current Matrix values multiplied by scale (float)
  10193. * @param scale defines the scale factor
  10194. * @returns a new Matrix
  10195. */
  10196. scale(scale: number): Matrix;
  10197. /**
  10198. * Scale the current Matrix values by a factor to a given result Matrix
  10199. * @param scale defines the scale factor
  10200. * @param result defines the Matrix to store the result
  10201. * @returns the current Matrix
  10202. */
  10203. scaleToRef(scale: number, result: Matrix): Matrix;
  10204. /**
  10205. * Scale the current Matrix values by a factor and add the result to a given Matrix
  10206. * @param scale defines the scale factor
  10207. * @param result defines the Matrix to store the result
  10208. * @returns the current Matrix
  10209. */
  10210. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  10211. /**
  10212. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  10213. * @param ref matrix to store the result
  10214. */
  10215. toNormalMatrix(ref: Matrix): void;
  10216. /**
  10217. * Returns a new Matrix as the extracted rotation matrix from the current one.
  10218. */
  10219. getRotationMatrix(): Matrix;
  10220. /**
  10221. * Extracts the rotation matrix from the current one and sets it as the passed "result".
  10222. * Returns the current Matrix.
  10223. */
  10224. getRotationMatrixToRef(result: Matrix): Matrix;
  10225. /**
  10226. * Returns a new Matrix set from the starting index of the passed array.
  10227. */
  10228. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  10229. /**
  10230. * Sets the passed "result" matrix from the starting index of the passed array.
  10231. */
  10232. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  10233. /**
  10234. * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale".
  10235. */
  10236. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  10237. /**
  10238. * Sets the passed matrix "result" with the 16 passed floats.
  10239. */
  10240. 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;
  10241. /**
  10242. * Static identity matrix to be used as readonly matrix
  10243. * Must not be updated.
  10244. */
  10245. static readonly IdentityReadOnly: Matrix;
  10246. /**
  10247. * Returns a new Matrix set from the 16 passed floats.
  10248. */
  10249. 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;
  10250. /**
  10251. * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  10252. */
  10253. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  10254. /**
  10255. * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  10256. */
  10257. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  10258. /**
  10259. * Returns a new indentity Matrix.
  10260. */
  10261. static Identity(): Matrix;
  10262. /**
  10263. * Sets the passed "result" as an identity matrix.
  10264. */
  10265. static IdentityToRef(result: Matrix): void;
  10266. /**
  10267. * Returns a new zero Matrix.
  10268. */
  10269. static Zero(): Matrix;
  10270. /**
  10271. * Returns a new rotation matrix for "angle" radians around the X axis.
  10272. */
  10273. static RotationX(angle: number): Matrix;
  10274. /**
  10275. * Returns a new Matrix as the passed inverted one.
  10276. */
  10277. static Invert(source: Matrix): Matrix;
  10278. /**
  10279. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis.
  10280. */
  10281. static RotationXToRef(angle: number, result: Matrix): void;
  10282. /**
  10283. * Returns a new rotation matrix for "angle" radians around the Y axis.
  10284. */
  10285. static RotationY(angle: number): Matrix;
  10286. /**
  10287. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis.
  10288. */
  10289. static RotationYToRef(angle: number, result: Matrix): void;
  10290. /**
  10291. * Returns a new rotation matrix for "angle" radians around the Z axis.
  10292. */
  10293. static RotationZ(angle: number): Matrix;
  10294. /**
  10295. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis.
  10296. */
  10297. static RotationZToRef(angle: number, result: Matrix): void;
  10298. /**
  10299. * Returns a new rotation matrix for "angle" radians around the passed axis.
  10300. */
  10301. static RotationAxis(axis: Vector3, angle: number): Matrix;
  10302. /**
  10303. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis.
  10304. */
  10305. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  10306. /**
  10307. * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z).
  10308. */
  10309. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  10310. /**
  10311. * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z).
  10312. */
  10313. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  10314. /**
  10315. * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z).
  10316. */
  10317. static Scaling(x: number, y: number, z: number): Matrix;
  10318. /**
  10319. * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z).
  10320. */
  10321. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  10322. /**
  10323. * Returns a new Matrix as a translation matrix from the passed floats (x, y, z).
  10324. */
  10325. static Translation(x: number, y: number, z: number): Matrix;
  10326. /**
  10327. * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z).
  10328. */
  10329. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  10330. /**
  10331. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  10332. * @param startValue defines the start value
  10333. * @param endValue defines the end value
  10334. * @param gradient defines the gradient factor
  10335. * @returns the new matrix
  10336. */
  10337. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  10338. /**
  10339. * Set the passed matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  10340. * @param startValue defines the start value
  10341. * @param endValue defines the end value
  10342. * @param gradient defines the gradient factor
  10343. * @param result defines the Matrix object where to store data
  10344. */
  10345. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  10346. /**
  10347. * Returns a new Matrix whose values are computed by :
  10348. * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices,
  10349. * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end,
  10350. * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices.
  10351. */
  10352. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  10353. /**
  10354. * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  10355. * This methods works for a Left-Handed system.
  10356. */
  10357. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  10358. /**
  10359. * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  10360. * This methods works for a Left-Handed system.
  10361. */
  10362. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  10363. /**
  10364. * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  10365. * This methods works for a Right-Handed system.
  10366. */
  10367. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  10368. /**
  10369. * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  10370. * This methods works for a Left-Handed system.
  10371. */
  10372. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  10373. /**
  10374. * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  10375. */
  10376. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  10377. /**
  10378. * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  10379. */
  10380. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  10381. /**
  10382. * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  10383. */
  10384. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  10385. /**
  10386. * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  10387. */
  10388. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  10389. /**
  10390. * Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  10391. */
  10392. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  10393. /**
  10394. * Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  10395. */
  10396. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  10397. /**
  10398. * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  10399. */
  10400. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  10401. /**
  10402. * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  10403. */
  10404. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  10405. /**
  10406. * Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  10407. */
  10408. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  10409. /**
  10410. * Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  10411. */
  10412. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  10413. /**
  10414. * Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  10415. */
  10416. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  10417. /**
  10418. * Sets the passed matrix "result" as a left-handed perspective projection matrix for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  10419. */
  10420. static PerspectiveFovWebVRToRef(fov: {
  10421. upDegrees: number;
  10422. downDegrees: number;
  10423. leftDegrees: number;
  10424. rightDegrees: number;
  10425. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  10426. /**
  10427. * Returns the final transformation matrix : world * view * projection * viewport
  10428. */
  10429. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  10430. /**
  10431. * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix.
  10432. */
  10433. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  10434. /**
  10435. * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix.
  10436. */
  10437. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  10438. /**
  10439. * Compute the transpose of the passed Matrix.
  10440. * Returns a new Matrix.
  10441. */
  10442. static Transpose(matrix: Matrix): Matrix;
  10443. /**
  10444. * Compute the transpose of the passed Matrix and store it in the result matrix.
  10445. */
  10446. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  10447. /**
  10448. * Returns a new Matrix as the reflection matrix across the passed plane.
  10449. */
  10450. static Reflection(plane: Plane): Matrix;
  10451. /**
  10452. * Sets the passed matrix "result" as the reflection matrix across the passed plane.
  10453. */
  10454. static ReflectionToRef(plane: Plane, result: Matrix): void;
  10455. /**
  10456. * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis.
  10457. */
  10458. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  10459. /**
  10460. * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion.
  10461. */
  10462. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  10463. }
  10464. class Plane {
  10465. normal: Vector3;
  10466. d: number;
  10467. /**
  10468. * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  10469. */
  10470. constructor(a: number, b: number, c: number, d: number);
  10471. /**
  10472. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  10473. */
  10474. asArray(): number[];
  10475. /**
  10476. * Returns a new plane copied from the current Plane.
  10477. */
  10478. clone(): Plane;
  10479. /**
  10480. * Returns the string "Plane".
  10481. */
  10482. getClassName(): string;
  10483. /**
  10484. * Returns the Plane hash code.
  10485. */
  10486. getHashCode(): number;
  10487. /**
  10488. * Normalize the current Plane in place.
  10489. * Returns the updated Plane.
  10490. */
  10491. normalize(): Plane;
  10492. /**
  10493. * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix.
  10494. */
  10495. transform(transformation: Matrix): Plane;
  10496. /**
  10497. * Returns the dot product (float) of the point coordinates and the plane normal.
  10498. */
  10499. dotCoordinate(point: Vector3): number;
  10500. /**
  10501. * Updates the current Plane from the plane defined by the three passed points.
  10502. * Returns the updated Plane.
  10503. */
  10504. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  10505. /**
  10506. * Boolean : True is the vector "direction" is the same side than the plane normal.
  10507. */
  10508. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  10509. /**
  10510. * Returns the signed distance (float) from the passed point to the Plane.
  10511. */
  10512. signedDistanceTo(point: Vector3): number;
  10513. /**
  10514. * Returns a new Plane from the passed array.
  10515. */
  10516. static FromArray(array: ArrayLike<number>): Plane;
  10517. /**
  10518. * Returns a new Plane defined by the three passed points.
  10519. */
  10520. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  10521. /**
  10522. * Returns a new Plane the normal vector to this plane at the passed origin point.
  10523. * Note : the vector "normal" is updated because normalized.
  10524. */
  10525. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  10526. /**
  10527. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point.
  10528. */
  10529. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  10530. }
  10531. class Viewport {
  10532. x: number;
  10533. y: number;
  10534. width: number;
  10535. height: number;
  10536. /**
  10537. * Creates a Viewport object located at (x, y) and sized (width, height).
  10538. */
  10539. constructor(x: number, y: number, width: number, height: number);
  10540. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  10541. /**
  10542. * Returns a new Viewport copied from the current one.
  10543. */
  10544. clone(): Viewport;
  10545. }
  10546. class Frustum {
  10547. /**
  10548. * Returns a new array of 6 Frustum planes computed by the passed transformation matrix.
  10549. */
  10550. static GetPlanes(transform: Matrix): Plane[];
  10551. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10552. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10553. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10554. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10555. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10556. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10557. /**
  10558. * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix.
  10559. */
  10560. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  10561. }
  10562. enum Space {
  10563. LOCAL = 0,
  10564. WORLD = 1,
  10565. BONE = 2,
  10566. }
  10567. class Axis {
  10568. static X: Vector3;
  10569. static Y: Vector3;
  10570. static Z: Vector3;
  10571. }
  10572. class BezierCurve {
  10573. /**
  10574. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats.
  10575. */
  10576. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  10577. }
  10578. enum Orientation {
  10579. CW = 0,
  10580. CCW = 1,
  10581. }
  10582. class Angle {
  10583. private _radians;
  10584. /**
  10585. * Creates an Angle object of "radians" radians (float).
  10586. */
  10587. constructor(radians: number);
  10588. /**
  10589. * Returns the Angle value in degrees (float).
  10590. */
  10591. degrees: () => number;
  10592. /**
  10593. * Returns the Angle value in radians (float).
  10594. */
  10595. radians: () => number;
  10596. /**
  10597. * Returns a new Angle object valued with the angle value in radians between the two passed vectors.
  10598. */
  10599. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  10600. /**
  10601. * Returns a new Angle object from the passed float in radians.
  10602. */
  10603. static FromRadians(radians: number): Angle;
  10604. /**
  10605. * Returns a new Angle object from the passed float in degrees.
  10606. */
  10607. static FromDegrees(degrees: number): Angle;
  10608. }
  10609. class Arc2 {
  10610. startPoint: Vector2;
  10611. midPoint: Vector2;
  10612. endPoint: Vector2;
  10613. centerPoint: Vector2;
  10614. radius: number;
  10615. angle: Angle;
  10616. startAngle: Angle;
  10617. orientation: Orientation;
  10618. /**
  10619. * Creates an Arc object from the three passed points : start, middle and end.
  10620. */
  10621. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  10622. }
  10623. class Path2 {
  10624. private _points;
  10625. private _length;
  10626. closed: boolean;
  10627. /**
  10628. * Creates a Path2 object from the starting 2D coordinates x and y.
  10629. */
  10630. constructor(x: number, y: number);
  10631. /**
  10632. * Adds a new segment until the passed coordinates (x, y) to the current Path2.
  10633. * Returns the updated Path2.
  10634. */
  10635. addLineTo(x: number, y: number): Path2;
  10636. /**
  10637. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  10638. * Returns the updated Path2.
  10639. */
  10640. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  10641. /**
  10642. * Closes the Path2.
  10643. * Returns the Path2.
  10644. */
  10645. close(): Path2;
  10646. /**
  10647. * Returns the Path2 total length (float).
  10648. */
  10649. length(): number;
  10650. /**
  10651. * Returns the Path2 internal array of points.
  10652. */
  10653. getPoints(): Vector2[];
  10654. /**
  10655. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  10656. */
  10657. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  10658. /**
  10659. * Returns a new Path2 starting at the coordinates (x, y).
  10660. */
  10661. static StartingAt(x: number, y: number): Path2;
  10662. }
  10663. class Path3D {
  10664. path: Vector3[];
  10665. private _curve;
  10666. private _distances;
  10667. private _tangents;
  10668. private _normals;
  10669. private _binormals;
  10670. private _raw;
  10671. /**
  10672. * new Path3D(path, normal, raw)
  10673. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  10674. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  10675. * path : an array of Vector3, the curve axis of the Path3D
  10676. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  10677. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  10678. */
  10679. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  10680. /**
  10681. * Returns the Path3D array of successive Vector3 designing its curve.
  10682. */
  10683. getCurve(): Vector3[];
  10684. /**
  10685. * Returns an array populated with tangent vectors on each Path3D curve point.
  10686. */
  10687. getTangents(): Vector3[];
  10688. /**
  10689. * Returns an array populated with normal vectors on each Path3D curve point.
  10690. */
  10691. getNormals(): Vector3[];
  10692. /**
  10693. * Returns an array populated with binormal vectors on each Path3D curve point.
  10694. */
  10695. getBinormals(): Vector3[];
  10696. /**
  10697. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  10698. */
  10699. getDistances(): number[];
  10700. /**
  10701. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  10702. * Returns the same object updated.
  10703. */
  10704. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  10705. private _compute(firstNormal);
  10706. private _getFirstNonNullVector(index);
  10707. private _getLastNonNullVector(index);
  10708. private _normalVector(v0, vt, va);
  10709. }
  10710. class Curve3 {
  10711. private _points;
  10712. private _length;
  10713. /**
  10714. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  10715. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  10716. * @param v1 (Vector3) the control point
  10717. * @param v2 (Vector3) the end point of the Quadratic Bezier
  10718. * @param nbPoints (integer) the wanted number of points in the curve
  10719. */
  10720. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  10721. /**
  10722. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  10723. * @param v0 (Vector3) the origin point of the Cubic Bezier
  10724. * @param v1 (Vector3) the first control point
  10725. * @param v2 (Vector3) the second control point
  10726. * @param v3 (Vector3) the end point of the Cubic Bezier
  10727. * @param nbPoints (integer) the wanted number of points in the curve
  10728. */
  10729. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  10730. /**
  10731. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  10732. * @param p1 (Vector3) the origin point of the Hermite Spline
  10733. * @param t1 (Vector3) the tangent vector at the origin point
  10734. * @param p2 (Vector3) the end point of the Hermite Spline
  10735. * @param t2 (Vector3) the tangent vector at the end point
  10736. * @param nbPoints (integer) the wanted number of points in the curve
  10737. */
  10738. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  10739. /**
  10740. * Returns a Curve3 object along a CatmullRom Spline curve :
  10741. * @param points (array of Vector3) the points the spline must pass through. At least, four points required.
  10742. * @param nbPoints (integer) the wanted number of points between each curve control points.
  10743. */
  10744. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3;
  10745. /**
  10746. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  10747. * A Curve3 is designed from a series of successive Vector3.
  10748. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  10749. */
  10750. constructor(points: Vector3[]);
  10751. /**
  10752. * Returns the Curve3 stored array of successive Vector3
  10753. */
  10754. getPoints(): Vector3[];
  10755. /**
  10756. * Returns the computed length (float) of the curve.
  10757. */
  10758. length(): number;
  10759. /**
  10760. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  10761. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  10762. * curveA and curveB keep unchanged.
  10763. */
  10764. continue(curve: Curve3): Curve3;
  10765. private _computeLength(path);
  10766. }
  10767. class PositionNormalVertex {
  10768. position: Vector3;
  10769. normal: Vector3;
  10770. constructor(position?: Vector3, normal?: Vector3);
  10771. clone(): PositionNormalVertex;
  10772. }
  10773. class PositionNormalTextureVertex {
  10774. position: Vector3;
  10775. normal: Vector3;
  10776. uv: Vector2;
  10777. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  10778. clone(): PositionNormalTextureVertex;
  10779. }
  10780. class Tmp {
  10781. static Color3: Color3[];
  10782. static Vector2: Vector2[];
  10783. static Vector3: Vector3[];
  10784. static Vector4: Vector4[];
  10785. static Quaternion: Quaternion[];
  10786. static Matrix: Matrix[];
  10787. }
  10788. }
  10789. declare module BABYLON {
  10790. class SphericalPolynomial {
  10791. x: Vector3;
  10792. y: Vector3;
  10793. z: Vector3;
  10794. xx: Vector3;
  10795. yy: Vector3;
  10796. zz: Vector3;
  10797. xy: Vector3;
  10798. yz: Vector3;
  10799. zx: Vector3;
  10800. addAmbient(color: Color3): void;
  10801. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  10802. scale(scale: number): void;
  10803. }
  10804. class SphericalHarmonics {
  10805. L00: Vector3;
  10806. L1_1: Vector3;
  10807. L10: Vector3;
  10808. L11: Vector3;
  10809. L2_2: Vector3;
  10810. L2_1: Vector3;
  10811. L20: Vector3;
  10812. L21: Vector3;
  10813. L22: Vector3;
  10814. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  10815. scale(scale: number): void;
  10816. convertIncidentRadianceToIrradiance(): void;
  10817. convertIrradianceToLambertianRadiance(): void;
  10818. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  10819. }
  10820. }
  10821. declare module BABYLON {
  10822. /**
  10823. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  10824. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  10825. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  10826. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  10827. */
  10828. class ColorCurves {
  10829. private _dirty;
  10830. private _tempColor;
  10831. private _globalCurve;
  10832. private _highlightsCurve;
  10833. private _midtonesCurve;
  10834. private _shadowsCurve;
  10835. private _positiveCurve;
  10836. private _negativeCurve;
  10837. private _globalHue;
  10838. private _globalDensity;
  10839. private _globalSaturation;
  10840. private _globalExposure;
  10841. /**
  10842. * Gets the global Hue value.
  10843. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  10844. */
  10845. /**
  10846. * Sets the global Hue value.
  10847. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  10848. */
  10849. globalHue: number;
  10850. /**
  10851. * Gets the global Density value.
  10852. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  10853. * Values less than zero provide a filter of opposite hue.
  10854. */
  10855. /**
  10856. * Sets the global Density value.
  10857. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  10858. * Values less than zero provide a filter of opposite hue.
  10859. */
  10860. globalDensity: number;
  10861. /**
  10862. * Gets the global Saturation value.
  10863. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  10864. */
  10865. /**
  10866. * Sets the global Saturation value.
  10867. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  10868. */
  10869. globalSaturation: number;
  10870. private _highlightsHue;
  10871. private _highlightsDensity;
  10872. private _highlightsSaturation;
  10873. private _highlightsExposure;
  10874. /**
  10875. * Gets the highlights Hue value.
  10876. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  10877. */
  10878. /**
  10879. * Sets the highlights Hue value.
  10880. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  10881. */
  10882. highlightsHue: number;
  10883. /**
  10884. * Gets the highlights Density value.
  10885. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  10886. * Values less than zero provide a filter of opposite hue.
  10887. */
  10888. /**
  10889. * Sets the highlights Density value.
  10890. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  10891. * Values less than zero provide a filter of opposite hue.
  10892. */
  10893. highlightsDensity: number;
  10894. /**
  10895. * Gets the highlights Saturation value.
  10896. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  10897. */
  10898. /**
  10899. * Sets the highlights Saturation value.
  10900. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  10901. */
  10902. highlightsSaturation: number;
  10903. /**
  10904. * Gets the highlights Exposure value.
  10905. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  10906. */
  10907. /**
  10908. * Sets the highlights Exposure value.
  10909. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  10910. */
  10911. highlightsExposure: number;
  10912. private _midtonesHue;
  10913. private _midtonesDensity;
  10914. private _midtonesSaturation;
  10915. private _midtonesExposure;
  10916. /**
  10917. * Gets the midtones Hue value.
  10918. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  10919. */
  10920. /**
  10921. * Sets the midtones Hue value.
  10922. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  10923. */
  10924. midtonesHue: number;
  10925. /**
  10926. * Gets the midtones Density value.
  10927. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  10928. * Values less than zero provide a filter of opposite hue.
  10929. */
  10930. /**
  10931. * Sets the midtones Density value.
  10932. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  10933. * Values less than zero provide a filter of opposite hue.
  10934. */
  10935. midtonesDensity: number;
  10936. /**
  10937. * Gets the midtones Saturation value.
  10938. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  10939. */
  10940. /**
  10941. * Sets the midtones Saturation value.
  10942. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  10943. */
  10944. midtonesSaturation: number;
  10945. /**
  10946. * Gets the midtones Exposure value.
  10947. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  10948. */
  10949. /**
  10950. * Sets the midtones Exposure value.
  10951. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  10952. */
  10953. midtonesExposure: number;
  10954. private _shadowsHue;
  10955. private _shadowsDensity;
  10956. private _shadowsSaturation;
  10957. private _shadowsExposure;
  10958. /**
  10959. * Gets the shadows Hue value.
  10960. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  10961. */
  10962. /**
  10963. * Sets the shadows Hue value.
  10964. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  10965. */
  10966. shadowsHue: number;
  10967. /**
  10968. * Gets the shadows Density value.
  10969. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  10970. * Values less than zero provide a filter of opposite hue.
  10971. */
  10972. /**
  10973. * Sets the shadows Density value.
  10974. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  10975. * Values less than zero provide a filter of opposite hue.
  10976. */
  10977. shadowsDensity: number;
  10978. /**
  10979. * Gets the shadows Saturation value.
  10980. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  10981. */
  10982. /**
  10983. * Sets the shadows Saturation value.
  10984. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  10985. */
  10986. shadowsSaturation: number;
  10987. /**
  10988. * Gets the shadows Exposure value.
  10989. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  10990. */
  10991. /**
  10992. * Sets the shadows Exposure value.
  10993. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  10994. */
  10995. shadowsExposure: number;
  10996. getClassName(): string;
  10997. /**
  10998. * Binds the color curves to the shader.
  10999. * @param colorCurves The color curve to bind
  11000. * @param effect The effect to bind to
  11001. */
  11002. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11003. /**
  11004. * Prepare the list of uniforms associated with the ColorCurves effects.
  11005. * @param uniformsList The list of uniforms used in the effect
  11006. */
  11007. static PrepareUniforms(uniformsList: string[]): void;
  11008. /**
  11009. * Returns color grading data based on a hue, density, saturation and exposure value.
  11010. * @param filterHue The hue of the color filter.
  11011. * @param filterDensity The density of the color filter.
  11012. * @param saturation The saturation.
  11013. * @param exposure The exposure.
  11014. * @param result The result data container.
  11015. */
  11016. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  11017. /**
  11018. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11019. * @param value The input slider value in range [-100,100].
  11020. * @returns Adjusted value.
  11021. */
  11022. private static applyColorGradingSliderNonlinear(value);
  11023. /**
  11024. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11025. * @param hue The hue (H) input.
  11026. * @param saturation The saturation (S) input.
  11027. * @param brightness The brightness (B) input.
  11028. * @result An RGBA color represented as Vector4.
  11029. */
  11030. private static fromHSBToRef(hue, saturation, brightness, result);
  11031. /**
  11032. * Returns a value clamped between min and max
  11033. * @param value The value to clamp
  11034. * @param min The minimum of value
  11035. * @param max The maximum of value
  11036. * @returns The clamped value.
  11037. */
  11038. private static clamp(value, min, max);
  11039. /**
  11040. * Clones the current color curve instance.
  11041. * @return The cloned curves
  11042. */
  11043. clone(): ColorCurves;
  11044. /**
  11045. * Serializes the current color curve instance to a json representation.
  11046. * @return a JSON representation
  11047. */
  11048. serialize(): any;
  11049. /**
  11050. * Parses the color curve from a json representation.
  11051. * @param source the JSON source to parse
  11052. * @return The parsed curves
  11053. */
  11054. static Parse(source: any): ColorCurves;
  11055. }
  11056. }
  11057. declare module BABYLON {
  11058. /**
  11059. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  11060. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  11061. */
  11062. class EffectFallbacks {
  11063. private _defines;
  11064. private _currentRank;
  11065. private _maxRank;
  11066. private _mesh;
  11067. /**
  11068. * Removes the fallback from the bound mesh.
  11069. */
  11070. unBindMesh(): void;
  11071. /**
  11072. * Adds a fallback on the specified property.
  11073. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  11074. * @param define The name of the define in the shader
  11075. */
  11076. addFallback(rank: number, define: string): void;
  11077. /**
  11078. * Sets the mesh to use CPU skinning when needing to fallback.
  11079. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  11080. * @param mesh The mesh to use the fallbacks.
  11081. */
  11082. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  11083. /**
  11084. * Checks to see if more fallbacks are still availible.
  11085. */
  11086. readonly isMoreFallbacks: boolean;
  11087. /**
  11088. * Removes the defines that shoould be removed when falling back.
  11089. * @param currentDefines defines the current define statements for the shader.
  11090. * @param effect defines the current effect we try to compile
  11091. * @returns The resulting defines with defines of the current rank removed.
  11092. */
  11093. reduce(currentDefines: string, effect: Effect): string;
  11094. }
  11095. /**
  11096. * Options to be used when creating an effect.
  11097. */
  11098. class EffectCreationOptions {
  11099. /**
  11100. * Atrributes that will be used in the shader.
  11101. */
  11102. attributes: string[];
  11103. /**
  11104. * Uniform varible names that will be set in the shader.
  11105. */
  11106. uniformsNames: string[];
  11107. /**
  11108. * Uniform buffer varible names that will be set in the shader.
  11109. */
  11110. uniformBuffersNames: string[];
  11111. /**
  11112. * Sampler texture variable names that will be set in the shader.
  11113. */
  11114. samplers: string[];
  11115. /**
  11116. * Define statements that will be set in the shader.
  11117. */
  11118. defines: any;
  11119. /**
  11120. * Possible fallbacks for this effect to improve performance when needed.
  11121. */
  11122. fallbacks: Nullable<EffectFallbacks>;
  11123. /**
  11124. * Callback that will be called when the shader is compiled.
  11125. */
  11126. onCompiled: Nullable<(effect: Effect) => void>;
  11127. /**
  11128. * Callback that will be called if an error occurs during shader compilation.
  11129. */
  11130. onError: Nullable<(effect: Effect, errors: string) => void>;
  11131. /**
  11132. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  11133. */
  11134. indexParameters: any;
  11135. /**
  11136. * Max number of lights that can be used in the shader.
  11137. */
  11138. maxSimultaneousLights: number;
  11139. /**
  11140. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  11141. */
  11142. transformFeedbackVaryings: Nullable<string[]>;
  11143. }
  11144. /**
  11145. * Effect containing vertex and fragment shader that can be executed on an object.
  11146. */
  11147. class Effect {
  11148. /**
  11149. * Name of the effect.
  11150. */
  11151. name: any;
  11152. /**
  11153. * String container all the define statements that should be set on the shader.
  11154. */
  11155. defines: string;
  11156. /**
  11157. * Callback that will be called when the shader is compiled.
  11158. */
  11159. onCompiled: Nullable<(effect: Effect) => void>;
  11160. /**
  11161. * Callback that will be called if an error occurs during shader compilation.
  11162. */
  11163. onError: Nullable<(effect: Effect, errors: string) => void>;
  11164. /**
  11165. * Callback that will be called when effect is bound.
  11166. */
  11167. onBind: Nullable<(effect: Effect) => void>;
  11168. /**
  11169. * Unique ID of the effect.
  11170. */
  11171. uniqueId: number;
  11172. /**
  11173. * Observable that will be called when the shader is compiled.
  11174. */
  11175. onCompileObservable: Observable<Effect>;
  11176. /**
  11177. * Observable that will be called if an error occurs during shader compilation.
  11178. */
  11179. onErrorObservable: Observable<Effect>;
  11180. /**
  11181. * Observable that will be called when effect is bound.
  11182. */
  11183. onBindObservable: Observable<Effect>;
  11184. private static _uniqueIdSeed;
  11185. private _engine;
  11186. private _uniformBuffersNames;
  11187. private _uniformsNames;
  11188. private _samplers;
  11189. private _isReady;
  11190. private _compilationError;
  11191. private _attributesNames;
  11192. private _attributes;
  11193. private _uniforms;
  11194. /**
  11195. * Key for the effect.
  11196. */
  11197. _key: string;
  11198. private _indexParameters;
  11199. private _fallbacks;
  11200. private _vertexSourceCode;
  11201. private _fragmentSourceCode;
  11202. private _vertexSourceCodeOverride;
  11203. private _fragmentSourceCodeOverride;
  11204. private _transformFeedbackVaryings;
  11205. /**
  11206. * Compiled shader to webGL program.
  11207. */
  11208. _program: WebGLProgram;
  11209. private _valueCache;
  11210. private static _baseCache;
  11211. /**
  11212. * Instantiates an effect.
  11213. * An effect can be used to create/manage/execute vertex and fragment shaders.
  11214. * @param baseName Name of the effect.
  11215. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  11216. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  11217. * @param samplers List of sampler variables that will be passed to the shader.
  11218. * @param engine Engine to be used to render the effect
  11219. * @param defines Define statements to be added to the shader.
  11220. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  11221. * @param onCompiled Callback that will be called when the shader is compiled.
  11222. * @param onError Callback that will be called if an error occurs during shader compilation.
  11223. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  11224. */
  11225. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  11226. private static _sourceCache;
  11227. private _getSourceCacheKey(baseName);
  11228. private _getFromCache(baseName);
  11229. private _setInCache(baseName);
  11230. /**
  11231. * Unique key for this effect
  11232. */
  11233. readonly key: string;
  11234. /**
  11235. * If the effect has been compiled and prepared.
  11236. * @returns if the effect is compiled and prepared.
  11237. */
  11238. isReady(): boolean;
  11239. /**
  11240. * The engine the effect was initialized with.
  11241. * @returns the engine.
  11242. */
  11243. getEngine(): Engine;
  11244. /**
  11245. * The compiled webGL program for the effect
  11246. * @returns the webGL program.
  11247. */
  11248. getProgram(): WebGLProgram;
  11249. /**
  11250. * The set of names of attribute variables for the shader.
  11251. * @returns An array of attribute names.
  11252. */
  11253. getAttributesNames(): string[];
  11254. /**
  11255. * Returns the attribute at the given index.
  11256. * @param index The index of the attribute.
  11257. * @returns The location of the attribute.
  11258. */
  11259. getAttributeLocation(index: number): number;
  11260. /**
  11261. * Returns the attribute based on the name of the variable.
  11262. * @param name of the attribute to look up.
  11263. * @returns the attribute location.
  11264. */
  11265. getAttributeLocationByName(name: string): number;
  11266. /**
  11267. * The number of attributes.
  11268. * @returns the numnber of attributes.
  11269. */
  11270. getAttributesCount(): number;
  11271. /**
  11272. * Gets the index of a uniform variable.
  11273. * @param uniformName of the uniform to look up.
  11274. * @returns the index.
  11275. */
  11276. getUniformIndex(uniformName: string): number;
  11277. /**
  11278. * Returns the attribute based on the name of the variable.
  11279. * @param uniformName of the uniform to look up.
  11280. * @returns the location of the uniform.
  11281. */
  11282. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  11283. /**
  11284. * Returns an array of sampler variable names
  11285. * @returns The array of sampler variable neames.
  11286. */
  11287. getSamplers(): string[];
  11288. /**
  11289. * The error from the last compilation.
  11290. * @returns the error string.
  11291. */
  11292. getCompilationError(): string;
  11293. /**
  11294. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  11295. * @param func The callback to be used.
  11296. */
  11297. executeWhenCompiled(func: (effect: Effect) => void): void;
  11298. /** @ignore */
  11299. _loadVertexShaderAsync(vertex: any): Promise<any>;
  11300. /** @ignore */
  11301. _loadFragmentShaderAsync(fragment: any): Promise<any>;
  11302. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  11303. private _processShaderConversion(sourceCode, isFragment);
  11304. private _processIncludesAsync(sourceCode);
  11305. private _processPrecision(source);
  11306. /**
  11307. * Recompiles the webGL program
  11308. * @param vertexSourceCode The source code for the vertex shader.
  11309. * @param fragmentSourceCode The source code for the fragment shader.
  11310. * @param onCompiled Callback called when completed.
  11311. * @param onError Callback called on error.
  11312. */
  11313. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  11314. /**
  11315. * Gets the uniform locations of the the specified variable names
  11316. * @param names THe names of the variables to lookup.
  11317. * @returns Array of locations in the same order as variable names.
  11318. */
  11319. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  11320. /**
  11321. * Prepares the effect
  11322. */
  11323. _prepareEffect(): void;
  11324. /**
  11325. * Checks if the effect is supported. (Must be called after compilation)
  11326. */
  11327. readonly isSupported: boolean;
  11328. /**
  11329. * Binds a texture to the engine to be used as output of the shader.
  11330. * @param channel Name of the output variable.
  11331. * @param texture Texture to bind.
  11332. */
  11333. _bindTexture(channel: string, texture: InternalTexture): void;
  11334. /**
  11335. * Sets a texture on the engine to be used in the shader.
  11336. * @param channel Name of the sampler variable.
  11337. * @param texture Texture to set.
  11338. */
  11339. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  11340. /**
  11341. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  11342. * @param channel Name of the sampler variable.
  11343. * @param texture Texture to set.
  11344. */
  11345. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  11346. /**
  11347. * Sets an array of textures on the engine to be used in the shader.
  11348. * @param channel Name of the variable.
  11349. * @param textures Textures to set.
  11350. */
  11351. setTextureArray(channel: string, textures: BaseTexture[]): void;
  11352. /**
  11353. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  11354. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  11355. * @param channel Name of the sampler variable.
  11356. * @param postProcess Post process to get the input texture from.
  11357. */
  11358. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  11359. /**
  11360. * Sets the output texture of the passed in post process to be input of this effect.
  11361. * @param channel Name of the sampler variable.
  11362. * @param postProcess Post process to get the output texture from.
  11363. */
  11364. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  11365. /** @ignore */
  11366. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  11367. /** @ignore */
  11368. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  11369. /** @ignore */
  11370. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  11371. /** @ignore */
  11372. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  11373. /**
  11374. * Binds a buffer to a uniform.
  11375. * @param buffer Buffer to bind.
  11376. * @param name Name of the uniform variable to bind to.
  11377. */
  11378. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  11379. /**
  11380. * Binds block to a uniform.
  11381. * @param blockName Name of the block to bind.
  11382. * @param index Index to bind.
  11383. */
  11384. bindUniformBlock(blockName: string, index: number): void;
  11385. /**
  11386. * Sets an interger value on a uniform variable.
  11387. * @param uniformName Name of the variable.
  11388. * @param value Value to be set.
  11389. * @returns this effect.
  11390. */
  11391. setInt(uniformName: string, value: number): Effect;
  11392. /**
  11393. * Sets an int array on a uniform variable.
  11394. * @param uniformName Name of the variable.
  11395. * @param array array to be set.
  11396. * @returns this effect.
  11397. */
  11398. setIntArray(uniformName: string, array: Int32Array): Effect;
  11399. /**
  11400. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  11401. * @param uniformName Name of the variable.
  11402. * @param array array to be set.
  11403. * @returns this effect.
  11404. */
  11405. setIntArray2(uniformName: string, array: Int32Array): Effect;
  11406. /**
  11407. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  11408. * @param uniformName Name of the variable.
  11409. * @param array array to be set.
  11410. * @returns this effect.
  11411. */
  11412. setIntArray3(uniformName: string, array: Int32Array): Effect;
  11413. /**
  11414. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  11415. * @param uniformName Name of the variable.
  11416. * @param array array to be set.
  11417. * @returns this effect.
  11418. */
  11419. setIntArray4(uniformName: string, array: Int32Array): Effect;
  11420. /**
  11421. * Sets an float array on a uniform variable.
  11422. * @param uniformName Name of the variable.
  11423. * @param array array to be set.
  11424. * @returns this effect.
  11425. */
  11426. setFloatArray(uniformName: string, array: Float32Array): Effect;
  11427. /**
  11428. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  11429. * @param uniformName Name of the variable.
  11430. * @param array array to be set.
  11431. * @returns this effect.
  11432. */
  11433. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  11434. /**
  11435. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  11436. * @param uniformName Name of the variable.
  11437. * @param array array to be set.
  11438. * @returns this effect.
  11439. */
  11440. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  11441. /**
  11442. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  11443. * @param uniformName Name of the variable.
  11444. * @param array array to be set.
  11445. * @returns this effect.
  11446. */
  11447. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  11448. /**
  11449. * Sets an array on a uniform variable.
  11450. * @param uniformName Name of the variable.
  11451. * @param array array to be set.
  11452. * @returns this effect.
  11453. */
  11454. setArray(uniformName: string, array: number[]): Effect;
  11455. /**
  11456. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  11457. * @param uniformName Name of the variable.
  11458. * @param array array to be set.
  11459. * @returns this effect.
  11460. */
  11461. setArray2(uniformName: string, array: number[]): Effect;
  11462. /**
  11463. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  11464. * @param uniformName Name of the variable.
  11465. * @param array array to be set.
  11466. * @returns this effect.
  11467. */
  11468. setArray3(uniformName: string, array: number[]): Effect;
  11469. /**
  11470. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  11471. * @param uniformName Name of the variable.
  11472. * @param array array to be set.
  11473. * @returns this effect.
  11474. */
  11475. setArray4(uniformName: string, array: number[]): Effect;
  11476. /**
  11477. * Sets matrices on a uniform variable.
  11478. * @param uniformName Name of the variable.
  11479. * @param matrices matrices to be set.
  11480. * @returns this effect.
  11481. */
  11482. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  11483. /**
  11484. * Sets matrix on a uniform variable.
  11485. * @param uniformName Name of the variable.
  11486. * @param matrix matrix to be set.
  11487. * @returns this effect.
  11488. */
  11489. setMatrix(uniformName: string, matrix: Matrix): Effect;
  11490. /**
  11491. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  11492. * @param uniformName Name of the variable.
  11493. * @param matrix matrix to be set.
  11494. * @returns this effect.
  11495. */
  11496. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  11497. /**
  11498. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  11499. * @param uniformName Name of the variable.
  11500. * @param matrix matrix to be set.
  11501. * @returns this effect.
  11502. */
  11503. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  11504. /**
  11505. * Sets a float on a uniform variable.
  11506. * @param uniformName Name of the variable.
  11507. * @param value value to be set.
  11508. * @returns this effect.
  11509. */
  11510. setFloat(uniformName: string, value: number): Effect;
  11511. /**
  11512. * Sets a boolean on a uniform variable.
  11513. * @param uniformName Name of the variable.
  11514. * @param bool value to be set.
  11515. * @returns this effect.
  11516. */
  11517. setBool(uniformName: string, bool: boolean): Effect;
  11518. /**
  11519. * Sets a Vector2 on a uniform variable.
  11520. * @param uniformName Name of the variable.
  11521. * @param vector2 vector2 to be set.
  11522. * @returns this effect.
  11523. */
  11524. setVector2(uniformName: string, vector2: Vector2): Effect;
  11525. /**
  11526. * Sets a float2 on a uniform variable.
  11527. * @param uniformName Name of the variable.
  11528. * @param x First float in float2.
  11529. * @param y Second float in float2.
  11530. * @returns this effect.
  11531. */
  11532. setFloat2(uniformName: string, x: number, y: number): Effect;
  11533. /**
  11534. * Sets a Vector3 on a uniform variable.
  11535. * @param uniformName Name of the variable.
  11536. * @param vector3 Value to be set.
  11537. * @returns this effect.
  11538. */
  11539. setVector3(uniformName: string, vector3: Vector3): Effect;
  11540. /**
  11541. * Sets a float3 on a uniform variable.
  11542. * @param uniformName Name of the variable.
  11543. * @param x First float in float3.
  11544. * @param y Second float in float3.
  11545. * @param z Third float in float3.
  11546. * @returns this effect.
  11547. */
  11548. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  11549. /**
  11550. * Sets a Vector4 on a uniform variable.
  11551. * @param uniformName Name of the variable.
  11552. * @param vector4 Value to be set.
  11553. * @returns this effect.
  11554. */
  11555. setVector4(uniformName: string, vector4: Vector4): Effect;
  11556. /**
  11557. * Sets a float4 on a uniform variable.
  11558. * @param uniformName Name of the variable.
  11559. * @param x First float in float4.
  11560. * @param y Second float in float4.
  11561. * @param z Third float in float4.
  11562. * @param w Fourth float in float4.
  11563. * @returns this effect.
  11564. */
  11565. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  11566. /**
  11567. * Sets a Color3 on a uniform variable.
  11568. * @param uniformName Name of the variable.
  11569. * @param color3 Value to be set.
  11570. * @returns this effect.
  11571. */
  11572. setColor3(uniformName: string, color3: Color3): Effect;
  11573. /**
  11574. * Sets a Color4 on a uniform variable.
  11575. * @param uniformName Name of the variable.
  11576. * @param color3 Value to be set.
  11577. * @param alpha Alpha value to be set.
  11578. * @returns this effect.
  11579. */
  11580. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  11581. /**
  11582. * Sets a Color4 on a uniform variable
  11583. * @param uniformName defines the name of the variable
  11584. * @param color4 defines the value to be set
  11585. * @returns this effect.
  11586. */
  11587. setDirectColor4(uniformName: string, color4: Color4): Effect;
  11588. /**
  11589. * Store of each shader (The can be looked up using effect.key)
  11590. */
  11591. static ShadersStore: {
  11592. [key: string]: string;
  11593. };
  11594. /**
  11595. * Store of each included file for a shader (The can be looked up using effect.key)
  11596. */
  11597. static IncludesShadersStore: {
  11598. [key: string]: string;
  11599. };
  11600. /**
  11601. * Resets the cache of effects.
  11602. */
  11603. static ResetCache(): void;
  11604. }
  11605. }
  11606. declare module BABYLON {
  11607. class FresnelParameters {
  11608. private _isEnabled;
  11609. isEnabled: boolean;
  11610. leftColor: Color3;
  11611. rightColor: Color3;
  11612. bias: number;
  11613. power: number;
  11614. clone(): FresnelParameters;
  11615. serialize(): any;
  11616. static Parse(parsedFresnelParameters: any): FresnelParameters;
  11617. }
  11618. }
  11619. declare module BABYLON {
  11620. /**
  11621. * Interface to follow in your material defines to integrate easily the
  11622. * Image proccessing functions.
  11623. * @ignore
  11624. */
  11625. interface IImageProcessingConfigurationDefines {
  11626. IMAGEPROCESSING: boolean;
  11627. VIGNETTE: boolean;
  11628. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11629. VIGNETTEBLENDMODEOPAQUE: boolean;
  11630. TONEMAPPING: boolean;
  11631. CONTRAST: boolean;
  11632. EXPOSURE: boolean;
  11633. COLORCURVES: boolean;
  11634. COLORGRADING: boolean;
  11635. COLORGRADING3D: boolean;
  11636. SAMPLER3DGREENDEPTH: boolean;
  11637. SAMPLER3DBGRMAP: boolean;
  11638. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11639. /**
  11640. * If the grain should be performed in the image processing shader.
  11641. */
  11642. GRAIN: boolean;
  11643. }
  11644. /**
  11645. * This groups together the common properties used for image processing either in direct forward pass
  11646. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11647. * or not.
  11648. */
  11649. class ImageProcessingConfiguration {
  11650. /**
  11651. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11652. */
  11653. colorCurves: Nullable<ColorCurves>;
  11654. private _colorCurvesEnabled;
  11655. /**
  11656. * Gets wether the color curves effect is enabled.
  11657. */
  11658. /**
  11659. * Sets wether the color curves effect is enabled.
  11660. */
  11661. colorCurvesEnabled: boolean;
  11662. /**
  11663. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11664. */
  11665. colorGradingTexture: Nullable<BaseTexture>;
  11666. private _colorGradingEnabled;
  11667. /**
  11668. * Gets wether the color grading effect is enabled.
  11669. */
  11670. /**
  11671. * Sets wether the color grading effect is enabled.
  11672. */
  11673. colorGradingEnabled: boolean;
  11674. private _colorGradingWithGreenDepth;
  11675. /**
  11676. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11677. */
  11678. /**
  11679. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11680. */
  11681. colorGradingWithGreenDepth: boolean;
  11682. private _colorGradingBGR;
  11683. /**
  11684. * Gets wether the color grading texture contains BGR values.
  11685. */
  11686. /**
  11687. * Sets wether the color grading texture contains BGR values.
  11688. */
  11689. colorGradingBGR: boolean;
  11690. _exposure: number;
  11691. /**
  11692. * Gets the Exposure used in the effect.
  11693. */
  11694. /**
  11695. * Sets the Exposure used in the effect.
  11696. */
  11697. exposure: number;
  11698. private _toneMappingEnabled;
  11699. /**
  11700. * Gets wether the tone mapping effect is enabled.
  11701. */
  11702. /**
  11703. * Sets wether the tone mapping effect is enabled.
  11704. */
  11705. toneMappingEnabled: boolean;
  11706. protected _contrast: number;
  11707. /**
  11708. * Gets the contrast used in the effect.
  11709. */
  11710. /**
  11711. * Sets the contrast used in the effect.
  11712. */
  11713. contrast: number;
  11714. /**
  11715. * Vignette stretch size.
  11716. */
  11717. vignetteStretch: number;
  11718. /**
  11719. * Vignette centre X Offset.
  11720. */
  11721. vignetteCentreX: number;
  11722. /**
  11723. * Vignette centre Y Offset.
  11724. */
  11725. vignetteCentreY: number;
  11726. /**
  11727. * Vignette weight or intensity of the vignette effect.
  11728. */
  11729. vignetteWeight: number;
  11730. /**
  11731. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11732. * if vignetteEnabled is set to true.
  11733. */
  11734. vignetteColor: Color4;
  11735. /**
  11736. * Camera field of view used by the Vignette effect.
  11737. */
  11738. vignetteCameraFov: number;
  11739. private _grainEnabled;
  11740. /**
  11741. * If the grain effect should be enabled.
  11742. */
  11743. grainEnabled: boolean;
  11744. private _grainIntensity;
  11745. /**
  11746. * Amount of grain to be applied by the grain effect.
  11747. */
  11748. grainIntensity: number;
  11749. private _grainAnimated;
  11750. /**
  11751. * If the grain effect should be animated.
  11752. */
  11753. grainAnimated: boolean;
  11754. private _vignetteBlendMode;
  11755. /**
  11756. * Gets the vignette blend mode allowing different kind of effect.
  11757. */
  11758. /**
  11759. * Sets the vignette blend mode allowing different kind of effect.
  11760. */
  11761. vignetteBlendMode: number;
  11762. private _vignetteEnabled;
  11763. /**
  11764. * Gets wether the vignette effect is enabled.
  11765. */
  11766. /**
  11767. * Sets wether the vignette effect is enabled.
  11768. */
  11769. vignetteEnabled: boolean;
  11770. private _applyByPostProcess;
  11771. /**
  11772. * Gets wether the image processing is applied through a post process or not.
  11773. */
  11774. /**
  11775. * Sets wether the image processing is applied through a post process or not.
  11776. */
  11777. applyByPostProcess: boolean;
  11778. private _isEnabled;
  11779. /**
  11780. * Gets wether the image processing is enabled or not.
  11781. */
  11782. /**
  11783. * Sets wether the image processing is enabled or not.
  11784. */
  11785. isEnabled: boolean;
  11786. /**
  11787. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11788. * @type {BABYLON.Observable}
  11789. */
  11790. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11791. /**
  11792. * Method called each time the image processing information changes requires to recompile the effect.
  11793. */
  11794. protected _updateParameters(): void;
  11795. getClassName(): string;
  11796. /**
  11797. * Prepare the list of uniforms associated with the Image Processing effects.
  11798. * @param uniformsList The list of uniforms used in the effect
  11799. * @param defines the list of defines currently in use
  11800. */
  11801. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11802. /**
  11803. * Prepare the list of samplers associated with the Image Processing effects.
  11804. * @param uniformsList The list of uniforms used in the effect
  11805. * @param defines the list of defines currently in use
  11806. */
  11807. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11808. /**
  11809. * Prepare the list of defines associated to the shader.
  11810. * @param defines the list of defines to complete
  11811. */
  11812. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11813. /**
  11814. * Returns true if all the image processing information are ready.
  11815. */
  11816. isReady(): boolean;
  11817. /**
  11818. * Binds the image processing to the shader.
  11819. * @param effect The effect to bind to
  11820. */
  11821. bind(effect: Effect, aspectRatio?: number): void;
  11822. /**
  11823. * Clones the current image processing instance.
  11824. * @return The cloned image processing
  11825. */
  11826. clone(): ImageProcessingConfiguration;
  11827. /**
  11828. * Serializes the current image processing instance to a json representation.
  11829. * @return a JSON representation
  11830. */
  11831. serialize(): any;
  11832. /**
  11833. * Parses the image processing from a json representation.
  11834. * @param source the JSON source to parse
  11835. * @return The parsed image processing
  11836. */
  11837. static Parse(source: any): ImageProcessingConfiguration;
  11838. private static _VIGNETTEMODE_MULTIPLY;
  11839. private static _VIGNETTEMODE_OPAQUE;
  11840. /**
  11841. * Used to apply the vignette as a mix with the pixel color.
  11842. */
  11843. static readonly VIGNETTEMODE_MULTIPLY: number;
  11844. /**
  11845. * Used to apply the vignette as a replacement of the pixel color.
  11846. */
  11847. static readonly VIGNETTEMODE_OPAQUE: number;
  11848. }
  11849. }
  11850. declare module BABYLON {
  11851. /**
  11852. * Manages the defines for the Material.
  11853. */
  11854. class MaterialDefines {
  11855. private _keys;
  11856. private _isDirty;
  11857. _renderId: number;
  11858. _areLightsDirty: boolean;
  11859. _areAttributesDirty: boolean;
  11860. _areTexturesDirty: boolean;
  11861. _areFresnelDirty: boolean;
  11862. _areMiscDirty: boolean;
  11863. _areImageProcessingDirty: boolean;
  11864. _normals: boolean;
  11865. _uvs: boolean;
  11866. _needNormals: boolean;
  11867. _needUVs: boolean;
  11868. /**
  11869. * Specifies if the material needs to be re-calculated.
  11870. */
  11871. readonly isDirty: boolean;
  11872. /**
  11873. * Marks the material to indicate that it has been re-calculated.
  11874. */
  11875. markAsProcessed(): void;
  11876. /**
  11877. * Marks the material to indicate that it needs to be re-calculated.
  11878. */
  11879. markAsUnprocessed(): void;
  11880. /**
  11881. * Marks the material to indicate all of its defines need to be re-calculated.
  11882. */
  11883. markAllAsDirty(): void;
  11884. /**
  11885. * Marks the material to indicate that image processing needs to be re-calculated.
  11886. */
  11887. markAsImageProcessingDirty(): void;
  11888. /**
  11889. * Marks the material to indicate the lights need to be re-calculated.
  11890. */
  11891. markAsLightDirty(): void;
  11892. /**
  11893. * Marks the attribute state as changed.
  11894. */
  11895. markAsAttributesDirty(): void;
  11896. /**
  11897. * Marks the texture state as changed.
  11898. */
  11899. markAsTexturesDirty(): void;
  11900. /**
  11901. * Marks the fresnel state as changed.
  11902. */
  11903. markAsFresnelDirty(): void;
  11904. /**
  11905. * Marks the misc state as changed.
  11906. */
  11907. markAsMiscDirty(): void;
  11908. /**
  11909. * Rebuilds the material defines.
  11910. */
  11911. rebuild(): void;
  11912. /**
  11913. * Specifies if two material defines are equal.
  11914. * @param other - A material define instance to compare to.
  11915. * @returns - Boolean indicating if the material defines are equal (true) or not (false).
  11916. */
  11917. isEqual(other: MaterialDefines): boolean;
  11918. /**
  11919. * Clones this instance's defines to another instance.
  11920. * @param other - material defines to clone values to.
  11921. */
  11922. cloneTo(other: MaterialDefines): void;
  11923. /**
  11924. * Resets the material define values.
  11925. */
  11926. reset(): void;
  11927. /**
  11928. * Converts the material define values to a string.
  11929. * @returns - String of material define information.
  11930. */
  11931. toString(): string;
  11932. }
  11933. /**
  11934. * This offers the main features of a material in BJS.
  11935. */
  11936. class Material implements IAnimatable {
  11937. private static _TriangleFillMode;
  11938. private static _WireFrameFillMode;
  11939. private static _PointFillMode;
  11940. private static _PointListDrawMode;
  11941. private static _LineListDrawMode;
  11942. private static _LineLoopDrawMode;
  11943. private static _LineStripDrawMode;
  11944. private static _TriangleStripDrawMode;
  11945. private static _TriangleFanDrawMode;
  11946. /**
  11947. * Returns the triangle fill mode.
  11948. */
  11949. static readonly TriangleFillMode: number;
  11950. /**
  11951. * Returns the wireframe mode.
  11952. */
  11953. static readonly WireFrameFillMode: number;
  11954. /**
  11955. * Returns the point fill mode.
  11956. */
  11957. static readonly PointFillMode: number;
  11958. /**
  11959. * Returns the point list draw mode.
  11960. */
  11961. static readonly PointListDrawMode: number;
  11962. /**
  11963. * Returns the line list draw mode.
  11964. */
  11965. static readonly LineListDrawMode: number;
  11966. /**
  11967. * Returns the line loop draw mode.
  11968. */
  11969. static readonly LineLoopDrawMode: number;
  11970. /**
  11971. * Returns the line strip draw mode.
  11972. */
  11973. static readonly LineStripDrawMode: number;
  11974. /**
  11975. * Returns the triangle strip draw mode.
  11976. */
  11977. static readonly TriangleStripDrawMode: number;
  11978. /**
  11979. * Returns the triangle fan draw mode.
  11980. */
  11981. static readonly TriangleFanDrawMode: number;
  11982. /**
  11983. * Stores the clock-wise side orientation.
  11984. */
  11985. private static _ClockWiseSideOrientation;
  11986. /**
  11987. * Stores the counter clock-wise side orientation.
  11988. */
  11989. private static _CounterClockWiseSideOrientation;
  11990. /**
  11991. * Returns the clock-wise side orientation.
  11992. */
  11993. static readonly ClockWiseSideOrientation: number;
  11994. /**
  11995. * Returns the counter clock-wise side orientation.
  11996. */
  11997. static readonly CounterClockWiseSideOrientation: number;
  11998. /**
  11999. * The dirty texture flag value.
  12000. */
  12001. private static _TextureDirtyFlag;
  12002. /**
  12003. * The dirty light flag value.
  12004. */
  12005. private static _LightDirtyFlag;
  12006. /**
  12007. * The dirty fresnel flag value.
  12008. */
  12009. private static _FresnelDirtyFlag;
  12010. /**
  12011. * The dirty attribute flag value.
  12012. */
  12013. private static _AttributesDirtyFlag;
  12014. /**
  12015. * The dirty misc flag value.
  12016. */
  12017. private static _MiscDirtyFlag;
  12018. /**
  12019. * Returns the dirty texture flag value.
  12020. */
  12021. static readonly TextureDirtyFlag: number;
  12022. /**
  12023. * Returns the dirty light flag value.
  12024. */
  12025. static readonly LightDirtyFlag: number;
  12026. /**
  12027. * Returns the dirty fresnel flag value.
  12028. */
  12029. static readonly FresnelDirtyFlag: number;
  12030. /**
  12031. * Returns the dirty attributes flag value.
  12032. */
  12033. static readonly AttributesDirtyFlag: number;
  12034. /**
  12035. * Returns the dirty misc flag value.
  12036. */
  12037. static readonly MiscDirtyFlag: number;
  12038. /**
  12039. * The ID of the material.
  12040. */
  12041. id: string;
  12042. /**
  12043. * The name of the material.
  12044. */
  12045. name: string;
  12046. /**
  12047. * Specifies if the ready state should be checked on each call.
  12048. */
  12049. checkReadyOnEveryCall: boolean;
  12050. /**
  12051. * Specifies if the ready state should be checked once.
  12052. */
  12053. checkReadyOnlyOnce: boolean;
  12054. /**
  12055. * The state of the material.
  12056. */
  12057. state: string;
  12058. /**
  12059. * The alpha value of the material.
  12060. */
  12061. protected _alpha: number;
  12062. /**
  12063. * Gets the alpha value of the material.
  12064. */
  12065. /**
  12066. * Sets the alpha value of the material.
  12067. */
  12068. alpha: number;
  12069. /**
  12070. * Specifies if back face culling is enabled.
  12071. */
  12072. protected _backFaceCulling: boolean;
  12073. /**
  12074. * Gets the back-face culling state.
  12075. */
  12076. /**
  12077. * Sets the back-face culling state.
  12078. */
  12079. backFaceCulling: boolean;
  12080. /**
  12081. * Stores the value for side orientation.
  12082. */
  12083. sideOrientation: number;
  12084. /**
  12085. * Callback triggered when the material is compiled.
  12086. */
  12087. onCompiled: (effect: Effect) => void;
  12088. /**
  12089. * Callback triggered when an error occurs.
  12090. */
  12091. onError: (effect: Effect, errors: string) => void;
  12092. /**
  12093. * Callback triggered to get the render target textures.
  12094. */
  12095. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  12096. /**
  12097. * Specifies if the material should be serialized.
  12098. */
  12099. doNotSerialize: boolean;
  12100. /**
  12101. * Specifies if the effect should be stored on sub meshes.
  12102. */
  12103. storeEffectOnSubMeshes: boolean;
  12104. /**
  12105. * Stores the animations for the material.
  12106. */
  12107. animations: Array<Animation>;
  12108. /**
  12109. * An event triggered when the material is disposed.
  12110. * @type {BABYLON.Observable}
  12111. */
  12112. onDisposeObservable: Observable<Material>;
  12113. /**
  12114. * An observer which watches for dispose events.
  12115. * @type {BABYLON.Observer}
  12116. */
  12117. private _onDisposeObserver;
  12118. /**
  12119. * Called during a dispose event.
  12120. */
  12121. onDispose: () => void;
  12122. /**
  12123. * An event triggered when the material is bound.
  12124. * @type {BABYLON.Observable}
  12125. */
  12126. onBindObservable: Observable<AbstractMesh>;
  12127. /**
  12128. * An observer which watches for bind events.
  12129. * @type {BABYLON.Observer}
  12130. */
  12131. private _onBindObserver;
  12132. /**
  12133. * Called during a bind event.
  12134. */
  12135. onBind: (Mesh: AbstractMesh) => void;
  12136. /**
  12137. * An event triggered when the material is unbound.
  12138. * @type {BABYLON.Observable}
  12139. */
  12140. onUnBindObservable: Observable<Material>;
  12141. /**
  12142. * Stores the value of the alpha mode.
  12143. */
  12144. private _alphaMode;
  12145. /**
  12146. * Gets the value of the alpha mode.
  12147. */
  12148. /**
  12149. * Sets the value of the alpha mode.
  12150. */
  12151. alphaMode: number;
  12152. /**
  12153. * Stores the state of the need depth pre-pass value.
  12154. */
  12155. private _needDepthPrePass;
  12156. /**
  12157. * Gets the depth pre-pass value.
  12158. */
  12159. /**
  12160. * Sets the need depth pre-pass value.
  12161. */
  12162. needDepthPrePass: boolean;
  12163. /**
  12164. * Specifies if depth writing should be disabled.
  12165. */
  12166. disableDepthWrite: boolean;
  12167. /**
  12168. * Specifies if depth writing should be forced.
  12169. */
  12170. forceDepthWrite: boolean;
  12171. /**
  12172. * Specifies if there should be a separate pass for culling.
  12173. */
  12174. separateCullingPass: boolean;
  12175. /**
  12176. * Stores the state specifing if fog should be enabled.
  12177. */
  12178. private _fogEnabled;
  12179. /**
  12180. * Gets the value of the fog enabled state.
  12181. */
  12182. /**
  12183. * Sets the state for enabling fog.
  12184. */
  12185. fogEnabled: boolean;
  12186. /**
  12187. * Stores the size of points.
  12188. */
  12189. pointSize: number;
  12190. /**
  12191. * Stores the z offset value.
  12192. */
  12193. zOffset: number;
  12194. /**
  12195. * Gets a value specifying if wireframe mode is enabled.
  12196. */
  12197. /**
  12198. * Sets the state of wireframe mode.
  12199. */
  12200. wireframe: boolean;
  12201. /**
  12202. * Gets the value specifying if point clouds are enabled.
  12203. */
  12204. /**
  12205. * Sets the state of point cloud mode.
  12206. */
  12207. pointsCloud: boolean;
  12208. /**
  12209. * Gets the material fill mode.
  12210. */
  12211. /**
  12212. * Sets the material fill mode.
  12213. */
  12214. fillMode: number;
  12215. /**
  12216. * Stores the effects for the material.
  12217. */
  12218. _effect: Nullable<Effect>;
  12219. /**
  12220. * Specifies if the material was previously ready.
  12221. */
  12222. _wasPreviouslyReady: boolean;
  12223. /**
  12224. * Specifies if uniform buffers should be used.
  12225. */
  12226. private _useUBO;
  12227. /**
  12228. * Stores a reference to the scene.
  12229. */
  12230. private _scene;
  12231. /**
  12232. * Stores the fill mode state.
  12233. */
  12234. private _fillMode;
  12235. /**
  12236. * Specifies if the depth write state should be cached.
  12237. */
  12238. private _cachedDepthWriteState;
  12239. /**
  12240. * Stores the uniform buffer.
  12241. */
  12242. protected _uniformBuffer: UniformBuffer;
  12243. /**
  12244. * Creates a material instance.
  12245. * @param name - The name of the material.
  12246. * @param scene - The BJS scene to reference.
  12247. * @param doNotAdd - Specifies if the material should be added to the scene.
  12248. */
  12249. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  12250. /**
  12251. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  12252. * subclasses should override adding information pertainent to themselves.
  12253. * @returns - String with material information.
  12254. */
  12255. toString(fullDetails?: boolean): string;
  12256. /**
  12257. * Gets the class name of the material.
  12258. * @returns - String with the class name of the material.
  12259. */
  12260. getClassName(): string;
  12261. /**
  12262. * Specifies if updates for the material been locked.
  12263. */
  12264. readonly isFrozen: boolean;
  12265. /**
  12266. * Locks updates for the material.
  12267. */
  12268. freeze(): void;
  12269. /**
  12270. * Unlocks updates for the material.
  12271. */
  12272. unfreeze(): void;
  12273. /**
  12274. * Specifies if the material is ready to be used.
  12275. * @param mesh - BJS mesh.
  12276. * @param useInstances - Specifies if instances should be used.
  12277. * @returns - Boolean indicating if the material is ready to be used.
  12278. */
  12279. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12280. /**
  12281. * Specifies that the submesh is ready to be used.
  12282. * @param mesh - BJS mesh.
  12283. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  12284. * @param useInstances - Specifies that instances should be used.
  12285. * @returns - boolean indicating that the submesh is ready or not.
  12286. */
  12287. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12288. /**
  12289. * Returns the material effect.
  12290. * @returns - Nullable material effect.
  12291. */
  12292. getEffect(): Nullable<Effect>;
  12293. /**
  12294. * Returns the BJS scene.
  12295. * @returns - BJS Scene.
  12296. */
  12297. getScene(): Scene;
  12298. /**
  12299. * Specifies if the material will require alpha blending
  12300. * @returns - Boolean specifying if alpha blending is needed.
  12301. */
  12302. needAlphaBlending(): boolean;
  12303. /**
  12304. * Specifies if the mesh will require alpha blending.
  12305. * @param mesh - BJS mesh.
  12306. * @returns - Boolean specifying if alpha blending is needed for the mesh.
  12307. */
  12308. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  12309. /**
  12310. * Specifies if this material should be rendered in alpha test mode.
  12311. * @returns - Boolean specifying if an alpha test is needed.
  12312. */
  12313. needAlphaTesting(): boolean;
  12314. /**
  12315. * Gets the texture used for the alpha test.
  12316. * @returns - Nullable alpha test texture.
  12317. */
  12318. getAlphaTestTexture(): Nullable<BaseTexture>;
  12319. /**
  12320. * Marks the material to indicate that it needs to be re-calculated.
  12321. */
  12322. markDirty(): void;
  12323. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  12324. /**
  12325. * Binds the material to the mesh.
  12326. * @param world - World transformation matrix.
  12327. * @param mesh - Mesh to bind the material to.
  12328. */
  12329. bind(world: Matrix, mesh?: Mesh): void;
  12330. /**
  12331. * Binds the submesh to the material.
  12332. * @param world - World transformation matrix.
  12333. * @param mesh - Mesh containing the submesh.
  12334. * @param subMesh - Submesh to bind the material to.
  12335. */
  12336. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  12337. /**
  12338. * Binds the world matrix to the material.
  12339. * @param world - World transformation matrix.
  12340. */
  12341. bindOnlyWorldMatrix(world: Matrix): void;
  12342. /**
  12343. * Binds the scene's uniform buffer to the effect.
  12344. * @param effect - Effect to bind to the scene uniform buffer.
  12345. * @param sceneUbo - Scene uniform buffer.
  12346. */
  12347. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  12348. /**
  12349. * Binds the view matrix to the effect.
  12350. * @param effect - Effect to bind the view matrix to.
  12351. */
  12352. bindView(effect: Effect): void;
  12353. /**
  12354. * Binds the view projection matrix to the effect.
  12355. * @param effect - Effect to bind the view projection matrix to.
  12356. */
  12357. bindViewProjection(effect: Effect): void;
  12358. /**
  12359. * Specifies if material alpha testing should be turned on for the mesh.
  12360. * @param mesh - BJS mesh.
  12361. */
  12362. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  12363. /**
  12364. * Processes to execute after binding the material to a mesh.
  12365. * @param mesh - BJS mesh.
  12366. */
  12367. protected _afterBind(mesh?: Mesh): void;
  12368. /**
  12369. * Unbinds the material from the mesh.
  12370. */
  12371. unbind(): void;
  12372. /**
  12373. * Gets the active textures from the material.
  12374. * @returns - Array of textures.
  12375. */
  12376. getActiveTextures(): BaseTexture[];
  12377. /**
  12378. * Specifies if the material uses a texture.
  12379. * @param texture - Texture to check against the material.
  12380. * @returns - Boolean specifying if the material uses the texture.
  12381. */
  12382. hasTexture(texture: BaseTexture): boolean;
  12383. /**
  12384. * Makes a duplicate of the material, and gives it a new name.
  12385. * @param name - Name to call the duplicated material.
  12386. * @returns - Nullable cloned material
  12387. */
  12388. clone(name: string): Nullable<Material>;
  12389. /**
  12390. * Gets the meshes bound to the material.
  12391. * @returns - Array of meshes bound to the material.
  12392. */
  12393. getBindedMeshes(): AbstractMesh[];
  12394. /**
  12395. * Force shader compilation
  12396. * @param mesh - BJS mesh.
  12397. * @param onCompiled - function to execute once the material is compiled.
  12398. * @param options - options to pass to this function.
  12399. */
  12400. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  12401. clipPlane: boolean;
  12402. }>): void;
  12403. /**
  12404. * Force shader compilation.
  12405. * @param mesh The mesh that will use this material
  12406. * @param options Additional options for compiling the shaders
  12407. * @returns A promise that resolves when the compilation completes
  12408. */
  12409. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  12410. clipPlane: boolean;
  12411. }>): Promise<void>;
  12412. /**
  12413. * Marks a define in the material to indicate that it needs to be re-computed.
  12414. * @param flag - Material define flag.
  12415. */
  12416. markAsDirty(flag: number): void;
  12417. /**
  12418. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated.
  12419. * @param func - function which checks material defines against the submeshes.
  12420. */
  12421. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  12422. /**
  12423. * Indicates that image processing needs to be re-calculated for all submeshes.
  12424. */
  12425. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  12426. /**
  12427. * Indicates that textures need to be re-calculated for all submeshes.
  12428. */
  12429. protected _markAllSubMeshesAsTexturesDirty(): void;
  12430. /**
  12431. * Indicates that fresnel needs to be re-calculated for all submeshes.
  12432. */
  12433. protected _markAllSubMeshesAsFresnelDirty(): void;
  12434. /**
  12435. * Indicates that fresnel and misc need to be re-calculated for all submeshes.
  12436. */
  12437. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  12438. /**
  12439. * Indicates that lights need to be re-calculated for all submeshes.
  12440. */
  12441. protected _markAllSubMeshesAsLightsDirty(): void;
  12442. /**
  12443. * Indicates that attributes need to be re-calculated for all submeshes.
  12444. */
  12445. protected _markAllSubMeshesAsAttributesDirty(): void;
  12446. /**
  12447. * Indicates that misc needs to be re-calculated for all submeshes.
  12448. */
  12449. protected _markAllSubMeshesAsMiscDirty(): void;
  12450. /**
  12451. * Indicates that textures and misc need to be re-calculated for all submeshes.
  12452. */
  12453. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  12454. /**
  12455. * Disposes the material.
  12456. * @param forceDisposeEffect - Specifies if effects should be force disposed.
  12457. * @param forceDisposeTextures - Specifies if textures should be force disposed.
  12458. */
  12459. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  12460. /**
  12461. * Serializes this material.
  12462. * @returns - serialized material object.
  12463. */
  12464. serialize(): any;
  12465. /**
  12466. * Creates a MultiMaterial from parse MultiMaterial data.
  12467. * @param parsedMultiMaterial - Parsed MultiMaterial data.
  12468. * @param scene - BJS scene.
  12469. * @returns - MultiMaterial.
  12470. */
  12471. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  12472. /**
  12473. * Creates a material from parsed material data.
  12474. * @param parsedMaterial - Parsed material data.
  12475. * @param scene - BJS scene.
  12476. * @param rootUrl - Root URL containing the material information.
  12477. * @returns - Parsed material.
  12478. */
  12479. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  12480. }
  12481. }
  12482. declare module BABYLON {
  12483. /**
  12484. * "Static Class" containing the most commonly used helper while dealing with material for
  12485. * rendering purpose.
  12486. *
  12487. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  12488. *
  12489. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12490. */
  12491. class MaterialHelper {
  12492. /**
  12493. * Bind the current view position to an effect.
  12494. * @param effect The effect to be bound
  12495. * @param scene The scene the eyes position is used from
  12496. */
  12497. static BindEyePosition(effect: Effect, scene: Scene): void;
  12498. /**
  12499. * Helps preparing the defines values about the UVs in used in the effect.
  12500. * UVs are shared as much as we can accross chanels in the shaders.
  12501. * @param texture The texture we are preparing the UVs for
  12502. * @param defines The defines to update
  12503. * @param key The chanel key "diffuse", "specular"... used in the shader
  12504. */
  12505. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  12506. /**
  12507. * Binds a texture matrix value to its corrsponding uniform
  12508. * @param texture The texture to bind the matrix for
  12509. * @param uniformBuffer The uniform buffer receivin the data
  12510. * @param key The chanel key "diffuse", "specular"... used in the shader
  12511. */
  12512. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  12513. /**
  12514. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  12515. * @param mesh defines the current mesh
  12516. * @param scene defines the current scene
  12517. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  12518. * @param pointsCloud defines if point cloud rendering has to be turned on
  12519. * @param fogEnabled defines if fog has to be turned on
  12520. * @param alphaTest defines if alpha testing has to be turned on
  12521. * @param defines defines the current list of defines
  12522. */
  12523. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  12524. /**
  12525. * Helper used to prepare the list of defines associated with frame values for shader compilation
  12526. * @param scene defines the current scene
  12527. * @param engine defines the current engine
  12528. * @param defines specifies the list of active defines
  12529. * @param useInstances defines if instances have to be turned on
  12530. * @param useClipPlane defines if clip plane have to be turned on
  12531. */
  12532. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  12533. /**
  12534. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  12535. * @param mesh The mesh containing the geometry data we will draw
  12536. * @param defines The defines to update
  12537. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  12538. * @param useBones Precise whether bones should be used or not (override mesh info)
  12539. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  12540. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  12541. * @returns false if defines are considered not dirty and have not been checked
  12542. */
  12543. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  12544. /**
  12545. * Prepares the defines related to the light information passed in parameter
  12546. * @param scene The scene we are intending to draw
  12547. * @param mesh The mesh the effect is compiling for
  12548. * @param defines The defines to update
  12549. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  12550. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  12551. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  12552. * @returns true if normals will be required for the rest of the effect
  12553. */
  12554. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  12555. /**
  12556. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  12557. * that won t be acctive due to defines being turned off.
  12558. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  12559. * @param samplersList The samplers list
  12560. * @param defines The defines helping in the list generation
  12561. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  12562. */
  12563. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  12564. /**
  12565. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  12566. * @param defines The defines to update while falling back
  12567. * @param fallbacks The authorized effect fallbacks
  12568. * @param maxSimultaneousLights The maximum number of lights allowed
  12569. * @param rank the current rank of the Effect
  12570. * @returns The newly affected rank
  12571. */
  12572. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  12573. /**
  12574. * Prepares the list of attributes required for morph targets according to the effect defines.
  12575. * @param attribs The current list of supported attribs
  12576. * @param mesh The mesh to prepare the morph targets attributes for
  12577. * @param defines The current Defines of the effect
  12578. */
  12579. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  12580. /**
  12581. * Prepares the list of attributes required for bones according to the effect defines.
  12582. * @param attribs The current list of supported attribs
  12583. * @param mesh The mesh to prepare the bones attributes for
  12584. * @param defines The current Defines of the effect
  12585. * @param fallbacks The current efffect fallback strategy
  12586. */
  12587. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  12588. /**
  12589. * Prepares the list of attributes required for instances according to the effect defines.
  12590. * @param attribs The current list of supported attribs
  12591. * @param defines The current Defines of the effect
  12592. */
  12593. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  12594. /**
  12595. * Binds the light shadow information to the effect for the given mesh.
  12596. * @param light The light containing the generator
  12597. * @param scene The scene the lights belongs to
  12598. * @param mesh The mesh we are binding the information to render
  12599. * @param lightIndex The light index in the effect used to render the mesh
  12600. * @param effect The effect we are binding the data to
  12601. */
  12602. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  12603. /**
  12604. * Binds the light information to the effect.
  12605. * @param light The light containing the generator
  12606. * @param effect The effect we are binding the data to
  12607. * @param lightIndex The light index in the effect used to render
  12608. */
  12609. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  12610. /**
  12611. * Binds the lights information from the scene to the effect for the given mesh.
  12612. * @param scene The scene the lights belongs to
  12613. * @param mesh The mesh we are binding the information to render
  12614. * @param effect The effect we are binding the data to
  12615. * @param defines The generated defines for the effect
  12616. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  12617. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  12618. */
  12619. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  12620. /**
  12621. * Binds the fog information from the scene to the effect for the given mesh.
  12622. * @param scene The scene the lights belongs to
  12623. * @param mesh The mesh we are binding the information to render
  12624. * @param effect The effect we are binding the data to
  12625. */
  12626. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  12627. /**
  12628. * Binds the bones information from the mesh to the effect.
  12629. * @param mesh The mesh we are binding the information to render
  12630. * @param effect The effect we are binding the data to
  12631. */
  12632. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  12633. /**
  12634. * Binds the morph targets information from the mesh to the effect.
  12635. * @param abstractMesh The mesh we are binding the information to render
  12636. * @param effect The effect we are binding the data to
  12637. */
  12638. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  12639. /**
  12640. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  12641. * @param defines The generated defines used in the effect
  12642. * @param effect The effect we are binding the data to
  12643. * @param scene The scene we are willing to render with logarithmic scale for
  12644. */
  12645. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  12646. /**
  12647. * Binds the clip plane information from the scene to the effect.
  12648. * @param scene The scene the clip plane information are extracted from
  12649. * @param effect The effect we are binding the data to
  12650. */
  12651. static BindClipPlane(effect: Effect, scene: Scene): void;
  12652. }
  12653. }
  12654. declare module BABYLON {
  12655. class MultiMaterial extends Material {
  12656. private _subMaterials;
  12657. subMaterials: Nullable<Material>[];
  12658. constructor(name: string, scene: Scene);
  12659. private _hookArray(array);
  12660. getSubMaterial(index: number): Nullable<Material>;
  12661. getActiveTextures(): BaseTexture[];
  12662. getClassName(): string;
  12663. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12664. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  12665. serialize(): any;
  12666. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  12667. }
  12668. }
  12669. declare module BABYLON {
  12670. class PushMaterial extends Material {
  12671. protected _activeEffect: Effect;
  12672. protected _normalMatrix: Matrix;
  12673. constructor(name: string, scene: Scene);
  12674. getEffect(): Effect;
  12675. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12676. /**
  12677. * Binds the given world matrix to the active effect
  12678. *
  12679. * @param world the matrix to bind
  12680. */
  12681. bindOnlyWorldMatrix(world: Matrix): void;
  12682. /**
  12683. * Binds the given normal matrix to the active effect
  12684. *
  12685. * @param normalMatrix the matrix to bind
  12686. */
  12687. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  12688. bind(world: Matrix, mesh?: Mesh): void;
  12689. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  12690. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  12691. }
  12692. }
  12693. declare module BABYLON {
  12694. class ShaderMaterial extends Material {
  12695. private _shaderPath;
  12696. private _options;
  12697. private _textures;
  12698. private _textureArrays;
  12699. private _floats;
  12700. private _ints;
  12701. private _floatsArrays;
  12702. private _colors3;
  12703. private _colors3Arrays;
  12704. private _colors4;
  12705. private _vectors2;
  12706. private _vectors3;
  12707. private _vectors4;
  12708. private _matrices;
  12709. private _matrices3x3;
  12710. private _matrices2x2;
  12711. private _vectors2Arrays;
  12712. private _vectors3Arrays;
  12713. private _cachedWorldViewMatrix;
  12714. private _renderId;
  12715. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  12716. getClassName(): string;
  12717. needAlphaBlending(): boolean;
  12718. needAlphaTesting(): boolean;
  12719. private _checkUniform(uniformName);
  12720. setTexture(name: string, texture: Texture): ShaderMaterial;
  12721. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12722. setFloat(name: string, value: number): ShaderMaterial;
  12723. setInt(name: string, value: number): ShaderMaterial;
  12724. setFloats(name: string, value: number[]): ShaderMaterial;
  12725. setColor3(name: string, value: Color3): ShaderMaterial;
  12726. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12727. setColor4(name: string, value: Color4): ShaderMaterial;
  12728. setVector2(name: string, value: Vector2): ShaderMaterial;
  12729. setVector3(name: string, value: Vector3): ShaderMaterial;
  12730. setVector4(name: string, value: Vector4): ShaderMaterial;
  12731. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12732. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12733. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12734. setArray2(name: string, value: number[]): ShaderMaterial;
  12735. setArray3(name: string, value: number[]): ShaderMaterial;
  12736. private _checkCache(scene, mesh?, useInstances?);
  12737. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12738. bindOnlyWorldMatrix(world: Matrix): void;
  12739. bind(world: Matrix, mesh?: Mesh): void;
  12740. getActiveTextures(): BaseTexture[];
  12741. hasTexture(texture: BaseTexture): boolean;
  12742. clone(name: string): ShaderMaterial;
  12743. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  12744. serialize(): any;
  12745. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12746. }
  12747. }
  12748. declare module BABYLON {
  12749. /** @ignore */
  12750. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  12751. MAINUV1: boolean;
  12752. MAINUV2: boolean;
  12753. DIFFUSE: boolean;
  12754. DIFFUSEDIRECTUV: number;
  12755. AMBIENT: boolean;
  12756. AMBIENTDIRECTUV: number;
  12757. OPACITY: boolean;
  12758. OPACITYDIRECTUV: number;
  12759. OPACITYRGB: boolean;
  12760. REFLECTION: boolean;
  12761. EMISSIVE: boolean;
  12762. EMISSIVEDIRECTUV: number;
  12763. SPECULAR: boolean;
  12764. SPECULARDIRECTUV: number;
  12765. BUMP: boolean;
  12766. BUMPDIRECTUV: number;
  12767. PARALLAX: boolean;
  12768. PARALLAXOCCLUSION: boolean;
  12769. SPECULAROVERALPHA: boolean;
  12770. CLIPPLANE: boolean;
  12771. ALPHATEST: boolean;
  12772. DEPTHPREPASS: boolean;
  12773. ALPHAFROMDIFFUSE: boolean;
  12774. POINTSIZE: boolean;
  12775. FOG: boolean;
  12776. SPECULARTERM: boolean;
  12777. DIFFUSEFRESNEL: boolean;
  12778. OPACITYFRESNEL: boolean;
  12779. REFLECTIONFRESNEL: boolean;
  12780. REFRACTIONFRESNEL: boolean;
  12781. EMISSIVEFRESNEL: boolean;
  12782. FRESNEL: boolean;
  12783. NORMAL: boolean;
  12784. UV1: boolean;
  12785. UV2: boolean;
  12786. VERTEXCOLOR: boolean;
  12787. VERTEXALPHA: boolean;
  12788. NUM_BONE_INFLUENCERS: number;
  12789. BonesPerMesh: number;
  12790. INSTANCES: boolean;
  12791. GLOSSINESS: boolean;
  12792. ROUGHNESS: boolean;
  12793. EMISSIVEASILLUMINATION: boolean;
  12794. LINKEMISSIVEWITHDIFFUSE: boolean;
  12795. REFLECTIONFRESNELFROMSPECULAR: boolean;
  12796. LIGHTMAP: boolean;
  12797. LIGHTMAPDIRECTUV: number;
  12798. OBJECTSPACE_NORMALMAP: boolean;
  12799. USELIGHTMAPASSHADOWMAP: boolean;
  12800. REFLECTIONMAP_3D: boolean;
  12801. REFLECTIONMAP_SPHERICAL: boolean;
  12802. REFLECTIONMAP_PLANAR: boolean;
  12803. REFLECTIONMAP_CUBIC: boolean;
  12804. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  12805. REFLECTIONMAP_PROJECTION: boolean;
  12806. REFLECTIONMAP_SKYBOX: boolean;
  12807. REFLECTIONMAP_EXPLICIT: boolean;
  12808. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  12809. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  12810. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  12811. INVERTCUBICMAP: boolean;
  12812. LOGARITHMICDEPTH: boolean;
  12813. REFRACTION: boolean;
  12814. REFRACTIONMAP_3D: boolean;
  12815. REFLECTIONOVERALPHA: boolean;
  12816. TWOSIDEDLIGHTING: boolean;
  12817. SHADOWFLOAT: boolean;
  12818. MORPHTARGETS: boolean;
  12819. MORPHTARGETS_NORMAL: boolean;
  12820. MORPHTARGETS_TANGENT: boolean;
  12821. NUM_MORPH_INFLUENCERS: number;
  12822. NONUNIFORMSCALING: boolean;
  12823. PREMULTIPLYALPHA: boolean;
  12824. IMAGEPROCESSING: boolean;
  12825. VIGNETTE: boolean;
  12826. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12827. VIGNETTEBLENDMODEOPAQUE: boolean;
  12828. TONEMAPPING: boolean;
  12829. CONTRAST: boolean;
  12830. COLORCURVES: boolean;
  12831. COLORGRADING: boolean;
  12832. COLORGRADING3D: boolean;
  12833. SAMPLER3DGREENDEPTH: boolean;
  12834. SAMPLER3DBGRMAP: boolean;
  12835. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12836. EXPOSURE: boolean;
  12837. GRAIN: boolean;
  12838. constructor();
  12839. setReflectionMode(modeToEnable: string): void;
  12840. }
  12841. class StandardMaterial extends PushMaterial {
  12842. private _diffuseTexture;
  12843. diffuseTexture: Nullable<BaseTexture>;
  12844. private _ambientTexture;
  12845. ambientTexture: Nullable<BaseTexture>;
  12846. private _opacityTexture;
  12847. opacityTexture: Nullable<BaseTexture>;
  12848. private _reflectionTexture;
  12849. reflectionTexture: Nullable<BaseTexture>;
  12850. private _emissiveTexture;
  12851. emissiveTexture: Nullable<BaseTexture>;
  12852. private _specularTexture;
  12853. specularTexture: Nullable<BaseTexture>;
  12854. private _bumpTexture;
  12855. bumpTexture: Nullable<BaseTexture>;
  12856. private _lightmapTexture;
  12857. lightmapTexture: Nullable<BaseTexture>;
  12858. private _refractionTexture;
  12859. refractionTexture: Nullable<BaseTexture>;
  12860. ambientColor: Color3;
  12861. diffuseColor: Color3;
  12862. specularColor: Color3;
  12863. emissiveColor: Color3;
  12864. specularPower: number;
  12865. private _useAlphaFromDiffuseTexture;
  12866. useAlphaFromDiffuseTexture: boolean;
  12867. private _useEmissiveAsIllumination;
  12868. useEmissiveAsIllumination: boolean;
  12869. private _linkEmissiveWithDiffuse;
  12870. linkEmissiveWithDiffuse: boolean;
  12871. private _useSpecularOverAlpha;
  12872. useSpecularOverAlpha: boolean;
  12873. private _useReflectionOverAlpha;
  12874. useReflectionOverAlpha: boolean;
  12875. private _disableLighting;
  12876. disableLighting: boolean;
  12877. private _useObjectSpaceNormalMap;
  12878. /**
  12879. * Allows using an object space normal map (instead of tangent space).
  12880. */
  12881. useObjectSpaceNormalMap: boolean;
  12882. private _useParallax;
  12883. useParallax: boolean;
  12884. private _useParallaxOcclusion;
  12885. useParallaxOcclusion: boolean;
  12886. parallaxScaleBias: number;
  12887. private _roughness;
  12888. roughness: number;
  12889. indexOfRefraction: number;
  12890. invertRefractionY: boolean;
  12891. private _useLightmapAsShadowmap;
  12892. useLightmapAsShadowmap: boolean;
  12893. private _diffuseFresnelParameters;
  12894. diffuseFresnelParameters: FresnelParameters;
  12895. private _opacityFresnelParameters;
  12896. opacityFresnelParameters: FresnelParameters;
  12897. private _reflectionFresnelParameters;
  12898. reflectionFresnelParameters: FresnelParameters;
  12899. private _refractionFresnelParameters;
  12900. refractionFresnelParameters: FresnelParameters;
  12901. private _emissiveFresnelParameters;
  12902. emissiveFresnelParameters: FresnelParameters;
  12903. private _useReflectionFresnelFromSpecular;
  12904. useReflectionFresnelFromSpecular: boolean;
  12905. private _useGlossinessFromSpecularMapAlpha;
  12906. useGlossinessFromSpecularMapAlpha: boolean;
  12907. private _maxSimultaneousLights;
  12908. maxSimultaneousLights: number;
  12909. /**
  12910. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  12911. */
  12912. private _invertNormalMapX;
  12913. invertNormalMapX: boolean;
  12914. /**
  12915. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  12916. */
  12917. private _invertNormalMapY;
  12918. invertNormalMapY: boolean;
  12919. /**
  12920. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  12921. */
  12922. private _twoSidedLighting;
  12923. twoSidedLighting: boolean;
  12924. /**
  12925. * Default configuration related to image processing available in the standard Material.
  12926. */
  12927. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12928. /**
  12929. * Gets the image processing configuration used either in this material.
  12930. */
  12931. /**
  12932. * Sets the Default image processing configuration used either in the this material.
  12933. *
  12934. * If sets to null, the scene one is in use.
  12935. */
  12936. imageProcessingConfiguration: ImageProcessingConfiguration;
  12937. /**
  12938. * Keep track of the image processing observer to allow dispose and replace.
  12939. */
  12940. private _imageProcessingObserver;
  12941. /**
  12942. * Attaches a new image processing configuration to the Standard Material.
  12943. * @param configuration
  12944. */
  12945. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12946. /**
  12947. * Gets wether the color curves effect is enabled.
  12948. */
  12949. /**
  12950. * Sets wether the color curves effect is enabled.
  12951. */
  12952. cameraColorCurvesEnabled: boolean;
  12953. /**
  12954. * Gets wether the color grading effect is enabled.
  12955. */
  12956. /**
  12957. * Gets wether the color grading effect is enabled.
  12958. */
  12959. cameraColorGradingEnabled: boolean;
  12960. /**
  12961. * Gets wether tonemapping is enabled or not.
  12962. */
  12963. /**
  12964. * Sets wether tonemapping is enabled or not
  12965. */
  12966. cameraToneMappingEnabled: boolean;
  12967. /**
  12968. * The camera exposure used on this material.
  12969. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  12970. * This corresponds to a photographic exposure.
  12971. */
  12972. /**
  12973. * The camera exposure used on this material.
  12974. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  12975. * This corresponds to a photographic exposure.
  12976. */
  12977. cameraExposure: number;
  12978. /**
  12979. * Gets The camera contrast used on this material.
  12980. */
  12981. /**
  12982. * Sets The camera contrast used on this material.
  12983. */
  12984. cameraContrast: number;
  12985. /**
  12986. * Gets the Color Grading 2D Lookup Texture.
  12987. */
  12988. /**
  12989. * Sets the Color Grading 2D Lookup Texture.
  12990. */
  12991. cameraColorGradingTexture: Nullable<BaseTexture>;
  12992. /**
  12993. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  12994. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  12995. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  12996. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  12997. */
  12998. /**
  12999. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13000. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13001. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  13002. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13003. */
  13004. cameraColorCurves: Nullable<ColorCurves>;
  13005. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  13006. protected _renderTargets: SmartArray<RenderTargetTexture>;
  13007. protected _worldViewProjectionMatrix: Matrix;
  13008. protected _globalAmbientColor: Color3;
  13009. protected _useLogarithmicDepth: boolean;
  13010. constructor(name: string, scene: Scene);
  13011. getClassName(): string;
  13012. useLogarithmicDepth: boolean;
  13013. needAlphaBlending(): boolean;
  13014. needAlphaTesting(): boolean;
  13015. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  13016. getAlphaTestTexture(): Nullable<BaseTexture>;
  13017. /**
  13018. * Child classes can use it to update shaders
  13019. */
  13020. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  13021. buildUniformLayout(): void;
  13022. unbind(): void;
  13023. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  13024. getAnimatables(): IAnimatable[];
  13025. getActiveTextures(): BaseTexture[];
  13026. hasTexture(texture: BaseTexture): boolean;
  13027. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13028. clone(name: string): StandardMaterial;
  13029. serialize(): any;
  13030. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  13031. static _DiffuseTextureEnabled: boolean;
  13032. static DiffuseTextureEnabled: boolean;
  13033. static _AmbientTextureEnabled: boolean;
  13034. static AmbientTextureEnabled: boolean;
  13035. static _OpacityTextureEnabled: boolean;
  13036. static OpacityTextureEnabled: boolean;
  13037. static _ReflectionTextureEnabled: boolean;
  13038. static ReflectionTextureEnabled: boolean;
  13039. static _EmissiveTextureEnabled: boolean;
  13040. static EmissiveTextureEnabled: boolean;
  13041. static _SpecularTextureEnabled: boolean;
  13042. static SpecularTextureEnabled: boolean;
  13043. static _BumpTextureEnabled: boolean;
  13044. static BumpTextureEnabled: boolean;
  13045. static _LightmapTextureEnabled: boolean;
  13046. static LightmapTextureEnabled: boolean;
  13047. static _RefractionTextureEnabled: boolean;
  13048. static RefractionTextureEnabled: boolean;
  13049. static _ColorGradingTextureEnabled: boolean;
  13050. static ColorGradingTextureEnabled: boolean;
  13051. static _FresnelEnabled: boolean;
  13052. static FresnelEnabled: boolean;
  13053. }
  13054. }
  13055. declare module BABYLON {
  13056. class UniformBuffer {
  13057. private _engine;
  13058. private _buffer;
  13059. private _data;
  13060. private _bufferData;
  13061. private _dynamic?;
  13062. private _uniformLocations;
  13063. private _uniformSizes;
  13064. private _uniformLocationPointer;
  13065. private _needSync;
  13066. private _noUBO;
  13067. private _currentEffect;
  13068. private static _MAX_UNIFORM_SIZE;
  13069. private static _tempBuffer;
  13070. /**
  13071. * Wrapper for updateUniform.
  13072. * @method updateMatrix3x3
  13073. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13074. * @param {Float32Array} matrix
  13075. */
  13076. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  13077. /**
  13078. * Wrapper for updateUniform.
  13079. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13080. * @param {Float32Array} matrix
  13081. */
  13082. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  13083. /**
  13084. * Wrapper for updateUniform.
  13085. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13086. * @param {number} x
  13087. */
  13088. updateFloat: (name: string, x: number) => void;
  13089. /**
  13090. * Wrapper for updateUniform.
  13091. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13092. * @param {number} x
  13093. * @param {number} y
  13094. * @param {string} [suffix] Suffix to add to the uniform name.
  13095. */
  13096. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  13097. /**
  13098. * Wrapper for updateUniform.
  13099. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13100. * @param {number} x
  13101. * @param {number} y
  13102. * @param {number} z
  13103. * @param {string} [suffix] Suffix to add to the uniform name.
  13104. */
  13105. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  13106. /**
  13107. * Wrapper for updateUniform.
  13108. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13109. * @param {number} x
  13110. * @param {number} y
  13111. * @param {number} z
  13112. * @param {number} w
  13113. * @param {string} [suffix] Suffix to add to the uniform name.
  13114. */
  13115. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  13116. /**
  13117. * Wrapper for updateUniform.
  13118. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13119. * @param {Matrix} A 4x4 matrix.
  13120. */
  13121. updateMatrix: (name: string, mat: Matrix) => void;
  13122. /**
  13123. * Wrapper for updateUniform.
  13124. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13125. * @param {Vector3} vector
  13126. */
  13127. updateVector3: (name: string, vector: Vector3) => void;
  13128. /**
  13129. * Wrapper for updateUniform.
  13130. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13131. * @param {Vector4} vector
  13132. */
  13133. updateVector4: (name: string, vector: Vector4) => void;
  13134. /**
  13135. * Wrapper for updateUniform.
  13136. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13137. * @param {Color3} color
  13138. * @param {string} [suffix] Suffix to add to the uniform name.
  13139. */
  13140. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  13141. /**
  13142. * Wrapper for updateUniform.
  13143. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13144. * @param {Color3} color
  13145. * @param {number} alpha
  13146. * @param {string} [suffix] Suffix to add to the uniform name.
  13147. */
  13148. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  13149. /**
  13150. * Uniform buffer objects.
  13151. *
  13152. * Handles blocks of uniform on the GPU.
  13153. *
  13154. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  13155. *
  13156. * For more information, please refer to :
  13157. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  13158. */
  13159. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  13160. /**
  13161. * Indicates if the buffer is using the WebGL2 UBO implementation,
  13162. * or just falling back on setUniformXXX calls.
  13163. */
  13164. readonly useUbo: boolean;
  13165. /**
  13166. * Indicates if the WebGL underlying uniform buffer is in sync
  13167. * with the javascript cache data.
  13168. */
  13169. readonly isSync: boolean;
  13170. /**
  13171. * Indicates if the WebGL underlying uniform buffer is dynamic.
  13172. * Also, a dynamic UniformBuffer will disable cache verification and always
  13173. * update the underlying WebGL uniform buffer to the GPU.
  13174. */
  13175. isDynamic(): boolean;
  13176. /**
  13177. * The data cache on JS side.
  13178. */
  13179. getData(): Float32Array;
  13180. /**
  13181. * The underlying WebGL Uniform buffer.
  13182. */
  13183. getBuffer(): Nullable<WebGLBuffer>;
  13184. /**
  13185. * std140 layout specifies how to align data within an UBO structure.
  13186. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  13187. * for specs.
  13188. */
  13189. private _fillAlignment(size);
  13190. /**
  13191. * Adds an uniform in the buffer.
  13192. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  13193. * for the layout to be correct !
  13194. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13195. * @param {number|number[]} size Data size, or data directly.
  13196. */
  13197. addUniform(name: string, size: number | number[]): void;
  13198. /**
  13199. * Wrapper for addUniform.
  13200. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13201. * @param {Matrix} mat A 4x4 matrix.
  13202. */
  13203. addMatrix(name: string, mat: Matrix): void;
  13204. /**
  13205. * Wrapper for addUniform.
  13206. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13207. * @param {number} x
  13208. * @param {number} y
  13209. */
  13210. addFloat2(name: string, x: number, y: number): void;
  13211. /**
  13212. * Wrapper for addUniform.
  13213. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13214. * @param {number} x
  13215. * @param {number} y
  13216. * @param {number} z
  13217. */
  13218. addFloat3(name: string, x: number, y: number, z: number): void;
  13219. /**
  13220. * Wrapper for addUniform.
  13221. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13222. * @param {Color3} color
  13223. */
  13224. addColor3(name: string, color: Color3): void;
  13225. /**
  13226. * Wrapper for addUniform.
  13227. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13228. * @param {Color3} color
  13229. * @param {number} alpha
  13230. */
  13231. addColor4(name: string, color: Color3, alpha: number): void;
  13232. /**
  13233. * Wrapper for addUniform.
  13234. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13235. * @param {Vector3} vector
  13236. */
  13237. addVector3(name: string, vector: Vector3): void;
  13238. /**
  13239. * Wrapper for addUniform.
  13240. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13241. */
  13242. addMatrix3x3(name: string): void;
  13243. /**
  13244. * Wrapper for addUniform.
  13245. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13246. */
  13247. addMatrix2x2(name: string): void;
  13248. /**
  13249. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  13250. */
  13251. create(): void;
  13252. _rebuild(): void;
  13253. /**
  13254. * Updates the WebGL Uniform Buffer on the GPU.
  13255. * If the `dynamic` flag is set to true, no cache comparison is done.
  13256. * Otherwise, the buffer will be updated only if the cache differs.
  13257. */
  13258. update(): void;
  13259. /**
  13260. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  13261. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  13262. * @param {number[]|Float32Array} data Flattened data
  13263. * @param {number} size Size of the data.
  13264. */
  13265. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  13266. private _updateMatrix3x3ForUniform(name, matrix);
  13267. private _updateMatrix3x3ForEffect(name, matrix);
  13268. private _updateMatrix2x2ForEffect(name, matrix);
  13269. private _updateMatrix2x2ForUniform(name, matrix);
  13270. private _updateFloatForEffect(name, x);
  13271. private _updateFloatForUniform(name, x);
  13272. private _updateFloat2ForEffect(name, x, y, suffix?);
  13273. private _updateFloat2ForUniform(name, x, y, suffix?);
  13274. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  13275. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  13276. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  13277. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  13278. private _updateMatrixForEffect(name, mat);
  13279. private _updateMatrixForUniform(name, mat);
  13280. private _updateVector3ForEffect(name, vector);
  13281. private _updateVector3ForUniform(name, vector);
  13282. private _updateVector4ForEffect(name, vector);
  13283. private _updateVector4ForUniform(name, vector);
  13284. private _updateColor3ForEffect(name, color, suffix?);
  13285. private _updateColor3ForUniform(name, color, suffix?);
  13286. private _updateColor4ForEffect(name, color, alpha, suffix?);
  13287. private _updateColor4ForUniform(name, color, alpha, suffix?);
  13288. /**
  13289. * Sets a sampler uniform on the effect.
  13290. * @param {string} name Name of the sampler.
  13291. * @param {Texture} texture
  13292. */
  13293. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  13294. /**
  13295. * Directly updates the value of the uniform in the cache AND on the GPU.
  13296. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  13297. * @param {number[]|Float32Array} data Flattened data
  13298. */
  13299. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  13300. /**
  13301. * Binds this uniform buffer to an effect.
  13302. * @param {Effect} effect
  13303. * @param {string} name Name of the uniform block in the shader.
  13304. */
  13305. bindToEffect(effect: Effect, name: string): void;
  13306. /**
  13307. * Disposes the uniform buffer.
  13308. */
  13309. dispose(): void;
  13310. }
  13311. }
  13312. declare module BABYLON {
  13313. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  13314. static OCCLUSION_TYPE_NONE: number;
  13315. static OCCLUSION_TYPE_OPTIMISTIC: number;
  13316. static OCCLUSION_TYPE_STRICT: number;
  13317. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  13318. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  13319. static readonly BILLBOARDMODE_NONE: number;
  13320. static readonly BILLBOARDMODE_X: number;
  13321. static readonly BILLBOARDMODE_Y: number;
  13322. static readonly BILLBOARDMODE_Z: number;
  13323. static readonly BILLBOARDMODE_ALL: number;
  13324. private _facetPositions;
  13325. private _facetNormals;
  13326. private _facetPartitioning;
  13327. private _facetNb;
  13328. private _partitioningSubdivisions;
  13329. private _partitioningBBoxRatio;
  13330. private _facetDataEnabled;
  13331. private _facetParameters;
  13332. private _bbSize;
  13333. private _subDiv;
  13334. private _facetDepthSort;
  13335. private _facetDepthSortEnabled;
  13336. private _depthSortedIndices;
  13337. private _depthSortedFacets;
  13338. private _facetDepthSortFunction;
  13339. private _facetDepthSortFrom;
  13340. private _facetDepthSortOrigin;
  13341. private _invertedMatrix;
  13342. /**
  13343. * Read-only : the number of facets in the mesh
  13344. */
  13345. readonly facetNb: number;
  13346. /**
  13347. * The number (integer) of subdivisions per axis in the partioning space
  13348. */
  13349. partitioningSubdivisions: number;
  13350. /**
  13351. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  13352. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box.
  13353. */
  13354. partitioningBBoxRatio: number;
  13355. /**
  13356. * Boolean : must the facet be depth sorted on next call to `updateFacetData()` ?
  13357. * Works only for updatable meshes.
  13358. * Doesn't work with multi-materials.
  13359. */
  13360. mustDepthSortFacets: boolean;
  13361. /**
  13362. * The location (Vector3) where the facet depth sort must be computed from.
  13363. * By default, the active camera position.
  13364. * Used only when facet depth sort is enabled.
  13365. */
  13366. facetDepthSortFrom: Vector3;
  13367. /**
  13368. * Read-only boolean : is the feature facetData enabled ?
  13369. */
  13370. readonly isFacetDataEnabled: boolean;
  13371. _updateNonUniformScalingState(value: boolean): boolean;
  13372. /**
  13373. * An event triggered when this mesh collides with another one
  13374. * @type {BABYLON.Observable}
  13375. */
  13376. onCollideObservable: Observable<AbstractMesh>;
  13377. private _onCollideObserver;
  13378. onCollide: () => void;
  13379. /**
  13380. * An event triggered when the collision's position changes
  13381. * @type {BABYLON.Observable}
  13382. */
  13383. onCollisionPositionChangeObservable: Observable<Vector3>;
  13384. private _onCollisionPositionChangeObserver;
  13385. onCollisionPositionChange: () => void;
  13386. /**
  13387. * An event triggered when material is changed
  13388. * @type {BABYLON.Observable}
  13389. */
  13390. onMaterialChangedObservable: Observable<AbstractMesh>;
  13391. definedFacingForward: boolean;
  13392. /**
  13393. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  13394. * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  13395. * or
  13396. * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE (Default Value) which is mapped to GL_ANY_SAMPLES_PASSED_CONSERVATIVE which is a false positive algorithm that is faster than GL_ANY_SAMPLES_PASSED but less accurate.
  13397. * for more info check WebGl documentations
  13398. */
  13399. occlusionQueryAlgorithmType: number;
  13400. /**
  13401. * This property is responsible for starting the occlusion query within the Mesh or not, this property is also used to determine what should happen when the occlusionRetryCount is reached. It has supports 3 values:
  13402. * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  13403. * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  13404. * OCCLUSION_TYPE_STRICT: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken restore the last state of the mesh occlusion if the mesh was visible then show the mesh if was hidden then hide don't show.
  13405. */
  13406. occlusionType: number;
  13407. /**
  13408. * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.
  13409. * The default value is -1 which means don't break the query and wait till the result.
  13410. */
  13411. occlusionRetryCount: number;
  13412. private _occlusionInternalRetryCounter;
  13413. protected _isOccluded: boolean;
  13414. /**
  13415. * Property isOccluded : Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not.
  13416. */
  13417. isOccluded: boolean;
  13418. private _isOcclusionQueryInProgress;
  13419. /**
  13420. * Flag to check the progress status of the query
  13421. */
  13422. readonly isOcclusionQueryInProgress: boolean;
  13423. private _occlusionQuery;
  13424. private _visibility;
  13425. /**
  13426. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  13427. */
  13428. /**
  13429. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  13430. */
  13431. visibility: number;
  13432. alphaIndex: number;
  13433. isVisible: boolean;
  13434. isPickable: boolean;
  13435. showBoundingBox: boolean;
  13436. showSubMeshesBoundingBox: boolean;
  13437. isBlocker: boolean;
  13438. enablePointerMoveEvents: boolean;
  13439. renderingGroupId: number;
  13440. private _material;
  13441. material: Nullable<Material>;
  13442. private _receiveShadows;
  13443. receiveShadows: boolean;
  13444. renderOutline: boolean;
  13445. outlineColor: Color3;
  13446. outlineWidth: number;
  13447. renderOverlay: boolean;
  13448. overlayColor: Color3;
  13449. overlayAlpha: number;
  13450. private _hasVertexAlpha;
  13451. hasVertexAlpha: boolean;
  13452. private _useVertexColors;
  13453. useVertexColors: boolean;
  13454. private _computeBonesUsingShaders;
  13455. computeBonesUsingShaders: boolean;
  13456. private _numBoneInfluencers;
  13457. numBoneInfluencers: number;
  13458. private _applyFog;
  13459. applyFog: boolean;
  13460. useOctreeForRenderingSelection: boolean;
  13461. useOctreeForPicking: boolean;
  13462. useOctreeForCollisions: boolean;
  13463. private _layerMask;
  13464. layerMask: number;
  13465. /**
  13466. * True if the mesh must be rendered in any case.
  13467. */
  13468. alwaysSelectAsActiveMesh: boolean;
  13469. /**
  13470. * This scene's action manager
  13471. * @type {BABYLON.ActionManager}
  13472. */
  13473. actionManager: Nullable<ActionManager>;
  13474. physicsImpostor: Nullable<PhysicsImpostor>;
  13475. private _checkCollisions;
  13476. private _collisionMask;
  13477. private _collisionGroup;
  13478. ellipsoid: Vector3;
  13479. ellipsoidOffset: Vector3;
  13480. private _collider;
  13481. private _oldPositionForCollisions;
  13482. private _diffPositionForCollisions;
  13483. collisionMask: number;
  13484. collisionGroup: number;
  13485. edgesWidth: number;
  13486. edgesColor: Color4;
  13487. _edgesRenderer: Nullable<EdgesRenderer>;
  13488. private _collisionsTransformMatrix;
  13489. private _collisionsScalingMatrix;
  13490. _masterMesh: Nullable<AbstractMesh>;
  13491. _boundingInfo: Nullable<BoundingInfo>;
  13492. _renderId: number;
  13493. subMeshes: SubMesh[];
  13494. _submeshesOctree: Octree<SubMesh>;
  13495. _intersectionsInProgress: AbstractMesh[];
  13496. _unIndexed: boolean;
  13497. _lightSources: Light[];
  13498. readonly _positions: Nullable<Vector3[]>;
  13499. _waitingActions: any;
  13500. _waitingFreezeWorldMatrix: Nullable<boolean>;
  13501. private _skeleton;
  13502. _bonesTransformMatrices: Nullable<Float32Array>;
  13503. skeleton: Nullable<Skeleton>;
  13504. constructor(name: string, scene?: Nullable<Scene>);
  13505. /**
  13506. * Returns the string "AbstractMesh"
  13507. */
  13508. getClassName(): string;
  13509. /**
  13510. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  13511. */
  13512. toString(fullDetails?: boolean): string;
  13513. _rebuild(): void;
  13514. _resyncLightSources(): void;
  13515. _resyncLighSource(light: Light): void;
  13516. _removeLightSource(light: Light): void;
  13517. private _markSubMeshesAsDirty(func);
  13518. _markSubMeshesAsLightDirty(): void;
  13519. _markSubMeshesAsAttributesDirty(): void;
  13520. _markSubMeshesAsMiscDirty(): void;
  13521. /**
  13522. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  13523. * Default : (1.0, 1.0, 1.0)
  13524. */
  13525. /**
  13526. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  13527. * Default : (1.0, 1.0, 1.0)
  13528. */
  13529. scaling: Vector3;
  13530. /**
  13531. * Disables the mesh edger rendering mode.
  13532. * Returns the AbstractMesh.
  13533. */
  13534. disableEdgesRendering(): AbstractMesh;
  13535. /**
  13536. * Enables the edge rendering mode on the mesh.
  13537. * This mode makes the mesh edges visible.
  13538. * Returns the AbstractMesh.
  13539. */
  13540. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  13541. /**
  13542. * Returns true if the mesh is blocked. Used by the class Mesh.
  13543. * Returns the boolean `false` by default.
  13544. */
  13545. readonly isBlocked: boolean;
  13546. /**
  13547. * Returns the mesh itself by default, used by the class Mesh.
  13548. * Returned type : AbstractMesh
  13549. */
  13550. getLOD(camera: Camera): AbstractMesh;
  13551. /**
  13552. * Returns 0 by default, used by the class Mesh.
  13553. * Returns an integer.
  13554. */
  13555. getTotalVertices(): number;
  13556. /**
  13557. * Returns null by default, used by the class Mesh.
  13558. * Returned type : integer array
  13559. */
  13560. getIndices(): Nullable<IndicesArray>;
  13561. /**
  13562. * Returns the array of the requested vertex data kind. Used by the class Mesh. Returns null here.
  13563. * Returned type : float array or Float32Array
  13564. */
  13565. getVerticesData(kind: string): Nullable<FloatArray>;
  13566. /**
  13567. * Sets the vertex data of the mesh geometry for the requested `kind`.
  13568. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  13569. * The `data` are either a numeric array either a Float32Array.
  13570. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  13571. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  13572. * Note that a new underlying VertexBuffer object is created each call.
  13573. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  13574. *
  13575. * Possible `kind` values :
  13576. * - BABYLON.VertexBuffer.PositionKind
  13577. * - BABYLON.VertexBuffer.UVKind
  13578. * - BABYLON.VertexBuffer.UV2Kind
  13579. * - BABYLON.VertexBuffer.UV3Kind
  13580. * - BABYLON.VertexBuffer.UV4Kind
  13581. * - BABYLON.VertexBuffer.UV5Kind
  13582. * - BABYLON.VertexBuffer.UV6Kind
  13583. * - BABYLON.VertexBuffer.ColorKind
  13584. * - BABYLON.VertexBuffer.MatricesIndicesKind
  13585. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  13586. * - BABYLON.VertexBuffer.MatricesWeightsKind
  13587. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  13588. *
  13589. * Returns the Mesh.
  13590. */
  13591. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  13592. /**
  13593. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  13594. * If the mesh has no geometry, it is simply returned as it is.
  13595. * The `data` are either a numeric array either a Float32Array.
  13596. * No new underlying VertexBuffer object is created.
  13597. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  13598. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  13599. *
  13600. * Possible `kind` values :
  13601. * - BABYLON.VertexBuffer.PositionKind
  13602. * - BABYLON.VertexBuffer.UVKind
  13603. * - BABYLON.VertexBuffer.UV2Kind
  13604. * - BABYLON.VertexBuffer.UV3Kind
  13605. * - BABYLON.VertexBuffer.UV4Kind
  13606. * - BABYLON.VertexBuffer.UV5Kind
  13607. * - BABYLON.VertexBuffer.UV6Kind
  13608. * - BABYLON.VertexBuffer.ColorKind
  13609. * - BABYLON.VertexBuffer.MatricesIndicesKind
  13610. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  13611. * - BABYLON.VertexBuffer.MatricesWeightsKind
  13612. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  13613. *
  13614. * Returns the Mesh.
  13615. */
  13616. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  13617. /**
  13618. * Sets the mesh indices.
  13619. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  13620. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  13621. * This method creates a new index buffer each call.
  13622. * Returns the Mesh.
  13623. */
  13624. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  13625. /** Returns false by default, used by the class Mesh.
  13626. * Returns a boolean
  13627. */
  13628. isVerticesDataPresent(kind: string): boolean;
  13629. /**
  13630. * Returns the mesh BoundingInfo object or creates a new one and returns it if undefined.
  13631. * Returns a BoundingInfo
  13632. */
  13633. getBoundingInfo(): BoundingInfo;
  13634. /**
  13635. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units).
  13636. * @param includeDescendants Take the hierarchy's bounding box instead of the mesh's bounding box.
  13637. */
  13638. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  13639. /**
  13640. * Sets a mesh new object BoundingInfo.
  13641. * Returns the AbstractMesh.
  13642. */
  13643. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  13644. readonly useBones: boolean;
  13645. _preActivate(): void;
  13646. _preActivateForIntermediateRendering(renderId: number): void;
  13647. _activate(renderId: number): void;
  13648. /**
  13649. * Returns the latest update of the World matrix
  13650. * Returns a Matrix.
  13651. */
  13652. getWorldMatrix(): Matrix;
  13653. /**
  13654. * Returns the latest update of the World matrix determinant.
  13655. */
  13656. protected _getWorldMatrixDeterminant(): number;
  13657. /**
  13658. * Perform relative position change from the point of view of behind the front of the mesh.
  13659. * This is performed taking into account the meshes current rotation, so you do not have to care.
  13660. * Supports definition of mesh facing forward or backward.
  13661. * @param {number} amountRight
  13662. * @param {number} amountUp
  13663. * @param {number} amountForward
  13664. *
  13665. * Returns the AbstractMesh.
  13666. */
  13667. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  13668. /**
  13669. * Calculate relative position change from the point of view of behind the front of the mesh.
  13670. * This is performed taking into account the meshes current rotation, so you do not have to care.
  13671. * Supports definition of mesh facing forward or backward.
  13672. * @param {number} amountRight
  13673. * @param {number} amountUp
  13674. * @param {number} amountForward
  13675. *
  13676. * Returns a new Vector3.
  13677. */
  13678. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  13679. /**
  13680. * Perform relative rotation change from the point of view of behind the front of the mesh.
  13681. * Supports definition of mesh facing forward or backward.
  13682. * @param {number} flipBack
  13683. * @param {number} twirlClockwise
  13684. * @param {number} tiltRight
  13685. *
  13686. * Returns the AbstractMesh.
  13687. */
  13688. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  13689. /**
  13690. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  13691. * Supports definition of mesh facing forward or backward.
  13692. * @param {number} flipBack
  13693. * @param {number} twirlClockwise
  13694. * @param {number} tiltRight
  13695. *
  13696. * Returns a new Vector3.
  13697. */
  13698. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  13699. /**
  13700. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  13701. * @param includeDescendants Include bounding info from descendants as well (true by default).
  13702. */
  13703. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  13704. min: Vector3;
  13705. max: Vector3;
  13706. };
  13707. /**
  13708. * Updates the mesh BoundingInfo object and all its children BoundingInfo objects also.
  13709. * Returns the AbstractMesh.
  13710. */
  13711. _updateBoundingInfo(): AbstractMesh;
  13712. /**
  13713. * Update a mesh's children BoundingInfo objects only.
  13714. * Returns the AbstractMesh.
  13715. */
  13716. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  13717. protected _afterComputeWorldMatrix(): void;
  13718. /**
  13719. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  13720. * A mesh is in the frustum if its bounding box intersects the frustum.
  13721. * Boolean returned.
  13722. */
  13723. isInFrustum(frustumPlanes: Plane[]): boolean;
  13724. /**
  13725. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  13726. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  13727. * Boolean returned.
  13728. */
  13729. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  13730. /**
  13731. * True if the mesh intersects another mesh or a SolidParticle object.
  13732. * Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  13733. * includeDescendants can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  13734. * Returns a boolean.
  13735. */
  13736. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  13737. /**
  13738. * Returns true if the passed point (Vector3) is inside the mesh bounding box.
  13739. * Returns a boolean.
  13740. */
  13741. intersectsPoint(point: Vector3): boolean;
  13742. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  13743. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13744. /**
  13745. * Returns the distance from the mesh to the active camera.
  13746. * Returns a float.
  13747. */
  13748. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13749. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  13750. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  13751. /**
  13752. * Property checkCollisions : Boolean, whether the camera should check the collisions against the mesh.
  13753. * Default `false`.
  13754. */
  13755. checkCollisions: boolean;
  13756. /**
  13757. * Gets Collider object used to compute collisions (not physics)
  13758. */
  13759. readonly collider: Collider;
  13760. moveWithCollisions(displacement: Vector3): AbstractMesh;
  13761. private _onCollisionPositionChange;
  13762. /**
  13763. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  13764. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree.
  13765. * Returns an Octree of submeshes.
  13766. */
  13767. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  13768. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  13769. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  13770. _checkCollision(collider: Collider): AbstractMesh;
  13771. _generatePointsArray(): boolean;
  13772. /**
  13773. * Checks if the passed Ray intersects with the mesh.
  13774. * Returns an object PickingInfo.
  13775. */
  13776. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  13777. /**
  13778. * Clones the mesh, used by the class Mesh.
  13779. * Just returns `null` for an AbstractMesh.
  13780. */
  13781. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  13782. /**
  13783. * Disposes all the mesh submeshes.
  13784. * Returns the AbstractMesh.
  13785. */
  13786. releaseSubMeshes(): AbstractMesh;
  13787. /**
  13788. * Releases resources associated with this abstract mesh.
  13789. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13790. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13791. */
  13792. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13793. /**
  13794. * Adds the passed mesh as a child to the current mesh.
  13795. * Returns the AbstractMesh.
  13796. */
  13797. addChild(mesh: AbstractMesh): AbstractMesh;
  13798. /**
  13799. * Removes the passed mesh from the current mesh children list.
  13800. * Returns the AbstractMesh.
  13801. */
  13802. removeChild(mesh: AbstractMesh): AbstractMesh;
  13803. /**
  13804. * Initialize the facet data arrays : facetNormals, facetPositions and facetPartitioning.
  13805. * Returns the AbstractMesh.
  13806. */
  13807. private _initFacetData();
  13808. /**
  13809. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  13810. * This method can be called within the render loop.
  13811. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation.
  13812. * Returns the AbstractMesh.
  13813. */
  13814. updateFacetData(): AbstractMesh;
  13815. /**
  13816. * Returns the facetLocalNormals array.
  13817. * The normals are expressed in the mesh local space.
  13818. */
  13819. getFacetLocalNormals(): Vector3[];
  13820. /**
  13821. * Returns the facetLocalPositions array.
  13822. * The facet positions are expressed in the mesh local space.
  13823. */
  13824. getFacetLocalPositions(): Vector3[];
  13825. /**
  13826. * Returns the facetLocalPartioning array.
  13827. */
  13828. getFacetLocalPartitioning(): number[][];
  13829. /**
  13830. * Returns the i-th facet position in the world system.
  13831. * This method allocates a new Vector3 per call.
  13832. */
  13833. getFacetPosition(i: number): Vector3;
  13834. /**
  13835. * Sets the reference Vector3 with the i-th facet position in the world system.
  13836. * Returns the AbstractMesh.
  13837. */
  13838. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  13839. /**
  13840. * Returns the i-th facet normal in the world system.
  13841. * This method allocates a new Vector3 per call.
  13842. */
  13843. getFacetNormal(i: number): Vector3;
  13844. /**
  13845. * Sets the reference Vector3 with the i-th facet normal in the world system.
  13846. * Returns the AbstractMesh.
  13847. */
  13848. getFacetNormalToRef(i: number, ref: Vector3): this;
  13849. /**
  13850. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system).
  13851. */
  13852. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  13853. /**
  13854. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found.
  13855. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) World projection on the facet.
  13856. * If checkFace is true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned.
  13857. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  13858. * If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position.
  13859. */
  13860. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  13861. /**
  13862. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found.
  13863. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) local projection on the facet.
  13864. * If checkFace is true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned.
  13865. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  13866. * If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position.
  13867. */
  13868. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  13869. /**
  13870. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  13871. */
  13872. getFacetDataParameters(): any;
  13873. /**
  13874. * Disables the feature FacetData and frees the related memory.
  13875. * Returns the AbstractMesh.
  13876. */
  13877. disableFacetData(): AbstractMesh;
  13878. /**
  13879. * Updates the AbstractMesh indices array. Actually, used by the Mesh object.
  13880. * Returns the mesh.
  13881. */
  13882. updateIndices(indices: IndicesArray): AbstractMesh;
  13883. /**
  13884. * The mesh Geometry. Actually used by the Mesh object.
  13885. * Returns a blank geometry object.
  13886. */
  13887. /**
  13888. * Creates new normals data for the mesh.
  13889. * @param updatable.
  13890. */
  13891. createNormals(updatable: boolean): void;
  13892. /**
  13893. * Align the mesh with a normal.
  13894. * Returns the mesh.
  13895. */
  13896. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  13897. protected checkOcclusionQuery(): void;
  13898. }
  13899. }
  13900. declare module BABYLON {
  13901. class Buffer {
  13902. private _engine;
  13903. private _buffer;
  13904. private _data;
  13905. private _updatable;
  13906. private _strideSize;
  13907. private _instanced;
  13908. constructor(engine: any, data: FloatArray, updatable: boolean, stride: number, postponeInternalCreation?: boolean, instanced?: boolean);
  13909. /**
  13910. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  13911. * @param kind defines the vertex buffer kind (position, normal, etc.)
  13912. * @param offset defines offset in the buffer (0 by default)
  13913. * @param size defines the size in floats of attributes (position is 3 for instance)
  13914. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  13915. * @param instanced defines if the vertex buffer contains indexed data
  13916. * @returns the new vertex buffer
  13917. */
  13918. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean): VertexBuffer;
  13919. isUpdatable(): boolean;
  13920. getData(): Nullable<FloatArray>;
  13921. getBuffer(): Nullable<WebGLBuffer>;
  13922. getStrideSize(): number;
  13923. create(data?: Nullable<FloatArray>): void;
  13924. _rebuild(): void;
  13925. update(data: FloatArray): void;
  13926. updateDirectly(data: Float32Array, offset: number, vertexCount?: number): void;
  13927. dispose(): void;
  13928. }
  13929. }
  13930. declare module BABYLON {
  13931. class CSG {
  13932. private polygons;
  13933. matrix: Matrix;
  13934. position: Vector3;
  13935. rotation: Vector3;
  13936. rotationQuaternion: Nullable<Quaternion>;
  13937. scaling: Vector3;
  13938. static FromMesh(mesh: Mesh): CSG;
  13939. private static FromPolygons(polygons);
  13940. clone(): CSG;
  13941. union(csg: CSG): CSG;
  13942. unionInPlace(csg: CSG): void;
  13943. subtract(csg: CSG): CSG;
  13944. subtractInPlace(csg: CSG): void;
  13945. intersect(csg: CSG): CSG;
  13946. intersectInPlace(csg: CSG): void;
  13947. inverse(): CSG;
  13948. inverseInPlace(): void;
  13949. copyTransformAttributes(csg: CSG): CSG;
  13950. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  13951. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  13952. }
  13953. }
  13954. declare module BABYLON {
  13955. /**
  13956. * Class used to store geometry data (vertex buffers + index buffer)
  13957. */
  13958. class Geometry implements IGetSetVerticesData {
  13959. /**
  13960. * Gets or sets the unique ID of the geometry
  13961. */
  13962. id: string;
  13963. /**
  13964. * Gets the delay loading state of the geometry (none by default which means not delayed)
  13965. */
  13966. delayLoadState: number;
  13967. /**
  13968. * Gets the file containing the data to load when running in delay load state
  13969. */
  13970. delayLoadingFile: Nullable<string>;
  13971. /**
  13972. * Callback called when the geometry is updated
  13973. */
  13974. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  13975. private _scene;
  13976. private _engine;
  13977. private _meshes;
  13978. private _totalVertices;
  13979. private _indices;
  13980. private _vertexBuffers;
  13981. private _isDisposed;
  13982. private _extend;
  13983. private _boundingBias;
  13984. /** @ignore */
  13985. _delayInfo: Array<string>;
  13986. private _indexBuffer;
  13987. private _indexBufferIsUpdatable;
  13988. /** @ignore */
  13989. _boundingInfo: Nullable<BoundingInfo>;
  13990. /** @ignore */
  13991. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  13992. /** @ignore */
  13993. _softwareSkinningRenderId: number;
  13994. private _vertexArrayObjects;
  13995. private _updatable;
  13996. /** @ignore */
  13997. _positions: Nullable<Vector3[]>;
  13998. /**
  13999. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  14000. */
  14001. /**
  14002. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  14003. */
  14004. boundingBias: Vector2;
  14005. /**
  14006. * Static function used to attach a new empty geometry to a mesh
  14007. * @param mesh defines the mesh to attach the geometry to
  14008. * @returns the new {BABYLON.Geometry}
  14009. */
  14010. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  14011. /**
  14012. * Creates a new geometry
  14013. * @param id defines the unique ID
  14014. * @param scene defines the hosting scene
  14015. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  14016. * @param updatable defines if geometry must be updatable (false by default)
  14017. * @param mesh defines the mesh that will be associated with the geometry
  14018. */
  14019. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  14020. /**
  14021. * Gets the current extend of the geometry
  14022. */
  14023. readonly extend: {
  14024. minimum: Vector3;
  14025. maximum: Vector3;
  14026. };
  14027. /**
  14028. * Gets the hosting scene
  14029. * @returns the hosting {BABYLON.Scene}
  14030. */
  14031. getScene(): Scene;
  14032. /**
  14033. * Gets the hosting engine
  14034. * @returns the hosting {BABYLON.Engine}
  14035. */
  14036. getEngine(): Engine;
  14037. /**
  14038. * Defines if the geometry is ready to use
  14039. * @returns true if the geometry is ready to be used
  14040. */
  14041. isReady(): boolean;
  14042. /**
  14043. * Gets a value indicating that the geometry should not be serialized
  14044. */
  14045. readonly doNotSerialize: boolean;
  14046. /** @ignore */
  14047. _rebuild(): void;
  14048. /**
  14049. * Affects all gemetry data in one call
  14050. * @param vertexData defines the geometry data
  14051. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  14052. */
  14053. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  14054. /**
  14055. * Set specific vertex data
  14056. * @param kind defines the data kind (Position, normal, etc...)
  14057. * @param data defines the vertex data to use
  14058. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  14059. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  14060. */
  14061. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  14062. /**
  14063. * Removes a specific vertex data
  14064. * @param kind defines the data kind (Position, normal, etc...)
  14065. */
  14066. removeVerticesData(kind: string): void;
  14067. /**
  14068. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  14069. * @param buffer defines the vertex buffer to use
  14070. */
  14071. setVerticesBuffer(buffer: VertexBuffer): void;
  14072. /**
  14073. * Update a specific vertex buffer
  14074. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  14075. * It will do nothing if the buffer is not updatable
  14076. * @param kind defines the data kind (Position, normal, etc...)
  14077. * @param data defines the data to use
  14078. * @param offset defines the offset in the target buffer where to store the data
  14079. */
  14080. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  14081. /**
  14082. * Update a specific vertex buffer
  14083. * This function will create a new buffer if the current one is not updatable
  14084. * @param kind defines the data kind (Position, normal, etc...)
  14085. * @param data defines the data to use
  14086. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  14087. */
  14088. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  14089. private updateBoundingInfo(updateExtends, data);
  14090. /** @ignore */
  14091. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  14092. /**
  14093. * Gets total number of vertices
  14094. * @returns the total number of vertices
  14095. */
  14096. getTotalVertices(): number;
  14097. /**
  14098. * Gets a specific vertex data attached to this geometry
  14099. * @param kind defines the data kind (Position, normal, etc...)
  14100. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  14101. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14102. * @returns a float array containing vertex data
  14103. */
  14104. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14105. /**
  14106. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  14107. * @param kind defines the data kind (Position, normal, etc...)
  14108. * @returns true if the vertex buffer with the specified kind is updatable
  14109. */
  14110. isVertexBufferUpdatable(kind: string): boolean;
  14111. /**
  14112. * Gets a specific vertex buffer
  14113. * @param kind defines the data kind (Position, normal, etc...)
  14114. * @returns a {BABYLON.VertexBuffer}
  14115. */
  14116. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14117. /**
  14118. * Returns all vertex buffers
  14119. * @return an object holding all vertex buffers indexed by kind
  14120. */
  14121. getVertexBuffers(): Nullable<{
  14122. [key: string]: VertexBuffer;
  14123. }>;
  14124. /**
  14125. * Gets a boolean indicating if specific vertex buffer is present
  14126. * @param kind defines the data kind (Position, normal, etc...)
  14127. * @returns true if data is present
  14128. */
  14129. isVerticesDataPresent(kind: string): boolean;
  14130. /**
  14131. * Gets a list of all attached data kinds (Position, normal, etc...)
  14132. * @returns a list of string containing all kinds
  14133. */
  14134. getVerticesDataKinds(): string[];
  14135. /**
  14136. * Update index buffer
  14137. * @param indices defines the indices to store in the index buffer
  14138. * @param offset defines the offset in the target buffer where to store the data
  14139. */
  14140. updateIndices(indices: IndicesArray, offset?: number): void;
  14141. /**
  14142. * Creates a new index buffer
  14143. * @param indices defines the indices to store in the index buffer
  14144. * @param totalVertices defines the total number of vertices (could be null)
  14145. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  14146. */
  14147. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  14148. /**
  14149. * Return the total number of indices
  14150. * @returns the total number of indices
  14151. */
  14152. getTotalIndices(): number;
  14153. /**
  14154. * Gets the index buffer array
  14155. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  14156. * @returns the index buffer array
  14157. */
  14158. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  14159. /**
  14160. * Gets the index buffer
  14161. * @return the index buffer
  14162. */
  14163. getIndexBuffer(): Nullable<WebGLBuffer>;
  14164. /** @ignore */
  14165. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  14166. /**
  14167. * Release the associated resources for a specific mesh
  14168. * @param mesh defines the source mesh
  14169. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  14170. */
  14171. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  14172. /**
  14173. * Apply current geometry to a given mesh
  14174. * @param mesh defines the mesh to apply geometry to
  14175. */
  14176. applyToMesh(mesh: Mesh): void;
  14177. private updateExtend(data?, stride?);
  14178. private _applyToMesh(mesh);
  14179. private notifyUpdate(kind?);
  14180. /**
  14181. * Load the geometry if it was flagged as delay loaded
  14182. * @param scene defines the hosting scene
  14183. * @param onLoaded defines a callback called when the geometry is loaded
  14184. */
  14185. load(scene: Scene, onLoaded?: () => void): void;
  14186. private _queueLoad(scene, onLoaded?);
  14187. /**
  14188. * Invert the geometry to move from a right handed system to a left handed one.
  14189. */
  14190. toLeftHanded(): void;
  14191. /** @ignore */
  14192. _resetPointsArrayCache(): void;
  14193. /** @ignore */
  14194. _generatePointsArray(): boolean;
  14195. /**
  14196. * Gets a value indicating if the geometry is disposed
  14197. * @returns true if the geometry was disposed
  14198. */
  14199. isDisposed(): boolean;
  14200. private _disposeVertexArrayObjects();
  14201. /**
  14202. * Free all associated resources
  14203. */
  14204. dispose(): void;
  14205. /**
  14206. * Clone the current geometry into a new geometry
  14207. * @param id defines the unique ID of the new geometry
  14208. * @returns a new geometry object
  14209. */
  14210. copy(id: string): Geometry;
  14211. /**
  14212. * Serialize the current geometry info (and not the vertices data) into a JSON object
  14213. * @return a JSON representation of the current geometry data (without the vertices data)
  14214. */
  14215. serialize(): any;
  14216. private toNumberArray(origin);
  14217. /**
  14218. * Serialize all vertices data into a JSON oject
  14219. * @returns a JSON representation of the current geometry data
  14220. */
  14221. serializeVerticeData(): any;
  14222. /**
  14223. * Extracts a clone of a mesh geometry
  14224. * @param mesh defines the source mesh
  14225. * @param id defines the unique ID of the new geometry object
  14226. * @returns the new geometry object
  14227. */
  14228. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  14229. /**
  14230. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  14231. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  14232. * Be aware Math.random() could cause collisions, but:
  14233. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  14234. * @returns a string containing a new GUID
  14235. */
  14236. static RandomId(): string;
  14237. /** @ignore */
  14238. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  14239. private static _CleanMatricesWeights(parsedGeometry, mesh);
  14240. /**
  14241. * Create a new geometry from persisted data (Using .babylon file format)
  14242. * @param parsedVertexData defines the persisted data
  14243. * @param scene defines the hosting scene
  14244. * @param rootUrl defines the root url to use to load assets (like delayed data)
  14245. * @returns the new geometry object
  14246. */
  14247. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  14248. }
  14249. /**
  14250. * Abstract class used to provide common services for all typed geometries
  14251. */
  14252. class _PrimitiveGeometry extends Geometry {
  14253. private _canBeRegenerated;
  14254. private _beingRegenerated;
  14255. /**
  14256. * Creates a new typed geometry
  14257. * @param id defines the unique ID of the geometry
  14258. * @param scene defines the hosting scene
  14259. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14260. * @param mesh defines the hosting mesh (can be null)
  14261. */
  14262. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  14263. /**
  14264. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  14265. * @returns true if the geometry can be regenerated
  14266. */
  14267. canBeRegenerated(): boolean;
  14268. /**
  14269. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  14270. */
  14271. regenerate(): void;
  14272. /**
  14273. * Clone the geometry
  14274. * @param id defines the unique ID of the new geometry
  14275. * @returns the new geometry
  14276. */
  14277. asNewGeometry(id: string): Geometry;
  14278. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  14279. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  14280. /** @ignore */
  14281. _regenerateVertexData(): VertexData;
  14282. copy(id: string): Geometry;
  14283. serialize(): any;
  14284. }
  14285. /**
  14286. * Creates a ribbon geometry
  14287. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  14288. */
  14289. class RibbonGeometry extends _PrimitiveGeometry {
  14290. /**
  14291. * Defines the array of paths to use
  14292. */
  14293. pathArray: Vector3[][];
  14294. /**
  14295. * Defines if the last and first points of each path in your pathArray must be joined
  14296. */
  14297. closeArray: boolean;
  14298. /**
  14299. * Defines if the last and first points of each path in your pathArray must be joined
  14300. */
  14301. closePath: boolean;
  14302. /**
  14303. * Defines the offset between points
  14304. */
  14305. offset: number;
  14306. /**
  14307. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14308. */
  14309. side: number;
  14310. /**
  14311. * Creates a ribbon geometry
  14312. * @param id defines the unique ID of the geometry
  14313. * @param scene defines the hosting scene
  14314. * @param pathArray defines the array of paths to use
  14315. * @param closeArray defines if the last path and the first path must be joined
  14316. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  14317. * @param offset defines the offset between points
  14318. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14319. * @param mesh defines the hosting mesh (can be null)
  14320. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14321. */
  14322. constructor(id: string, scene: Scene,
  14323. /**
  14324. * Defines the array of paths to use
  14325. */
  14326. pathArray: Vector3[][],
  14327. /**
  14328. * Defines if the last and first points of each path in your pathArray must be joined
  14329. */
  14330. closeArray: boolean,
  14331. /**
  14332. * Defines if the last and first points of each path in your pathArray must be joined
  14333. */
  14334. closePath: boolean,
  14335. /**
  14336. * Defines the offset between points
  14337. */
  14338. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  14339. /**
  14340. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14341. */
  14342. side?: number);
  14343. /** @ignore */
  14344. _regenerateVertexData(): VertexData;
  14345. copy(id: string): Geometry;
  14346. }
  14347. /**
  14348. * Creates a box geometry
  14349. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  14350. */
  14351. class BoxGeometry extends _PrimitiveGeometry {
  14352. /**
  14353. * Defines the zise of the box (width, height and depth are the same)
  14354. */
  14355. size: number;
  14356. /**
  14357. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14358. */
  14359. side: number;
  14360. /**
  14361. * Creates a box geometry
  14362. * @param id defines the unique ID of the geometry
  14363. * @param scene defines the hosting scene
  14364. * @param size defines the zise of the box (width, height and depth are the same)
  14365. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14366. * @param mesh defines the hosting mesh (can be null)
  14367. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14368. */
  14369. constructor(id: string, scene: Scene,
  14370. /**
  14371. * Defines the zise of the box (width, height and depth are the same)
  14372. */
  14373. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14374. /**
  14375. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14376. */
  14377. side?: number);
  14378. _regenerateVertexData(): VertexData;
  14379. copy(id: string): Geometry;
  14380. serialize(): any;
  14381. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  14382. }
  14383. /**
  14384. * Creates a sphere geometry
  14385. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  14386. */
  14387. class SphereGeometry extends _PrimitiveGeometry {
  14388. /**
  14389. * Defines the number of segments to use to create the sphere
  14390. */
  14391. segments: number;
  14392. /**
  14393. * Defines the diameter of the sphere
  14394. */
  14395. diameter: number;
  14396. /**
  14397. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14398. */
  14399. side: number;
  14400. /**
  14401. * Create a new sphere geometry
  14402. * @param id defines the unique ID of the geometry
  14403. * @param scene defines the hosting scene
  14404. * @param segments defines the number of segments to use to create the sphere
  14405. * @param diameter defines the diameter of the sphere
  14406. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14407. * @param mesh defines the hosting mesh (can be null)
  14408. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14409. */
  14410. constructor(id: string, scene: Scene,
  14411. /**
  14412. * Defines the number of segments to use to create the sphere
  14413. */
  14414. segments: number,
  14415. /**
  14416. * Defines the diameter of the sphere
  14417. */
  14418. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14419. /**
  14420. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14421. */
  14422. side?: number);
  14423. _regenerateVertexData(): VertexData;
  14424. copy(id: string): Geometry;
  14425. serialize(): any;
  14426. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  14427. }
  14428. /**
  14429. * Creates a disc geometry
  14430. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  14431. */
  14432. class DiscGeometry extends _PrimitiveGeometry {
  14433. /**
  14434. * Defines the radius of the disc
  14435. */
  14436. radius: number;
  14437. /**
  14438. * Defines the tesselation factor to apply to the disc
  14439. */
  14440. tessellation: number;
  14441. /**
  14442. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14443. */
  14444. side: number;
  14445. /**
  14446. * Creates a new disc geometry
  14447. * @param id defines the unique ID of the geometry
  14448. * @param scene defines the hosting scene
  14449. * @param radius defines the radius of the disc
  14450. * @param tessellation defines the tesselation factor to apply to the disc
  14451. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14452. * @param mesh defines the hosting mesh (can be null)
  14453. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14454. */
  14455. constructor(id: string, scene: Scene,
  14456. /**
  14457. * Defines the radius of the disc
  14458. */
  14459. radius: number,
  14460. /**
  14461. * Defines the tesselation factor to apply to the disc
  14462. */
  14463. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14464. /**
  14465. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14466. */
  14467. side?: number);
  14468. _regenerateVertexData(): VertexData;
  14469. copy(id: string): Geometry;
  14470. }
  14471. /**
  14472. * Creates a new cylinder geometry
  14473. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  14474. */
  14475. class CylinderGeometry extends _PrimitiveGeometry {
  14476. /**
  14477. * Defines the height of the cylinder
  14478. */
  14479. height: number;
  14480. /**
  14481. * Defines the diameter of the cylinder's top cap
  14482. */
  14483. diameterTop: number;
  14484. /**
  14485. * Defines the diameter of the cylinder's bottom cap
  14486. */
  14487. diameterBottom: number;
  14488. /**
  14489. * Defines the tessellation factor to apply to the cylinder
  14490. */
  14491. tessellation: number;
  14492. /**
  14493. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  14494. */
  14495. subdivisions: number;
  14496. /**
  14497. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14498. */
  14499. side: number;
  14500. /**
  14501. * Creates a new cylinder geometry
  14502. * @param id defines the unique ID of the geometry
  14503. * @param scene defines the hosting scene
  14504. * @param height defines the height of the cylinder
  14505. * @param diameterTop defines the diameter of the cylinder's top cap
  14506. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  14507. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  14508. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  14509. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14510. * @param mesh defines the hosting mesh (can be null)
  14511. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14512. */
  14513. constructor(id: string, scene: Scene,
  14514. /**
  14515. * Defines the height of the cylinder
  14516. */
  14517. height: number,
  14518. /**
  14519. * Defines the diameter of the cylinder's top cap
  14520. */
  14521. diameterTop: number,
  14522. /**
  14523. * Defines the diameter of the cylinder's bottom cap
  14524. */
  14525. diameterBottom: number,
  14526. /**
  14527. * Defines the tessellation factor to apply to the cylinder
  14528. */
  14529. tessellation: number,
  14530. /**
  14531. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  14532. */
  14533. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14534. /**
  14535. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14536. */
  14537. side?: number);
  14538. _regenerateVertexData(): VertexData;
  14539. copy(id: string): Geometry;
  14540. serialize(): any;
  14541. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  14542. }
  14543. /**
  14544. * Creates a new torus geometry
  14545. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  14546. */
  14547. class TorusGeometry extends _PrimitiveGeometry {
  14548. /**
  14549. * Defines the diameter of the torus
  14550. */
  14551. diameter: number;
  14552. /**
  14553. * Defines the thickness of the torus (ie. internal diameter)
  14554. */
  14555. thickness: number;
  14556. /**
  14557. * Defines the tesselation factor to apply to the torus
  14558. */
  14559. tessellation: number;
  14560. /**
  14561. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14562. */
  14563. side: number;
  14564. /**
  14565. * Creates a new torus geometry
  14566. * @param id defines the unique ID of the geometry
  14567. * @param scene defines the hosting scene
  14568. * @param diameter defines the diameter of the torus
  14569. * @param thickness defines the thickness of the torus (ie. internal diameter)
  14570. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  14571. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14572. * @param mesh defines the hosting mesh (can be null)
  14573. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14574. */
  14575. constructor(id: string, scene: Scene,
  14576. /**
  14577. * Defines the diameter of the torus
  14578. */
  14579. diameter: number,
  14580. /**
  14581. * Defines the thickness of the torus (ie. internal diameter)
  14582. */
  14583. thickness: number,
  14584. /**
  14585. * Defines the tesselation factor to apply to the torus
  14586. */
  14587. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14588. /**
  14589. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14590. */
  14591. side?: number);
  14592. _regenerateVertexData(): VertexData;
  14593. copy(id: string): Geometry;
  14594. serialize(): any;
  14595. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  14596. }
  14597. /**
  14598. * Creates a new ground geometry
  14599. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  14600. */
  14601. class GroundGeometry extends _PrimitiveGeometry {
  14602. /**
  14603. * Defines the width of the ground
  14604. */
  14605. width: number;
  14606. /**
  14607. * Defines the height of the ground
  14608. */
  14609. height: number;
  14610. /**
  14611. * Defines the subdivisions to apply to the ground
  14612. */
  14613. subdivisions: number;
  14614. /**
  14615. * Creates a new ground geometry
  14616. * @param id defines the unique ID of the geometry
  14617. * @param scene defines the hosting scene
  14618. * @param width defines the width of the ground
  14619. * @param height defines the height of the ground
  14620. * @param subdivisions defines the subdivisions to apply to the ground
  14621. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14622. * @param mesh defines the hosting mesh (can be null)
  14623. */
  14624. constructor(id: string, scene: Scene,
  14625. /**
  14626. * Defines the width of the ground
  14627. */
  14628. width: number,
  14629. /**
  14630. * Defines the height of the ground
  14631. */
  14632. height: number,
  14633. /**
  14634. * Defines the subdivisions to apply to the ground
  14635. */
  14636. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  14637. _regenerateVertexData(): VertexData;
  14638. copy(id: string): Geometry;
  14639. serialize(): any;
  14640. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  14641. }
  14642. /**
  14643. * Creates a tiled ground geometry
  14644. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  14645. */
  14646. class TiledGroundGeometry extends _PrimitiveGeometry {
  14647. /**
  14648. * Defines the minimum value on X axis
  14649. */
  14650. xmin: number;
  14651. /**
  14652. * Defines the minimum value on Z axis
  14653. */
  14654. zmin: number;
  14655. /**
  14656. * Defines the maximum value on X axis
  14657. */
  14658. xmax: number;
  14659. /**
  14660. * Defines the maximum value on Z axis
  14661. */
  14662. zmax: number;
  14663. /**
  14664. * Defines the subdivisions to apply to the ground
  14665. */
  14666. subdivisions: {
  14667. w: number;
  14668. h: number;
  14669. };
  14670. /**
  14671. * Defines the precision to use when computing the tiles
  14672. */
  14673. precision: {
  14674. w: number;
  14675. h: number;
  14676. };
  14677. /**
  14678. * Creates a tiled ground geometry
  14679. * @param id defines the unique ID of the geometry
  14680. * @param scene defines the hosting scene
  14681. * @param xmin defines the minimum value on X axis
  14682. * @param zmin defines the minimum value on Z axis
  14683. * @param xmax defines the maximum value on X axis
  14684. * @param zmax defines the maximum value on Z axis
  14685. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  14686. * @param precision defines the precision to use when computing the tiles
  14687. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14688. * @param mesh defines the hosting mesh (can be null)
  14689. */
  14690. constructor(id: string, scene: Scene,
  14691. /**
  14692. * Defines the minimum value on X axis
  14693. */
  14694. xmin: number,
  14695. /**
  14696. * Defines the minimum value on Z axis
  14697. */
  14698. zmin: number,
  14699. /**
  14700. * Defines the maximum value on X axis
  14701. */
  14702. xmax: number,
  14703. /**
  14704. * Defines the maximum value on Z axis
  14705. */
  14706. zmax: number,
  14707. /**
  14708. * Defines the subdivisions to apply to the ground
  14709. */
  14710. subdivisions: {
  14711. w: number;
  14712. h: number;
  14713. },
  14714. /**
  14715. * Defines the precision to use when computing the tiles
  14716. */
  14717. precision: {
  14718. w: number;
  14719. h: number;
  14720. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  14721. _regenerateVertexData(): VertexData;
  14722. copy(id: string): Geometry;
  14723. }
  14724. /**
  14725. * Creates a plane geometry
  14726. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  14727. */
  14728. class PlaneGeometry extends _PrimitiveGeometry {
  14729. /**
  14730. * Defines the size of the plane (width === height)
  14731. */
  14732. size: number;
  14733. /**
  14734. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14735. */
  14736. side: number;
  14737. /**
  14738. * Creates a plane geometry
  14739. * @param id defines the unique ID of the geometry
  14740. * @param scene defines the hosting scene
  14741. * @param size defines the size of the plane (width === height)
  14742. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14743. * @param mesh defines the hosting mesh (can be null)
  14744. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14745. */
  14746. constructor(id: string, scene: Scene,
  14747. /**
  14748. * Defines the size of the plane (width === height)
  14749. */
  14750. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14751. /**
  14752. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14753. */
  14754. side?: number);
  14755. _regenerateVertexData(): VertexData;
  14756. copy(id: string): Geometry;
  14757. serialize(): any;
  14758. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  14759. }
  14760. /**
  14761. * Creates a torus knot geometry
  14762. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  14763. */
  14764. class TorusKnotGeometry extends _PrimitiveGeometry {
  14765. /**
  14766. * Defines the radius of the torus knot
  14767. */
  14768. radius: number;
  14769. /**
  14770. * Defines the thickness of the torus knot tube
  14771. */
  14772. tube: number;
  14773. /**
  14774. * Defines the number of radial segments
  14775. */
  14776. radialSegments: number;
  14777. /**
  14778. * Defines the number of tubular segments
  14779. */
  14780. tubularSegments: number;
  14781. /**
  14782. * Defines the first number of windings
  14783. */
  14784. p: number;
  14785. /**
  14786. * Defines the second number of windings
  14787. */
  14788. q: number;
  14789. /**
  14790. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14791. */
  14792. side: number;
  14793. /**
  14794. * Creates a torus knot geometry
  14795. * @param id defines the unique ID of the geometry
  14796. * @param scene defines the hosting scene
  14797. * @param radius defines the radius of the torus knot
  14798. * @param tube defines the thickness of the torus knot tube
  14799. * @param radialSegments defines the number of radial segments
  14800. * @param tubularSegments defines the number of tubular segments
  14801. * @param p defines the first number of windings
  14802. * @param q defines the second number of windings
  14803. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14804. * @param mesh defines the hosting mesh (can be null)
  14805. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14806. */
  14807. constructor(id: string, scene: Scene,
  14808. /**
  14809. * Defines the radius of the torus knot
  14810. */
  14811. radius: number,
  14812. /**
  14813. * Defines the thickness of the torus knot tube
  14814. */
  14815. tube: number,
  14816. /**
  14817. * Defines the number of radial segments
  14818. */
  14819. radialSegments: number,
  14820. /**
  14821. * Defines the number of tubular segments
  14822. */
  14823. tubularSegments: number,
  14824. /**
  14825. * Defines the first number of windings
  14826. */
  14827. p: number,
  14828. /**
  14829. * Defines the second number of windings
  14830. */
  14831. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14832. /**
  14833. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14834. */
  14835. side?: number);
  14836. _regenerateVertexData(): VertexData;
  14837. copy(id: string): Geometry;
  14838. serialize(): any;
  14839. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  14840. }
  14841. }
  14842. declare module BABYLON {
  14843. class GroundMesh extends Mesh {
  14844. generateOctree: boolean;
  14845. private _heightQuads;
  14846. _subdivisionsX: number;
  14847. _subdivisionsY: number;
  14848. _width: number;
  14849. _height: number;
  14850. _minX: number;
  14851. _maxX: number;
  14852. _minZ: number;
  14853. _maxZ: number;
  14854. constructor(name: string, scene: Scene);
  14855. getClassName(): string;
  14856. readonly subdivisions: number;
  14857. readonly subdivisionsX: number;
  14858. readonly subdivisionsY: number;
  14859. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  14860. /**
  14861. * Returns a height (y) value in the Worl system :
  14862. * the ground altitude at the coordinates (x, z) expressed in the World system.
  14863. * Returns the ground y position if (x, z) are outside the ground surface.
  14864. */
  14865. getHeightAtCoordinates(x: number, z: number): number;
  14866. /**
  14867. * Returns a normalized vector (Vector3) orthogonal to the ground
  14868. * at the ground coordinates (x, z) expressed in the World system.
  14869. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  14870. */
  14871. getNormalAtCoordinates(x: number, z: number): Vector3;
  14872. /**
  14873. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  14874. * at the ground coordinates (x, z) expressed in the World system.
  14875. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  14876. * Returns the GroundMesh.
  14877. */
  14878. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  14879. /**
  14880. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  14881. * if the ground has been updated.
  14882. * This can be used in the render loop.
  14883. * Returns the GroundMesh.
  14884. */
  14885. updateCoordinateHeights(): GroundMesh;
  14886. private _getFacetAt(x, z);
  14887. private _initHeightQuads();
  14888. private _computeHeightQuads();
  14889. serialize(serializationObject: any): void;
  14890. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  14891. }
  14892. }
  14893. declare module BABYLON {
  14894. /**
  14895. * Creates an instance based on a source mesh.
  14896. */
  14897. class InstancedMesh extends AbstractMesh {
  14898. private _sourceMesh;
  14899. private _currentLOD;
  14900. constructor(name: string, source: Mesh);
  14901. /**
  14902. * Returns the string "InstancedMesh".
  14903. */
  14904. getClassName(): string;
  14905. readonly receiveShadows: boolean;
  14906. readonly material: Nullable<Material>;
  14907. readonly visibility: number;
  14908. readonly skeleton: Nullable<Skeleton>;
  14909. renderingGroupId: number;
  14910. /**
  14911. * Returns the total number of vertices (integer).
  14912. */
  14913. getTotalVertices(): number;
  14914. readonly sourceMesh: Mesh;
  14915. /**
  14916. * Is this node ready to be used/rendered
  14917. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14918. * @return {boolean} is it ready
  14919. */
  14920. isReady(completeCheck?: boolean): boolean;
  14921. /**
  14922. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  14923. */
  14924. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  14925. /**
  14926. * Sets the vertex data of the mesh geometry for the requested `kind`.
  14927. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  14928. * The `data` are either a numeric array either a Float32Array.
  14929. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  14930. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  14931. * Note that a new underlying VertexBuffer object is created each call.
  14932. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  14933. *
  14934. * Possible `kind` values :
  14935. * - BABYLON.VertexBuffer.PositionKind
  14936. * - BABYLON.VertexBuffer.UVKind
  14937. * - BABYLON.VertexBuffer.UV2Kind
  14938. * - BABYLON.VertexBuffer.UV3Kind
  14939. * - BABYLON.VertexBuffer.UV4Kind
  14940. * - BABYLON.VertexBuffer.UV5Kind
  14941. * - BABYLON.VertexBuffer.UV6Kind
  14942. * - BABYLON.VertexBuffer.ColorKind
  14943. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14944. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14945. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14946. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14947. *
  14948. * Returns the Mesh.
  14949. */
  14950. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14951. /**
  14952. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  14953. * If the mesh has no geometry, it is simply returned as it is.
  14954. * The `data` are either a numeric array either a Float32Array.
  14955. * No new underlying VertexBuffer object is created.
  14956. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  14957. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  14958. *
  14959. * Possible `kind` values :
  14960. * - BABYLON.VertexBuffer.PositionKind
  14961. * - BABYLON.VertexBuffer.UVKind
  14962. * - BABYLON.VertexBuffer.UV2Kind
  14963. * - BABYLON.VertexBuffer.UV3Kind
  14964. * - BABYLON.VertexBuffer.UV4Kind
  14965. * - BABYLON.VertexBuffer.UV5Kind
  14966. * - BABYLON.VertexBuffer.UV6Kind
  14967. * - BABYLON.VertexBuffer.ColorKind
  14968. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14969. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14970. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14971. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14972. *
  14973. * Returns the Mesh.
  14974. */
  14975. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14976. /**
  14977. * Sets the mesh indices.
  14978. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  14979. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  14980. * This method creates a new index buffer each call.
  14981. * Returns the Mesh.
  14982. */
  14983. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  14984. /**
  14985. * Boolean : True if the mesh owns the requested kind of data.
  14986. */
  14987. isVerticesDataPresent(kind: string): boolean;
  14988. /**
  14989. * Returns an array of indices (IndicesArray).
  14990. */
  14991. getIndices(): Nullable<IndicesArray>;
  14992. readonly _positions: Nullable<Vector3[]>;
  14993. /**
  14994. * Sets a new updated BoundingInfo to the mesh.
  14995. * Returns the mesh.
  14996. */
  14997. refreshBoundingInfo(): InstancedMesh;
  14998. _preActivate(): InstancedMesh;
  14999. _activate(renderId: number): InstancedMesh;
  15000. /**
  15001. * Returns the current associated LOD AbstractMesh.
  15002. */
  15003. getLOD(camera: Camera): AbstractMesh;
  15004. _syncSubMeshes(): InstancedMesh;
  15005. _generatePointsArray(): boolean;
  15006. /**
  15007. * Creates a new InstancedMesh from the current mesh.
  15008. * - name (string) : the cloned mesh name
  15009. * - newParent (optional Node) : the optional Node to parent the clone to.
  15010. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15011. *
  15012. * Returns the clone.
  15013. */
  15014. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  15015. /**
  15016. * Disposes the InstancedMesh.
  15017. * Returns nothing.
  15018. */
  15019. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15020. }
  15021. }
  15022. declare module BABYLON {
  15023. class LinesMesh extends Mesh {
  15024. useVertexColor: boolean | undefined;
  15025. useVertexAlpha: boolean | undefined;
  15026. color: Color3;
  15027. alpha: number;
  15028. /**
  15029. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15030. * This margin is expressed in world space coordinates, so its value may vary.
  15031. * Default value is 0.1
  15032. * @returns the intersection Threshold value.
  15033. */
  15034. /**
  15035. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15036. * This margin is expressed in world space coordinates, so its value may vary.
  15037. * @param value the new threshold to apply
  15038. */
  15039. intersectionThreshold: number;
  15040. private _intersectionThreshold;
  15041. private _colorShader;
  15042. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  15043. /**
  15044. * Returns the string "LineMesh"
  15045. */
  15046. getClassName(): string;
  15047. material: Material;
  15048. readonly checkCollisions: boolean;
  15049. createInstance(name: string): InstancedMesh;
  15050. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  15051. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  15052. dispose(doNotRecurse?: boolean): void;
  15053. /**
  15054. * Returns a new LineMesh object cloned from the current one.
  15055. */
  15056. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  15057. }
  15058. }
  15059. declare module BABYLON {
  15060. class _InstancesBatch {
  15061. mustReturn: boolean;
  15062. visibleInstances: Nullable<InstancedMesh[]>[];
  15063. renderSelf: boolean[];
  15064. }
  15065. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  15066. static _FRONTSIDE: number;
  15067. static _BACKSIDE: number;
  15068. static _DOUBLESIDE: number;
  15069. static _DEFAULTSIDE: number;
  15070. static _NO_CAP: number;
  15071. static _CAP_START: number;
  15072. static _CAP_END: number;
  15073. static _CAP_ALL: number;
  15074. /**
  15075. * Mesh side orientation : usually the external or front surface
  15076. */
  15077. static readonly FRONTSIDE: number;
  15078. /**
  15079. * Mesh side orientation : usually the internal or back surface
  15080. */
  15081. static readonly BACKSIDE: number;
  15082. /**
  15083. * Mesh side orientation : both internal and external or front and back surfaces
  15084. */
  15085. static readonly DOUBLESIDE: number;
  15086. /**
  15087. * Mesh side orientation : by default, `FRONTSIDE`
  15088. */
  15089. static readonly DEFAULTSIDE: number;
  15090. /**
  15091. * Mesh cap setting : no cap
  15092. */
  15093. static readonly NO_CAP: number;
  15094. /**
  15095. * Mesh cap setting : one cap at the beginning of the mesh
  15096. */
  15097. static readonly CAP_START: number;
  15098. /**
  15099. * Mesh cap setting : one cap at the end of the mesh
  15100. */
  15101. static readonly CAP_END: number;
  15102. /**
  15103. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  15104. */
  15105. static readonly CAP_ALL: number;
  15106. /**
  15107. * An event triggered before rendering the mesh
  15108. * @type {BABYLON.Observable}
  15109. */
  15110. onBeforeRenderObservable: Observable<Mesh>;
  15111. /**
  15112. * An event triggered after rendering the mesh
  15113. * @type {BABYLON.Observable}
  15114. */
  15115. onAfterRenderObservable: Observable<Mesh>;
  15116. /**
  15117. * An event triggered before drawing the mesh
  15118. * @type {BABYLON.Observable}
  15119. */
  15120. onBeforeDrawObservable: Observable<Mesh>;
  15121. private _onBeforeDrawObserver;
  15122. onBeforeDraw: () => void;
  15123. delayLoadState: number;
  15124. instances: InstancedMesh[];
  15125. delayLoadingFile: string;
  15126. _binaryInfo: any;
  15127. private _LODLevels;
  15128. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  15129. private _morphTargetManager;
  15130. morphTargetManager: Nullable<MorphTargetManager>;
  15131. _geometry: Nullable<Geometry>;
  15132. _delayInfo: Array<string>;
  15133. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  15134. _visibleInstances: any;
  15135. private _renderIdForInstances;
  15136. private _batchCache;
  15137. private _instancesBufferSize;
  15138. private _instancesBuffer;
  15139. private _instancesData;
  15140. private _overridenInstanceCount;
  15141. private _effectiveMaterial;
  15142. _shouldGenerateFlatShading: boolean;
  15143. private _preActivateId;
  15144. _originalBuilderSideOrientation: number;
  15145. overrideMaterialSideOrientation: Nullable<number>;
  15146. private _areNormalsFrozen;
  15147. private _sourcePositions;
  15148. private _sourceNormals;
  15149. private _source;
  15150. readonly source: Nullable<Mesh>;
  15151. isUnIndexed: boolean;
  15152. /**
  15153. * @constructor
  15154. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  15155. * @param {Scene} scene The scene to add this mesh to.
  15156. * @param {Node} parent The parent of this mesh, if it has one
  15157. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  15158. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15159. * When false, achieved by calling a clone(), also passing False.
  15160. * This will make creation of children, recursive.
  15161. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  15162. */
  15163. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  15164. /**
  15165. * Returns the string "Mesh".
  15166. */
  15167. getClassName(): string;
  15168. /**
  15169. * Returns a string.
  15170. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  15171. */
  15172. toString(fullDetails?: boolean): string;
  15173. /**
  15174. * True if the mesh has some Levels Of Details (LOD).
  15175. * Returns a boolean.
  15176. */
  15177. readonly hasLODLevels: boolean;
  15178. /**
  15179. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  15180. * @returns an array of {BABYLON.MeshLODLevel}
  15181. */
  15182. getLODLevels(): MeshLODLevel[];
  15183. private _sortLODLevels();
  15184. /**
  15185. * Add a mesh as LOD level triggered at the given distance.
  15186. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  15187. * @param {number} distance The distance from the center of the object to show this level
  15188. * @param {Mesh} mesh The mesh to be added as LOD level
  15189. * @return {Mesh} This mesh (for chaining)
  15190. */
  15191. addLODLevel(distance: number, mesh: Mesh): Mesh;
  15192. /**
  15193. * Returns the LOD level mesh at the passed distance or null if not found.
  15194. * It is related to the method `addLODLevel(distance, mesh)`.
  15195. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  15196. * Returns an object Mesh or `null`.
  15197. */
  15198. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  15199. /**
  15200. * Remove a mesh from the LOD array
  15201. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  15202. * @param {Mesh} mesh The mesh to be removed.
  15203. * @return {Mesh} This mesh (for chaining)
  15204. */
  15205. removeLODLevel(mesh: Mesh): Mesh;
  15206. /**
  15207. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  15208. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  15209. */
  15210. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  15211. /**
  15212. * Returns the mesh internal Geometry object.
  15213. */
  15214. readonly geometry: Nullable<Geometry>;
  15215. /**
  15216. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  15217. */
  15218. getTotalVertices(): number;
  15219. /**
  15220. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  15221. * If `copywhenShared` is true (default false) and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  15222. * You can force the copy with forceCopy === true
  15223. * Returns null if the mesh has no geometry or no vertex buffer.
  15224. * Possible `kind` values :
  15225. * - BABYLON.VertexBuffer.PositionKind
  15226. * - BABYLON.VertexBuffer.UVKind
  15227. * - BABYLON.VertexBuffer.UV2Kind
  15228. * - BABYLON.VertexBuffer.UV3Kind
  15229. * - BABYLON.VertexBuffer.UV4Kind
  15230. * - BABYLON.VertexBuffer.UV5Kind
  15231. * - BABYLON.VertexBuffer.UV6Kind
  15232. * - BABYLON.VertexBuffer.ColorKind
  15233. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15234. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15235. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15236. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15237. */
  15238. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  15239. /**
  15240. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  15241. * Returns `null` if the mesh has no geometry.
  15242. * Possible `kind` values :
  15243. * - BABYLON.VertexBuffer.PositionKind
  15244. * - BABYLON.VertexBuffer.UVKind
  15245. * - BABYLON.VertexBuffer.UV2Kind
  15246. * - BABYLON.VertexBuffer.UV3Kind
  15247. * - BABYLON.VertexBuffer.UV4Kind
  15248. * - BABYLON.VertexBuffer.UV5Kind
  15249. * - BABYLON.VertexBuffer.UV6Kind
  15250. * - BABYLON.VertexBuffer.ColorKind
  15251. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15252. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15253. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15254. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15255. */
  15256. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  15257. /**
  15258. * Returns a boolean depending on the existence of the Vertex Data for the requested `kind`.
  15259. * Possible `kind` values :
  15260. * - BABYLON.VertexBuffer.PositionKind
  15261. * - BABYLON.VertexBuffer.UVKind
  15262. * - BABYLON.VertexBuffer.UV2Kind
  15263. * - BABYLON.VertexBuffer.UV3Kind
  15264. * - BABYLON.VertexBuffer.UV4Kind
  15265. * - BABYLON.VertexBuffer.UV5Kind
  15266. * - BABYLON.VertexBuffer.UV6Kind
  15267. * - BABYLON.VertexBuffer.ColorKind
  15268. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15269. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15270. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15271. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15272. */
  15273. isVerticesDataPresent(kind: string): boolean;
  15274. /**
  15275. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  15276. * Possible `kind` values :
  15277. * - BABYLON.VertexBuffer.PositionKind
  15278. * - BABYLON.VertexBuffer.UVKind
  15279. * - BABYLON.VertexBuffer.UV2Kind
  15280. * - BABYLON.VertexBuffer.UV3Kind
  15281. * - BABYLON.VertexBuffer.UV4Kind
  15282. * - BABYLON.VertexBuffer.UV5Kind
  15283. * - BABYLON.VertexBuffer.UV6Kind
  15284. * - BABYLON.VertexBuffer.ColorKind
  15285. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15286. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15287. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15288. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15289. */
  15290. isVertexBufferUpdatable(kind: string): boolean;
  15291. /**
  15292. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  15293. * Possible `kind` values :
  15294. * - BABYLON.VertexBuffer.PositionKind
  15295. * - BABYLON.VertexBuffer.UVKind
  15296. * - BABYLON.VertexBuffer.UV2Kind
  15297. * - BABYLON.VertexBuffer.UV3Kind
  15298. * - BABYLON.VertexBuffer.UV4Kind
  15299. * - BABYLON.VertexBuffer.UV5Kind
  15300. * - BABYLON.VertexBuffer.UV6Kind
  15301. * - BABYLON.VertexBuffer.ColorKind
  15302. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15303. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15304. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15305. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15306. */
  15307. getVerticesDataKinds(): string[];
  15308. /**
  15309. * Returns a positive integer : the total number of indices in this mesh geometry.
  15310. * Returns zero if the mesh has no geometry.
  15311. */
  15312. getTotalIndices(): number;
  15313. /**
  15314. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15315. * If the parameter `copyWhenShared` is true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  15316. * Returns an empty array if the mesh has no geometry.
  15317. */
  15318. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  15319. readonly isBlocked: boolean;
  15320. /**
  15321. * Determine if the current mesh is ready to be rendered
  15322. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15323. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  15324. * @returns true if all associated assets are ready (material, textures, shaders)
  15325. */
  15326. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  15327. /**
  15328. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  15329. * This property is pertinent only for updatable parametric shapes.
  15330. */
  15331. readonly areNormalsFrozen: boolean;
  15332. /**
  15333. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  15334. * It has no effect at all on other shapes.
  15335. * It prevents the mesh normals from being recomputed on next `positions` array update.
  15336. * Returns the Mesh.
  15337. */
  15338. freezeNormals(): Mesh;
  15339. /**
  15340. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  15341. * It has no effect at all on other shapes.
  15342. * It reactivates the mesh normals computation if it was previously frozen.
  15343. * Returns the Mesh.
  15344. */
  15345. unfreezeNormals(): Mesh;
  15346. /**
  15347. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  15348. */
  15349. overridenInstanceCount: number;
  15350. _preActivate(): Mesh;
  15351. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15352. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  15353. /**
  15354. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15355. * This means the mesh underlying bounding box and sphere are recomputed.
  15356. * Returns the Mesh.
  15357. */
  15358. refreshBoundingInfo(): Mesh;
  15359. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  15360. private _getPositionData(applySkeleton);
  15361. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  15362. subdivide(count: number): void;
  15363. /**
  15364. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15365. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15366. * The `data` are either a numeric array either a Float32Array.
  15367. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15368. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  15369. * Note that a new underlying VertexBuffer object is created each call.
  15370. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15371. *
  15372. * Possible `kind` values :
  15373. * - BABYLON.VertexBuffer.PositionKind
  15374. * - BABYLON.VertexBuffer.UVKind
  15375. * - BABYLON.VertexBuffer.UV2Kind
  15376. * - BABYLON.VertexBuffer.UV3Kind
  15377. * - BABYLON.VertexBuffer.UV4Kind
  15378. * - BABYLON.VertexBuffer.UV5Kind
  15379. * - BABYLON.VertexBuffer.UV6Kind
  15380. * - BABYLON.VertexBuffer.ColorKind
  15381. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15382. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15383. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15384. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15385. *
  15386. * Returns the Mesh.
  15387. */
  15388. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  15389. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  15390. /**
  15391. * Sets the mesh VertexBuffer.
  15392. * Returns the Mesh.
  15393. */
  15394. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  15395. /**
  15396. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15397. * If the mesh has no geometry, it is simply returned as it is.
  15398. * The `data` are either a numeric array either a Float32Array.
  15399. * No new underlying VertexBuffer object is created.
  15400. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15401. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15402. *
  15403. * Possible `kind` values :
  15404. * - BABYLON.VertexBuffer.PositionKind
  15405. * - BABYLON.VertexBuffer.UVKind
  15406. * - BABYLON.VertexBuffer.UV2Kind
  15407. * - BABYLON.VertexBuffer.UV3Kind
  15408. * - BABYLON.VertexBuffer.UV4Kind
  15409. * - BABYLON.VertexBuffer.UV5Kind
  15410. * - BABYLON.VertexBuffer.UV6Kind
  15411. * - BABYLON.VertexBuffer.ColorKind
  15412. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15413. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15414. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15415. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15416. *
  15417. * Returns the Mesh.
  15418. */
  15419. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15420. /**
  15421. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  15422. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  15423. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  15424. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  15425. * Returns the Mesh.
  15426. */
  15427. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  15428. /**
  15429. * Creates a un-shared specific occurence of the geometry for the mesh.
  15430. * Returns the Mesh.
  15431. */
  15432. makeGeometryUnique(): Mesh;
  15433. /**
  15434. * Sets the mesh indices.
  15435. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15436. * Type is Uint16Array by default unless the mesh has more than 65536 vertices.
  15437. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15438. * This method creates a new index buffer each call.
  15439. * Returns the Mesh.
  15440. */
  15441. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  15442. /**
  15443. * Update the current index buffer
  15444. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  15445. * Returns the Mesh.
  15446. */
  15447. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  15448. /**
  15449. * Invert the geometry to move from a right handed system to a left handed one.
  15450. * Returns the Mesh.
  15451. */
  15452. toLeftHanded(): Mesh;
  15453. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15454. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  15455. /**
  15456. * Registers for this mesh a javascript function called just before the rendering process.
  15457. * This function is passed the current mesh.
  15458. * Return the Mesh.
  15459. */
  15460. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  15461. /**
  15462. * Disposes a previously registered javascript function called before the rendering.
  15463. * This function is passed the current mesh.
  15464. * Returns the Mesh.
  15465. */
  15466. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  15467. /**
  15468. * Registers for this mesh a javascript function called just after the rendering is complete.
  15469. * This function is passed the current mesh.
  15470. * Returns the Mesh.
  15471. */
  15472. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  15473. /**
  15474. * Disposes a previously registered javascript function called after the rendering.
  15475. * This function is passed the current mesh.
  15476. * Return the Mesh.
  15477. */
  15478. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  15479. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  15480. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  15481. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  15482. /**
  15483. * Triggers the draw call for the mesh.
  15484. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  15485. * Returns the Mesh.
  15486. */
  15487. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  15488. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  15489. /**
  15490. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  15491. */
  15492. getEmittedParticleSystems(): IParticleSystem[];
  15493. /**
  15494. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  15495. */
  15496. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  15497. _checkDelayState(): Mesh;
  15498. private _queueLoad(scene);
  15499. /**
  15500. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  15501. */
  15502. isInFrustum(frustumPlanes: Plane[]): boolean;
  15503. /**
  15504. * Sets the mesh material by the material or multiMaterial `id` property.
  15505. * The material `id` is a string identifying the material or the multiMaterial.
  15506. * This method returns the Mesh.
  15507. */
  15508. setMaterialByID(id: string): Mesh;
  15509. /**
  15510. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  15511. */
  15512. getAnimatables(): IAnimatable[];
  15513. /**
  15514. * Modifies the mesh geometry according to the passed transformation matrix.
  15515. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  15516. * The mesh normals are modified accordingly the same transformation.
  15517. * tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  15518. * Note that, under the hood, this method sets a new VertexBuffer each call.
  15519. * Returns the Mesh.
  15520. */
  15521. bakeTransformIntoVertices(transform: Matrix): Mesh;
  15522. /**
  15523. * Modifies the mesh geometry according to its own current World Matrix.
  15524. * The mesh World Matrix is then reset.
  15525. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  15526. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  15527. * Note that, under the hood, this method sets a new VertexBuffer each call.
  15528. * Returns the Mesh.
  15529. */
  15530. bakeCurrentTransformIntoVertices(): Mesh;
  15531. readonly _positions: Nullable<Vector3[]>;
  15532. _resetPointsArrayCache(): Mesh;
  15533. _generatePointsArray(): boolean;
  15534. /**
  15535. * Returns a new Mesh object generated from the current mesh properties.
  15536. * This method must not get confused with createInstance().
  15537. * The parameter `name` is a string, the name given to the new mesh.
  15538. * The optional parameter `newParent` can be any Node object (default `null`).
  15539. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  15540. * The parameter `clonePhysicsImpostor` (default `true`) allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any.
  15541. */
  15542. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  15543. /**
  15544. * Releases resources associated with this mesh.
  15545. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15546. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15547. */
  15548. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15549. /**
  15550. * Modifies the mesh geometry according to a displacement map.
  15551. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  15552. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  15553. * This method returns nothing.
  15554. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  15555. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  15556. * The parameter `onSuccess` is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  15557. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  15558. * The parameter `uvScale` is an optional vector2 used to scale UV.
  15559. *
  15560. * Returns the Mesh.
  15561. */
  15562. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  15563. /**
  15564. * Modifies the mesh geometry according to a displacementMap buffer.
  15565. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  15566. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  15567. * This method returns nothing.
  15568. * The parameter `buffer` is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  15569. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  15570. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  15571. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  15572. * The parameter `uvScale` is an optional vector2 used to scale UV.
  15573. *
  15574. * Returns the Mesh.
  15575. */
  15576. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  15577. /**
  15578. * Modify the mesh to get a flat shading rendering.
  15579. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  15580. * This method returns the Mesh.
  15581. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  15582. */
  15583. convertToFlatShadedMesh(): Mesh;
  15584. /**
  15585. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  15586. * In other words, more vertices, no more indices and a single bigger VBO.
  15587. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  15588. * Returns the Mesh.
  15589. */
  15590. convertToUnIndexedMesh(): Mesh;
  15591. /**
  15592. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  15593. * This method returns the Mesh.
  15594. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  15595. */
  15596. flipFaces(flipNormals?: boolean): Mesh;
  15597. /**
  15598. * Creates a new InstancedMesh object from the mesh model.
  15599. * An instance shares the same properties and the same material than its model.
  15600. * Only these properties of each instance can then be set individually :
  15601. * - position
  15602. * - rotation
  15603. * - rotationQuaternion
  15604. * - setPivotMatrix
  15605. * - scaling
  15606. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  15607. * Warning : this method is not supported for Line mesh and LineSystem
  15608. */
  15609. createInstance(name: string): InstancedMesh;
  15610. /**
  15611. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  15612. * After this call, all the mesh instances have the same submeshes than the current mesh.
  15613. * This method returns the Mesh.
  15614. */
  15615. synchronizeInstances(): Mesh;
  15616. /**
  15617. * Simplify the mesh according to the given array of settings.
  15618. * Function will return immediately and will simplify async. It returns the Mesh.
  15619. * @param settings a collection of simplification settings.
  15620. * @param parallelProcessing should all levels calculate parallel or one after the other.
  15621. * @param type the type of simplification to run.
  15622. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  15623. */
  15624. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  15625. /**
  15626. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  15627. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  15628. * This should be used together with the simplification to avoid disappearing triangles.
  15629. * Returns the Mesh.
  15630. * @param successCallback an optional success callback to be called after the optimization finished.
  15631. */
  15632. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  15633. serialize(serializationObject: any): void;
  15634. _syncGeometryWithMorphTargetManager(): void;
  15635. /**
  15636. * Returns a new Mesh object parsed from the source provided.
  15637. * The parameter `parsedMesh` is the source.
  15638. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15639. */
  15640. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  15641. /**
  15642. * Creates a ribbon mesh.
  15643. * Please consider using the same method from the MeshBuilder class instead.
  15644. * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  15645. *
  15646. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  15647. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  15648. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  15649. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  15650. * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path.
  15651. * It's the offset to join together the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11.
  15652. * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
  15653. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15654. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15655. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15656. */
  15657. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15658. /**
  15659. * Creates a plane polygonal mesh. By default, this is a disc.
  15660. * Please consider using the same method from the MeshBuilder class instead.
  15661. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  15662. * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc.
  15663. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15664. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15665. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15666. */
  15667. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  15668. /**
  15669. * Creates a box mesh.
  15670. * Please consider using the same method from the MeshBuilder class instead.
  15671. * The parameter `size` sets the size (float) of each box side (default 1).
  15672. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15673. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15674. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15675. */
  15676. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  15677. /**
  15678. * Creates a sphere mesh.
  15679. * Please consider using the same method from the MeshBuilder class instead.
  15680. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  15681. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  15682. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15683. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15684. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15685. */
  15686. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15687. /**
  15688. * Creates a cylinder or a cone mesh.
  15689. * Please consider using the same method from the MeshBuilder class instead.
  15690. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  15691. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  15692. * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  15693. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  15694. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  15695. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15696. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15697. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15698. */
  15699. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  15700. /**
  15701. * Creates a torus mesh.
  15702. * Please consider using the same method from the MeshBuilder class instead.
  15703. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  15704. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  15705. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  15706. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15707. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15708. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15709. */
  15710. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15711. /**
  15712. * Creates a torus knot mesh.
  15713. * Please consider using the same method from the MeshBuilder class instead.
  15714. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  15715. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  15716. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  15717. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  15718. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15719. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15720. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15721. */
  15722. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15723. /**
  15724. * Creates a line mesh.
  15725. * Please consider using the same method from the MeshBuilder class instead.
  15726. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter.
  15727. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  15728. * The parameter `points` is an array successive Vector3.
  15729. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  15730. * When updating an instance, remember that only point positions can change, not the number of points.
  15731. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15732. */
  15733. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  15734. /**
  15735. * Creates a dashed line mesh.
  15736. * Please consider using the same method from the MeshBuilder class instead.
  15737. * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter.
  15738. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  15739. * The parameter `points` is an array successive Vector3.
  15740. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  15741. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  15742. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  15743. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  15744. * When updating an instance, remember that only point positions can change, not the number of points.
  15745. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15746. */
  15747. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  15748. /**
  15749. * Creates a polygon mesh.
  15750. * Please consider using the same method from the MeshBuilder class instead.
  15751. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  15752. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  15753. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15754. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15755. * Remember you can only change the shape positions, not their number when updating a polygon.
  15756. */
  15757. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  15758. /**
  15759. * Creates an extruded polygon mesh, with depth in the Y direction.
  15760. * Please consider using the same method from the MeshBuilder class instead.
  15761. */
  15762. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  15763. /**
  15764. * Creates an extruded shape mesh.
  15765. * The extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  15766. * Please consider using the same method from the MeshBuilder class instead.
  15767. *
  15768. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  15769. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be
  15770. * extruded along the Z axis.
  15771. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  15772. * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  15773. * The parameter `scale` (float, default 1) is the value to scale the shape.
  15774. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  15775. * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  15776. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  15777. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15778. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15779. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15780. */
  15781. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15782. /**
  15783. * Creates an custom extruded shape mesh.
  15784. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  15785. * Please consider using the same method from the MeshBuilder class instead.
  15786. *
  15787. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  15788. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be
  15789. * extruded along the Z axis.
  15790. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  15791. * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path
  15792. * and the distance of this point from the begining of the path :
  15793. * ```javascript
  15794. * var rotationFunction = function(i, distance) {
  15795. * // do things
  15796. * return rotationValue; }
  15797. * ```
  15798. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  15799. * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path
  15800. * and the distance of this point from the begining of the path :
  15801. * ```javascript
  15802. * var scaleFunction = function(i, distance) {
  15803. * // do things
  15804. * return scaleValue;}
  15805. * ```
  15806. * It must returns a float value that will be the scale value applied to the shape on each path point.
  15807. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  15808. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  15809. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  15810. * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  15811. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  15812. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15813. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15814. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15815. */
  15816. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15817. /**
  15818. * Creates lathe mesh.
  15819. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15820. * Please consider using the same method from the MeshBuilder class instead.
  15821. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be
  15822. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  15823. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  15824. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  15825. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15826. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15827. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15828. */
  15829. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15830. /**
  15831. * Creates a plane mesh.
  15832. * Please consider using the same method from the MeshBuilder class instead.
  15833. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  15834. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15835. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15836. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15837. */
  15838. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15839. /**
  15840. * Creates a ground mesh.
  15841. * Please consider using the same method from the MeshBuilder class instead.
  15842. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  15843. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  15844. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15845. */
  15846. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15847. /**
  15848. * Creates a tiled ground mesh.
  15849. * Please consider using the same method from the MeshBuilder class instead.
  15850. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  15851. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  15852. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  15853. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  15854. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  15855. * numbers of subdivisions on the ground width and height of each tile.
  15856. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15857. */
  15858. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15859. w: number;
  15860. h: number;
  15861. }, precision: {
  15862. w: number;
  15863. h: number;
  15864. }, scene: Scene, updatable?: boolean): Mesh;
  15865. /**
  15866. * Creates a ground mesh from a height map.
  15867. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  15868. * Please consider using the same method from the MeshBuilder class instead.
  15869. * The parameter `url` sets the URL of the height map image resource.
  15870. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  15871. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  15872. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  15873. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  15874. * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  15875. * This function is passed the newly built mesh :
  15876. * ```javascript
  15877. * function(mesh) { // do things
  15878. * return; }
  15879. * ```
  15880. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15881. */
  15882. 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;
  15883. /**
  15884. * Creates a tube mesh.
  15885. * The tube is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  15886. * Please consider using the same method from the MeshBuilder class instead.
  15887. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  15888. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  15889. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  15890. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  15891. * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path.
  15892. * It must return a radius value (positive float) :
  15893. * ```javascript
  15894. * var radiusFunction = function(i, distance) {
  15895. * // do things
  15896. * return radius; }
  15897. * ```
  15898. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  15899. * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#tube
  15900. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15901. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15902. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15903. */
  15904. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15905. (i: number, distance: number): number;
  15906. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15907. /**
  15908. * Creates a polyhedron mesh.
  15909. * Please consider using the same method from the MeshBuilder class instead.
  15910. * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial
  15911. * to choose the wanted type.
  15912. * The parameter `size` (positive float, default 1) sets the polygon size.
  15913. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  15914. * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`.
  15915. * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  15916. * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`).
  15917. * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  15918. * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored.
  15919. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15920. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15921. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15922. */
  15923. static CreatePolyhedron(name: string, options: {
  15924. type?: number;
  15925. size?: number;
  15926. sizeX?: number;
  15927. sizeY?: number;
  15928. sizeZ?: number;
  15929. custom?: any;
  15930. faceUV?: Vector4[];
  15931. faceColors?: Color4[];
  15932. updatable?: boolean;
  15933. sideOrientation?: number;
  15934. }, scene: Scene): Mesh;
  15935. /**
  15936. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  15937. * Please consider using the same method from the MeshBuilder class instead.
  15938. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  15939. * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`).
  15940. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  15941. * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface.
  15942. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15943. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15944. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15945. */
  15946. static CreateIcoSphere(name: string, options: {
  15947. radius?: number;
  15948. flat?: boolean;
  15949. subdivisions?: number;
  15950. sideOrientation?: number;
  15951. updatable?: boolean;
  15952. }, scene: Scene): Mesh;
  15953. /**
  15954. * Creates a decal mesh.
  15955. * Please consider using the same method from the MeshBuilder class instead.
  15956. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal.
  15957. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  15958. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  15959. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  15960. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  15961. */
  15962. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15963. /**
  15964. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15965. */
  15966. setPositionsForCPUSkinning(): Float32Array;
  15967. /**
  15968. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15969. */
  15970. setNormalsForCPUSkinning(): Float32Array;
  15971. /**
  15972. * Updates the vertex buffer by applying transformation from the bones.
  15973. * Returns the Mesh.
  15974. *
  15975. * @param {skeleton} skeleton to apply
  15976. */
  15977. applySkeleton(skeleton: Skeleton): Mesh;
  15978. /**
  15979. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  15980. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  15981. */
  15982. static MinMax(meshes: AbstractMesh[]): {
  15983. min: Vector3;
  15984. max: Vector3;
  15985. };
  15986. /**
  15987. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  15988. */
  15989. static Center(meshesOrMinMaxVector: {
  15990. min: Vector3;
  15991. max: Vector3;
  15992. } | AbstractMesh[]): Vector3;
  15993. /**
  15994. * Merge the array of meshes into a single mesh for performance reasons.
  15995. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  15996. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  15997. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  15998. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15999. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  16000. */
  16001. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  16002. }
  16003. }
  16004. declare module BABYLON {
  16005. interface IGetSetVerticesData {
  16006. isVerticesDataPresent(kind: string): boolean;
  16007. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  16008. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  16009. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  16010. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  16011. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  16012. }
  16013. class VertexData {
  16014. positions: Nullable<FloatArray>;
  16015. normals: Nullable<FloatArray>;
  16016. tangents: Nullable<FloatArray>;
  16017. uvs: Nullable<FloatArray>;
  16018. uvs2: Nullable<FloatArray>;
  16019. uvs3: Nullable<FloatArray>;
  16020. uvs4: Nullable<FloatArray>;
  16021. uvs5: Nullable<FloatArray>;
  16022. uvs6: Nullable<FloatArray>;
  16023. colors: Nullable<FloatArray>;
  16024. matricesIndices: Nullable<FloatArray>;
  16025. matricesWeights: Nullable<FloatArray>;
  16026. matricesIndicesExtra: Nullable<FloatArray>;
  16027. matricesWeightsExtra: Nullable<FloatArray>;
  16028. indices: Nullable<IndicesArray>;
  16029. set(data: FloatArray, kind: string): void;
  16030. /**
  16031. * Associates the vertexData to the passed Mesh.
  16032. * Sets it as updatable or not (default `false`).
  16033. * Returns the VertexData.
  16034. */
  16035. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  16036. /**
  16037. * Associates the vertexData to the passed Geometry.
  16038. * Sets it as updatable or not (default `false`).
  16039. * Returns the VertexData.
  16040. */
  16041. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  16042. /**
  16043. * Updates the associated mesh.
  16044. * Returns the VertexData.
  16045. */
  16046. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  16047. /**
  16048. * Updates the associated geometry.
  16049. * Returns the VertexData.
  16050. */
  16051. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  16052. private _applyTo(meshOrGeometry, updatable?);
  16053. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  16054. /**
  16055. * Transforms each position and each normal of the vertexData according to the passed Matrix.
  16056. * Returns the VertexData.
  16057. */
  16058. transform(matrix: Matrix): VertexData;
  16059. /**
  16060. * Merges the passed VertexData into the current one.
  16061. * Returns the modified VertexData.
  16062. */
  16063. merge(other: VertexData): VertexData;
  16064. private _mergeElement(source, other);
  16065. private _validate();
  16066. /**
  16067. * Serializes the VertexData.
  16068. * Returns a serialized object.
  16069. */
  16070. serialize(): any;
  16071. /**
  16072. * Returns the object VertexData associated to the passed mesh.
  16073. */
  16074. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  16075. /**
  16076. * Returns the object VertexData associated to the passed geometry.
  16077. */
  16078. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  16079. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  16080. /**
  16081. * Creates the vertexData of the Ribbon.
  16082. */
  16083. static CreateRibbon(options: {
  16084. pathArray: Vector3[][];
  16085. closeArray?: boolean;
  16086. closePath?: boolean;
  16087. offset?: number;
  16088. sideOrientation?: number;
  16089. frontUVs?: Vector4;
  16090. backUVs?: Vector4;
  16091. invertUV?: boolean;
  16092. uvs?: Vector2[];
  16093. colors?: Color4[];
  16094. }): VertexData;
  16095. /**
  16096. * Creates the VertexData of the Box.
  16097. */
  16098. static CreateBox(options: {
  16099. size?: number;
  16100. width?: number;
  16101. height?: number;
  16102. depth?: number;
  16103. faceUV?: Vector4[];
  16104. faceColors?: Color4[];
  16105. sideOrientation?: number;
  16106. frontUVs?: Vector4;
  16107. backUVs?: Vector4;
  16108. }): VertexData;
  16109. /**
  16110. * Creates the VertexData of the Sphere.
  16111. */
  16112. static CreateSphere(options: {
  16113. segments?: number;
  16114. diameter?: number;
  16115. diameterX?: number;
  16116. diameterY?: number;
  16117. diameterZ?: number;
  16118. arc?: number;
  16119. slice?: number;
  16120. sideOrientation?: number;
  16121. frontUVs?: Vector4;
  16122. backUVs?: Vector4;
  16123. }): VertexData;
  16124. /**
  16125. * Creates the VertexData of the Cylinder or Cone.
  16126. */
  16127. static CreateCylinder(options: {
  16128. height?: number;
  16129. diameterTop?: number;
  16130. diameterBottom?: number;
  16131. diameter?: number;
  16132. tessellation?: number;
  16133. subdivisions?: number;
  16134. arc?: number;
  16135. faceColors?: Color4[];
  16136. faceUV?: Vector4[];
  16137. hasRings?: boolean;
  16138. enclose?: boolean;
  16139. sideOrientation?: number;
  16140. frontUVs?: Vector4;
  16141. backUVs?: Vector4;
  16142. }): VertexData;
  16143. /**
  16144. * Creates the VertexData of the Torus.
  16145. */
  16146. static CreateTorus(options: {
  16147. diameter?: number;
  16148. thickness?: number;
  16149. tessellation?: number;
  16150. sideOrientation?: number;
  16151. frontUVs?: Vector4;
  16152. backUVs?: Vector4;
  16153. }): VertexData;
  16154. /**
  16155. * Creates the VertexData of the LineSystem.
  16156. */
  16157. static CreateLineSystem(options: {
  16158. lines: Vector3[][];
  16159. colors?: Nullable<Color4[][]>;
  16160. }): VertexData;
  16161. /**
  16162. * Create the VertexData of the DashedLines.
  16163. */
  16164. static CreateDashedLines(options: {
  16165. points: Vector3[];
  16166. dashSize?: number;
  16167. gapSize?: number;
  16168. dashNb?: number;
  16169. }): VertexData;
  16170. /**
  16171. * Creates the VertexData of the Ground.
  16172. */
  16173. static CreateGround(options: {
  16174. width?: number;
  16175. height?: number;
  16176. subdivisions?: number;
  16177. subdivisionsX?: number;
  16178. subdivisionsY?: number;
  16179. }): VertexData;
  16180. /**
  16181. * Creates the VertexData of the TiledGround.
  16182. */
  16183. static CreateTiledGround(options: {
  16184. xmin: number;
  16185. zmin: number;
  16186. xmax: number;
  16187. zmax: number;
  16188. subdivisions?: {
  16189. w: number;
  16190. h: number;
  16191. };
  16192. precision?: {
  16193. w: number;
  16194. h: number;
  16195. };
  16196. }): VertexData;
  16197. /**
  16198. * Creates the VertexData of the Ground designed from a heightmap.
  16199. */
  16200. static CreateGroundFromHeightMap(options: {
  16201. width: number;
  16202. height: number;
  16203. subdivisions: number;
  16204. minHeight: number;
  16205. maxHeight: number;
  16206. colorFilter: Color3;
  16207. buffer: Uint8Array;
  16208. bufferWidth: number;
  16209. bufferHeight: number;
  16210. }): VertexData;
  16211. /**
  16212. * Creates the VertexData of the Plane.
  16213. */
  16214. static CreatePlane(options: {
  16215. size?: number;
  16216. width?: number;
  16217. height?: number;
  16218. sideOrientation?: number;
  16219. frontUVs?: Vector4;
  16220. backUVs?: Vector4;
  16221. }): VertexData;
  16222. /**
  16223. * Creates the VertexData of the Disc or regular Polygon.
  16224. */
  16225. static CreateDisc(options: {
  16226. radius?: number;
  16227. tessellation?: number;
  16228. arc?: number;
  16229. sideOrientation?: number;
  16230. frontUVs?: Vector4;
  16231. backUVs?: Vector4;
  16232. }): VertexData;
  16233. /**
  16234. * Re-creates the VertexData of the Polygon for sideOrientation.
  16235. */
  16236. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  16237. /**
  16238. * Creates the VertexData of the IcoSphere.
  16239. */
  16240. static CreateIcoSphere(options: {
  16241. radius?: number;
  16242. radiusX?: number;
  16243. radiusY?: number;
  16244. radiusZ?: number;
  16245. flat?: boolean;
  16246. subdivisions?: number;
  16247. sideOrientation?: number;
  16248. frontUVs?: Vector4;
  16249. backUVs?: Vector4;
  16250. }): VertexData;
  16251. /**
  16252. * Creates the VertexData of the Polyhedron.
  16253. */
  16254. static CreatePolyhedron(options: {
  16255. type?: number;
  16256. size?: number;
  16257. sizeX?: number;
  16258. sizeY?: number;
  16259. sizeZ?: number;
  16260. custom?: any;
  16261. faceUV?: Vector4[];
  16262. faceColors?: Color4[];
  16263. flat?: boolean;
  16264. sideOrientation?: number;
  16265. frontUVs?: Vector4;
  16266. backUVs?: Vector4;
  16267. }): VertexData;
  16268. /**
  16269. * Creates the VertexData of the Torus Knot.
  16270. */
  16271. static CreateTorusKnot(options: {
  16272. radius?: number;
  16273. tube?: number;
  16274. radialSegments?: number;
  16275. tubularSegments?: number;
  16276. p?: number;
  16277. q?: number;
  16278. sideOrientation?: number;
  16279. frontUVs?: Vector4;
  16280. backUVs?: Vector4;
  16281. }): VertexData;
  16282. /**
  16283. * @param {any} - positions (number[] or Float32Array)
  16284. * @param {any} - indices (number[] or Uint16Array)
  16285. * @param {any} - normals (number[] or Float32Array)
  16286. * options (optional) :
  16287. * facetPositions : optional array of facet positions (vector3)
  16288. * facetNormals : optional array of facet normals (vector3)
  16289. * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  16290. * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  16291. * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  16292. * bbSize : optional bounding box size data, required for facetPartitioning computation
  16293. * bInfo : optional bounding info, required for facetPartitioning computation
  16294. * useRightHandedSystem: optional boolean to for right handed system computation
  16295. * depthSort : optional boolean to enable the facet depth sort computation
  16296. * distanceTo : optional Vector3 to compute the facet depth from this location
  16297. * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  16298. */
  16299. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  16300. facetNormals?: any;
  16301. facetPositions?: any;
  16302. facetPartitioning?: any;
  16303. ratio?: number;
  16304. bInfo?: any;
  16305. bbSize?: Vector3;
  16306. subDiv?: any;
  16307. useRightHandedSystem?: boolean;
  16308. depthSort?: boolean;
  16309. distanceTo?: Vector3;
  16310. depthSortedFacets?: any;
  16311. }): void;
  16312. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  16313. /**
  16314. * Creates a new VertexData from the imported parameters.
  16315. */
  16316. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  16317. }
  16318. }
  16319. declare module BABYLON {
  16320. class MeshBuilder {
  16321. private static updateSideOrientation(orientation?);
  16322. /**
  16323. * Creates a box mesh.
  16324. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  16325. * The parameter `size` sets the size (float) of each box side (default 1).
  16326. * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`).
  16327. * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements).
  16328. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  16329. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16330. * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4).
  16331. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16332. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16333. */
  16334. static CreateBox(name: string, options: {
  16335. size?: number;
  16336. width?: number;
  16337. height?: number;
  16338. depth?: number;
  16339. faceUV?: Vector4[];
  16340. faceColors?: Color4[];
  16341. sideOrientation?: number;
  16342. frontUVs?: Vector4;
  16343. backUVs?: Vector4;
  16344. updatable?: boolean;
  16345. }, scene?: Nullable<Scene>): Mesh;
  16346. /**
  16347. * Creates a sphere mesh.
  16348. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  16349. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  16350. * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value than `diameter`).
  16351. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  16352. * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  16353. * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude).
  16354. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16355. * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4).
  16356. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16357. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16358. */
  16359. static CreateSphere(name: string, options: {
  16360. segments?: number;
  16361. diameter?: number;
  16362. diameterX?: number;
  16363. diameterY?: number;
  16364. diameterZ?: number;
  16365. arc?: number;
  16366. slice?: number;
  16367. sideOrientation?: number;
  16368. frontUVs?: Vector4;
  16369. backUVs?: Vector4;
  16370. updatable?: boolean;
  16371. }, scene: any): Mesh;
  16372. /**
  16373. * Creates a plane polygonal mesh. By default, this is a disc.
  16374. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
  16375. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  16376. * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc.
  16377. * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  16378. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16379. * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4).
  16380. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16381. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16382. */
  16383. static CreateDisc(name: string, options: {
  16384. radius?: number;
  16385. tessellation?: number;
  16386. arc?: number;
  16387. updatable?: boolean;
  16388. sideOrientation?: number;
  16389. frontUVs?: Vector4;
  16390. backUVs?: Vector4;
  16391. }, scene?: Nullable<Scene>): Mesh;
  16392. /**
  16393. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  16394. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
  16395. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  16396. * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`).
  16397. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  16398. * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface.
  16399. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16400. * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4).
  16401. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16402. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16403. */
  16404. static CreateIcoSphere(name: string, options: {
  16405. radius?: number;
  16406. radiusX?: number;
  16407. radiusY?: number;
  16408. radiusZ?: number;
  16409. flat?: boolean;
  16410. subdivisions?: number;
  16411. sideOrientation?: number;
  16412. frontUVs?: Vector4;
  16413. backUVs?: Vector4;
  16414. updatable?: boolean;
  16415. }, scene: Scene): Mesh;
  16416. /**
  16417. * Creates a ribbon mesh.
  16418. * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  16419. *
  16420. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  16421. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  16422. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  16423. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  16424. * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path.
  16425. * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11.
  16426. * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
  16427. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16428. * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4).
  16429. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16430. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16431. * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones.
  16432. * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values.
  16433. * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that
  16434. * if you set `closePath` to `true`, there's one extra vertex per path in the geometry.
  16435. * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time.
  16436. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16437. */
  16438. static CreateRibbon(name: string, options: {
  16439. pathArray: Vector3[][];
  16440. closeArray?: boolean;
  16441. closePath?: boolean;
  16442. offset?: number;
  16443. updatable?: boolean;
  16444. sideOrientation?: number;
  16445. frontUVs?: Vector4;
  16446. backUVs?: Vector4;
  16447. instance?: Mesh;
  16448. invertUV?: boolean;
  16449. uvs?: Vector2[];
  16450. colors?: Color4[];
  16451. }, scene?: Nullable<Scene>): Mesh;
  16452. /**
  16453. * Creates a cylinder or a cone mesh.
  16454. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  16455. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  16456. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  16457. * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  16458. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  16459. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  16460. * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  16461. * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  16462. * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  16463. * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  16464. * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  16465. * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  16466. * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  16467. * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  16468. * If `enclose` is false, a ring surface is one element.
  16469. * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  16470. * Example how to set colors and textures on a sliced cylinder : http://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  16471. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16472. * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4).
  16473. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16474. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16475. */
  16476. static CreateCylinder(name: string, options: {
  16477. height?: number;
  16478. diameterTop?: number;
  16479. diameterBottom?: number;
  16480. diameter?: number;
  16481. tessellation?: number;
  16482. subdivisions?: number;
  16483. arc?: number;
  16484. faceColors?: Color4[];
  16485. faceUV?: Vector4[];
  16486. updatable?: boolean;
  16487. hasRings?: boolean;
  16488. enclose?: boolean;
  16489. sideOrientation?: number;
  16490. frontUVs?: Vector4;
  16491. backUVs?: Vector4;
  16492. }, scene: any): Mesh;
  16493. /**
  16494. * Creates a torus mesh.
  16495. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  16496. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  16497. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  16498. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  16499. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16500. * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4).
  16501. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16502. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16503. */
  16504. static CreateTorus(name: string, options: {
  16505. diameter?: number;
  16506. thickness?: number;
  16507. tessellation?: number;
  16508. updatable?: boolean;
  16509. sideOrientation?: number;
  16510. frontUVs?: Vector4;
  16511. backUVs?: Vector4;
  16512. }, scene: any): Mesh;
  16513. /**
  16514. * Creates a torus knot mesh.
  16515. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  16516. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  16517. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  16518. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  16519. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  16520. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16521. * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4).
  16522. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16523. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16524. */
  16525. static CreateTorusKnot(name: string, options: {
  16526. radius?: number;
  16527. tube?: number;
  16528. radialSegments?: number;
  16529. tubularSegments?: number;
  16530. p?: number;
  16531. q?: number;
  16532. updatable?: boolean;
  16533. sideOrientation?: number;
  16534. frontUVs?: Vector4;
  16535. backUVs?: Vector4;
  16536. }, scene: any): Mesh;
  16537. /**
  16538. * Creates a line system mesh.
  16539. * A line system is a pool of many lines gathered in a single mesh.
  16540. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#linesystem
  16541. * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter.
  16542. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function.
  16543. * The parameter `lines` is an array of lines, each line being an array of successive Vector3.
  16544. * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter. The way to update it is the same than for
  16545. * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point.
  16546. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need the alpha blending (faster).
  16547. * updating a simple Line mesh, you just need to update every line in the `lines` array : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  16548. * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines.
  16549. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16550. */
  16551. static CreateLineSystem(name: string, options: {
  16552. lines: Vector3[][];
  16553. updatable: boolean;
  16554. instance: Nullable<LinesMesh>;
  16555. colors?: Nullable<Color4[][]>;
  16556. useVertexAlpha?: boolean;
  16557. }, scene: Nullable<Scene>): LinesMesh;
  16558. /**
  16559. * Creates a line mesh.
  16560. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lines
  16561. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter.
  16562. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  16563. * The parameter `points` is an array successive Vector3.
  16564. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  16565. * The optional parameter `colors` is an array of successive Color4, one per line point.
  16566. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need alpha blending (faster).
  16567. * When updating an instance, remember that only point positions can change, not the number of points.
  16568. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16569. */
  16570. static CreateLines(name: string, options: {
  16571. points: Vector3[];
  16572. updatable: boolean;
  16573. instance: Nullable<LinesMesh>;
  16574. colors?: Color4[];
  16575. useVertexAlpha?: boolean;
  16576. }, scene?: Nullable<Scene>): LinesMesh;
  16577. /**
  16578. * Creates a dashed line mesh.
  16579. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#dashed-lines
  16580. * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter.
  16581. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  16582. * The parameter `points` is an array successive Vector3.
  16583. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  16584. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  16585. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  16586. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  16587. * When updating an instance, remember that only point positions can change, not the number of points.
  16588. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16589. */
  16590. static CreateDashedLines(name: string, options: {
  16591. points: Vector3[];
  16592. dashSize?: number;
  16593. gapSize?: number;
  16594. dashNb?: number;
  16595. updatable?: boolean;
  16596. instance?: LinesMesh;
  16597. }, scene?: Nullable<Scene>): LinesMesh;
  16598. /**
  16599. * Creates an extruded shape mesh.
  16600. * The extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  16601. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes
  16602. *
  16603. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  16604. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be
  16605. * extruded along the Z axis.
  16606. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  16607. * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  16608. * The parameter `scale` (float, default 1) is the value to scale the shape.
  16609. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  16610. * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  16611. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  16612. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16613. * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4).
  16614. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16615. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16616. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16617. */
  16618. static ExtrudeShape(name: string, options: {
  16619. shape: Vector3[];
  16620. path: Vector3[];
  16621. scale?: number;
  16622. rotation?: number;
  16623. cap?: number;
  16624. updatable?: boolean;
  16625. sideOrientation?: number;
  16626. frontUVs?: Vector4;
  16627. backUVs?: Vector4;
  16628. instance?: Mesh;
  16629. invertUV?: boolean;
  16630. }, scene?: Nullable<Scene>): Mesh;
  16631. /**
  16632. * Creates an custom extruded shape mesh.
  16633. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  16634. * tuto :http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#custom-extruded-shapes
  16635. *
  16636. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  16637. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be
  16638. * extruded along the Z axis.
  16639. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  16640. * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path
  16641. * and the distance of this point from the begining of the path :
  16642. * ```javascript
  16643. * var rotationFunction = function(i, distance) {
  16644. * // do things
  16645. * return rotationValue; }
  16646. * ```
  16647. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  16648. * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path
  16649. * and the distance of this point from the begining of the path :
  16650. * ```javascript
  16651. * var scaleFunction = function(i, distance) {
  16652. * // do things
  16653. * return scaleValue;}
  16654. * ```
  16655. * It must returns a float value that will be the scale value applied to the shape on each path point.
  16656. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  16657. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  16658. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  16659. * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  16660. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  16661. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16662. * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4).
  16663. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16664. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16665. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16666. */
  16667. static ExtrudeShapeCustom(name: string, options: {
  16668. shape: Vector3[];
  16669. path: Vector3[];
  16670. scaleFunction?: any;
  16671. rotationFunction?: any;
  16672. ribbonCloseArray?: boolean;
  16673. ribbonClosePath?: boolean;
  16674. cap?: number;
  16675. updatable?: boolean;
  16676. sideOrientation?: number;
  16677. frontUVs?: Vector4;
  16678. backUVs?: Vector4;
  16679. instance?: Mesh;
  16680. invertUV?: boolean;
  16681. }, scene: Scene): Mesh;
  16682. /**
  16683. * Creates lathe mesh.
  16684. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  16685. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lathe
  16686. *
  16687. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be
  16688. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  16689. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  16690. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  16691. * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape.
  16692. * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc".
  16693. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  16694. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16695. * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4).
  16696. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16697. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16698. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16699. */
  16700. static CreateLathe(name: string, options: {
  16701. shape: Vector3[];
  16702. radius?: number;
  16703. tessellation?: number;
  16704. arc?: number;
  16705. closed?: boolean;
  16706. updatable?: boolean;
  16707. sideOrientation?: number;
  16708. frontUVs?: Vector4;
  16709. backUVs?: Vector4;
  16710. cap?: number;
  16711. invertUV?: boolean;
  16712. }, scene: Scene): Mesh;
  16713. /**
  16714. * Creates a plane mesh.
  16715. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  16716. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  16717. * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`).
  16718. * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane.
  16719. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16720. * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4).
  16721. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16722. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16723. */
  16724. static CreatePlane(name: string, options: {
  16725. size?: number;
  16726. width?: number;
  16727. height?: number;
  16728. sideOrientation?: number;
  16729. frontUVs?: Vector4;
  16730. backUVs?: Vector4;
  16731. updatable?: boolean;
  16732. sourcePlane?: Plane;
  16733. }, scene: Scene): Mesh;
  16734. /**
  16735. * Creates a ground mesh.
  16736. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  16737. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  16738. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  16739. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16740. */
  16741. static CreateGround(name: string, options: {
  16742. width?: number;
  16743. height?: number;
  16744. subdivisions?: number;
  16745. subdivisionsX?: number;
  16746. subdivisionsY?: number;
  16747. updatable?: boolean;
  16748. }, scene: any): Mesh;
  16749. /**
  16750. * Creates a tiled ground mesh.
  16751. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  16752. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  16753. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  16754. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  16755. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  16756. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  16757. * numbers of subdivisions on the ground width and height of each tile.
  16758. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16759. */
  16760. static CreateTiledGround(name: string, options: {
  16761. xmin: number;
  16762. zmin: number;
  16763. xmax: number;
  16764. zmax: number;
  16765. subdivisions?: {
  16766. w: number;
  16767. h: number;
  16768. };
  16769. precision?: {
  16770. w: number;
  16771. h: number;
  16772. };
  16773. updatable?: boolean;
  16774. }, scene: Scene): Mesh;
  16775. /**
  16776. * Creates a ground mesh from a height map.
  16777. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  16778. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  16779. * The parameter `url` sets the URL of the height map image resource.
  16780. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  16781. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  16782. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  16783. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  16784. * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  16785. * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  16786. * This function is passed the newly built mesh :
  16787. * ```javascript
  16788. * function(mesh) { // do things
  16789. * return; }
  16790. * ```
  16791. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16792. */
  16793. static CreateGroundFromHeightMap(name: string, url: string, options: {
  16794. width?: number;
  16795. height?: number;
  16796. subdivisions?: number;
  16797. minHeight?: number;
  16798. maxHeight?: number;
  16799. colorFilter?: Color3;
  16800. updatable?: boolean;
  16801. onReady?: (mesh: GroundMesh) => void;
  16802. }, scene: Scene): GroundMesh;
  16803. /**
  16804. * Creates a polygon mesh.
  16805. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  16806. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  16807. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16808. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16809. * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4).
  16810. * Remember you can only change the shape positions, not their number when updating a polygon.
  16811. */
  16812. static CreatePolygon(name: string, options: {
  16813. shape: Vector3[];
  16814. holes?: Vector3[][];
  16815. depth?: number;
  16816. faceUV?: Vector4[];
  16817. faceColors?: Color4[];
  16818. updatable?: boolean;
  16819. sideOrientation?: number;
  16820. frontUVs?: Vector4;
  16821. backUVs?: Vector4;
  16822. }, scene: Scene): Mesh;
  16823. /**
  16824. * Creates an extruded polygon mesh, with depth in the Y direction.
  16825. * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements).
  16826. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  16827. */
  16828. static ExtrudePolygon(name: string, options: {
  16829. shape: Vector3[];
  16830. holes?: Vector3[][];
  16831. depth?: number;
  16832. faceUV?: Vector4[];
  16833. faceColors?: Color4[];
  16834. updatable?: boolean;
  16835. sideOrientation?: number;
  16836. frontUVs?: Vector4;
  16837. backUVs?: Vector4;
  16838. }, scene: Scene): Mesh;
  16839. /**
  16840. * Creates a tube mesh.
  16841. * The tube is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  16842. *
  16843. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  16844. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  16845. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  16846. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  16847. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  16848. * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path.
  16849. * It must return a radius value (positive float) :
  16850. * ```javascript
  16851. * var radiusFunction = function(i, distance) {
  16852. * // do things
  16853. * return radius; }
  16854. * ```
  16855. * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc.
  16856. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  16857. * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#tube
  16858. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16859. * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4).
  16860. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16861. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16862. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16863. */
  16864. static CreateTube(name: string, options: {
  16865. path: Vector3[];
  16866. radius?: number;
  16867. tessellation?: number;
  16868. radiusFunction?: {
  16869. (i: number, distance: number): number;
  16870. };
  16871. cap?: number;
  16872. arc?: number;
  16873. updatable?: boolean;
  16874. sideOrientation?: number;
  16875. frontUVs?: Vector4;
  16876. backUVs?: Vector4;
  16877. instance?: Mesh;
  16878. invertUV?: boolean;
  16879. }, scene: Scene): Mesh;
  16880. /**
  16881. * Creates a polyhedron mesh.
  16882. *
  16883. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#polyhedron
  16884. * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial
  16885. * to choose the wanted type.
  16886. * The parameter `size` (positive float, default 1) sets the polygon size.
  16887. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  16888. * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`.
  16889. * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  16890. * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`).
  16891. * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  16892. * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored.
  16893. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16894. * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4).
  16895. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16896. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16897. */
  16898. static CreatePolyhedron(name: string, options: {
  16899. type?: number;
  16900. size?: number;
  16901. sizeX?: number;
  16902. sizeY?: number;
  16903. sizeZ?: number;
  16904. custom?: any;
  16905. faceUV?: Vector4[];
  16906. faceColors?: Color4[];
  16907. flat?: boolean;
  16908. updatable?: boolean;
  16909. sideOrientation?: number;
  16910. frontUVs?: Vector4;
  16911. backUVs?: Vector4;
  16912. }, scene: Scene): Mesh;
  16913. /**
  16914. * Creates a decal mesh.
  16915. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#decals
  16916. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal.
  16917. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  16918. * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates.
  16919. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  16920. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  16921. */
  16922. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  16923. position?: Vector3;
  16924. normal?: Vector3;
  16925. size?: Vector3;
  16926. angle?: number;
  16927. }): Mesh;
  16928. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  16929. }
  16930. }
  16931. declare module BABYLON {
  16932. class MeshLODLevel {
  16933. distance: number;
  16934. mesh: Mesh;
  16935. constructor(distance: number, mesh: Mesh);
  16936. }
  16937. }
  16938. declare module BABYLON {
  16939. /**
  16940. * A simplifier interface for future simplification implementations.
  16941. */
  16942. interface ISimplifier {
  16943. /**
  16944. * Simplification of a given mesh according to the given settings.
  16945. * Since this requires computation, it is assumed that the function runs async.
  16946. * @param settings The settings of the simplification, including quality and distance
  16947. * @param successCallback A callback that will be called after the mesh was simplified.
  16948. * @param errorCallback in case of an error, this callback will be called. optional.
  16949. */
  16950. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  16951. }
  16952. /**
  16953. * Expected simplification settings.
  16954. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  16955. */
  16956. interface ISimplificationSettings {
  16957. quality: number;
  16958. distance: number;
  16959. optimizeMesh?: boolean;
  16960. }
  16961. class SimplificationSettings implements ISimplificationSettings {
  16962. quality: number;
  16963. distance: number;
  16964. optimizeMesh: boolean | undefined;
  16965. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  16966. }
  16967. interface ISimplificationTask {
  16968. settings: Array<ISimplificationSettings>;
  16969. simplificationType: SimplificationType;
  16970. mesh: Mesh;
  16971. successCallback?: () => void;
  16972. parallelProcessing: boolean;
  16973. }
  16974. class SimplificationQueue {
  16975. private _simplificationArray;
  16976. running: boolean;
  16977. constructor();
  16978. addTask(task: ISimplificationTask): void;
  16979. executeNext(): void;
  16980. runSimplification(task: ISimplificationTask): void;
  16981. private getSimplifier(task);
  16982. }
  16983. /**
  16984. * The implemented types of simplification.
  16985. * At the moment only Quadratic Error Decimation is implemented.
  16986. */
  16987. enum SimplificationType {
  16988. QUADRATIC = 0,
  16989. }
  16990. class DecimationTriangle {
  16991. vertices: Array<DecimationVertex>;
  16992. normal: Vector3;
  16993. error: Array<number>;
  16994. deleted: boolean;
  16995. isDirty: boolean;
  16996. borderFactor: number;
  16997. deletePending: boolean;
  16998. originalOffset: number;
  16999. constructor(vertices: Array<DecimationVertex>);
  17000. }
  17001. class DecimationVertex {
  17002. position: Vector3;
  17003. id: number;
  17004. q: QuadraticMatrix;
  17005. isBorder: boolean;
  17006. triangleStart: number;
  17007. triangleCount: number;
  17008. originalOffsets: Array<number>;
  17009. constructor(position: Vector3, id: number);
  17010. updatePosition(newPosition: Vector3): void;
  17011. }
  17012. class QuadraticMatrix {
  17013. data: Array<number>;
  17014. constructor(data?: Array<number>);
  17015. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  17016. addInPlace(matrix: QuadraticMatrix): void;
  17017. addArrayInPlace(data: Array<number>): void;
  17018. add(matrix: QuadraticMatrix): QuadraticMatrix;
  17019. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  17020. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  17021. }
  17022. class Reference {
  17023. vertexId: number;
  17024. triangleId: number;
  17025. constructor(vertexId: number, triangleId: number);
  17026. }
  17027. /**
  17028. * An implementation of the Quadratic Error simplification algorithm.
  17029. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  17030. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  17031. * @author RaananW
  17032. */
  17033. class QuadraticErrorSimplification implements ISimplifier {
  17034. private _mesh;
  17035. private triangles;
  17036. private vertices;
  17037. private references;
  17038. private _reconstructedMesh;
  17039. syncIterations: number;
  17040. aggressiveness: number;
  17041. decimationIterations: number;
  17042. boundingBoxEpsilon: number;
  17043. constructor(_mesh: Mesh);
  17044. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  17045. private runDecimation(settings, submeshIndex, successCallback);
  17046. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  17047. private init(callback);
  17048. private reconstructMesh(submeshIndex);
  17049. private initDecimatedMesh();
  17050. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  17051. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  17052. private identifyBorder();
  17053. private updateMesh(identifyBorders?);
  17054. private vertexError(q, point);
  17055. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  17056. }
  17057. }
  17058. declare module BABYLON {
  17059. class Polygon {
  17060. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  17061. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  17062. static Parse(input: string): Vector2[];
  17063. static StartingAt(x: number, y: number): Path2;
  17064. }
  17065. class PolygonMeshBuilder {
  17066. private _points;
  17067. private _outlinepoints;
  17068. private _holes;
  17069. private _name;
  17070. private _scene;
  17071. private _epoints;
  17072. private _eholes;
  17073. private _addToepoint(points);
  17074. constructor(name: string, contours: Path2, scene: Scene);
  17075. constructor(name: string, contours: Vector2[], scene: Scene);
  17076. addHole(hole: Vector2[]): PolygonMeshBuilder;
  17077. build(updatable?: boolean, depth?: number): Mesh;
  17078. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  17079. }
  17080. }
  17081. declare module BABYLON {
  17082. class BaseSubMesh {
  17083. _materialDefines: Nullable<MaterialDefines>;
  17084. _materialEffect: Nullable<Effect>;
  17085. readonly effect: Nullable<Effect>;
  17086. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  17087. }
  17088. class SubMesh extends BaseSubMesh implements ICullable {
  17089. materialIndex: number;
  17090. verticesStart: number;
  17091. verticesCount: number;
  17092. indexStart: number;
  17093. indexCount: number;
  17094. linesIndexCount: number;
  17095. private _mesh;
  17096. private _renderingMesh;
  17097. private _boundingInfo;
  17098. private _linesIndexBuffer;
  17099. _lastColliderWorldVertices: Nullable<Vector3[]>;
  17100. _trianglePlanes: Plane[];
  17101. _lastColliderTransformMatrix: Matrix;
  17102. _renderId: number;
  17103. _alphaIndex: number;
  17104. _distanceToCamera: number;
  17105. _id: number;
  17106. private _currentMaterial;
  17107. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  17108. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  17109. readonly IsGlobal: boolean;
  17110. /**
  17111. * Returns the submesh BoudingInfo object.
  17112. */
  17113. getBoundingInfo(): BoundingInfo;
  17114. /**
  17115. * Sets the submesh BoundingInfo.
  17116. * Return the SubMesh.
  17117. */
  17118. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  17119. /**
  17120. * Returns the mesh of the current submesh.
  17121. */
  17122. getMesh(): AbstractMesh;
  17123. /**
  17124. * Returns the rendering mesh of the submesh.
  17125. */
  17126. getRenderingMesh(): Mesh;
  17127. /**
  17128. * Returns the submesh material.
  17129. */
  17130. getMaterial(): Nullable<Material>;
  17131. /**
  17132. * Sets a new updated BoundingInfo object to the submesh.
  17133. * Returns the SubMesh.
  17134. */
  17135. refreshBoundingInfo(): SubMesh;
  17136. _checkCollision(collider: Collider): boolean;
  17137. /**
  17138. * Updates the submesh BoundingInfo.
  17139. * Returns the Submesh.
  17140. */
  17141. updateBoundingInfo(world: Matrix): SubMesh;
  17142. /**
  17143. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  17144. * Boolean returned.
  17145. */
  17146. isInFrustum(frustumPlanes: Plane[]): boolean;
  17147. /**
  17148. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  17149. * Boolean returned.
  17150. */
  17151. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  17152. /**
  17153. * Renders the submesh.
  17154. * Returns it.
  17155. */
  17156. render(enableAlphaMode: boolean): SubMesh;
  17157. /**
  17158. * Returns a new Index Buffer.
  17159. * Type returned : WebGLBuffer.
  17160. */
  17161. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  17162. /**
  17163. * True is the passed Ray intersects the submesh bounding box.
  17164. * Boolean returned.
  17165. */
  17166. canIntersects(ray: Ray): boolean;
  17167. /**
  17168. * Returns an object IntersectionInfo.
  17169. */
  17170. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  17171. _rebuild(): void;
  17172. /**
  17173. * Creates a new Submesh from the passed Mesh.
  17174. */
  17175. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  17176. /**
  17177. * Disposes the Submesh.
  17178. * Returns nothing.
  17179. */
  17180. dispose(): void;
  17181. /**
  17182. * Creates a new Submesh from the passed parameters :
  17183. * - materialIndex (integer) : the index of the main mesh material.
  17184. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  17185. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  17186. * - mesh (Mesh) : the main mesh to create the submesh from.
  17187. * - renderingMesh (optional Mesh) : rendering mesh.
  17188. */
  17189. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  17190. }
  17191. }
  17192. declare module BABYLON {
  17193. class TransformNode extends Node {
  17194. static BILLBOARDMODE_NONE: number;
  17195. static BILLBOARDMODE_X: number;
  17196. static BILLBOARDMODE_Y: number;
  17197. static BILLBOARDMODE_Z: number;
  17198. static BILLBOARDMODE_ALL: number;
  17199. private _rotation;
  17200. private _rotationQuaternion;
  17201. protected _scaling: Vector3;
  17202. protected _isDirty: boolean;
  17203. private _transformToBoneReferal;
  17204. billboardMode: number;
  17205. scalingDeterminant: number;
  17206. infiniteDistance: boolean;
  17207. position: Vector3;
  17208. _poseMatrix: Matrix;
  17209. private _localWorld;
  17210. _worldMatrix: Matrix;
  17211. _worldMatrixDeterminant: number;
  17212. private _absolutePosition;
  17213. private _pivotMatrix;
  17214. private _pivotMatrixInverse;
  17215. private _postMultiplyPivotMatrix;
  17216. protected _isWorldMatrixFrozen: boolean;
  17217. /**
  17218. * An event triggered after the world matrix is updated
  17219. * @type {BABYLON.Observable}
  17220. */
  17221. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  17222. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  17223. /**
  17224. * Gets a string idenfifying the name of the class
  17225. * @returns "TransformNode" string
  17226. */
  17227. getClassName(): string;
  17228. /**
  17229. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  17230. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  17231. * Default : (0.0, 0.0, 0.0)
  17232. */
  17233. rotation: Vector3;
  17234. /**
  17235. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  17236. * Default : (1.0, 1.0, 1.0)
  17237. */
  17238. /**
  17239. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  17240. * Default : (1.0, 1.0, 1.0)
  17241. */
  17242. scaling: Vector3;
  17243. /**
  17244. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  17245. * It's null by default.
  17246. * If set, only the rotationQuaternion is then used to compute the mesh rotation and its property `.rotation\ is then ignored and set to (0.0, 0.0, 0.0)
  17247. */
  17248. rotationQuaternion: Nullable<Quaternion>;
  17249. /**
  17250. * Returns the latest update of the World matrix
  17251. * Returns a Matrix.
  17252. */
  17253. getWorldMatrix(): Matrix;
  17254. /**
  17255. * Returns the latest update of the World matrix determinant.
  17256. */
  17257. protected _getWorldMatrixDeterminant(): number;
  17258. /**
  17259. * Returns directly the latest state of the mesh World matrix.
  17260. * A Matrix is returned.
  17261. */
  17262. readonly worldMatrixFromCache: Matrix;
  17263. /**
  17264. * Copies the paramater passed Matrix into the mesh Pose matrix.
  17265. * Returns the AbstractMesh.
  17266. */
  17267. updatePoseMatrix(matrix: Matrix): TransformNode;
  17268. /**
  17269. * Returns the mesh Pose matrix.
  17270. * Returned object : Matrix
  17271. */
  17272. getPoseMatrix(): Matrix;
  17273. _isSynchronized(): boolean;
  17274. _initCache(): void;
  17275. markAsDirty(property: string): TransformNode;
  17276. /**
  17277. * Returns the current mesh absolute position.
  17278. * Retuns a Vector3.
  17279. */
  17280. readonly absolutePosition: Vector3;
  17281. /**
  17282. * Sets a new matrix to apply before all other transformation
  17283. * @param matrix defines the transform matrix
  17284. * @returns the current TransformNode
  17285. */
  17286. setPreTransformMatrix(matrix: Matrix): TransformNode;
  17287. /**
  17288. * Sets a new pivot matrix to the current node
  17289. * @param matrix defines the new pivot matrix to use
  17290. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  17291. * @returns the current TransformNode
  17292. */
  17293. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  17294. /**
  17295. * Returns the mesh pivot matrix.
  17296. * Default : Identity.
  17297. * A Matrix is returned.
  17298. */
  17299. getPivotMatrix(): Matrix;
  17300. /**
  17301. * Prevents the World matrix to be computed any longer.
  17302. * Returns the AbstractMesh.
  17303. */
  17304. freezeWorldMatrix(): TransformNode;
  17305. /**
  17306. * Allows back the World matrix computation.
  17307. * Returns the AbstractMesh.
  17308. */
  17309. unfreezeWorldMatrix(): this;
  17310. /**
  17311. * True if the World matrix has been frozen.
  17312. * Returns a boolean.
  17313. */
  17314. readonly isWorldMatrixFrozen: boolean;
  17315. /**
  17316. * Retuns the mesh absolute position in the World.
  17317. * Returns a Vector3.
  17318. */
  17319. getAbsolutePosition(): Vector3;
  17320. /**
  17321. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  17322. * Returns the AbstractMesh.
  17323. */
  17324. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  17325. /**
  17326. * Sets the mesh position in its local space.
  17327. * Returns the AbstractMesh.
  17328. */
  17329. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  17330. /**
  17331. * Returns the mesh position in the local space from the current World matrix values.
  17332. * Returns a new Vector3.
  17333. */
  17334. getPositionExpressedInLocalSpace(): Vector3;
  17335. /**
  17336. * Translates the mesh along the passed Vector3 in its local space.
  17337. * Returns the AbstractMesh.
  17338. */
  17339. locallyTranslate(vector3: Vector3): TransformNode;
  17340. private static _lookAtVectorCache;
  17341. /**
  17342. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  17343. * @param targetPoint the position (must be in same space as current mesh) to look at
  17344. * @param yawCor optional yaw (y-axis) correction in radians
  17345. * @param pitchCor optional pitch (x-axis) correction in radians
  17346. * @param rollCor optional roll (z-axis) correction in radians
  17347. * @param space the choosen space of the target
  17348. * @returns the TransformNode.
  17349. */
  17350. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  17351. /**
  17352. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  17353. * This Vector3 is expressed in the World space.
  17354. */
  17355. getDirection(localAxis: Vector3): Vector3;
  17356. /**
  17357. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  17358. * localAxis is expressed in the mesh local space.
  17359. * result is computed in the Wordl space from the mesh World matrix.
  17360. * Returns the AbstractMesh.
  17361. */
  17362. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  17363. /**
  17364. * Sets a new pivot point to the current node
  17365. * @param point defines the new pivot point to use
  17366. * @param space defines if the point is in world or local space (local by default)
  17367. * @returns the current TransformNode
  17368. */
  17369. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  17370. /**
  17371. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  17372. */
  17373. getPivotPoint(): Vector3;
  17374. /**
  17375. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  17376. * Returns the AbstractMesh.
  17377. */
  17378. getPivotPointToRef(result: Vector3): TransformNode;
  17379. /**
  17380. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  17381. */
  17382. getAbsolutePivotPoint(): Vector3;
  17383. /**
  17384. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  17385. * Returns the AbstractMesh.
  17386. */
  17387. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  17388. /**
  17389. * Defines the passed node as the parent of the current node.
  17390. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  17391. * Returns the TransformNode.
  17392. */
  17393. setParent(node: Nullable<Node>): TransformNode;
  17394. private _nonUniformScaling;
  17395. readonly nonUniformScaling: boolean;
  17396. _updateNonUniformScalingState(value: boolean): boolean;
  17397. /**
  17398. * Attach the current TransformNode to another TransformNode associated with a bone
  17399. * @param bone Bone affecting the TransformNode
  17400. * @param affectedTransformNode TransformNode associated with the bone
  17401. */
  17402. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  17403. detachFromBone(): TransformNode;
  17404. private static _rotationAxisCache;
  17405. /**
  17406. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  17407. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  17408. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  17409. * The passed axis is also normalized.
  17410. * Returns the AbstractMesh.
  17411. */
  17412. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  17413. /**
  17414. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  17415. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  17416. * The passed axis is also normalized.
  17417. * Returns the AbstractMesh.
  17418. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  17419. */
  17420. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  17421. /**
  17422. * Translates the mesh along the axis vector for the passed distance in the given space.
  17423. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  17424. * Returns the AbstractMesh.
  17425. */
  17426. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  17427. /**
  17428. * Adds a rotation step to the mesh current rotation.
  17429. * x, y, z are Euler angles expressed in radians.
  17430. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  17431. * This means this rotation is made in the mesh local space only.
  17432. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  17433. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  17434. * ```javascript
  17435. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  17436. * ```
  17437. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  17438. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  17439. * Returns the AbstractMesh.
  17440. */
  17441. addRotation(x: number, y: number, z: number): TransformNode;
  17442. /**
  17443. * Computes the mesh World matrix and returns it.
  17444. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  17445. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  17446. * If the parameter `force`is set to `true`, the actual computation is done.
  17447. * Returns the mesh World Matrix.
  17448. */
  17449. computeWorldMatrix(force?: boolean): Matrix;
  17450. protected _afterComputeWorldMatrix(): void;
  17451. /**
  17452. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  17453. * @param func: callback function to add
  17454. *
  17455. * Returns the TransformNode.
  17456. */
  17457. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  17458. /**
  17459. * Removes a registered callback function.
  17460. * Returns the TransformNode.
  17461. */
  17462. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  17463. /**
  17464. * Clone the current transform node
  17465. * Returns the new transform node
  17466. * @param name Name of the new clone
  17467. * @param newParent New parent for the clone
  17468. * @param doNotCloneChildren Do not clone children hierarchy
  17469. */
  17470. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  17471. serialize(currentSerializationObject?: any): any;
  17472. /**
  17473. * Returns a new TransformNode object parsed from the source provided.
  17474. * The parameter `parsedMesh` is the source.
  17475. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  17476. */
  17477. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  17478. /**
  17479. * Releases resources associated with this transform node.
  17480. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17481. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17482. */
  17483. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17484. }
  17485. }
  17486. declare module BABYLON {
  17487. class VertexBuffer {
  17488. private _buffer;
  17489. private _kind;
  17490. private _offset;
  17491. private _size;
  17492. private _stride;
  17493. private _ownsBuffer;
  17494. private _instanced;
  17495. private _instanceDivisor;
  17496. /**
  17497. * Gets or sets the instance divisor when in instanced mode
  17498. */
  17499. instanceDivisor: number;
  17500. constructor(engine: any, data: FloatArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number);
  17501. _rebuild(): void;
  17502. /**
  17503. * Returns the kind of the VertexBuffer (string).
  17504. */
  17505. getKind(): string;
  17506. /**
  17507. * Boolean : is the VertexBuffer updatable ?
  17508. */
  17509. isUpdatable(): boolean;
  17510. /**
  17511. * Returns an array of numbers or a Float32Array containing the VertexBuffer data.
  17512. */
  17513. getData(): Nullable<FloatArray>;
  17514. /**
  17515. * Returns the WebGLBuffer associated to the VertexBuffer.
  17516. */
  17517. getBuffer(): Nullable<WebGLBuffer>;
  17518. /**
  17519. * Returns the stride of the VertexBuffer (integer).
  17520. */
  17521. getStrideSize(): number;
  17522. /**
  17523. * Returns the offset (integer).
  17524. */
  17525. getOffset(): number;
  17526. /**
  17527. * Returns the VertexBuffer total size (integer).
  17528. */
  17529. getSize(): number;
  17530. /**
  17531. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  17532. */
  17533. getIsInstanced(): boolean;
  17534. /**
  17535. * Returns the instancing divisor, zero for non-instanced (integer).
  17536. */
  17537. getInstanceDivisor(): number;
  17538. /**
  17539. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  17540. * Returns the created WebGLBuffer.
  17541. */
  17542. create(data?: FloatArray): void;
  17543. /**
  17544. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  17545. * This function will create a new buffer if the current one is not updatable
  17546. * Returns the updated WebGLBuffer.
  17547. */
  17548. update(data: FloatArray): void;
  17549. /**
  17550. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  17551. * Returns the directly updated WebGLBuffer.
  17552. */
  17553. updateDirectly(data: Float32Array, offset: number): void;
  17554. /**
  17555. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  17556. */
  17557. dispose(): void;
  17558. private static _PositionKind;
  17559. private static _NormalKind;
  17560. private static _TangentKind;
  17561. private static _UVKind;
  17562. private static _UV2Kind;
  17563. private static _UV3Kind;
  17564. private static _UV4Kind;
  17565. private static _UV5Kind;
  17566. private static _UV6Kind;
  17567. private static _ColorKind;
  17568. private static _MatricesIndicesKind;
  17569. private static _MatricesWeightsKind;
  17570. private static _MatricesIndicesExtraKind;
  17571. private static _MatricesWeightsExtraKind;
  17572. static readonly PositionKind: string;
  17573. static readonly NormalKind: string;
  17574. static readonly TangentKind: string;
  17575. static readonly UVKind: string;
  17576. static readonly UV2Kind: string;
  17577. static readonly UV3Kind: string;
  17578. static readonly UV4Kind: string;
  17579. static readonly UV5Kind: string;
  17580. static readonly UV6Kind: string;
  17581. static readonly ColorKind: string;
  17582. static readonly MatricesIndicesKind: string;
  17583. static readonly MatricesWeightsKind: string;
  17584. static readonly MatricesIndicesExtraKind: string;
  17585. static readonly MatricesWeightsExtraKind: string;
  17586. /**
  17587. * Deduces the stride given a kind.
  17588. * @param kind The kind string to deduce
  17589. * @returns The deduced stride
  17590. */
  17591. static DeduceStride(kind: string): number;
  17592. }
  17593. }
  17594. declare module BABYLON {
  17595. class MorphTarget {
  17596. name: string;
  17597. animations: Animation[];
  17598. private _positions;
  17599. private _normals;
  17600. private _tangents;
  17601. private _influence;
  17602. onInfluenceChanged: Observable<boolean>;
  17603. influence: number;
  17604. constructor(name: string, influence?: number);
  17605. readonly hasPositions: boolean;
  17606. readonly hasNormals: boolean;
  17607. readonly hasTangents: boolean;
  17608. setPositions(data: Nullable<FloatArray>): void;
  17609. getPositions(): Nullable<FloatArray>;
  17610. setNormals(data: Nullable<FloatArray>): void;
  17611. getNormals(): Nullable<FloatArray>;
  17612. setTangents(data: Nullable<FloatArray>): void;
  17613. getTangents(): Nullable<FloatArray>;
  17614. /**
  17615. * Serializes the current target into a Serialization object.
  17616. * Returns the serialized object.
  17617. */
  17618. serialize(): any;
  17619. static Parse(serializationObject: any): MorphTarget;
  17620. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  17621. }
  17622. }
  17623. declare module BABYLON {
  17624. class MorphTargetManager {
  17625. private _targets;
  17626. private _targetObservable;
  17627. private _activeTargets;
  17628. private _scene;
  17629. private _influences;
  17630. private _supportsNormals;
  17631. private _supportsTangents;
  17632. private _vertexCount;
  17633. private _uniqueId;
  17634. private _tempInfluences;
  17635. constructor(scene?: Nullable<Scene>);
  17636. readonly uniqueId: number;
  17637. readonly vertexCount: number;
  17638. readonly supportsNormals: boolean;
  17639. readonly supportsTangents: boolean;
  17640. readonly numTargets: number;
  17641. readonly numInfluencers: number;
  17642. readonly influences: Float32Array;
  17643. getActiveTarget(index: number): MorphTarget;
  17644. getTarget(index: number): MorphTarget;
  17645. addTarget(target: MorphTarget): void;
  17646. removeTarget(target: MorphTarget): void;
  17647. /**
  17648. * Serializes the current manager into a Serialization object.
  17649. * Returns the serialized object.
  17650. */
  17651. serialize(): any;
  17652. private _syncActiveTargets(needUpdate);
  17653. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  17654. }
  17655. }
  17656. declare module BABYLON {
  17657. /**
  17658. * This represents a GPU particle system in Babylon
  17659. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  17660. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  17661. */
  17662. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  17663. /**
  17664. * The id of the Particle system.
  17665. */
  17666. id: string;
  17667. /**
  17668. * The friendly name of the Particle system.
  17669. */
  17670. name: string;
  17671. /**
  17672. * The emitter represents the Mesh or position we are attaching the particle system to.
  17673. */
  17674. emitter: Nullable<AbstractMesh | Vector3>;
  17675. /**
  17676. * The rendering group used by the Particle system to chose when to render.
  17677. */
  17678. renderingGroupId: number;
  17679. /**
  17680. * The layer mask we are rendering the particles through.
  17681. */
  17682. layerMask: number;
  17683. private _capacity;
  17684. private _activeCount;
  17685. private _currentActiveCount;
  17686. private _renderEffect;
  17687. private _updateEffect;
  17688. private _buffer0;
  17689. private _buffer1;
  17690. private _spriteBuffer;
  17691. private _updateVAO;
  17692. private _renderVAO;
  17693. private _targetIndex;
  17694. private _sourceBuffer;
  17695. private _targetBuffer;
  17696. private _scene;
  17697. private _engine;
  17698. private _currentRenderId;
  17699. private _started;
  17700. private _stopped;
  17701. private _timeDelta;
  17702. private _randomTexture;
  17703. private readonly _attributesStrideSize;
  17704. private _updateEffectOptions;
  17705. private _randomTextureSize;
  17706. private _actualFrame;
  17707. /**
  17708. * List of animations used by the particle system.
  17709. */
  17710. animations: Animation[];
  17711. /**
  17712. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  17713. */
  17714. static readonly IsSupported: boolean;
  17715. /**
  17716. * An event triggered when the system is disposed.
  17717. */
  17718. onDisposeObservable: Observable<GPUParticleSystem>;
  17719. /**
  17720. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17721. */
  17722. updateSpeed: number;
  17723. /**
  17724. * The amount of time the particle system is running (depends of the overall update speed).
  17725. */
  17726. targetStopDuration: number;
  17727. /**
  17728. * The texture used to render each particle. (this can be a spritesheet)
  17729. */
  17730. particleTexture: Nullable<Texture>;
  17731. /**
  17732. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17733. */
  17734. blendMode: number;
  17735. /**
  17736. * Minimum life time of emitting particles.
  17737. */
  17738. minLifeTime: number;
  17739. /**
  17740. * Maximum life time of emitting particles.
  17741. */
  17742. maxLifeTime: number;
  17743. /**
  17744. * Minimum Size of emitting particles.
  17745. */
  17746. minSize: number;
  17747. /**
  17748. * Maximum Size of emitting particles.
  17749. */
  17750. maxSize: number;
  17751. /**
  17752. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17753. */
  17754. color1: Color4;
  17755. /**
  17756. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17757. */
  17758. color2: Color4;
  17759. /**
  17760. * Color the particle will have at the end of its lifetime.
  17761. */
  17762. colorDead: Color4;
  17763. /**
  17764. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17765. */
  17766. emitRate: number;
  17767. /**
  17768. * You can use gravity if you want to give an orientation to your particles.
  17769. */
  17770. gravity: Vector3;
  17771. /**
  17772. * Minimum power of emitting particles.
  17773. */
  17774. minEmitPower: number;
  17775. /**
  17776. * Maximum power of emitting particles.
  17777. */
  17778. maxEmitPower: number;
  17779. /**
  17780. * The particle emitter type defines the emitter used by the particle system.
  17781. * It can be for example box, sphere, or cone...
  17782. */
  17783. particleEmitterType: Nullable<IParticleEmitterType>;
  17784. /**
  17785. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17786. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17787. */
  17788. direction1: Vector3;
  17789. /**
  17790. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17791. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17792. */
  17793. direction2: Vector3;
  17794. /**
  17795. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17796. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17797. */
  17798. minEmitBox: Vector3;
  17799. /**
  17800. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17801. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17802. */
  17803. maxEmitBox: Vector3;
  17804. /**
  17805. * Gets the maximum number of particles active at the same time.
  17806. * @returns The max number of active particles.
  17807. */
  17808. getCapacity(): number;
  17809. /**
  17810. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17811. * to override the particles.
  17812. */
  17813. forceDepthWrite: boolean;
  17814. /**
  17815. * Gets or set the number of active particles
  17816. */
  17817. activeParticleCount: number;
  17818. /**
  17819. * Is this system ready to be used/rendered
  17820. * @return true if the system is ready
  17821. */
  17822. isReady(): boolean;
  17823. /**
  17824. * Gets Wether the system has been started.
  17825. * @returns True if it has been started, otherwise false.
  17826. */
  17827. isStarted(): boolean;
  17828. /**
  17829. * Starts the particle system and begins to emit.
  17830. */
  17831. start(): void;
  17832. /**
  17833. * Stops the particle system.
  17834. */
  17835. stop(): void;
  17836. /**
  17837. * Remove all active particles
  17838. */
  17839. reset(): void;
  17840. /**
  17841. * Returns the string "GPUParticleSystem"
  17842. * @returns a string containing the class name
  17843. */
  17844. getClassName(): string;
  17845. /**
  17846. * Instantiates a GPU particle system.
  17847. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17848. * @param name The name of the particle system
  17849. * @param capacity The max number of particles alive at the same time
  17850. * @param scene The scene the particle system belongs to
  17851. */
  17852. constructor(name: string, options: Partial<{
  17853. capacity: number;
  17854. randomTextureSize: number;
  17855. }>, scene: Scene);
  17856. private _createUpdateVAO(source);
  17857. private _createRenderVAO(source, spriteSource);
  17858. private _initialize(force?);
  17859. /** @ignore */
  17860. _recreateUpdateEffect(): void;
  17861. /** @ignore */
  17862. _recreateRenderEffect(): void;
  17863. /**
  17864. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17865. */
  17866. animate(): void;
  17867. /**
  17868. * Renders the particle system in its current state.
  17869. * @returns the current number of particles
  17870. */
  17871. render(): number;
  17872. /**
  17873. * Rebuilds the particle system
  17874. */
  17875. rebuild(): void;
  17876. private _releaseBuffers();
  17877. private _releaseVAOs();
  17878. /**
  17879. * Disposes the particle system and free the associated resources
  17880. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17881. */
  17882. dispose(disposeTexture?: boolean): void;
  17883. /**
  17884. * Clones the particle system.
  17885. * @param name The name of the cloned object
  17886. * @param newEmitter The new emitter to use
  17887. * @returns the cloned particle system
  17888. */
  17889. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  17890. /**
  17891. * Serializes the particle system to a JSON object.
  17892. * @returns the JSON object
  17893. */
  17894. serialize(): any;
  17895. /**
  17896. * Parses a JSON object to create a GPU particle system.
  17897. * @param parsedParticleSystem The JSON object to parse
  17898. * @param scene The scene to create the particle system in
  17899. * @param rootUrl The root url to use to load external dependencies like texture
  17900. * @returns the parsed GPU particle system
  17901. */
  17902. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  17903. }
  17904. }
  17905. declare module BABYLON {
  17906. /**
  17907. * Interface representing a particle system in Babylon.
  17908. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17909. * A particle system represents a way to manage particles (@see Particle) from their emission to their animation and rendering.
  17910. */
  17911. interface IParticleSystem {
  17912. /**
  17913. * The id of the Particle system.
  17914. */
  17915. id: string;
  17916. /**
  17917. * The name of the Particle system.
  17918. */
  17919. name: string;
  17920. /**
  17921. * The emitter represents the Mesh or position we are attaching the particle system to.
  17922. */
  17923. emitter: Nullable<AbstractMesh | Vector3>;
  17924. /**
  17925. * The rendering group used by the Particle system to chose when to render.
  17926. */
  17927. renderingGroupId: number;
  17928. /**
  17929. * The layer mask we are rendering the particles through.
  17930. */
  17931. layerMask: number;
  17932. /**
  17933. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17934. */
  17935. updateSpeed: number;
  17936. /**
  17937. * The amount of time the particle system is running (depends of the overall update speed).
  17938. */
  17939. targetStopDuration: number;
  17940. /**
  17941. * The texture used to render each particle. (this can be a spritesheet)
  17942. */
  17943. particleTexture: Nullable<Texture>;
  17944. /**
  17945. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17946. */
  17947. blendMode: number;
  17948. /**
  17949. * Minimum life time of emitting particles.
  17950. */
  17951. minLifeTime: number;
  17952. /**
  17953. * Maximum life time of emitting particles.
  17954. */
  17955. maxLifeTime: number;
  17956. /**
  17957. * Minimum Size of emitting particles.
  17958. */
  17959. minSize: number;
  17960. /**
  17961. * Maximum Size of emitting particles.
  17962. */
  17963. maxSize: number;
  17964. /**
  17965. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17966. */
  17967. color1: Color4;
  17968. /**
  17969. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17970. */
  17971. color2: Color4;
  17972. /**
  17973. * Color the particle will have at the end of its lifetime.
  17974. */
  17975. colorDead: Color4;
  17976. /**
  17977. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17978. */
  17979. emitRate: number;
  17980. /**
  17981. * You can use gravity if you want to give an orientation to your particles.
  17982. */
  17983. gravity: Vector3;
  17984. /**
  17985. * Minimum power of emitting particles.
  17986. */
  17987. minEmitPower: number;
  17988. /**
  17989. * Maximum power of emitting particles.
  17990. */
  17991. maxEmitPower: number;
  17992. /**
  17993. * The particle emitter type defines the emitter used by the particle system.
  17994. * It can be for example box, sphere, or cone...
  17995. */
  17996. particleEmitterType: Nullable<IParticleEmitterType>;
  17997. /**
  17998. * Gets the maximum number of particles active at the same time.
  17999. * @returns The max number of active particles.
  18000. */
  18001. getCapacity(): number;
  18002. /**
  18003. * Gets Wether the system has been started.
  18004. * @returns True if it has been started, otherwise false.
  18005. */
  18006. isStarted(): boolean;
  18007. /**
  18008. * Gets if the particle system has been started.
  18009. * @return true if the system has been started, otherwise false.
  18010. */
  18011. isStarted(): boolean;
  18012. /**
  18013. * Animates the particle system for this frame.
  18014. */
  18015. animate(): void;
  18016. /**
  18017. * Renders the particle system in its current state.
  18018. * @returns the current number of particles
  18019. */
  18020. render(): number;
  18021. /**
  18022. * Dispose the particle system and frees its associated resources.
  18023. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18024. */
  18025. dispose(disposeTexture?: boolean): void;
  18026. /**
  18027. * Clones the particle system.
  18028. * @param name The name of the cloned object
  18029. * @param newEmitter The new emitter to use
  18030. * @returns the cloned particle system
  18031. */
  18032. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18033. /**
  18034. * Serializes the particle system to a JSON object.
  18035. * @returns the JSON object
  18036. */
  18037. serialize(): any;
  18038. /**
  18039. * Rebuild the particle system
  18040. */
  18041. rebuild(): void;
  18042. /**
  18043. * Starts the particle system and begins to emit.
  18044. */
  18045. start(): void;
  18046. /**
  18047. * Stops the particle system.
  18048. */
  18049. stop(): void;
  18050. /**
  18051. * Remove all active particles
  18052. */
  18053. reset(): void;
  18054. /**
  18055. * Is this system ready to be used/rendered
  18056. * @return true if the system is ready
  18057. */
  18058. isReady(): boolean;
  18059. }
  18060. }
  18061. declare module BABYLON {
  18062. /**
  18063. * A particle represents one of the element emitted by a particle system.
  18064. * This is mainly define by its coordinates, direction, velocity and age.
  18065. */
  18066. class Particle {
  18067. /**
  18068. * particleSystem the particle system the particle belongs to.
  18069. */
  18070. particleSystem: ParticleSystem;
  18071. /**
  18072. * The world position of the particle in the scene.
  18073. */
  18074. position: Vector3;
  18075. /**
  18076. * The world direction of the particle in the scene.
  18077. */
  18078. direction: Vector3;
  18079. /**
  18080. * The color of the particle.
  18081. */
  18082. color: Color4;
  18083. /**
  18084. * The color change of the particle per step.
  18085. */
  18086. colorStep: Color4;
  18087. /**
  18088. * Defines how long will the life of the particle be.
  18089. */
  18090. lifeTime: number;
  18091. /**
  18092. * The current age of the particle.
  18093. */
  18094. age: number;
  18095. /**
  18096. * The current size of the particle.
  18097. */
  18098. size: number;
  18099. /**
  18100. * The current angle of the particle.
  18101. */
  18102. angle: number;
  18103. /**
  18104. * Defines how fast is the angle changing.
  18105. */
  18106. angularSpeed: number;
  18107. /**
  18108. * Defines the cell index used by the particle to be rendered from a sprite.
  18109. */
  18110. cellIndex: number;
  18111. private _currentFrameCounter;
  18112. /**
  18113. * Creates a new instance of @see Particle
  18114. * @param particleSystem the particle system the particle belongs to
  18115. */
  18116. constructor(
  18117. /**
  18118. * particleSystem the particle system the particle belongs to.
  18119. */
  18120. particleSystem: ParticleSystem);
  18121. private updateCellInfoFromSystem();
  18122. /**
  18123. * Defines how the sprite cell index is updated for the particle. This is
  18124. * defined as a callback.
  18125. */
  18126. updateCellIndex: (scaledUpdateSpeed: number) => void;
  18127. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  18128. private _updateCellIndexWithCustomSpeed();
  18129. /**
  18130. * Copy the properties of particle to another one.
  18131. * @param other the particle to copy the information to.
  18132. */
  18133. copyTo(other: Particle): void;
  18134. }
  18135. }
  18136. declare module BABYLON {
  18137. /**
  18138. * This represents a particle system in Babylon.
  18139. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  18140. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  18141. * @example https://doc.babylonjs.com/babylon101/particles
  18142. */
  18143. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  18144. /**
  18145. * Source color is added to the destination color without alpha affecting the result.
  18146. */
  18147. static BLENDMODE_ONEONE: number;
  18148. /**
  18149. * Blend current color and particle color using particle’s alpha.
  18150. */
  18151. static BLENDMODE_STANDARD: number;
  18152. /**
  18153. * List of animations used by the particle system.
  18154. */
  18155. animations: Animation[];
  18156. /**
  18157. * The id of the Particle system.
  18158. */
  18159. id: string;
  18160. /**
  18161. * The friendly name of the Particle system.
  18162. */
  18163. name: string;
  18164. /**
  18165. * The rendering group used by the Particle system to chose when to render.
  18166. */
  18167. renderingGroupId: number;
  18168. /**
  18169. * The emitter represents the Mesh or position we are attaching the particle system to.
  18170. */
  18171. emitter: Nullable<AbstractMesh | Vector3>;
  18172. /**
  18173. * The maximum number of particles to emit per frame
  18174. */
  18175. emitRate: number;
  18176. /**
  18177. * If you want to launch only a few particles at once, that can be done, as well.
  18178. */
  18179. manualEmitCount: number;
  18180. /**
  18181. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18182. */
  18183. updateSpeed: number;
  18184. /**
  18185. * The amount of time the particle system is running (depends of the overall update speed).
  18186. */
  18187. targetStopDuration: number;
  18188. /**
  18189. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18190. */
  18191. disposeOnStop: boolean;
  18192. /**
  18193. * Minimum power of emitting particles.
  18194. */
  18195. minEmitPower: number;
  18196. /**
  18197. * Maximum power of emitting particles.
  18198. */
  18199. maxEmitPower: number;
  18200. /**
  18201. * Minimum life time of emitting particles.
  18202. */
  18203. minLifeTime: number;
  18204. /**
  18205. * Maximum life time of emitting particles.
  18206. */
  18207. maxLifeTime: number;
  18208. /**
  18209. * Minimum Size of emitting particles.
  18210. */
  18211. minSize: number;
  18212. /**
  18213. * Maximum Size of emitting particles.
  18214. */
  18215. maxSize: number;
  18216. /**
  18217. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18218. */
  18219. minAngularSpeed: number;
  18220. /**
  18221. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18222. */
  18223. maxAngularSpeed: number;
  18224. /**
  18225. * The texture used to render each particle. (this can be a spritesheet)
  18226. */
  18227. particleTexture: Nullable<Texture>;
  18228. /**
  18229. * The layer mask we are rendering the particles through.
  18230. */
  18231. layerMask: number;
  18232. /**
  18233. * This can help using your own shader to render the particle system.
  18234. * The according effect will be created
  18235. */
  18236. customShader: any;
  18237. /**
  18238. * By default particle system starts as soon as they are created. This prevents the
  18239. * automatic start to happen and let you decide when to start emitting particles.
  18240. */
  18241. preventAutoStart: boolean;
  18242. /**
  18243. * This function can be defined to provide custom update for active particles.
  18244. * This function will be called instead of regular update (age, position, color, etc.).
  18245. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  18246. */
  18247. updateFunction: (particles: Particle[]) => void;
  18248. /**
  18249. * Callback triggered when the particle animation is ending.
  18250. */
  18251. onAnimationEnd: Nullable<() => void>;
  18252. /**
  18253. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18254. */
  18255. blendMode: number;
  18256. /**
  18257. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  18258. * to override the particles.
  18259. */
  18260. forceDepthWrite: boolean;
  18261. /**
  18262. * You can use gravity if you want to give an orientation to your particles.
  18263. */
  18264. gravity: Vector3;
  18265. /**
  18266. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18267. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18268. */
  18269. direction1: Vector3;
  18270. /**
  18271. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18272. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18273. */
  18274. direction2: Vector3;
  18275. /**
  18276. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  18277. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18278. */
  18279. minEmitBox: Vector3;
  18280. /**
  18281. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  18282. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18283. */
  18284. maxEmitBox: Vector3;
  18285. /**
  18286. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18287. */
  18288. color1: Color4;
  18289. /**
  18290. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18291. */
  18292. color2: Color4;
  18293. /**
  18294. * Color the particle will have at the end of its lifetime.
  18295. */
  18296. colorDead: Color4;
  18297. /**
  18298. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  18299. */
  18300. textureMask: Color4;
  18301. /**
  18302. * The particle emitter type defines the emitter used by the particle system.
  18303. * It can be for example box, sphere, or cone...
  18304. */
  18305. particleEmitterType: IParticleEmitterType;
  18306. /**
  18307. * This function can be defined to specify initial direction for every new particle.
  18308. * It by default use the emitterType defined function.
  18309. */
  18310. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  18311. /**
  18312. * This function can be defined to specify initial position for every new particle.
  18313. * It by default use the emitterType defined function.
  18314. */
  18315. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  18316. /**
  18317. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  18318. */
  18319. spriteCellLoop: boolean;
  18320. /**
  18321. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  18322. */
  18323. spriteCellChangeSpeed: number;
  18324. /**
  18325. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  18326. */
  18327. startSpriteCellID: number;
  18328. /**
  18329. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  18330. */
  18331. endSpriteCellID: number;
  18332. /**
  18333. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  18334. */
  18335. spriteCellWidth: number;
  18336. /**
  18337. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  18338. */
  18339. spriteCellHeight: number;
  18340. /**
  18341. * An event triggered when the system is disposed.
  18342. */
  18343. onDisposeObservable: Observable<ParticleSystem>;
  18344. private _onDisposeObserver;
  18345. /**
  18346. * Sets a callback that will be triggered when the system is disposed.
  18347. */
  18348. onDispose: () => void;
  18349. /**
  18350. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  18351. */
  18352. readonly isAnimationSheetEnabled: Boolean;
  18353. private _particles;
  18354. private _epsilon;
  18355. private _capacity;
  18356. private _scene;
  18357. private _stockParticles;
  18358. private _newPartsExcess;
  18359. private _vertexData;
  18360. private _vertexBuffer;
  18361. private _vertexBuffers;
  18362. private _indexBuffer;
  18363. private _effect;
  18364. private _customEffect;
  18365. private _cachedDefines;
  18366. private _scaledColorStep;
  18367. private _colorDiff;
  18368. private _scaledDirection;
  18369. private _scaledGravity;
  18370. private _currentRenderId;
  18371. private _alive;
  18372. private _started;
  18373. private _stopped;
  18374. private _actualFrame;
  18375. private _scaledUpdateSpeed;
  18376. private _vertexBufferSize;
  18377. private _isAnimationSheetEnabled;
  18378. /**
  18379. * this is the Sub-emitters templates that will be used to generate particle system when the particle dies, this property is used by the root particle system only.
  18380. */
  18381. subEmitters: ParticleSystem[];
  18382. /**
  18383. * The current active Sub-systems, this property is used by the root particle system only.
  18384. */
  18385. activeSubSystems: Array<ParticleSystem>;
  18386. private _rootParticleSystem;
  18387. /**
  18388. * Gets the current list of active particles
  18389. */
  18390. readonly particles: Particle[];
  18391. /**
  18392. * Returns the string "ParticleSystem"
  18393. * @returns a string containing the class name
  18394. */
  18395. getClassName(): string;
  18396. /**
  18397. * Instantiates a particle system.
  18398. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  18399. * @param name The name of the particle system
  18400. * @param capacity The max number of particles alive at the same time
  18401. * @param scene The scene the particle system belongs to
  18402. * @param customEffect a custom effect used to change the way particles are rendered by default
  18403. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  18404. * @param epsilon Offset used to render the particles
  18405. */
  18406. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  18407. private _createIndexBuffer();
  18408. /**
  18409. * Gets the maximum number of particles active at the same time.
  18410. * @returns The max number of active particles.
  18411. */
  18412. getCapacity(): number;
  18413. /**
  18414. * Gets Wether there are still active particles in the system.
  18415. * @returns True if it is alive, otherwise false.
  18416. */
  18417. isAlive(): boolean;
  18418. /**
  18419. * Gets Wether the system has been started.
  18420. * @returns True if it has been started, otherwise false.
  18421. */
  18422. isStarted(): boolean;
  18423. /**
  18424. * Starts the particle system and begins to emit.
  18425. */
  18426. start(): void;
  18427. /**
  18428. * Stops the particle system.
  18429. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  18430. */
  18431. stop(stopSubEmitters?: boolean): void;
  18432. /**
  18433. * Remove all active particles
  18434. */
  18435. reset(): void;
  18436. /**
  18437. * @ignore (for internal use only)
  18438. */
  18439. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18440. /**
  18441. * @ignore (for internal use only)
  18442. */
  18443. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18444. /**
  18445. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18446. * Its lifetime will start back at 0.
  18447. */
  18448. recycleParticle: (particle: Particle) => void;
  18449. private _stopSubEmitters();
  18450. private _createParticle;
  18451. private _removeFromRoot();
  18452. private _emitFromParticle;
  18453. private _update(newParticles);
  18454. private _getEffect();
  18455. /**
  18456. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18457. */
  18458. animate(): void;
  18459. private _appendParticleVertexes;
  18460. private _appenedParticleVertexesWithSheet(offset, particle);
  18461. private _appenedParticleVertexesNoSheet(offset, particle);
  18462. /**
  18463. * Rebuilds the particle system.
  18464. */
  18465. rebuild(): void;
  18466. /**
  18467. * Is this system ready to be used/rendered
  18468. * @return true if the system is ready
  18469. */
  18470. isReady(): boolean;
  18471. /**
  18472. * Renders the particle system in its current state.
  18473. * @returns the current number of particles
  18474. */
  18475. render(): number;
  18476. /**
  18477. * Disposes the particle system and free the associated resources
  18478. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18479. */
  18480. dispose(disposeTexture?: boolean): void;
  18481. /**
  18482. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  18483. * @param radius The radius of the sphere to emit from
  18484. * @returns the emitter
  18485. */
  18486. createSphereEmitter(radius?: number): SphereParticleEmitter;
  18487. /**
  18488. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  18489. * @param radius The radius of the sphere to emit from
  18490. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18491. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18492. * @returns the emitter
  18493. */
  18494. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  18495. /**
  18496. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  18497. * @param radius The radius of the cone to emit from
  18498. * @param angle The base angle of the cone
  18499. * @returns the emitter
  18500. */
  18501. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  18502. /**
  18503. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18504. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18505. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18506. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18507. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18508. * @returns the emitter
  18509. */
  18510. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18511. /**
  18512. * Clones the particle system.
  18513. * @param name The name of the cloned object
  18514. * @param newEmitter The new emitter to use
  18515. * @returns the cloned particle system
  18516. */
  18517. clone(name: string, newEmitter: any): ParticleSystem;
  18518. /**
  18519. * Serializes the particle system to a JSON object.
  18520. * @returns the JSON object
  18521. */
  18522. serialize(): any;
  18523. /**
  18524. * Parses a JSON object to create a particle system.
  18525. * @param parsedParticleSystem The JSON object to parse
  18526. * @param scene The scene to create the particle system in
  18527. * @param rootUrl The root url to use to load external dependencies like texture
  18528. * @returns the Parsed particle system
  18529. */
  18530. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  18531. }
  18532. }
  18533. declare module BABYLON {
  18534. /**
  18535. * Represents one particle of a solid particle system.
  18536. * @see SolidParticleSystem
  18537. */
  18538. class SolidParticle {
  18539. /**
  18540. * particle global index
  18541. */
  18542. idx: number;
  18543. /**
  18544. * The color of the particle
  18545. */
  18546. color: Nullable<Color4>;
  18547. /**
  18548. * The world space position of the particle.
  18549. */
  18550. position: Vector3;
  18551. /**
  18552. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  18553. */
  18554. rotation: Vector3;
  18555. /**
  18556. * The world space rotation quaternion of the particle.
  18557. */
  18558. rotationQuaternion: Nullable<Quaternion>;
  18559. /**
  18560. * The scaling of the particle.
  18561. */
  18562. scaling: Vector3;
  18563. /**
  18564. * The uvs of the particle.
  18565. */
  18566. uvs: Vector4;
  18567. /**
  18568. * The current speed of the particle.
  18569. */
  18570. velocity: Vector3;
  18571. /**
  18572. * The pivot point in the particle local space.
  18573. */
  18574. pivot: Vector3;
  18575. /**
  18576. * Must the particle be translated from its pivot point in its local space ?
  18577. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  18578. * Default : false
  18579. */
  18580. translateFromPivot: boolean;
  18581. /**
  18582. * Is the particle active or not ?
  18583. */
  18584. alive: boolean;
  18585. /**
  18586. * Is the particle visible or not ?
  18587. */
  18588. isVisible: boolean;
  18589. /**
  18590. * Index of this particle in the global "positions" array (Internal use)
  18591. */
  18592. _pos: number;
  18593. /**
  18594. * Index of this particle in the global "indices" array (Internal use)
  18595. */
  18596. _ind: number;
  18597. /**
  18598. * ModelShape of this particle (Internal use)
  18599. */
  18600. _model: ModelShape;
  18601. /**
  18602. * ModelShape id of this particle
  18603. */
  18604. shapeId: number;
  18605. /**
  18606. * Index of the particle in its shape id (Internal use)
  18607. */
  18608. idxInShape: number;
  18609. /**
  18610. * Reference to the shape model BoundingInfo object (Internal use)
  18611. */
  18612. _modelBoundingInfo: BoundingInfo;
  18613. /**
  18614. * Particle BoundingInfo object (Internal use)
  18615. */
  18616. _boundingInfo: BoundingInfo;
  18617. /**
  18618. * Reference to the SPS what the particle belongs to (Internal use)
  18619. */
  18620. _sps: SolidParticleSystem;
  18621. /**
  18622. * Still set as invisible in order to skip useless computations (Internal use)
  18623. */
  18624. _stillInvisible: boolean;
  18625. /**
  18626. * Last computed particle rotation matrix
  18627. */
  18628. _rotationMatrix: number[];
  18629. /**
  18630. * Parent particle Id, if any.
  18631. * Default null.
  18632. */
  18633. parentId: Nullable<number>;
  18634. /**
  18635. * Internal global position in the SPS.
  18636. */
  18637. _globalPosition: Vector3;
  18638. /**
  18639. * Creates a Solid Particle object.
  18640. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  18641. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  18642. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  18643. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  18644. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  18645. * @param shapeId (integer) is the model shape identifier in the SPS.
  18646. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  18647. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  18648. */
  18649. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  18650. /**
  18651. * Legacy support, changed scale to scaling
  18652. */
  18653. /**
  18654. * Legacy support, changed scale to scaling
  18655. */
  18656. scale: Vector3;
  18657. /**
  18658. * Legacy support, changed quaternion to rotationQuaternion
  18659. */
  18660. /**
  18661. * Legacy support, changed quaternion to rotationQuaternion
  18662. */
  18663. quaternion: Nullable<Quaternion>;
  18664. /**
  18665. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  18666. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  18667. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  18668. * @returns true if it intersects
  18669. */
  18670. intersectsMesh(target: Mesh | SolidParticle): boolean;
  18671. }
  18672. /**
  18673. * Represents the shape of the model used by one particle of a solid particle system.
  18674. * SPS internal tool, don't use it manually.
  18675. * @see SolidParticleSystem
  18676. */
  18677. class ModelShape {
  18678. /**
  18679. * The shape id.
  18680. */
  18681. shapeID: number;
  18682. /**
  18683. * flat array of model positions (internal use)
  18684. */
  18685. _shape: Vector3[];
  18686. /**
  18687. * flat array of model UVs (internal use)
  18688. */
  18689. _shapeUV: number[];
  18690. /**
  18691. * length of the shape in the model indices array (internal use)
  18692. */
  18693. _indicesLength: number;
  18694. /**
  18695. * Custom position function (internal use)
  18696. */
  18697. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  18698. /**
  18699. * Custom vertex function (internal use)
  18700. */
  18701. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  18702. /**
  18703. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  18704. * SPS internal tool, don't use it manually.
  18705. * @ignore
  18706. */
  18707. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  18708. }
  18709. /**
  18710. * Represents a Depth Sorted Particle in the solid particle system.
  18711. * @see SolidParticleSystem
  18712. */
  18713. class DepthSortedParticle {
  18714. /**
  18715. * Index of the particle in the "indices" array
  18716. */
  18717. ind: number;
  18718. /**
  18719. * Length of the particle shape in the "indices" array
  18720. */
  18721. indicesLength: number;
  18722. /**
  18723. * Squared distance from the particle to the camera
  18724. */
  18725. sqDistance: number;
  18726. }
  18727. }
  18728. declare module BABYLON {
  18729. /**
  18730. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  18731. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  18732. * The SPS is also a particle system. It provides some methods to manage the particles.
  18733. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  18734. *
  18735. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  18736. */
  18737. class SolidParticleSystem implements IDisposable {
  18738. /**
  18739. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  18740. * Example : var p = SPS.particles[i];
  18741. */
  18742. particles: SolidParticle[];
  18743. /**
  18744. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  18745. */
  18746. nbParticles: number;
  18747. /**
  18748. * If the particles must ever face the camera (default false). Useful for planar particles.
  18749. */
  18750. billboard: boolean;
  18751. /**
  18752. * Recompute normals when adding a shape
  18753. */
  18754. recomputeNormals: boolean;
  18755. /**
  18756. * This a counter ofr your own usage. It's not set by any SPS functions.
  18757. */
  18758. counter: number;
  18759. /**
  18760. * The SPS name. This name is also given to the underlying mesh.
  18761. */
  18762. name: string;
  18763. /**
  18764. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  18765. */
  18766. mesh: Mesh;
  18767. /**
  18768. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  18769. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  18770. */
  18771. vars: any;
  18772. /**
  18773. * This array is populated when the SPS is set as 'pickable'.
  18774. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  18775. * Each element of this array is an object `{idx: int, faceId: int}`.
  18776. * `idx` is the picked particle index in the `SPS.particles` array
  18777. * `faceId` is the picked face index counted within this particle.
  18778. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  18779. */
  18780. pickedParticles: {
  18781. idx: number;
  18782. faceId: number;
  18783. }[];
  18784. /**
  18785. * This array is populated when `enableDepthSort` is set to true.
  18786. * Each element of this array is an instance of the class DepthSortedParticle.
  18787. */
  18788. depthSortedParticles: DepthSortedParticle[];
  18789. /**
  18790. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  18791. */
  18792. _bSphereOnly: boolean;
  18793. /**
  18794. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  18795. */
  18796. _bSphereRadiusFactor: number;
  18797. private _scene;
  18798. private _positions;
  18799. private _indices;
  18800. private _normals;
  18801. private _colors;
  18802. private _uvs;
  18803. private _indices32;
  18804. private _positions32;
  18805. private _normals32;
  18806. private _fixedNormal32;
  18807. private _colors32;
  18808. private _uvs32;
  18809. private _index;
  18810. private _updatable;
  18811. private _pickable;
  18812. private _isVisibilityBoxLocked;
  18813. private _alwaysVisible;
  18814. private _depthSort;
  18815. private _shapeCounter;
  18816. private _copy;
  18817. private _shape;
  18818. private _shapeUV;
  18819. private _color;
  18820. private _computeParticleColor;
  18821. private _computeParticleTexture;
  18822. private _computeParticleRotation;
  18823. private _computeParticleVertex;
  18824. private _computeBoundingBox;
  18825. private _depthSortParticles;
  18826. private _cam_axisZ;
  18827. private _cam_axisY;
  18828. private _cam_axisX;
  18829. private _axisZ;
  18830. private _camera;
  18831. private _particle;
  18832. private _camDir;
  18833. private _camInvertedPosition;
  18834. private _rotMatrix;
  18835. private _invertMatrix;
  18836. private _rotated;
  18837. private _quaternion;
  18838. private _vertex;
  18839. private _normal;
  18840. private _yaw;
  18841. private _pitch;
  18842. private _roll;
  18843. private _halfroll;
  18844. private _halfpitch;
  18845. private _halfyaw;
  18846. private _sinRoll;
  18847. private _cosRoll;
  18848. private _sinPitch;
  18849. private _cosPitch;
  18850. private _sinYaw;
  18851. private _cosYaw;
  18852. private _mustUnrotateFixedNormals;
  18853. private _minimum;
  18854. private _maximum;
  18855. private _minBbox;
  18856. private _maxBbox;
  18857. private _particlesIntersect;
  18858. private _depthSortFunction;
  18859. private _needs32Bits;
  18860. private _pivotBackTranslation;
  18861. private _scaledPivot;
  18862. private _particleHasParent;
  18863. private _parent;
  18864. /**
  18865. * Creates a SPS (Solid Particle System) object.
  18866. * @param name (String) is the SPS name, this will be the underlying mesh name.
  18867. * @param scene (Scene) is the scene in which the SPS is added.
  18868. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  18869. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  18870. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  18871. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  18872. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  18873. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  18874. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  18875. */
  18876. constructor(name: string, scene: Scene, options?: {
  18877. updatable?: boolean;
  18878. isPickable?: boolean;
  18879. enableDepthSort?: boolean;
  18880. particleIntersection?: boolean;
  18881. boundingSphereOnly?: boolean;
  18882. bSphereRadiusFactor?: number;
  18883. });
  18884. /**
  18885. * Builds the SPS underlying mesh. Returns a standard Mesh.
  18886. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  18887. * @returns the created mesh
  18888. */
  18889. buildMesh(): Mesh;
  18890. /**
  18891. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  18892. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  18893. * Thus the particles generated from `digest()` have their property `position` set yet.
  18894. * @param mesh ( Mesh ) is the mesh to be digested
  18895. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  18896. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  18897. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  18898. * @returns the current SPS
  18899. */
  18900. digest(mesh: Mesh, options?: {
  18901. facetNb?: number;
  18902. number?: number;
  18903. delta?: number;
  18904. }): SolidParticleSystem;
  18905. private _unrotateFixedNormals();
  18906. private _resetCopy();
  18907. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  18908. private _posToShape(positions);
  18909. private _uvsToShapeUV(uvs);
  18910. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  18911. /**
  18912. * Adds some particles to the SPS from the model shape. Returns the shape id.
  18913. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  18914. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  18915. * @param nb (positive integer) the number of particles to be created from this model
  18916. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  18917. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  18918. * @returns the number of shapes in the system
  18919. */
  18920. addShape(mesh: Mesh, nb: number, options?: {
  18921. positionFunction?: any;
  18922. vertexFunction?: any;
  18923. }): number;
  18924. private _rebuildParticle(particle);
  18925. /**
  18926. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  18927. * @returns the SPS.
  18928. */
  18929. rebuildMesh(): SolidParticleSystem;
  18930. /**
  18931. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  18932. * This method calls `updateParticle()` for each particle of the SPS.
  18933. * For an animated SPS, it is usually called within the render loop.
  18934. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  18935. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  18936. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  18937. * @returns the SPS.
  18938. */
  18939. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  18940. private _quaternionRotationYPR();
  18941. private _quaternionToRotationMatrix();
  18942. /**
  18943. * Disposes the SPS.
  18944. */
  18945. dispose(): void;
  18946. /**
  18947. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  18948. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18949. * @returns the SPS.
  18950. */
  18951. refreshVisibleSize(): SolidParticleSystem;
  18952. /**
  18953. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  18954. * @param size the size (float) of the visibility box
  18955. * note : this doesn't lock the SPS mesh bounding box.
  18956. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18957. */
  18958. setVisibilityBox(size: number): void;
  18959. /**
  18960. * Gets whether the SPS as always visible or not
  18961. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18962. */
  18963. /**
  18964. * Sets the SPS as always visible or not
  18965. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18966. */
  18967. isAlwaysVisible: boolean;
  18968. /**
  18969. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  18970. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18971. */
  18972. /**
  18973. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  18974. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18975. */
  18976. isVisibilityBoxLocked: boolean;
  18977. /**
  18978. * Gets if `setParticles()` computes the particle rotations or not.
  18979. * Default value : true. The SPS is faster when it's set to false.
  18980. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  18981. */
  18982. /**
  18983. * Tells to `setParticles()` to compute the particle rotations or not.
  18984. * Default value : true. The SPS is faster when it's set to false.
  18985. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  18986. */
  18987. computeParticleRotation: boolean;
  18988. /**
  18989. * Gets if `setParticles()` computes the particle colors or not.
  18990. * Default value : true. The SPS is faster when it's set to false.
  18991. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  18992. */
  18993. /**
  18994. * Tells to `setParticles()` to compute the particle colors or not.
  18995. * Default value : true. The SPS is faster when it's set to false.
  18996. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  18997. */
  18998. computeParticleColor: boolean;
  18999. /**
  19000. * Gets if `setParticles()` computes the particle textures or not.
  19001. * Default value : true. The SPS is faster when it's set to false.
  19002. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  19003. */
  19004. computeParticleTexture: boolean;
  19005. /**
  19006. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  19007. * Default value : false. The SPS is faster when it's set to false.
  19008. * Note : the particle custom vertex positions aren't stored values.
  19009. */
  19010. /**
  19011. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  19012. * Default value : false. The SPS is faster when it's set to false.
  19013. * Note : the particle custom vertex positions aren't stored values.
  19014. */
  19015. computeParticleVertex: boolean;
  19016. /**
  19017. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  19018. */
  19019. /**
  19020. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  19021. */
  19022. computeBoundingBox: boolean;
  19023. /**
  19024. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  19025. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19026. * Default : `true`
  19027. */
  19028. /**
  19029. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  19030. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19031. * Default : `true`
  19032. */
  19033. depthSortParticles: boolean;
  19034. /**
  19035. * This function does nothing. It may be overwritten to set all the particle first values.
  19036. * The SPS doesn't call this function, you may have to call it by your own.
  19037. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19038. */
  19039. initParticles(): void;
  19040. /**
  19041. * This function does nothing. It may be overwritten to recycle a particle.
  19042. * The SPS doesn't call this function, you may have to call it by your own.
  19043. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19044. * @param particle The particle to recycle
  19045. * @returns the recycled particle
  19046. */
  19047. recycleParticle(particle: SolidParticle): SolidParticle;
  19048. /**
  19049. * Updates a particle : this function should be overwritten by the user.
  19050. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  19051. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19052. * @example : just set a particle position or velocity and recycle conditions
  19053. * @param particle The particle to update
  19054. * @returns the updated particle
  19055. */
  19056. updateParticle(particle: SolidParticle): SolidParticle;
  19057. /**
  19058. * Updates a vertex of a particle : it can be overwritten by the user.
  19059. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  19060. * @param particle the current particle
  19061. * @param vertex the current index of the current particle
  19062. * @param pt the index of the current vertex in the particle shape
  19063. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  19064. * @example : just set a vertex particle position
  19065. * @returns the updated vertex
  19066. */
  19067. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  19068. /**
  19069. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  19070. * This does nothing and may be overwritten by the user.
  19071. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19072. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19073. * @param update the boolean update value actually passed to setParticles()
  19074. */
  19075. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19076. /**
  19077. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  19078. * This will be passed three parameters.
  19079. * This does nothing and may be overwritten by the user.
  19080. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19081. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19082. * @param update the boolean update value actually passed to setParticles()
  19083. */
  19084. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19085. }
  19086. }
  19087. declare module BABYLON {
  19088. interface PhysicsImpostorJoint {
  19089. mainImpostor: PhysicsImpostor;
  19090. connectedImpostor: PhysicsImpostor;
  19091. joint: PhysicsJoint;
  19092. }
  19093. class PhysicsEngine {
  19094. private _physicsPlugin;
  19095. gravity: Vector3;
  19096. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  19097. setGravity(gravity: Vector3): void;
  19098. /**
  19099. * Set the time step of the physics engine.
  19100. * default is 1/60.
  19101. * To slow it down, enter 1/600 for example.
  19102. * To speed it up, 1/30
  19103. * @param {number} newTimeStep the new timestep to apply to this world.
  19104. */
  19105. setTimeStep(newTimeStep?: number): void;
  19106. /**
  19107. * Get the time step of the physics engine.
  19108. */
  19109. getTimeStep(): number;
  19110. dispose(): void;
  19111. getPhysicsPluginName(): string;
  19112. static Epsilon: number;
  19113. private _impostors;
  19114. private _joints;
  19115. /**
  19116. * Adding a new impostor for the impostor tracking.
  19117. * This will be done by the impostor itself.
  19118. * @param {PhysicsImpostor} impostor the impostor to add
  19119. */
  19120. addImpostor(impostor: PhysicsImpostor): void;
  19121. /**
  19122. * Remove an impostor from the engine.
  19123. * This impostor and its mesh will not longer be updated by the physics engine.
  19124. * @param {PhysicsImpostor} impostor the impostor to remove
  19125. */
  19126. removeImpostor(impostor: PhysicsImpostor): void;
  19127. /**
  19128. * Add a joint to the physics engine
  19129. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  19130. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  19131. * @param {PhysicsJoint} the joint that will connect both impostors.
  19132. */
  19133. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19134. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19135. /**
  19136. * Called by the scene. no need to call it.
  19137. */
  19138. _step(delta: number): void;
  19139. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19140. getImpostors(): Array<PhysicsImpostor>;
  19141. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19142. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19143. }
  19144. interface IPhysicsEnginePlugin {
  19145. world: any;
  19146. name: string;
  19147. setGravity(gravity: Vector3): void;
  19148. setTimeStep(timeStep: number): void;
  19149. getTimeStep(): number;
  19150. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19151. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19152. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19153. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19154. removePhysicsBody(impostor: PhysicsImpostor): void;
  19155. generateJoint(joint: PhysicsImpostorJoint): void;
  19156. removeJoint(joint: PhysicsImpostorJoint): void;
  19157. isSupported(): boolean;
  19158. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19159. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19160. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19161. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19162. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19163. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19164. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19165. getBodyMass(impostor: PhysicsImpostor): number;
  19166. getBodyFriction(impostor: PhysicsImpostor): number;
  19167. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19168. getBodyRestitution(impostor: PhysicsImpostor): number;
  19169. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19170. sleepBody(impostor: PhysicsImpostor): void;
  19171. wakeUpBody(impostor: PhysicsImpostor): void;
  19172. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19173. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19174. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19175. getRadius(impostor: PhysicsImpostor): number;
  19176. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19177. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19178. dispose(): void;
  19179. }
  19180. }
  19181. declare module BABYLON {
  19182. class PhysicsHelper {
  19183. private _scene;
  19184. private _physicsEngine;
  19185. constructor(scene: Scene);
  19186. /**
  19187. * @param {Vector3} origin the origin of the explosion
  19188. * @param {number} radius the explosion radius
  19189. * @param {number} strength the explosion strength
  19190. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  19191. */
  19192. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  19193. /**
  19194. * @param {Vector3} origin the origin of the explosion
  19195. * @param {number} radius the explosion radius
  19196. * @param {number} strength the explosion strength
  19197. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  19198. */
  19199. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  19200. /**
  19201. * @param {Vector3} origin the origin of the explosion
  19202. * @param {number} radius the explosion radius
  19203. * @param {number} strength the explosion strength
  19204. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  19205. */
  19206. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  19207. /**
  19208. * @param {Vector3} origin the origin of the updraft
  19209. * @param {number} radius the radius of the updraft
  19210. * @param {number} strength the strength of the updraft
  19211. * @param {number} height the height of the updraft
  19212. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  19213. */
  19214. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  19215. /**
  19216. * @param {Vector3} origin the of the vortex
  19217. * @param {number} radius the radius of the vortex
  19218. * @param {number} strength the strength of the vortex
  19219. * @param {number} height the height of the vortex
  19220. */
  19221. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  19222. }
  19223. /***** Radial explosion *****/
  19224. class PhysicsRadialExplosionEvent {
  19225. private _scene;
  19226. private _sphere;
  19227. private _sphereOptions;
  19228. private _rays;
  19229. private _dataFetched;
  19230. constructor(scene: Scene);
  19231. /**
  19232. * Returns the data related to the radial explosion event (sphere & rays).
  19233. * @returns {PhysicsRadialExplosionEventData}
  19234. */
  19235. getData(): PhysicsRadialExplosionEventData;
  19236. /**
  19237. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  19238. * @param impostor
  19239. * @param {Vector3} origin the origin of the explosion
  19240. * @param {number} radius the explosion radius
  19241. * @param {number} strength the explosion strength
  19242. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  19243. * @returns {Nullable<PhysicsForceAndContactPoint>}
  19244. */
  19245. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  19246. /**
  19247. * Disposes the sphere.
  19248. * @param {bolean} force
  19249. */
  19250. dispose(force?: boolean): void;
  19251. /*** Helpers ***/
  19252. private _prepareSphere();
  19253. private _intersectsWithSphere(impostor, origin, radius);
  19254. }
  19255. /***** Gravitational Field *****/
  19256. class PhysicsGravitationalFieldEvent {
  19257. private _physicsHelper;
  19258. private _scene;
  19259. private _origin;
  19260. private _radius;
  19261. private _strength;
  19262. private _falloff;
  19263. private _tickCallback;
  19264. private _sphere;
  19265. private _dataFetched;
  19266. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  19267. /**
  19268. * Returns the data related to the gravitational field event (sphere).
  19269. * @returns {PhysicsGravitationalFieldEventData}
  19270. */
  19271. getData(): PhysicsGravitationalFieldEventData;
  19272. /**
  19273. * Enables the gravitational field.
  19274. */
  19275. enable(): void;
  19276. /**
  19277. * Disables the gravitational field.
  19278. */
  19279. disable(): void;
  19280. /**
  19281. * Disposes the sphere.
  19282. * @param {bolean} force
  19283. */
  19284. dispose(force?: boolean): void;
  19285. private _tick();
  19286. }
  19287. /***** Updraft *****/
  19288. class PhysicsUpdraftEvent {
  19289. private _scene;
  19290. private _origin;
  19291. private _radius;
  19292. private _strength;
  19293. private _height;
  19294. private _updraftMode;
  19295. private _physicsEngine;
  19296. private _originTop;
  19297. private _originDirection;
  19298. private _tickCallback;
  19299. private _cylinder;
  19300. private _cylinderPosition;
  19301. private _dataFetched;
  19302. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  19303. /**
  19304. * Returns the data related to the updraft event (cylinder).
  19305. * @returns {PhysicsUpdraftEventData}
  19306. */
  19307. getData(): PhysicsUpdraftEventData;
  19308. /**
  19309. * Enables the updraft.
  19310. */
  19311. enable(): void;
  19312. /**
  19313. * Disables the cortex.
  19314. */
  19315. disable(): void;
  19316. /**
  19317. * Disposes the sphere.
  19318. * @param {bolean} force
  19319. */
  19320. dispose(force?: boolean): void;
  19321. private getImpostorForceAndContactPoint(impostor);
  19322. private _tick();
  19323. /*** Helpers ***/
  19324. private _prepareCylinder();
  19325. private _intersectsWithCylinder(impostor);
  19326. }
  19327. /***** Vortex *****/
  19328. class PhysicsVortexEvent {
  19329. private _scene;
  19330. private _origin;
  19331. private _radius;
  19332. private _strength;
  19333. private _height;
  19334. private _physicsEngine;
  19335. private _originTop;
  19336. private _centripetalForceThreshold;
  19337. private _updraftMultiplier;
  19338. private _tickCallback;
  19339. private _cylinder;
  19340. private _cylinderPosition;
  19341. private _dataFetched;
  19342. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  19343. /**
  19344. * Returns the data related to the vortex event (cylinder).
  19345. * @returns {PhysicsVortexEventData}
  19346. */
  19347. getData(): PhysicsVortexEventData;
  19348. /**
  19349. * Enables the vortex.
  19350. */
  19351. enable(): void;
  19352. /**
  19353. * Disables the cortex.
  19354. */
  19355. disable(): void;
  19356. /**
  19357. * Disposes the sphere.
  19358. * @param {bolean} force
  19359. */
  19360. dispose(force?: boolean): void;
  19361. private getImpostorForceAndContactPoint(impostor);
  19362. private _tick();
  19363. /*** Helpers ***/
  19364. private _prepareCylinder();
  19365. private _intersectsWithCylinder(impostor);
  19366. }
  19367. /***** Enums *****/
  19368. /**
  19369. * The strenght of the force in correspondence to the distance of the affected object
  19370. */
  19371. enum PhysicsRadialImpulseFalloff {
  19372. Constant = 0,
  19373. Linear = 1,
  19374. }
  19375. /**
  19376. * The strenght of the force in correspondence to the distance of the affected object
  19377. */
  19378. enum PhysicsUpdraftMode {
  19379. Center = 0,
  19380. Perpendicular = 1,
  19381. }
  19382. /***** Data interfaces *****/
  19383. interface PhysicsForceAndContactPoint {
  19384. force: Vector3;
  19385. contactPoint: Vector3;
  19386. }
  19387. interface PhysicsRadialExplosionEventData {
  19388. sphere: Mesh;
  19389. rays: Array<Ray>;
  19390. }
  19391. interface PhysicsGravitationalFieldEventData {
  19392. sphere: Mesh;
  19393. }
  19394. interface PhysicsUpdraftEventData {
  19395. cylinder: Mesh;
  19396. }
  19397. interface PhysicsVortexEventData {
  19398. cylinder: Mesh;
  19399. }
  19400. }
  19401. declare module BABYLON {
  19402. interface PhysicsImpostorParameters {
  19403. mass: number;
  19404. friction?: number;
  19405. restitution?: number;
  19406. nativeOptions?: any;
  19407. ignoreParent?: boolean;
  19408. disableBidirectionalTransformation?: boolean;
  19409. }
  19410. interface IPhysicsEnabledObject {
  19411. position: Vector3;
  19412. rotationQuaternion: Nullable<Quaternion>;
  19413. scaling: Vector3;
  19414. rotation?: Vector3;
  19415. parent?: any;
  19416. getBoundingInfo(): BoundingInfo;
  19417. computeWorldMatrix(force: boolean): Matrix;
  19418. getWorldMatrix?(): Matrix;
  19419. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19420. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19421. getIndices?(): Nullable<IndicesArray>;
  19422. getScene?(): Scene;
  19423. getAbsolutePosition(): Vector3;
  19424. getAbsolutePivotPoint(): Vector3;
  19425. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19426. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19427. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19428. getClassName(): string;
  19429. }
  19430. class PhysicsImpostor {
  19431. object: IPhysicsEnabledObject;
  19432. type: number;
  19433. private _options;
  19434. private _scene;
  19435. static DEFAULT_OBJECT_SIZE: Vector3;
  19436. static IDENTITY_QUATERNION: Quaternion;
  19437. private _physicsEngine;
  19438. private _physicsBody;
  19439. private _bodyUpdateRequired;
  19440. private _onBeforePhysicsStepCallbacks;
  19441. private _onAfterPhysicsStepCallbacks;
  19442. private _onPhysicsCollideCallbacks;
  19443. private _deltaPosition;
  19444. private _deltaRotation;
  19445. private _deltaRotationConjugated;
  19446. private _parent;
  19447. private _isDisposed;
  19448. private static _tmpVecs;
  19449. private static _tmpQuat;
  19450. readonly isDisposed: boolean;
  19451. mass: number;
  19452. friction: number;
  19453. restitution: number;
  19454. uniqueId: number;
  19455. private _joints;
  19456. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19457. /**
  19458. * This function will completly initialize this impostor.
  19459. * It will create a new body - but only if this mesh has no parent.
  19460. * If it has, this impostor will not be used other than to define the impostor
  19461. * of the child mesh.
  19462. */
  19463. _init(): void;
  19464. private _getPhysicsParent();
  19465. /**
  19466. * Should a new body be generated.
  19467. */
  19468. isBodyInitRequired(): boolean;
  19469. setScalingUpdated(updated: boolean): void;
  19470. /**
  19471. * Force a regeneration of this or the parent's impostor's body.
  19472. * Use under cautious - This will remove all joints already implemented.
  19473. */
  19474. forceUpdate(): void;
  19475. /**
  19476. * Gets the body that holds this impostor. Either its own, or its parent.
  19477. */
  19478. /**
  19479. * Set the physics body. Used mainly by the physics engine/plugin
  19480. */
  19481. physicsBody: any;
  19482. parent: Nullable<PhysicsImpostor>;
  19483. resetUpdateFlags(): void;
  19484. getObjectExtendSize(): Vector3;
  19485. getObjectCenter(): Vector3;
  19486. /**
  19487. * Get a specific parametes from the options parameter.
  19488. */
  19489. getParam(paramName: string): any;
  19490. /**
  19491. * Sets a specific parameter in the options given to the physics plugin
  19492. */
  19493. setParam(paramName: string, value: number): void;
  19494. /**
  19495. * Specifically change the body's mass option. Won't recreate the physics body object
  19496. */
  19497. setMass(mass: number): void;
  19498. getLinearVelocity(): Nullable<Vector3>;
  19499. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19500. getAngularVelocity(): Nullable<Vector3>;
  19501. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19502. /**
  19503. * Execute a function with the physics plugin native code.
  19504. * Provide a function the will have two variables - the world object and the physics body object.
  19505. */
  19506. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19507. /**
  19508. * Register a function that will be executed before the physics world is stepping forward.
  19509. */
  19510. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19511. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19512. /**
  19513. * Register a function that will be executed after the physics step
  19514. */
  19515. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19516. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19517. /**
  19518. * register a function that will be executed when this impostor collides against a different body.
  19519. */
  19520. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19521. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19522. private _tmpQuat;
  19523. private _tmpQuat2;
  19524. getParentsRotation(): Quaternion;
  19525. /**
  19526. * this function is executed by the physics engine.
  19527. */
  19528. beforeStep: () => void;
  19529. /**
  19530. * this function is executed by the physics engine.
  19531. */
  19532. afterStep: () => void;
  19533. /**
  19534. * Legacy collision detection event support
  19535. */
  19536. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19537. onCollide: (e: {
  19538. body: any;
  19539. }) => void;
  19540. /**
  19541. * Apply a force
  19542. */
  19543. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19544. /**
  19545. * Apply an impulse
  19546. */
  19547. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19548. /**
  19549. * A help function to create a joint.
  19550. */
  19551. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19552. /**
  19553. * Add a joint to this impostor with a different impostor.
  19554. */
  19555. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19556. /**
  19557. * Will keep this body still, in a sleep mode.
  19558. */
  19559. sleep(): PhysicsImpostor;
  19560. /**
  19561. * Wake the body up.
  19562. */
  19563. wakeUp(): PhysicsImpostor;
  19564. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19565. dispose(): void;
  19566. setDeltaPosition(position: Vector3): void;
  19567. setDeltaRotation(rotation: Quaternion): void;
  19568. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19569. getRadius(): number;
  19570. /**
  19571. * Sync a bone with this impostor
  19572. * @param bone The bone to sync to the impostor.
  19573. * @param boneMesh The mesh that the bone is influencing.
  19574. * @param jointPivot The pivot of the joint / bone in local space.
  19575. * @param distToJoint Optional distance from the impostor to the joint.
  19576. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19577. */
  19578. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19579. /**
  19580. * Sync impostor to a bone
  19581. * @param bone The bone that the impostor will be synced to.
  19582. * @param boneMesh The mesh that the bone is influencing.
  19583. * @param jointPivot The pivot of the joint / bone in local space.
  19584. * @param distToJoint Optional distance from the impostor to the joint.
  19585. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19586. * @param boneAxis Optional vector3 axis the bone is aligned with
  19587. */
  19588. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19589. static NoImpostor: number;
  19590. static SphereImpostor: number;
  19591. static BoxImpostor: number;
  19592. static PlaneImpostor: number;
  19593. static MeshImpostor: number;
  19594. static CylinderImpostor: number;
  19595. static ParticleImpostor: number;
  19596. static HeightmapImpostor: number;
  19597. }
  19598. }
  19599. declare module BABYLON {
  19600. interface PhysicsJointData {
  19601. mainPivot?: Vector3;
  19602. connectedPivot?: Vector3;
  19603. mainAxis?: Vector3;
  19604. connectedAxis?: Vector3;
  19605. collision?: boolean;
  19606. nativeParams?: any;
  19607. }
  19608. /**
  19609. * This is a holder class for the physics joint created by the physics plugin.
  19610. * It holds a set of functions to control the underlying joint.
  19611. */
  19612. class PhysicsJoint {
  19613. type: number;
  19614. jointData: PhysicsJointData;
  19615. private _physicsJoint;
  19616. protected _physicsPlugin: IPhysicsEnginePlugin;
  19617. constructor(type: number, jointData: PhysicsJointData);
  19618. physicsJoint: any;
  19619. physicsPlugin: IPhysicsEnginePlugin;
  19620. /**
  19621. * Execute a function that is physics-plugin specific.
  19622. * @param {Function} func the function that will be executed.
  19623. * It accepts two parameters: the physics world and the physics joint.
  19624. */
  19625. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19626. static DistanceJoint: number;
  19627. static HingeJoint: number;
  19628. static BallAndSocketJoint: number;
  19629. static WheelJoint: number;
  19630. static SliderJoint: number;
  19631. static PrismaticJoint: number;
  19632. static UniversalJoint: number;
  19633. static Hinge2Joint: number;
  19634. static PointToPointJoint: number;
  19635. static SpringJoint: number;
  19636. static LockJoint: number;
  19637. }
  19638. /**
  19639. * A class representing a physics distance joint.
  19640. */
  19641. class DistanceJoint extends PhysicsJoint {
  19642. constructor(jointData: DistanceJointData);
  19643. /**
  19644. * Update the predefined distance.
  19645. */
  19646. updateDistance(maxDistance: number, minDistance?: number): void;
  19647. }
  19648. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19649. constructor(type: number, jointData: PhysicsJointData);
  19650. /**
  19651. * Set the motor values.
  19652. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19653. * @param {number} force the force to apply
  19654. * @param {number} maxForce max force for this motor.
  19655. */
  19656. setMotor(force?: number, maxForce?: number): void;
  19657. /**
  19658. * Set the motor's limits.
  19659. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19660. */
  19661. setLimit(upperLimit: number, lowerLimit?: number): void;
  19662. }
  19663. /**
  19664. * This class represents a single hinge physics joint
  19665. */
  19666. class HingeJoint extends MotorEnabledJoint {
  19667. constructor(jointData: PhysicsJointData);
  19668. /**
  19669. * Set the motor values.
  19670. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19671. * @param {number} force the force to apply
  19672. * @param {number} maxForce max force for this motor.
  19673. */
  19674. setMotor(force?: number, maxForce?: number): void;
  19675. /**
  19676. * Set the motor's limits.
  19677. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19678. */
  19679. setLimit(upperLimit: number, lowerLimit?: number): void;
  19680. }
  19681. /**
  19682. * This class represents a dual hinge physics joint (same as wheel joint)
  19683. */
  19684. class Hinge2Joint extends MotorEnabledJoint {
  19685. constructor(jointData: PhysicsJointData);
  19686. /**
  19687. * Set the motor values.
  19688. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19689. * @param {number} force the force to apply
  19690. * @param {number} maxForce max force for this motor.
  19691. * @param {motorIndex} the motor's index, 0 or 1.
  19692. */
  19693. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19694. /**
  19695. * Set the motor limits.
  19696. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19697. * @param {number} upperLimit the upper limit
  19698. * @param {number} lowerLimit lower limit
  19699. * @param {motorIndex} the motor's index, 0 or 1.
  19700. */
  19701. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19702. }
  19703. interface IMotorEnabledJoint {
  19704. physicsJoint: any;
  19705. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19706. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19707. }
  19708. interface DistanceJointData extends PhysicsJointData {
  19709. maxDistance: number;
  19710. }
  19711. interface SpringJointData extends PhysicsJointData {
  19712. length: number;
  19713. stiffness: number;
  19714. damping: number;
  19715. }
  19716. }
  19717. declare module BABYLON {
  19718. class ReflectionProbe {
  19719. name: string;
  19720. private _scene;
  19721. private _renderTargetTexture;
  19722. private _projectionMatrix;
  19723. private _viewMatrix;
  19724. private _target;
  19725. private _add;
  19726. private _attachedMesh;
  19727. private _invertYAxis;
  19728. position: Vector3;
  19729. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  19730. samples: number;
  19731. refreshRate: number;
  19732. getScene(): Scene;
  19733. readonly cubeTexture: RenderTargetTexture;
  19734. readonly renderList: Nullable<AbstractMesh[]>;
  19735. attachToMesh(mesh: AbstractMesh): void;
  19736. /**
  19737. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19738. *
  19739. * @param renderingGroupId The rendering group id corresponding to its index
  19740. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19741. */
  19742. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19743. dispose(): void;
  19744. }
  19745. }
  19746. declare module BABYLON {
  19747. class AnaglyphPostProcess extends PostProcess {
  19748. private _passedProcess;
  19749. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  19750. }
  19751. }
  19752. declare module BABYLON {
  19753. class BlackAndWhitePostProcess extends PostProcess {
  19754. degree: number;
  19755. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  19756. }
  19757. }
  19758. declare module BABYLON {
  19759. /**
  19760. * The Blur Post Process which blurs an image based on a kernel and direction.
  19761. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19762. */
  19763. class BlurPostProcess extends PostProcess {
  19764. /** The direction in which to blur the image. */ direction: Vector2;
  19765. private blockCompilation;
  19766. protected _kernel: number;
  19767. protected _idealKernel: number;
  19768. protected _packedFloat: boolean;
  19769. private _staticDefines;
  19770. /**
  19771. * Gets the length in pixels of the blur sample region
  19772. */
  19773. /**
  19774. * Sets the length in pixels of the blur sample region
  19775. */
  19776. kernel: number;
  19777. /**
  19778. * Gets wether or not the blur is unpacking/repacking floats
  19779. */
  19780. /**
  19781. * Sets wether or not the blur needs to unpack/repack floats
  19782. */
  19783. packedFloat: boolean;
  19784. /**
  19785. * Creates a new instance of @see BlurPostProcess
  19786. * @param name The name of the effect.
  19787. * @param direction The direction in which to blur the image.
  19788. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  19789. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19790. * @param camera The camera to apply the render pass to.
  19791. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19792. * @param engine The engine which the post process will be applied. (default: current engine)
  19793. * @param reusable If the post process can be reused on the same frame. (default: false)
  19794. * @param textureType Type of textures used when performing the post process. (default: 0)
  19795. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  19796. */
  19797. constructor(name: string, /** The direction in which to blur the image. */ direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  19798. /**
  19799. * Updates the effect with the current post process compile time values and recompiles the shader.
  19800. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19801. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19802. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19803. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  19804. * @param onCompiled Called when the shader has been compiled.
  19805. * @param onError Called if there is an error when compiling a shader.
  19806. */
  19807. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19808. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19809. /**
  19810. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  19811. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  19812. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  19813. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  19814. * The gaps between physical kernels are compensated for in the weighting of the samples
  19815. * @param idealKernel Ideal blur kernel.
  19816. * @return Nearest best kernel.
  19817. */
  19818. protected _nearestBestKernel(idealKernel: number): number;
  19819. /**
  19820. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  19821. * @param x The point on the Gaussian distribution to sample.
  19822. * @return the value of the Gaussian function at x.
  19823. */
  19824. protected _gaussianWeight(x: number): number;
  19825. /**
  19826. * Generates a string that can be used as a floating point number in GLSL.
  19827. * @param x Value to print.
  19828. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  19829. * @return GLSL float string.
  19830. */
  19831. protected _glslFloat(x: number, decimalFigures?: number): string;
  19832. }
  19833. }
  19834. declare module BABYLON {
  19835. /**
  19836. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  19837. */
  19838. class ChromaticAberrationPostProcess extends PostProcess {
  19839. /**
  19840. * The amount of seperation of rgb channels (default: 30)
  19841. */
  19842. aberrationAmount: number;
  19843. /**
  19844. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  19845. */
  19846. radialIntensity: number;
  19847. /**
  19848. * The normilized direction in which the rgb channels should be seperated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  19849. */
  19850. direction: Vector2;
  19851. /**
  19852. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corder] (default: Vector2(0.5 ,0.5))
  19853. */
  19854. centerPosition: Vector2;
  19855. /**
  19856. * Creates a new instance of @see ChromaticAberrationPostProcess
  19857. * @param name The name of the effect.
  19858. * @param screenWidth The width of the screen to apply the effect on.
  19859. * @param screenHeight The height of the screen to apply the effect on.
  19860. * @param options The required width/height ratio to downsize to before computing the render pass.
  19861. * @param camera The camera to apply the render pass to.
  19862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19863. * @param engine The engine which the post process will be applied. (default: current engine)
  19864. * @param reusable If the post process can be reused on the same frame. (default: false)
  19865. * @param textureType Type of textures used when performing the post process. (default: 0)
  19866. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  19867. */
  19868. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  19869. }
  19870. }
  19871. declare module BABYLON {
  19872. /**
  19873. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  19874. */
  19875. class CircleOfConfusionPostProcess extends PostProcess {
  19876. /**
  19877. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  19878. */
  19879. lensSize: number;
  19880. /**
  19881. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  19882. */
  19883. fStop: number;
  19884. /**
  19885. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  19886. */
  19887. focusDistance: number;
  19888. /**
  19889. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  19890. */
  19891. focalLength: number;
  19892. private _depthTexture;
  19893. /**
  19894. * Creates a new instance of @see CircleOfConfusionPostProcess
  19895. * @param name The name of the effect.
  19896. * @param depthTexture The depth texture of the scene to compute the circle of confusion. This must be set in order for this to function but may be set after initialization if needed.
  19897. * @param options The required width/height ratio to downsize to before computing the render pass.
  19898. * @param camera The camera to apply the render pass to.
  19899. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19900. * @param engine The engine which the post process will be applied. (default: current engine)
  19901. * @param reusable If the post process can be reused on the same frame. (default: false)
  19902. * @param textureType Type of textures used when performing the post process. (default: 0)
  19903. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  19904. */
  19905. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  19906. /**
  19907. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  19908. */
  19909. depthTexture: RenderTargetTexture;
  19910. }
  19911. }
  19912. declare module BABYLON {
  19913. class ColorCorrectionPostProcess extends PostProcess {
  19914. private _colorTableTexture;
  19915. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  19916. }
  19917. }
  19918. declare module BABYLON {
  19919. /**
  19920. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  19921. * input texture to perform effects such as edge detection or sharpening
  19922. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  19923. */
  19924. class ConvolutionPostProcess extends PostProcess {
  19925. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  19926. /**
  19927. * Creates a new instance of @see ConvolutionPostProcess
  19928. * @param name The name of the effect.
  19929. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  19930. * @param options The required width/height ratio to downsize to before computing the render pass.
  19931. * @param camera The camera to apply the render pass to.
  19932. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19933. * @param engine The engine which the post process will be applied. (default: current engine)
  19934. * @param reusable If the post process can be reused on the same frame. (default: false)
  19935. * @param textureType Type of textures used when performing the post process. (default: 0)
  19936. */
  19937. constructor(name: string, /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  19938. /**
  19939. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  19940. */
  19941. static EdgeDetect0Kernel: number[];
  19942. /**
  19943. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  19944. */
  19945. static EdgeDetect1Kernel: number[];
  19946. /**
  19947. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  19948. */
  19949. static EdgeDetect2Kernel: number[];
  19950. /**
  19951. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  19952. */
  19953. static SharpenKernel: number[];
  19954. /**
  19955. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  19956. */
  19957. static EmbossKernel: number[];
  19958. /**
  19959. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  19960. */
  19961. static GaussianKernel: number[];
  19962. }
  19963. }
  19964. declare module BABYLON {
  19965. /**
  19966. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  19967. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  19968. * based on samples that have a large difference in distance than the center pixel.
  19969. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  19970. */
  19971. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  19972. direction: Vector2;
  19973. /**
  19974. * Creates a new instance of @see CircleOfConfusionPostProcess
  19975. * @param name The name of the effect.
  19976. * @param scene The scene the effect belongs to.
  19977. * @param direction The direction the blur should be applied.
  19978. * @param kernel The size of the kernel used to blur.
  19979. * @param options The required width/height ratio to downsize to before computing the render pass.
  19980. * @param camera The camera to apply the render pass to.
  19981. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  19982. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  19983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19984. * @param engine The engine which the post process will be applied. (default: current engine)
  19985. * @param reusable If the post process can be reused on the same frame. (default: false)
  19986. * @param textureType Type of textures used when performing the post process. (default: 0)
  19987. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  19988. */
  19989. constructor(name: string, scene: Scene, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, circleOfConfusion: PostProcess, imageToBlur?: Nullable<PostProcess>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  19990. }
  19991. }
  19992. declare module BABYLON {
  19993. /**
  19994. * Specifies the level of max blur that should be applied when using the depth of field effect
  19995. */
  19996. enum DepthOfFieldEffectBlurLevel {
  19997. /**
  19998. * Subtle blur
  19999. */
  20000. Low = 0,
  20001. /**
  20002. * Medium blur
  20003. */
  20004. Medium = 1,
  20005. /**
  20006. * Large blur
  20007. */
  20008. High = 2,
  20009. }
  20010. /**
  20011. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  20012. */
  20013. class DepthOfFieldEffect extends PostProcessRenderEffect {
  20014. private _circleOfConfusion;
  20015. private _depthOfFieldBlurX;
  20016. private _depthOfFieldBlurY;
  20017. /**
  20018. * Private, last post process of dof
  20019. */
  20020. _depthOfFieldMerge: DepthOfFieldMergePostProcess;
  20021. private _effects;
  20022. /**
  20023. * The focal the length of the camera used in the effect
  20024. */
  20025. focalLength: number;
  20026. /**
  20027. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  20028. */
  20029. fStop: number;
  20030. /**
  20031. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  20032. */
  20033. focusDistance: number;
  20034. /**
  20035. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  20036. */
  20037. lensSize: number;
  20038. /**
  20039. * Creates a new instance of @see DepthOfFieldEffect
  20040. * @param scene The scene the effect belongs to.
  20041. * @param depthTexture The depth texture of the scene to compute the circle of confusion.This must be set in order for this to function but may be set after initialization if needed.
  20042. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  20043. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20044. */
  20045. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  20046. /**
  20047. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  20048. */
  20049. depthTexture: RenderTargetTexture;
  20050. /**
  20051. * Disposes each of the internal effects for a given camera.
  20052. * @param camera The camera to dispose the effect on.
  20053. */
  20054. disposeEffects(camera: Camera): void;
  20055. /**
  20056. * Internal
  20057. */
  20058. _updateEffects(): void;
  20059. /**
  20060. * Internal
  20061. * @returns if all the contained post processes are ready.
  20062. */
  20063. _isReady(): boolean;
  20064. }
  20065. }
  20066. declare module BABYLON {
  20067. /**
  20068. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  20069. */
  20070. class DepthOfFieldMergePostProcess extends PostProcess {
  20071. private blurSteps;
  20072. /**
  20073. * Creates a new instance of @see CircleOfConfusionPostProcess
  20074. * @param name The name of the effect.
  20075. * @param original The non-blurred image to be modified
  20076. * @param circleOfConfusion The circle of confusion post process that will determine how blurred each pixel should become.
  20077. * @param blurSteps Incrimental bluring post processes.
  20078. * @param options The required width/height ratio to downsize to before computing the render pass.
  20079. * @param camera The camera to apply the render pass to.
  20080. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20081. * @param engine The engine which the post process will be applied. (default: current engine)
  20082. * @param reusable If the post process can be reused on the same frame. (default: false)
  20083. * @param textureType Type of textures used when performing the post process. (default: 0)
  20084. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20085. */
  20086. constructor(name: string, original: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20087. /**
  20088. * Updates the effect with the current post process compile time values and recompiles the shader.
  20089. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20090. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20091. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20092. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20093. * @param onCompiled Called when the shader has been compiled.
  20094. * @param onError Called if there is an error when compiling a shader.
  20095. */
  20096. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20097. }
  20098. }
  20099. declare module BABYLON {
  20100. class DisplayPassPostProcess extends PostProcess {
  20101. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20102. }
  20103. }
  20104. declare module BABYLON {
  20105. class FilterPostProcess extends PostProcess {
  20106. kernelMatrix: Matrix;
  20107. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20108. }
  20109. }
  20110. declare module BABYLON {
  20111. class FxaaPostProcess extends PostProcess {
  20112. texelWidth: number;
  20113. texelHeight: number;
  20114. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  20115. }
  20116. }
  20117. declare module BABYLON {
  20118. class HighlightsPostProcess extends PostProcess {
  20119. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  20120. }
  20121. }
  20122. declare module BABYLON {
  20123. class ImageProcessingPostProcess extends PostProcess {
  20124. /**
  20125. * Default configuration related to image processing available in the PBR Material.
  20126. */
  20127. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  20128. /**
  20129. * Gets the image processing configuration used either in this material.
  20130. */
  20131. /**
  20132. * Sets the Default image processing configuration used either in the this material.
  20133. *
  20134. * If sets to null, the scene one is in use.
  20135. */
  20136. imageProcessingConfiguration: ImageProcessingConfiguration;
  20137. /**
  20138. * Keep track of the image processing observer to allow dispose and replace.
  20139. */
  20140. private _imageProcessingObserver;
  20141. /**
  20142. * Attaches a new image processing configuration to the PBR Material.
  20143. * @param configuration
  20144. */
  20145. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  20146. /**
  20147. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  20148. */
  20149. /**
  20150. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  20151. */
  20152. colorCurves: Nullable<ColorCurves>;
  20153. /**
  20154. * Gets wether the color curves effect is enabled.
  20155. */
  20156. /**
  20157. * Sets wether the color curves effect is enabled.
  20158. */
  20159. colorCurvesEnabled: boolean;
  20160. /**
  20161. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  20162. */
  20163. /**
  20164. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  20165. */
  20166. colorGradingTexture: Nullable<BaseTexture>;
  20167. /**
  20168. * Gets wether the color grading effect is enabled.
  20169. */
  20170. /**
  20171. * Gets wether the color grading effect is enabled.
  20172. */
  20173. colorGradingEnabled: boolean;
  20174. /**
  20175. * Gets exposure used in the effect.
  20176. */
  20177. /**
  20178. * Sets exposure used in the effect.
  20179. */
  20180. exposure: number;
  20181. /**
  20182. * Gets wether tonemapping is enabled or not.
  20183. */
  20184. /**
  20185. * Sets wether tonemapping is enabled or not
  20186. */
  20187. toneMappingEnabled: boolean;
  20188. /**
  20189. * Gets contrast used in the effect.
  20190. */
  20191. /**
  20192. * Sets contrast used in the effect.
  20193. */
  20194. contrast: number;
  20195. /**
  20196. * Gets Vignette stretch size.
  20197. */
  20198. /**
  20199. * Sets Vignette stretch size.
  20200. */
  20201. vignetteStretch: number;
  20202. /**
  20203. * Gets Vignette centre X Offset.
  20204. */
  20205. /**
  20206. * Sets Vignette centre X Offset.
  20207. */
  20208. vignetteCentreX: number;
  20209. /**
  20210. * Gets Vignette centre Y Offset.
  20211. */
  20212. /**
  20213. * Sets Vignette centre Y Offset.
  20214. */
  20215. vignetteCentreY: number;
  20216. /**
  20217. * Gets Vignette weight or intensity of the vignette effect.
  20218. */
  20219. /**
  20220. * Sets Vignette weight or intensity of the vignette effect.
  20221. */
  20222. vignetteWeight: number;
  20223. /**
  20224. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  20225. * if vignetteEnabled is set to true.
  20226. */
  20227. /**
  20228. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  20229. * if vignetteEnabled is set to true.
  20230. */
  20231. vignetteColor: Color4;
  20232. /**
  20233. * Gets Camera field of view used by the Vignette effect.
  20234. */
  20235. /**
  20236. * Sets Camera field of view used by the Vignette effect.
  20237. */
  20238. vignetteCameraFov: number;
  20239. /**
  20240. * Gets the vignette blend mode allowing different kind of effect.
  20241. */
  20242. /**
  20243. * Sets the vignette blend mode allowing different kind of effect.
  20244. */
  20245. vignetteBlendMode: number;
  20246. /**
  20247. * Gets wether the vignette effect is enabled.
  20248. */
  20249. /**
  20250. * Sets wether the vignette effect is enabled.
  20251. */
  20252. vignetteEnabled: boolean;
  20253. /**
  20254. * Gets wether the grain effect is enabled.
  20255. */
  20256. /**
  20257. * Sets wether the grain effect is enabled.
  20258. */
  20259. grainEnabled: boolean;
  20260. /**
  20261. * Gets the grain effect's intensity.
  20262. */
  20263. /**
  20264. * Sets the grain effect's intensity.
  20265. */
  20266. grainIntensity: number;
  20267. /**
  20268. * Gets wether the grain effect is animated.
  20269. */
  20270. /**
  20271. * Sets wether the grain effect is animated.
  20272. */
  20273. grainAnimated: boolean;
  20274. private _fromLinearSpace;
  20275. /**
  20276. * Gets wether the input of the processing is in Gamma or Linear Space.
  20277. */
  20278. /**
  20279. * Sets wether the input of the processing is in Gamma or Linear Space.
  20280. */
  20281. fromLinearSpace: boolean;
  20282. /**
  20283. * Defines cache preventing GC.
  20284. */
  20285. private _defines;
  20286. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  20287. getClassName(): string;
  20288. protected _updateParameters(): void;
  20289. dispose(camera?: Camera): void;
  20290. }
  20291. }
  20292. declare module BABYLON {
  20293. class PassPostProcess extends PostProcess {
  20294. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20295. }
  20296. }
  20297. declare module BABYLON {
  20298. type PostProcessOptions = {
  20299. width: number;
  20300. height: number;
  20301. };
  20302. /**
  20303. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20304. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20305. */
  20306. class PostProcess {
  20307. /** Name of the PostProcess. */ name: string;
  20308. /**
  20309. * Width of the texture to apply the post process on
  20310. */
  20311. width: number;
  20312. /**
  20313. * Height of the texture to apply the post process on
  20314. */
  20315. height: number;
  20316. /**
  20317. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20318. */
  20319. _outputTexture: Nullable<InternalTexture>;
  20320. /**
  20321. * Sampling mode used by the shader
  20322. * See https://doc.babylonjs.com/classes/3.1/texture
  20323. */
  20324. renderTargetSamplingMode: number;
  20325. /**
  20326. * Clear color to use when screen clearing
  20327. */
  20328. clearColor: Color4;
  20329. /**
  20330. * If the buffer needs to be cleared before applying the post process. (default: true)
  20331. * Should be set to false if shader will overwrite all previous pixels.
  20332. */
  20333. autoClear: boolean;
  20334. /**
  20335. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20336. */
  20337. alphaMode: number;
  20338. /**
  20339. * Sets the setAlphaBlendConstants of the babylon engine
  20340. */
  20341. alphaConstants: Color4;
  20342. /**
  20343. * Animations to be used for the post processing
  20344. */
  20345. animations: Animation[];
  20346. /**
  20347. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20348. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20349. */
  20350. enablePixelPerfectMode: boolean;
  20351. /**
  20352. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20353. */
  20354. scaleMode: number;
  20355. /**
  20356. * Force textures to be a power of two (default: false)
  20357. */
  20358. alwaysForcePOT: boolean;
  20359. /**
  20360. * Number of sample textures (default: 1)
  20361. */
  20362. samples: number;
  20363. /**
  20364. * Modify the scale of the post process to be the same as the viewport (default: false)
  20365. */
  20366. adaptScaleToCurrentViewport: boolean;
  20367. private _camera;
  20368. private _scene;
  20369. private _engine;
  20370. private _options;
  20371. private _reusable;
  20372. private _textureType;
  20373. /**
  20374. * Smart array of input and output textures for the post process.
  20375. */
  20376. _textures: SmartArray<InternalTexture>;
  20377. /**
  20378. * The index in _textures that corresponds to the output texture.
  20379. */
  20380. _currentRenderTextureInd: number;
  20381. private _effect;
  20382. private _samplers;
  20383. private _fragmentUrl;
  20384. private _vertexUrl;
  20385. private _parameters;
  20386. private _scaleRatio;
  20387. protected _indexParameters: any;
  20388. private _shareOutputWithPostProcess;
  20389. private _texelSize;
  20390. private _forcedOutputTexture;
  20391. /**
  20392. * An event triggered when the postprocess is activated.
  20393. * @type {BABYLON.Observable}
  20394. */
  20395. onActivateObservable: Observable<Camera>;
  20396. private _onActivateObserver;
  20397. /**
  20398. * A function that is added to the onActivateObservable
  20399. */
  20400. onActivate: Nullable<(camera: Camera) => void>;
  20401. /**
  20402. * An event triggered when the postprocess changes its size.
  20403. * @type {BABYLON.Observable}
  20404. */
  20405. onSizeChangedObservable: Observable<PostProcess>;
  20406. private _onSizeChangedObserver;
  20407. /**
  20408. * A function that is added to the onSizeChangedObservable
  20409. */
  20410. onSizeChanged: (postProcess: PostProcess) => void;
  20411. /**
  20412. * An event triggered when the postprocess applies its effect.
  20413. * @type {BABYLON.Observable}
  20414. */
  20415. onApplyObservable: Observable<Effect>;
  20416. private _onApplyObserver;
  20417. /**
  20418. * A function that is added to the onApplyObservable
  20419. */
  20420. onApply: (effect: Effect) => void;
  20421. /**
  20422. * An event triggered before rendering the postprocess
  20423. * @type {BABYLON.Observable}
  20424. */
  20425. onBeforeRenderObservable: Observable<Effect>;
  20426. private _onBeforeRenderObserver;
  20427. /**
  20428. * A function that is added to the onBeforeRenderObservable
  20429. */
  20430. onBeforeRender: (effect: Effect) => void;
  20431. /**
  20432. * An event triggered after rendering the postprocess
  20433. * @type {BABYLON.Observable}
  20434. */
  20435. onAfterRenderObservable: Observable<Effect>;
  20436. private _onAfterRenderObserver;
  20437. /**
  20438. * A function that is added to the onAfterRenderObservable
  20439. */
  20440. onAfterRender: (efect: Effect) => void;
  20441. /**
  20442. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  20443. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20444. */
  20445. inputTexture: InternalTexture;
  20446. /**
  20447. * Gets the camera which post process is applied to.
  20448. * @returns The camera the post process is applied to.
  20449. */
  20450. getCamera(): Camera;
  20451. /**
  20452. * Gets the texel size of the postprocess.
  20453. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20454. */
  20455. readonly texelSize: Vector2;
  20456. /**
  20457. * Creates a new instance of @see PostProcess
  20458. * @param name The name of the PostProcess.
  20459. * @param fragmentUrl The url of the fragment shader to be used.
  20460. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20461. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20462. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20463. * @param camera The camera to apply the render pass to.
  20464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20465. * @param engine The engine which the post process will be applied. (default: current engine)
  20466. * @param reusable If the post process can be reused on the same frame. (default: false)
  20467. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20468. * @param textureType Type of textures used when performing the post process. (default: 0)
  20469. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20470. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20471. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20472. */
  20473. constructor(/** Name of the PostProcess. */ name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  20474. /**
  20475. * Gets the engine which this post process belongs to.
  20476. * @returns The engine the post process was enabled with.
  20477. */
  20478. getEngine(): Engine;
  20479. /**
  20480. * The effect that is created when initializing the post process.
  20481. * @returns The created effect corrisponding the the postprocess.
  20482. */
  20483. getEffect(): Effect;
  20484. /**
  20485. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20486. * @param postProcess The post process to share the output with.
  20487. * @returns This post process.
  20488. */
  20489. shareOutputWith(postProcess: PostProcess): PostProcess;
  20490. /**
  20491. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20492. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20493. */
  20494. useOwnOutput(): void;
  20495. /**
  20496. * Updates the effect with the current post process compile time values and recompiles the shader.
  20497. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20498. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20499. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20500. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20501. * @param onCompiled Called when the shader has been compiled.
  20502. * @param onError Called if there is an error when compiling a shader.
  20503. */
  20504. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20505. /**
  20506. * The post process is reusable if it can be used multiple times within one frame.
  20507. * @returns If the post process is reusable
  20508. */
  20509. isReusable(): boolean;
  20510. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20511. markTextureDirty(): void;
  20512. /**
  20513. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20514. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  20515. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20516. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20517. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20518. * @returns The target texture that was bound to be written to.
  20519. */
  20520. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20521. /**
  20522. * If the post process is supported.
  20523. */
  20524. readonly isSupported: boolean;
  20525. /**
  20526. * The aspect ratio of the output texture.
  20527. */
  20528. readonly aspectRatio: number;
  20529. /**
  20530. * Get a value indicating if the post-process is ready to be used
  20531. * @returns true if the post-process is ready (shader is compiled)
  20532. */
  20533. isReady(): boolean;
  20534. /**
  20535. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20536. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  20537. */
  20538. apply(): Nullable<Effect>;
  20539. private _disposeTextures();
  20540. /**
  20541. * Disposes the post process.
  20542. * @param camera The camera to dispose the post process on.
  20543. */
  20544. dispose(camera?: Camera): void;
  20545. }
  20546. }
  20547. declare module BABYLON {
  20548. /**
  20549. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20550. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20551. */
  20552. class PostProcessManager {
  20553. private _scene;
  20554. private _indexBuffer;
  20555. private _vertexBuffers;
  20556. /**
  20557. * Creates a new instance of @see PostProcess
  20558. * @param scene The scene that the post process is associated with.
  20559. */
  20560. constructor(scene: Scene);
  20561. private _prepareBuffers();
  20562. private _buildIndexBuffer();
  20563. /**
  20564. * Rebuilds the vertex buffers of the manager.
  20565. */
  20566. _rebuild(): void;
  20567. /**
  20568. * Prepares a frame to be run through a post process.
  20569. * @param sourceTexture The input texture to the post procesess. (default: null)
  20570. * @param postProcesses An array of post processes to be run. (default: null)
  20571. * @returns True if the post processes were able to be run.
  20572. */
  20573. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20574. /**
  20575. * Manually render a set of post processes to a texture.
  20576. * @param postProcesses An array of post processes to be run.
  20577. * @param targetTexture The target texture to render to.
  20578. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20579. */
  20580. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  20581. /**
  20582. * Finalize the result of the output of the postprocesses.
  20583. * @param doNotPresent If true the result will not be displayed to the screen.
  20584. * @param targetTexture The target texture to render to.
  20585. * @param faceIndex The index of the face to bind the target texture to.
  20586. * @param postProcesses The array of post processes to render.
  20587. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20588. */
  20589. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20590. /**
  20591. * Disposes of the post process manager.
  20592. */
  20593. dispose(): void;
  20594. }
  20595. }
  20596. declare module BABYLON {
  20597. class RefractionPostProcess extends PostProcess {
  20598. color: Color3;
  20599. depth: number;
  20600. colorLevel: number;
  20601. private _refTexture;
  20602. private _ownRefractionTexture;
  20603. /**
  20604. * Gets or sets the refraction texture
  20605. * Please note that you are responsible for disposing the texture if you set it manually
  20606. */
  20607. refractionTexture: Texture;
  20608. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20609. dispose(camera: Camera): void;
  20610. }
  20611. }
  20612. declare module BABYLON {
  20613. /**
  20614. * The SharpenPostProcess applies a sharpen kernel to every pixel
  20615. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  20616. */
  20617. class SharpenPostProcess extends PostProcess {
  20618. /**
  20619. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  20620. */
  20621. colorAmount: number;
  20622. /**
  20623. * How much sharpness should be applied (default: 0.3)
  20624. */
  20625. edgeAmount: number;
  20626. /**
  20627. * Creates a new instance of @see ConvolutionPostProcess
  20628. * @param name The name of the effect.
  20629. * @param options The required width/height ratio to downsize to before computing the render pass.
  20630. * @param camera The camera to apply the render pass to.
  20631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20632. * @param engine The engine which the post process will be applied. (default: current engine)
  20633. * @param reusable If the post process can be reused on the same frame. (default: false)
  20634. * @param textureType Type of textures used when performing the post process. (default: 0)
  20635. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20636. */
  20637. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20638. }
  20639. }
  20640. declare module BABYLON {
  20641. class StereoscopicInterlacePostProcess extends PostProcess {
  20642. private _stepSize;
  20643. private _passedProcess;
  20644. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20645. }
  20646. }
  20647. declare module BABYLON {
  20648. enum TonemappingOperator {
  20649. Hable = 0,
  20650. Reinhard = 1,
  20651. HejiDawson = 2,
  20652. Photographic = 3,
  20653. }
  20654. class TonemapPostProcess extends PostProcess {
  20655. private _operator;
  20656. exposureAdjustment: number;
  20657. constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  20658. }
  20659. }
  20660. declare module BABYLON {
  20661. class VolumetricLightScatteringPostProcess extends PostProcess {
  20662. private _volumetricLightScatteringPass;
  20663. private _volumetricLightScatteringRTT;
  20664. private _viewPort;
  20665. private _screenCoordinates;
  20666. private _cachedDefines;
  20667. /**
  20668. * If not undefined, the mesh position is computed from the attached node position
  20669. * @type {{position: Vector3}}
  20670. */
  20671. attachedNode: {
  20672. position: Vector3;
  20673. };
  20674. /**
  20675. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  20676. * @type {Vector3}
  20677. */
  20678. customMeshPosition: Vector3;
  20679. /**
  20680. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  20681. * @type {boolean}
  20682. */
  20683. useCustomMeshPosition: boolean;
  20684. /**
  20685. * If the post-process should inverse the light scattering direction
  20686. * @type {boolean}
  20687. */
  20688. invert: boolean;
  20689. /**
  20690. * The internal mesh used by the post-process
  20691. * @type {boolean}
  20692. */
  20693. mesh: Mesh;
  20694. useDiffuseColor: boolean;
  20695. /**
  20696. * Array containing the excluded meshes not rendered in the internal pass
  20697. */
  20698. excludedMeshes: AbstractMesh[];
  20699. /**
  20700. * Controls the overall intensity of the post-process
  20701. * @type {number}
  20702. */
  20703. exposure: number;
  20704. /**
  20705. * Dissipates each sample's contribution in range [0, 1]
  20706. * @type {number}
  20707. */
  20708. decay: number;
  20709. /**
  20710. * Controls the overall intensity of each sample
  20711. * @type {number}
  20712. */
  20713. weight: number;
  20714. /**
  20715. * Controls the density of each sample
  20716. * @type {number}
  20717. */
  20718. density: number;
  20719. /**
  20720. * @constructor
  20721. * @param {string} name - The post-process name
  20722. * @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)
  20723. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  20724. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  20725. * @param {number} samples - The post-process quality, default 100
  20726. * @param {number} samplingMode - The post-process filtering mode
  20727. * @param {BABYLON.Engine} engine - The babylon engine
  20728. * @param {boolean} reusable - If the post-process is reusable
  20729. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  20730. */
  20731. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  20732. getClassName(): string;
  20733. private _isReady(subMesh, useInstances);
  20734. /**
  20735. * Sets the new light position for light scattering effect
  20736. * @param {BABYLON.Vector3} The new custom light position
  20737. */
  20738. setCustomMeshPosition(position: Vector3): void;
  20739. /**
  20740. * Returns the light position for light scattering effect
  20741. * @return {BABYLON.Vector3} The custom light position
  20742. */
  20743. getCustomMeshPosition(): Vector3;
  20744. /**
  20745. * Disposes the internal assets and detaches the post-process from the camera
  20746. */
  20747. dispose(camera: Camera): void;
  20748. /**
  20749. * Returns the render target texture used by the post-process
  20750. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  20751. */
  20752. getPass(): RenderTargetTexture;
  20753. private _meshExcluded(mesh);
  20754. private _createPass(scene, ratio);
  20755. private _updateMeshScreenCoordinates(scene);
  20756. /**
  20757. * Creates a default mesh for the Volumeric Light Scattering post-process
  20758. * @param {string} The mesh name
  20759. * @param {BABYLON.Scene} The scene where to create the mesh
  20760. * @return {BABYLON.Mesh} the default mesh
  20761. */
  20762. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  20763. }
  20764. }
  20765. declare module BABYLON {
  20766. class VRDistortionCorrectionPostProcess extends PostProcess {
  20767. private _isRightEye;
  20768. private _distortionFactors;
  20769. private _postProcessScaleFactor;
  20770. private _lensCenterOffset;
  20771. private _scaleIn;
  20772. private _scaleFactor;
  20773. private _lensCenter;
  20774. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  20775. }
  20776. }
  20777. declare module BABYLON {
  20778. class BoundingBoxRenderer {
  20779. frontColor: Color3;
  20780. backColor: Color3;
  20781. showBackLines: boolean;
  20782. renderList: SmartArray<BoundingBox>;
  20783. private _scene;
  20784. private _colorShader;
  20785. private _vertexBuffers;
  20786. private _indexBuffer;
  20787. constructor(scene: Scene);
  20788. private _prepareRessources();
  20789. private _createIndexBuffer();
  20790. _rebuild(): void;
  20791. reset(): void;
  20792. render(): void;
  20793. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  20794. dispose(): void;
  20795. }
  20796. }
  20797. declare module BABYLON {
  20798. /**
  20799. * This represents a depth renderer in Babylon.
  20800. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  20801. */
  20802. class DepthRenderer {
  20803. private _scene;
  20804. private _depthMap;
  20805. private _effect;
  20806. private _cachedDefines;
  20807. private _camera;
  20808. /**
  20809. * Instantiates a depth renderer
  20810. * @param scene The scene the renderer belongs to
  20811. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  20812. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  20813. */
  20814. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  20815. /**
  20816. * Creates the depth rendering effect and checks if the effect is ready.
  20817. * @param subMesh The submesh to be used to render the depth map of
  20818. * @param useInstances If multiple world instances should be used
  20819. * @returns if the depth renderer is ready to render the depth map
  20820. */
  20821. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  20822. /**
  20823. * Gets the texture which the depth map will be written to.
  20824. * @returns The depth map texture
  20825. */
  20826. getDepthMap(): RenderTargetTexture;
  20827. /**
  20828. * Disposes of the depth renderer.
  20829. */
  20830. dispose(): void;
  20831. }
  20832. }
  20833. declare module BABYLON {
  20834. class EdgesRenderer {
  20835. edgesWidthScalerForOrthographic: number;
  20836. edgesWidthScalerForPerspective: number;
  20837. private _source;
  20838. private _linesPositions;
  20839. private _linesNormals;
  20840. private _linesIndices;
  20841. private _epsilon;
  20842. private _indicesCount;
  20843. private _lineShader;
  20844. private _ib;
  20845. private _buffers;
  20846. private _checkVerticesInsteadOfIndices;
  20847. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20848. private _prepareRessources();
  20849. _rebuild(): void;
  20850. dispose(): void;
  20851. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  20852. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  20853. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  20854. _generateEdgesLines(): void;
  20855. render(): void;
  20856. }
  20857. }
  20858. declare module BABYLON {
  20859. /**
  20860. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  20861. */
  20862. class GeometryBufferRenderer {
  20863. private _scene;
  20864. private _multiRenderTarget;
  20865. private _ratio;
  20866. private _enablePosition;
  20867. protected _effect: Effect;
  20868. protected _cachedDefines: string;
  20869. /**
  20870. * Set the render list (meshes to be rendered) used in the G buffer.
  20871. */
  20872. renderList: Mesh[];
  20873. /**
  20874. * Gets wether or not G buffer are supported by the running hardware.
  20875. * This requires draw buffer supports
  20876. */
  20877. readonly isSupported: boolean;
  20878. /**
  20879. * Gets wether or not position are enabled for the G buffer.
  20880. */
  20881. /**
  20882. * Sets wether or not position are enabled for the G buffer.
  20883. */
  20884. enablePosition: boolean;
  20885. /**
  20886. * Gets the scene associated with the buffer.
  20887. */
  20888. readonly scene: Scene;
  20889. /**
  20890. * Gets the ratio used by the buffer during its creation.
  20891. * How big is the buffer related to the main canvas.
  20892. */
  20893. readonly ratio: number;
  20894. /**
  20895. * Creates a new G Buffer for the scene. @see GeometryBufferRenderer
  20896. * @param scene The scene the buffer belongs to
  20897. * @param ratio How big is the buffer related to the main canvas.
  20898. */
  20899. constructor(scene: Scene, ratio?: number);
  20900. /**
  20901. * Checks wether everything is ready to render a submesh to the G buffer.
  20902. * @param subMesh the submesh to check readiness for
  20903. * @param useInstances is the mesh drawn using instance or not
  20904. * @returns true if ready otherwise false
  20905. */
  20906. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  20907. /**
  20908. * Gets the current underlying G Buffer.
  20909. * @returns the buffer
  20910. */
  20911. getGBuffer(): MultiRenderTarget;
  20912. /**
  20913. * Gets the number of samples used to render the buffer (anti aliasing).
  20914. */
  20915. /**
  20916. * Sets the number of samples used to render the buffer (anti aliasing).
  20917. */
  20918. samples: number;
  20919. /**
  20920. * Disposes the renderer and frees up associated resources.
  20921. */
  20922. dispose(): void;
  20923. protected _createRenderTargets(): void;
  20924. }
  20925. }
  20926. declare module BABYLON {
  20927. class OutlineRenderer {
  20928. private _scene;
  20929. private _effect;
  20930. private _cachedDefines;
  20931. zOffset: number;
  20932. constructor(scene: Scene);
  20933. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  20934. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  20935. }
  20936. }
  20937. declare module BABYLON {
  20938. class RenderingGroup {
  20939. index: number;
  20940. private _scene;
  20941. private _opaqueSubMeshes;
  20942. private _transparentSubMeshes;
  20943. private _alphaTestSubMeshes;
  20944. private _depthOnlySubMeshes;
  20945. private _particleSystems;
  20946. private _spriteManagers;
  20947. private _opaqueSortCompareFn;
  20948. private _alphaTestSortCompareFn;
  20949. private _transparentSortCompareFn;
  20950. private _renderOpaque;
  20951. private _renderAlphaTest;
  20952. private _renderTransparent;
  20953. private _edgesRenderers;
  20954. onBeforeTransparentRendering: () => void;
  20955. /**
  20956. * Set the opaque sort comparison function.
  20957. * If null the sub meshes will be render in the order they were created
  20958. */
  20959. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20960. /**
  20961. * Set the alpha test sort comparison function.
  20962. * If null the sub meshes will be render in the order they were created
  20963. */
  20964. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20965. /**
  20966. * Set the transparent sort comparison function.
  20967. * If null the sub meshes will be render in the order they were created
  20968. */
  20969. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20970. /**
  20971. * Creates a new rendering group.
  20972. * @param index The rendering group index
  20973. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20974. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20975. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20976. */
  20977. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20978. /**
  20979. * Render all the sub meshes contained in the group.
  20980. * @param customRenderFunction Used to override the default render behaviour of the group.
  20981. * @returns true if rendered some submeshes.
  20982. */
  20983. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20984. /**
  20985. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20986. * @param subMeshes The submeshes to render
  20987. */
  20988. private renderOpaqueSorted(subMeshes);
  20989. /**
  20990. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20991. * @param subMeshes The submeshes to render
  20992. */
  20993. private renderAlphaTestSorted(subMeshes);
  20994. /**
  20995. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20996. * @param subMeshes The submeshes to render
  20997. */
  20998. private renderTransparentSorted(subMeshes);
  20999. /**
  21000. * Renders the submeshes in a specified order.
  21001. * @param subMeshes The submeshes to sort before render
  21002. * @param sortCompareFn The comparison function use to sort
  21003. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  21004. * @param transparent Specifies to activate blending if true
  21005. */
  21006. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  21007. /**
  21008. * Renders the submeshes in the order they were dispatched (no sort applied).
  21009. * @param subMeshes The submeshes to render
  21010. */
  21011. private static renderUnsorted(subMeshes);
  21012. /**
  21013. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21014. * are rendered back to front if in the same alpha index.
  21015. *
  21016. * @param a The first submesh
  21017. * @param b The second submesh
  21018. * @returns The result of the comparison
  21019. */
  21020. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  21021. /**
  21022. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21023. * are rendered back to front.
  21024. *
  21025. * @param a The first submesh
  21026. * @param b The second submesh
  21027. * @returns The result of the comparison
  21028. */
  21029. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  21030. /**
  21031. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21032. * are rendered front to back (prevent overdraw).
  21033. *
  21034. * @param a The first submesh
  21035. * @param b The second submesh
  21036. * @returns The result of the comparison
  21037. */
  21038. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  21039. /**
  21040. * Resets the different lists of submeshes to prepare a new frame.
  21041. */
  21042. prepare(): void;
  21043. dispose(): void;
  21044. /**
  21045. * Inserts the submesh in its correct queue depending on its material.
  21046. * @param subMesh The submesh to dispatch
  21047. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21048. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21049. */
  21050. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21051. dispatchSprites(spriteManager: SpriteManager): void;
  21052. dispatchParticles(particleSystem: IParticleSystem): void;
  21053. private _renderParticles(activeMeshes);
  21054. private _renderSprites();
  21055. }
  21056. }
  21057. declare module BABYLON {
  21058. class RenderingManager {
  21059. /**
  21060. * The max id used for rendering groups (not included)
  21061. */
  21062. static MAX_RENDERINGGROUPS: number;
  21063. /**
  21064. * The min id used for rendering groups (included)
  21065. */
  21066. static MIN_RENDERINGGROUPS: number;
  21067. /**
  21068. * Used to globally prevent autoclearing scenes.
  21069. */
  21070. static AUTOCLEAR: boolean;
  21071. private _scene;
  21072. private _renderingGroups;
  21073. private _depthStencilBufferAlreadyCleaned;
  21074. private _autoClearDepthStencil;
  21075. private _customOpaqueSortCompareFn;
  21076. private _customAlphaTestSortCompareFn;
  21077. private _customTransparentSortCompareFn;
  21078. private _renderinGroupInfo;
  21079. constructor(scene: Scene);
  21080. private _clearDepthStencilBuffer(depth?, stencil?);
  21081. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  21082. reset(): void;
  21083. dispose(): void;
  21084. /**
  21085. * Clear the info related to rendering groups preventing retention points during dispose.
  21086. */
  21087. freeRenderingGroups(): void;
  21088. private _prepareRenderingGroup(renderingGroupId);
  21089. dispatchSprites(spriteManager: SpriteManager): void;
  21090. dispatchParticles(particleSystem: IParticleSystem): void;
  21091. /**
  21092. * @param subMesh The submesh to dispatch
  21093. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21094. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21095. */
  21096. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21097. /**
  21098. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21099. * This allowed control for front to back rendering or reversly depending of the special needs.
  21100. *
  21101. * @param renderingGroupId The rendering group id corresponding to its index
  21102. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21103. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21104. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21105. */
  21106. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  21107. /**
  21108. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21109. *
  21110. * @param renderingGroupId The rendering group id corresponding to its index
  21111. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21112. * @param depth Automatically clears depth between groups if true and autoClear is true.
  21113. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  21114. */
  21115. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  21116. }
  21117. }
  21118. declare module BABYLON {
  21119. class Sprite {
  21120. name: string;
  21121. position: Vector3;
  21122. color: Color4;
  21123. width: number;
  21124. height: number;
  21125. angle: number;
  21126. cellIndex: number;
  21127. invertU: number;
  21128. invertV: number;
  21129. disposeWhenFinishedAnimating: boolean;
  21130. animations: Animation[];
  21131. isPickable: boolean;
  21132. actionManager: ActionManager;
  21133. private _animationStarted;
  21134. private _loopAnimation;
  21135. private _fromIndex;
  21136. private _toIndex;
  21137. private _delay;
  21138. private _direction;
  21139. private _manager;
  21140. private _time;
  21141. private _onAnimationEnd;
  21142. size: number;
  21143. constructor(name: string, manager: SpriteManager);
  21144. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  21145. stopAnimation(): void;
  21146. _animate(deltaTime: number): void;
  21147. dispose(): void;
  21148. }
  21149. }
  21150. declare module BABYLON {
  21151. class SpriteManager {
  21152. name: string;
  21153. sprites: Sprite[];
  21154. renderingGroupId: number;
  21155. layerMask: number;
  21156. fogEnabled: boolean;
  21157. isPickable: boolean;
  21158. cellWidth: number;
  21159. cellHeight: number;
  21160. /**
  21161. * An event triggered when the manager is disposed.
  21162. * @type {BABYLON.Observable}
  21163. */
  21164. onDisposeObservable: Observable<SpriteManager>;
  21165. private _onDisposeObserver;
  21166. onDispose: () => void;
  21167. private _capacity;
  21168. private _spriteTexture;
  21169. private _epsilon;
  21170. private _scene;
  21171. private _vertexData;
  21172. private _buffer;
  21173. private _vertexBuffers;
  21174. private _indexBuffer;
  21175. private _effectBase;
  21176. private _effectFog;
  21177. texture: Texture;
  21178. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  21179. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  21180. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  21181. render(): void;
  21182. dispose(): void;
  21183. }
  21184. }
  21185. declare module BABYLON {
  21186. class _AlphaState {
  21187. private _isAlphaBlendDirty;
  21188. private _isBlendFunctionParametersDirty;
  21189. private _isBlendEquationParametersDirty;
  21190. private _isBlendConstantsDirty;
  21191. private _alphaBlend;
  21192. private _blendFunctionParameters;
  21193. private _blendEquationParameters;
  21194. private _blendConstants;
  21195. /**
  21196. * Initializes the state.
  21197. */
  21198. constructor();
  21199. readonly isDirty: boolean;
  21200. alphaBlend: boolean;
  21201. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  21202. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  21203. setAlphaEquationParameters(rgb: number, alpha: number): void;
  21204. reset(): void;
  21205. apply(gl: WebGLRenderingContext): void;
  21206. }
  21207. }
  21208. declare module BABYLON {
  21209. class _DepthCullingState {
  21210. private _isDepthTestDirty;
  21211. private _isDepthMaskDirty;
  21212. private _isDepthFuncDirty;
  21213. private _isCullFaceDirty;
  21214. private _isCullDirty;
  21215. private _isZOffsetDirty;
  21216. private _isFrontFaceDirty;
  21217. private _depthTest;
  21218. private _depthMask;
  21219. private _depthFunc;
  21220. private _cull;
  21221. private _cullFace;
  21222. private _zOffset;
  21223. private _frontFace;
  21224. /**
  21225. * Initializes the state.
  21226. */
  21227. constructor();
  21228. readonly isDirty: boolean;
  21229. zOffset: number;
  21230. cullFace: Nullable<number>;
  21231. cull: Nullable<boolean>;
  21232. depthFunc: Nullable<number>;
  21233. depthMask: boolean;
  21234. depthTest: boolean;
  21235. frontFace: Nullable<number>;
  21236. reset(): void;
  21237. apply(gl: WebGLRenderingContext): void;
  21238. }
  21239. }
  21240. declare module BABYLON {
  21241. class _StencilState {
  21242. private _isStencilTestDirty;
  21243. private _isStencilMaskDirty;
  21244. private _isStencilFuncDirty;
  21245. private _isStencilOpDirty;
  21246. private _stencilTest;
  21247. private _stencilMask;
  21248. private _stencilFunc;
  21249. private _stencilFuncRef;
  21250. private _stencilFuncMask;
  21251. private _stencilOpStencilFail;
  21252. private _stencilOpDepthFail;
  21253. private _stencilOpStencilDepthPass;
  21254. readonly isDirty: boolean;
  21255. stencilFunc: number;
  21256. stencilFuncRef: number;
  21257. stencilFuncMask: number;
  21258. stencilOpStencilFail: number;
  21259. stencilOpDepthFail: number;
  21260. stencilOpStencilDepthPass: number;
  21261. stencilMask: number;
  21262. stencilTest: boolean;
  21263. constructor();
  21264. reset(): void;
  21265. apply(gl: WebGLRenderingContext): void;
  21266. }
  21267. }
  21268. declare module BABYLON {
  21269. class AndOrNotEvaluator {
  21270. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  21271. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  21272. private static _SimplifyNegation(booleanString);
  21273. }
  21274. }
  21275. declare module BABYLON {
  21276. /**
  21277. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  21278. */
  21279. enum AssetTaskState {
  21280. /**
  21281. * Initialization
  21282. */
  21283. INIT = 0,
  21284. /**
  21285. * Running
  21286. */
  21287. RUNNING = 1,
  21288. /**
  21289. * Done
  21290. */
  21291. DONE = 2,
  21292. /**
  21293. * Error
  21294. */
  21295. ERROR = 3,
  21296. }
  21297. /**
  21298. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  21299. */
  21300. abstract class AbstractAssetTask {
  21301. /**
  21302. * Task name
  21303. */ name: string;
  21304. /**
  21305. * Callback called when the task is successful
  21306. */
  21307. onSuccess: (task: any) => void;
  21308. /**
  21309. * Callback called when the task is successful
  21310. */
  21311. onError: (task: any, message?: string, exception?: any) => void;
  21312. /**
  21313. * Creates a new {BABYLON.AssetsManager}
  21314. * @param name defines the name of the task
  21315. */
  21316. constructor(
  21317. /**
  21318. * Task name
  21319. */ name: string);
  21320. private _isCompleted;
  21321. private _taskState;
  21322. private _errorObject;
  21323. /**
  21324. * Get if the task is completed
  21325. */
  21326. readonly isCompleted: boolean;
  21327. /**
  21328. * Gets the current state of the task
  21329. */
  21330. readonly taskState: AssetTaskState;
  21331. /**
  21332. * Gets the current error object (if task is in error)
  21333. */
  21334. readonly errorObject: {
  21335. message?: string;
  21336. exception?: any;
  21337. };
  21338. /**
  21339. * Internal only
  21340. * @ignore
  21341. */
  21342. _setErrorObject(message?: string, exception?: any): void;
  21343. /**
  21344. * Execute the current task
  21345. * @param scene defines the scene where you want your assets to be loaded
  21346. * @param onSuccess is a callback called when the task is successfully executed
  21347. * @param onError is a callback called if an error occurs
  21348. */
  21349. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21350. /**
  21351. * Execute the current task
  21352. * @param scene defines the scene where you want your assets to be loaded
  21353. * @param onSuccess is a callback called when the task is successfully executed
  21354. * @param onError is a callback called if an error occurs
  21355. */
  21356. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21357. private onErrorCallback(onError, message?, exception?);
  21358. private onDoneCallback(onSuccess, onError);
  21359. }
  21360. /**
  21361. * Define the interface used by progress events raised during assets loading
  21362. */
  21363. interface IAssetsProgressEvent {
  21364. /**
  21365. * Defines the number of remaining tasks to process
  21366. */
  21367. remainingCount: number;
  21368. /**
  21369. * Defines the total number of tasks
  21370. */
  21371. totalCount: number;
  21372. /**
  21373. * Defines the task that was just processed
  21374. */
  21375. task: AbstractAssetTask;
  21376. }
  21377. /**
  21378. * Class used to share progress information about assets loading
  21379. */
  21380. class AssetsProgressEvent implements IAssetsProgressEvent {
  21381. /**
  21382. * Defines the number of remaining tasks to process
  21383. */
  21384. remainingCount: number;
  21385. /**
  21386. * Defines the total number of tasks
  21387. */
  21388. totalCount: number;
  21389. /**
  21390. * Defines the task that was just processed
  21391. */
  21392. task: AbstractAssetTask;
  21393. /**
  21394. * Creates a {BABYLON.AssetsProgressEvent}
  21395. * @param remainingCount defines the number of remaining tasks to process
  21396. * @param totalCount defines the total number of tasks
  21397. * @param task defines the task that was just processed
  21398. */
  21399. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  21400. }
  21401. /**
  21402. * Define a task used by {BABYLON.AssetsManager} to load meshes
  21403. */
  21404. class MeshAssetTask extends AbstractAssetTask {
  21405. /**
  21406. * Defines the name of the task
  21407. */
  21408. name: string;
  21409. /**
  21410. * Defines the list of mesh's names you want to load
  21411. */
  21412. meshesNames: any;
  21413. /**
  21414. * Defines the root url to use as a base to load your meshes and associated resources
  21415. */
  21416. rootUrl: string;
  21417. /**
  21418. * Defines the filename of the scene to load from
  21419. */
  21420. sceneFilename: string;
  21421. /**
  21422. * Gets the list of loaded meshes
  21423. */
  21424. loadedMeshes: Array<AbstractMesh>;
  21425. /**
  21426. * Gets the list of loaded particle systems
  21427. */
  21428. loadedParticleSystems: Array<ParticleSystem>;
  21429. /**
  21430. * Gets the list of loaded skeletons
  21431. */
  21432. loadedSkeletons: Array<Skeleton>;
  21433. /**
  21434. * Callback called when the task is successful
  21435. */
  21436. onSuccess: (task: MeshAssetTask) => void;
  21437. /**
  21438. * Callback called when the task is successful
  21439. */
  21440. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  21441. /**
  21442. * Creates a new {BABYLON.MeshAssetTask}
  21443. * @param name defines the name of the task
  21444. * @param meshesNames defines the list of mesh's names you want to load
  21445. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  21446. * @param sceneFilename defines the filename of the scene to load from
  21447. */
  21448. constructor(
  21449. /**
  21450. * Defines the name of the task
  21451. */
  21452. name: string,
  21453. /**
  21454. * Defines the list of mesh's names you want to load
  21455. */
  21456. meshesNames: any,
  21457. /**
  21458. * Defines the root url to use as a base to load your meshes and associated resources
  21459. */
  21460. rootUrl: string,
  21461. /**
  21462. * Defines the filename of the scene to load from
  21463. */
  21464. sceneFilename: string);
  21465. /**
  21466. * Execute the current task
  21467. * @param scene defines the scene where you want your assets to be loaded
  21468. * @param onSuccess is a callback called when the task is successfully executed
  21469. * @param onError is a callback called if an error occurs
  21470. */
  21471. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21472. }
  21473. /**
  21474. * Define a task used by {BABYLON.AssetsManager} to load text content
  21475. */
  21476. class TextFileAssetTask extends AbstractAssetTask {
  21477. /**
  21478. * Defines the name of the task
  21479. */
  21480. name: string;
  21481. /**
  21482. * Defines the location of the file to load
  21483. */
  21484. url: string;
  21485. /**
  21486. * Gets the loaded text string
  21487. */
  21488. text: string;
  21489. /**
  21490. * Callback called when the task is successful
  21491. */
  21492. onSuccess: (task: TextFileAssetTask) => void;
  21493. /**
  21494. * Callback called when the task is successful
  21495. */
  21496. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  21497. /**
  21498. * Creates a new TextFileAssetTask object
  21499. * @param name defines the name of the task
  21500. * @param url defines the location of the file to load
  21501. */
  21502. constructor(
  21503. /**
  21504. * Defines the name of the task
  21505. */
  21506. name: string,
  21507. /**
  21508. * Defines the location of the file to load
  21509. */
  21510. url: string);
  21511. /**
  21512. * Execute the current task
  21513. * @param scene defines the scene where you want your assets to be loaded
  21514. * @param onSuccess is a callback called when the task is successfully executed
  21515. * @param onError is a callback called if an error occurs
  21516. */
  21517. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21518. }
  21519. /**
  21520. * Define a task used by {BABYLON.AssetsManager} to load binary data
  21521. */
  21522. class BinaryFileAssetTask extends AbstractAssetTask {
  21523. /**
  21524. * Defines the name of the task
  21525. */
  21526. name: string;
  21527. /**
  21528. * Defines the location of the file to load
  21529. */
  21530. url: string;
  21531. /**
  21532. * Gets the lodaded data (as an array buffer)
  21533. */
  21534. data: ArrayBuffer;
  21535. /**
  21536. * Callback called when the task is successful
  21537. */
  21538. onSuccess: (task: BinaryFileAssetTask) => void;
  21539. /**
  21540. * Callback called when the task is successful
  21541. */
  21542. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  21543. /**
  21544. * Creates a new BinaryFileAssetTask object
  21545. * @param name defines the name of the new task
  21546. * @param url defines the location of the file to load
  21547. */
  21548. constructor(
  21549. /**
  21550. * Defines the name of the task
  21551. */
  21552. name: string,
  21553. /**
  21554. * Defines the location of the file to load
  21555. */
  21556. url: string);
  21557. /**
  21558. * Execute the current task
  21559. * @param scene defines the scene where you want your assets to be loaded
  21560. * @param onSuccess is a callback called when the task is successfully executed
  21561. * @param onError is a callback called if an error occurs
  21562. */
  21563. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21564. }
  21565. /**
  21566. * Define a task used by {BABYLON.AssetsManager} to load images
  21567. */
  21568. class ImageAssetTask extends AbstractAssetTask {
  21569. /**
  21570. * Defines the name of the task
  21571. */
  21572. name: string;
  21573. /**
  21574. * Defines the location of the image to load
  21575. */
  21576. url: string;
  21577. /**
  21578. * Gets the loaded images
  21579. */
  21580. image: HTMLImageElement;
  21581. /**
  21582. * Callback called when the task is successful
  21583. */
  21584. onSuccess: (task: ImageAssetTask) => void;
  21585. /**
  21586. * Callback called when the task is successful
  21587. */
  21588. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  21589. /**
  21590. * Creates a new ImageAssetTask
  21591. * @param name defines the name of the task
  21592. * @param url defines the location of the image to load
  21593. */
  21594. constructor(
  21595. /**
  21596. * Defines the name of the task
  21597. */
  21598. name: string,
  21599. /**
  21600. * Defines the location of the image to load
  21601. */
  21602. url: string);
  21603. /**
  21604. * Execute the current task
  21605. * @param scene defines the scene where you want your assets to be loaded
  21606. * @param onSuccess is a callback called when the task is successfully executed
  21607. * @param onError is a callback called if an error occurs
  21608. */
  21609. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21610. }
  21611. /**
  21612. * Defines the interface used by texture loading tasks
  21613. */
  21614. interface ITextureAssetTask<TEX extends BaseTexture> {
  21615. /**
  21616. * Gets the loaded texture
  21617. */
  21618. texture: TEX;
  21619. }
  21620. /**
  21621. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  21622. */
  21623. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  21624. /**
  21625. * Defines the name of the task
  21626. */
  21627. name: string;
  21628. /**
  21629. * Defines the location of the file to load
  21630. */
  21631. url: string;
  21632. /**
  21633. * Defines if mipmap should not be generated (default is false)
  21634. */
  21635. noMipmap: boolean | undefined;
  21636. /**
  21637. * Defines if texture must be inverted on Y axis (default is false)
  21638. */
  21639. invertY: boolean | undefined;
  21640. /**
  21641. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  21642. */
  21643. samplingMode: number;
  21644. /**
  21645. * Gets the loaded texture
  21646. */
  21647. texture: Texture;
  21648. /**
  21649. * Callback called when the task is successful
  21650. */
  21651. onSuccess: (task: TextureAssetTask) => void;
  21652. /**
  21653. * Callback called when the task is successful
  21654. */
  21655. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  21656. /**
  21657. * Creates a new TextureAssetTask object
  21658. * @param name defines the name of the task
  21659. * @param url defines the location of the file to load
  21660. * @param noMipmap defines if mipmap should not be generated (default is false)
  21661. * @param invertY defines if texture must be inverted on Y axis (default is false)
  21662. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  21663. */
  21664. constructor(
  21665. /**
  21666. * Defines the name of the task
  21667. */
  21668. name: string,
  21669. /**
  21670. * Defines the location of the file to load
  21671. */
  21672. url: string,
  21673. /**
  21674. * Defines if mipmap should not be generated (default is false)
  21675. */
  21676. noMipmap?: boolean | undefined,
  21677. /**
  21678. * Defines if texture must be inverted on Y axis (default is false)
  21679. */
  21680. invertY?: boolean | undefined,
  21681. /**
  21682. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  21683. */
  21684. samplingMode?: number);
  21685. /**
  21686. * Execute the current task
  21687. * @param scene defines the scene where you want your assets to be loaded
  21688. * @param onSuccess is a callback called when the task is successfully executed
  21689. * @param onError is a callback called if an error occurs
  21690. */
  21691. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21692. }
  21693. /**
  21694. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  21695. */
  21696. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  21697. /**
  21698. * Defines the name of the task
  21699. */
  21700. name: string;
  21701. /**
  21702. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  21703. */
  21704. url: string;
  21705. /**
  21706. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  21707. */
  21708. extensions: string[] | undefined;
  21709. /**
  21710. * Defines if mipmaps should not be generated (default is false)
  21711. */
  21712. noMipmap: boolean | undefined;
  21713. /**
  21714. * Defines the explicit list of files (undefined by default)
  21715. */
  21716. files: string[] | undefined;
  21717. /**
  21718. * Gets the loaded texture
  21719. */
  21720. texture: CubeTexture;
  21721. /**
  21722. * Callback called when the task is successful
  21723. */
  21724. onSuccess: (task: CubeTextureAssetTask) => void;
  21725. /**
  21726. * Callback called when the task is successful
  21727. */
  21728. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  21729. /**
  21730. * Creates a new CubeTextureAssetTask
  21731. * @param name defines the name of the task
  21732. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  21733. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  21734. * @param noMipmap defines if mipmaps should not be generated (default is false)
  21735. * @param files defines the explicit list of files (undefined by default)
  21736. */
  21737. constructor(
  21738. /**
  21739. * Defines the name of the task
  21740. */
  21741. name: string,
  21742. /**
  21743. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  21744. */
  21745. url: string,
  21746. /**
  21747. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  21748. */
  21749. extensions?: string[] | undefined,
  21750. /**
  21751. * Defines if mipmaps should not be generated (default is false)
  21752. */
  21753. noMipmap?: boolean | undefined,
  21754. /**
  21755. * Defines the explicit list of files (undefined by default)
  21756. */
  21757. files?: string[] | undefined);
  21758. /**
  21759. * Execute the current task
  21760. * @param scene defines the scene where you want your assets to be loaded
  21761. * @param onSuccess is a callback called when the task is successfully executed
  21762. * @param onError is a callback called if an error occurs
  21763. */
  21764. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21765. }
  21766. /**
  21767. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  21768. */
  21769. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  21770. /**
  21771. * Defines the name of the task
  21772. */
  21773. name: string;
  21774. /**
  21775. * Defines the location of the file to load
  21776. */
  21777. url: string;
  21778. /**
  21779. * Defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
  21780. */
  21781. size: number | undefined;
  21782. /**
  21783. * Defines if mipmaps should not be generated (default is false)
  21784. */
  21785. noMipmap: boolean;
  21786. /**
  21787. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  21788. */
  21789. generateHarmonics: boolean;
  21790. /**
  21791. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  21792. */
  21793. useInGammaSpace: boolean;
  21794. /**
  21795. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  21796. */
  21797. usePMREMGenerator: boolean;
  21798. /**
  21799. * Gets the loaded texture
  21800. */
  21801. texture: HDRCubeTexture;
  21802. /**
  21803. * Callback called when the task is successful
  21804. */
  21805. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  21806. /**
  21807. * Callback called when the task is successful
  21808. */
  21809. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  21810. /**
  21811. * Creates a new HDRCubeTextureAssetTask object
  21812. * @param name defines the name of the task
  21813. * @param url defines the location of the file to load
  21814. * @param size defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
  21815. * @param noMipmap defines if mipmaps should not be generated (default is false)
  21816. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  21817. * @param useInGammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  21818. * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  21819. */
  21820. constructor(
  21821. /**
  21822. * Defines the name of the task
  21823. */
  21824. name: string,
  21825. /**
  21826. * Defines the location of the file to load
  21827. */
  21828. url: string,
  21829. /**
  21830. * Defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
  21831. */
  21832. size?: number | undefined,
  21833. /**
  21834. * Defines if mipmaps should not be generated (default is false)
  21835. */
  21836. noMipmap?: boolean,
  21837. /**
  21838. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  21839. */
  21840. generateHarmonics?: boolean,
  21841. /**
  21842. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  21843. */
  21844. useInGammaSpace?: boolean,
  21845. /**
  21846. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  21847. */
  21848. usePMREMGenerator?: boolean);
  21849. /**
  21850. * Execute the current task
  21851. * @param scene defines the scene where you want your assets to be loaded
  21852. * @param onSuccess is a callback called when the task is successfully executed
  21853. * @param onError is a callback called if an error occurs
  21854. */
  21855. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21856. }
  21857. /**
  21858. * This class can be used to easily import assets into a scene
  21859. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  21860. */
  21861. class AssetsManager {
  21862. private _scene;
  21863. private _isLoading;
  21864. protected _tasks: AbstractAssetTask[];
  21865. protected _waitingTasksCount: number;
  21866. protected _totalTasksCount: number;
  21867. /**
  21868. * Callback called when all tasks are processed
  21869. */
  21870. onFinish: (tasks: AbstractAssetTask[]) => void;
  21871. /**
  21872. * Callback called when a task is successful
  21873. */
  21874. onTaskSuccess: (task: AbstractAssetTask) => void;
  21875. /**
  21876. * Callback called when a task had an error
  21877. */
  21878. onTaskError: (task: AbstractAssetTask) => void;
  21879. /**
  21880. * Callback called when a task is done (whatever the result is)
  21881. */
  21882. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  21883. /**
  21884. * Observable called when all tasks are processed
  21885. */
  21886. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  21887. /**
  21888. * Observable called when a task had an error
  21889. */
  21890. onTaskErrorObservable: Observable<AbstractAssetTask>;
  21891. /**
  21892. * Observable called when a task is successful
  21893. */
  21894. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  21895. /**
  21896. * Observable called when a task is done (whatever the result is)
  21897. */
  21898. onProgressObservable: Observable<IAssetsProgressEvent>;
  21899. /**
  21900. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  21901. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  21902. */
  21903. useDefaultLoadingScreen: boolean;
  21904. /**
  21905. * Creates a new AssetsManager
  21906. * @param scene defines the scene to work on
  21907. */
  21908. constructor(scene: Scene);
  21909. /**
  21910. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  21911. * @param taskName defines the name of the new task
  21912. * @param meshesNames defines the name of meshes to load
  21913. * @param rootUrl defines the root url to use to locate files
  21914. * @param sceneFilename defines the filename of the scene file
  21915. * @returns a new {BABYLON.MeshAssetTask} object
  21916. */
  21917. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  21918. /**
  21919. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  21920. * @param taskName defines the name of the new task
  21921. * @param url defines the url of the file to load
  21922. * @returns a new {BABYLON.TextFileAssetTask} object
  21923. */
  21924. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  21925. /**
  21926. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  21927. * @param taskName defines the name of the new task
  21928. * @param url defines the url of the file to load
  21929. * @returns a new {BABYLON.BinaryFileAssetTask} object
  21930. */
  21931. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  21932. /**
  21933. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  21934. * @param taskName defines the name of the new task
  21935. * @param url defines the url of the file to load
  21936. * @returns a new {BABYLON.ImageAssetTask} object
  21937. */
  21938. addImageTask(taskName: string, url: string): ImageAssetTask;
  21939. /**
  21940. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  21941. * @param taskName defines the name of the new task
  21942. * @param url defines the url of the file to load
  21943. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  21944. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  21945. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  21946. * @returns a new {BABYLON.TextureAssetTask} object
  21947. */
  21948. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  21949. /**
  21950. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  21951. * @param taskName defines the name of the new task
  21952. * @param url defines the url of the file to load
  21953. * @param extensions defines the extension to use to load the cube map (can be null)
  21954. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  21955. * @param files defines the list of files to load (can be null)
  21956. * @returns a new {BABYLON.CubeTextureAssetTask} object
  21957. */
  21958. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  21959. /**
  21960. *
  21961. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  21962. * @param taskName defines the name of the new task
  21963. * @param url defines the url of the file to load
  21964. * @param size defines the size you want for the cubemap (can be null)
  21965. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  21966. * @param generateHarmonics defines if you want to automatically generate (true by default)
  21967. * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
  21968. * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
  21969. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  21970. */
  21971. addHDRCubeTextureTask(taskName: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): HDRCubeTextureAssetTask;
  21972. private _decreaseWaitingTasksCount(task);
  21973. private _runTask(task);
  21974. /**
  21975. * Reset the {BABYLON.AssetsManager} and remove all tasks
  21976. * @return the current instance of the {BABYLON.AssetsManager}
  21977. */
  21978. reset(): AssetsManager;
  21979. /**
  21980. * Start the loading process
  21981. * @return the current instance of the {BABYLON.AssetsManager}
  21982. */
  21983. load(): AssetsManager;
  21984. }
  21985. }
  21986. declare module BABYLON {
  21987. class Database {
  21988. private callbackManifestChecked;
  21989. private currentSceneUrl;
  21990. private db;
  21991. private _enableSceneOffline;
  21992. private _enableTexturesOffline;
  21993. private manifestVersionFound;
  21994. private mustUpdateRessources;
  21995. private hasReachedQuota;
  21996. private isSupported;
  21997. private idbFactory;
  21998. static IsUASupportingBlobStorage: boolean;
  21999. static IDBStorageEnabled: boolean;
  22000. readonly enableSceneOffline: boolean;
  22001. readonly enableTexturesOffline: boolean;
  22002. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  22003. static parseURL: (url: string) => string;
  22004. static ReturnFullUrlLocation: (url: string) => string;
  22005. checkManifestFile(): void;
  22006. openAsync(successCallback: () => void, errorCallback: () => void): void;
  22007. loadImageFromDB(url: string, image: HTMLImageElement): void;
  22008. private _loadImageFromDBAsync(url, image, notInDBCallback);
  22009. private _saveImageIntoDBAsync(url, image);
  22010. private _checkVersionFromDB(url, versionLoaded);
  22011. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  22012. private _saveVersionIntoDBAsync(url, callback);
  22013. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  22014. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  22015. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  22016. }
  22017. }
  22018. declare module BABYLON {
  22019. interface DDSInfo {
  22020. width: number;
  22021. height: number;
  22022. mipmapCount: number;
  22023. isFourCC: boolean;
  22024. isRGB: boolean;
  22025. isLuminance: boolean;
  22026. isCube: boolean;
  22027. isCompressed: boolean;
  22028. dxgiFormat: number;
  22029. textureType: number;
  22030. }
  22031. class DDSTools {
  22032. static StoreLODInAlphaChannel: boolean;
  22033. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  22034. private static _FloatView;
  22035. private static _Int32View;
  22036. private static _ToHalfFloat(value);
  22037. private static _FromHalfFloat(value);
  22038. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  22039. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  22040. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  22041. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  22042. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  22043. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  22044. private static _ExtractLongWordOrder(value);
  22045. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  22046. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  22047. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  22048. }
  22049. }
  22050. declare module BABYLON {
  22051. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  22052. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22053. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22054. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22055. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22056. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22057. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22058. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22059. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22060. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22061. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22062. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22063. class SerializationHelper {
  22064. static Serialize<T>(entity: T, serializationObject?: any): any;
  22065. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  22066. static Clone<T>(creationFunction: () => T, source: T): T;
  22067. static Instanciate<T>(creationFunction: () => T, source: T): T;
  22068. }
  22069. }
  22070. declare module BABYLON {
  22071. /**
  22072. * Wrapper class for promise with external resolve and reject.
  22073. */
  22074. class Deferred<T> {
  22075. /**
  22076. * The promise associated with this deferred object.
  22077. */
  22078. readonly promise: Promise<T>;
  22079. private _resolve;
  22080. private _reject;
  22081. /**
  22082. * The resolve method of the promise associated with this deferred object.
  22083. */
  22084. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  22085. /**
  22086. * The reject method of the promise associated with this deferred object.
  22087. */
  22088. readonly reject: (reason?: any) => void;
  22089. /**
  22090. * Constructor for this deferred object.
  22091. */
  22092. constructor();
  22093. }
  22094. }
  22095. declare module Earcut {
  22096. /**
  22097. * The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
  22098. * @param data is a flat array of vertice coordinates like [x0, y0, x1, y1, x2, y2, ...].
  22099. * @param holeIndices is an array of hole indices if any (e.g. [5, 8] for a 12- vertice input would mean one hole with vertices 5–7 and another with 8–11).
  22100. * @param dim is the number of coordinates per vertice in the input array (2 by default).
  22101. */
  22102. function earcut(data: number[], holeIndices: number[], dim: number): Array<number>;
  22103. /**
  22104. * return a percentage difference between the polygon area and its triangulation area;
  22105. * used to verify correctness of triangulation
  22106. */
  22107. function deviation(data: number[], holeIndices: number[], dim: number, triangles: number[]): number;
  22108. /**
  22109. * turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
  22110. */
  22111. function flatten(data: number[][][]): {
  22112. vertices: number[];
  22113. holes: number[];
  22114. dimensions: number;
  22115. };
  22116. }
  22117. declare module BABYLON {
  22118. class FilesInput {
  22119. static FilesToLoad: {
  22120. [key: string]: File;
  22121. };
  22122. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  22123. private _engine;
  22124. private _currentScene;
  22125. private _sceneLoadedCallback;
  22126. private _progressCallback;
  22127. private _additionalRenderLoopLogicCallback;
  22128. private _textureLoadingCallback;
  22129. private _startingProcessingFilesCallback;
  22130. private _onReloadCallback;
  22131. private _errorCallback;
  22132. private _elementToMonitor;
  22133. private _sceneFileToLoad;
  22134. private _filesToLoad;
  22135. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: () => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  22136. private _dragEnterHandler;
  22137. private _dragOverHandler;
  22138. private _dropHandler;
  22139. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  22140. dispose(): void;
  22141. private renderFunction();
  22142. private drag(e);
  22143. private drop(eventDrop);
  22144. private _traverseFolder(folder, files, remaining, callback);
  22145. private _processFiles(files);
  22146. loadFiles(event: any): void;
  22147. private _processReload();
  22148. reload(): void;
  22149. }
  22150. }
  22151. declare module BABYLON {
  22152. /**
  22153. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  22154. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  22155. */
  22156. class KhronosTextureContainer {
  22157. arrayBuffer: any;
  22158. static HEADER_LEN: number;
  22159. static COMPRESSED_2D: number;
  22160. static COMPRESSED_3D: number;
  22161. static TEX_2D: number;
  22162. static TEX_3D: number;
  22163. glType: number;
  22164. glTypeSize: number;
  22165. glFormat: number;
  22166. glInternalFormat: number;
  22167. glBaseInternalFormat: number;
  22168. pixelWidth: number;
  22169. pixelHeight: number;
  22170. pixelDepth: number;
  22171. numberOfArrayElements: number;
  22172. numberOfFaces: number;
  22173. numberOfMipmapLevels: number;
  22174. bytesOfKeyValueData: number;
  22175. loadType: number;
  22176. /**
  22177. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  22178. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  22179. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  22180. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  22181. */
  22182. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  22183. switchEndainness(val: number): number;
  22184. /**
  22185. * It is assumed that the texture has already been created & is currently bound
  22186. */
  22187. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  22188. private _upload2DCompressedLevels(gl, loadMipmaps);
  22189. }
  22190. }
  22191. declare module BABYLON {
  22192. /**
  22193. * A class serves as a medium between the observable and its observers
  22194. */
  22195. class EventState {
  22196. /**
  22197. * Create a new EventState
  22198. * @param mask defines the mask associated with this state
  22199. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  22200. * @param target defines the original target of the state
  22201. * @param currentTarget defines the current target of the state
  22202. */
  22203. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  22204. /**
  22205. * Initialize the current event state
  22206. * @param mask defines the mask associated with this state
  22207. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  22208. * @param target defines the original target of the state
  22209. * @param currentTarget defines the current target of the state
  22210. * @returns the current event state
  22211. */
  22212. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  22213. /**
  22214. * An Observer can set this property to true to prevent subsequent observers of being notified
  22215. */
  22216. skipNextObservers: boolean;
  22217. /**
  22218. * Get the mask value that were used to trigger the event corresponding to this EventState object
  22219. */
  22220. mask: number;
  22221. /**
  22222. * The object that originally notified the event
  22223. */
  22224. target?: any;
  22225. /**
  22226. * The current object in the bubbling phase
  22227. */
  22228. currentTarget?: any;
  22229. /**
  22230. * This will be populated with the return value of the last function that was executed.
  22231. * If it is the first function in the callback chain it will be the event data.
  22232. */
  22233. lastReturnValue?: any;
  22234. }
  22235. /**
  22236. * Represent an Observer registered to a given Observable object.
  22237. */
  22238. class Observer<T> {
  22239. /**
  22240. * Defines the callback to call when the observer is notified
  22241. */
  22242. callback: (eventData: T, eventState: EventState) => void;
  22243. /**
  22244. * Defines the mask of the observer (used to filter notifications)
  22245. */
  22246. mask: number;
  22247. /**
  22248. * Defines the current scope used to restore the JS context
  22249. */
  22250. scope: any;
  22251. /** @ignore */
  22252. _willBeUnregistered: boolean;
  22253. /**
  22254. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  22255. */
  22256. unregisterOnNextCall: boolean;
  22257. /**
  22258. * Creates a new observer
  22259. * @param callback defines the callback to call when the observer is notified
  22260. * @param mask defines the mask of the observer (used to filter notifications)
  22261. * @param scope defines the current scope used to restore the JS context
  22262. */
  22263. constructor(
  22264. /**
  22265. * Defines the callback to call when the observer is notified
  22266. */
  22267. callback: (eventData: T, eventState: EventState) => void,
  22268. /**
  22269. * Defines the mask of the observer (used to filter notifications)
  22270. */
  22271. mask: number,
  22272. /**
  22273. * Defines the current scope used to restore the JS context
  22274. */
  22275. scope?: any);
  22276. }
  22277. /**
  22278. * Represent a list of observers registered to multiple Observables object.
  22279. */
  22280. class MultiObserver<T> {
  22281. private _observers;
  22282. private _observables;
  22283. /**
  22284. * Release associated resources
  22285. */
  22286. dispose(): void;
  22287. /**
  22288. * Raise a callback when one of the observable will notify
  22289. * @param observables defines a list of observables to watch
  22290. * @param callback defines the callback to call on notification
  22291. * @param mask defines the mask used to filter notifications
  22292. * @param scope defines the current scope used to restore the JS context
  22293. * @returns the new MultiObserver
  22294. */
  22295. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  22296. }
  22297. /**
  22298. * The Observable class is a simple implementation of the Observable pattern.
  22299. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  22300. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  22301. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  22302. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  22303. */
  22304. class Observable<T> {
  22305. private _observers;
  22306. private _eventState;
  22307. private _onObserverAdded;
  22308. /**
  22309. * Creates a new observable
  22310. * @param onObserverAdded defines a callback to call when a new observer is added
  22311. */
  22312. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  22313. /**
  22314. * Create a new Observer with the specified callback
  22315. * @param callback the callback that will be executed for that Observer
  22316. * @param mask the mask used to filter observers
  22317. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  22318. * @param scope optional scope for the callback to be called from
  22319. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  22320. * @returns the new observer created for the callback
  22321. */
  22322. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  22323. /**
  22324. * Remove an Observer from the Observable object
  22325. * @param observer the instance of the Observer to remove
  22326. * @returns false if it doesn't belong to this Observable
  22327. */
  22328. remove(observer: Nullable<Observer<T>>): boolean;
  22329. /**
  22330. * Remove a callback from the Observable object
  22331. * @param callback the callback to remove
  22332. * @param scope optional scope. If used only the callbacks with this scope will be removed
  22333. * @returns false if it doesn't belong to this Observable
  22334. */
  22335. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  22336. private _deferUnregister(observer);
  22337. /**
  22338. * Notify all Observers by calling their respective callback with the given data
  22339. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  22340. * @param eventData defines the data to send to all observers
  22341. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  22342. * @param target defines the original target of the state
  22343. * @param currentTarget defines the current target of the state
  22344. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  22345. */
  22346. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  22347. /**
  22348. * Calling this will execute each callback, expecting it to be a promise or return a value.
  22349. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  22350. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  22351. * and it is crucial that all callbacks will be executed.
  22352. * The order of the callbacks is kept, callbacks are not executed parallel.
  22353. *
  22354. * @param eventData The data to be sent to each callback
  22355. * @param mask is used to filter observers defaults to -1
  22356. * @param target defines the callback target (see EventState)
  22357. * @param currentTarget defines he current object in the bubbling phase
  22358. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  22359. */
  22360. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  22361. /**
  22362. * Notify a specific observer
  22363. * @param observer defines the observer to notify
  22364. * @param eventData defines the data to be sent to each callback
  22365. * @param mask is used to filter observers defaults to -1
  22366. */
  22367. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  22368. /**
  22369. * Gets a boolean indicating if the observable has at least one observer
  22370. * @returns true is the Observable has at least one Observer registered
  22371. */
  22372. hasObservers(): boolean;
  22373. /**
  22374. * Clear the list of observers
  22375. */
  22376. clear(): void;
  22377. /**
  22378. * Clone the current observable
  22379. * @returns a new observable
  22380. */
  22381. clone(): Observable<T>;
  22382. /**
  22383. * Does this observable handles observer registered with a given mask
  22384. * @param mask defines the mask to be tested
  22385. * @return whether or not one observer registered with the given mask is handeled
  22386. **/
  22387. hasSpecificMask(mask?: number): boolean;
  22388. }
  22389. }
  22390. declare module BABYLON {
  22391. /**
  22392. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  22393. */
  22394. class PerformanceMonitor {
  22395. private _enabled;
  22396. private _rollingFrameTime;
  22397. private _lastFrameTimeMs;
  22398. /**
  22399. * constructor
  22400. * @param frameSampleSize The number of samples required to saturate the sliding window
  22401. */
  22402. constructor(frameSampleSize?: number);
  22403. /**
  22404. * Samples current frame
  22405. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  22406. */
  22407. sampleFrame(timeMs?: number): void;
  22408. /**
  22409. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  22410. * @return Average frame time in milliseconds
  22411. */
  22412. readonly averageFrameTime: number;
  22413. /**
  22414. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  22415. * @return Frame time variance in milliseconds squared
  22416. */
  22417. readonly averageFrameTimeVariance: number;
  22418. /**
  22419. * Returns the frame time of the most recent frame
  22420. * @return Frame time in milliseconds
  22421. */
  22422. readonly instantaneousFrameTime: number;
  22423. /**
  22424. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  22425. * @return Framerate in frames per second
  22426. */
  22427. readonly averageFPS: number;
  22428. /**
  22429. * Returns the average framerate in frames per second using the most recent frame time
  22430. * @return Framerate in frames per second
  22431. */
  22432. readonly instantaneousFPS: number;
  22433. /**
  22434. * Returns true if enough samples have been taken to completely fill the sliding window
  22435. * @return true if saturated
  22436. */
  22437. readonly isSaturated: boolean;
  22438. /**
  22439. * Enables contributions to the sliding window sample set
  22440. */
  22441. enable(): void;
  22442. /**
  22443. * Disables contributions to the sliding window sample set
  22444. * Samples will not be interpolated over the disabled period
  22445. */
  22446. disable(): void;
  22447. /**
  22448. * Returns true if sampling is enabled
  22449. * @return true if enabled
  22450. */
  22451. readonly isEnabled: boolean;
  22452. /**
  22453. * Resets performance monitor
  22454. */
  22455. reset(): void;
  22456. }
  22457. /**
  22458. * RollingAverage
  22459. *
  22460. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  22461. */
  22462. class RollingAverage {
  22463. /**
  22464. * Current average
  22465. */
  22466. average: number;
  22467. /**
  22468. * Current variance
  22469. */
  22470. variance: number;
  22471. protected _samples: Array<number>;
  22472. protected _sampleCount: number;
  22473. protected _pos: number;
  22474. protected _m2: number;
  22475. /**
  22476. * constructor
  22477. * @param length The number of samples required to saturate the sliding window
  22478. */
  22479. constructor(length: number);
  22480. /**
  22481. * Adds a sample to the sample set
  22482. * @param v The sample value
  22483. */
  22484. add(v: number): void;
  22485. /**
  22486. * Returns previously added values or null if outside of history or outside the sliding window domain
  22487. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  22488. * @return Value previously recorded with add() or null if outside of range
  22489. */
  22490. history(i: number): number;
  22491. /**
  22492. * Returns true if enough samples have been taken to completely fill the sliding window
  22493. * @return true if sample-set saturated
  22494. */
  22495. isSaturated(): boolean;
  22496. /**
  22497. * Resets the rolling average (equivalent to 0 samples taken so far)
  22498. */
  22499. reset(): void;
  22500. /**
  22501. * Wraps a value around the sample range boundaries
  22502. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  22503. * @return Wrapped position in sample range
  22504. */
  22505. protected _wrapPosition(i: number): number;
  22506. }
  22507. }
  22508. declare module BABYLON {
  22509. /**
  22510. * Helper class that provides a small promise polyfill
  22511. */
  22512. class PromisePolyfill {
  22513. /**
  22514. * Static function used to check if the polyfill is required
  22515. * If this is the case then the function will inject the polyfill to window.Promise
  22516. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  22517. */
  22518. static Apply(force?: boolean): void;
  22519. }
  22520. }
  22521. declare module BABYLON {
  22522. /**
  22523. * Defines the root class used to create scene optimization to use with SceneOptimizer
  22524. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22525. */
  22526. class SceneOptimization {
  22527. /**
  22528. * Defines the priority of this optimization (0 by default which means first in the list)
  22529. */
  22530. priority: number;
  22531. /**
  22532. * Gets a string describing the action executed by the current optimization
  22533. * @returns description string
  22534. */
  22535. getDescription(): string;
  22536. /**
  22537. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22538. * @param scene defines the current scene where to apply this optimization
  22539. * @param optimizer defines the current optimizer
  22540. * @returns true if everything that can be done was applied
  22541. */
  22542. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22543. /**
  22544. * Creates the SceneOptimization object
  22545. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  22546. * @param desc defines the description associated with the optimization
  22547. */
  22548. constructor(
  22549. /**
  22550. * Defines the priority of this optimization (0 by default which means first in the list)
  22551. */
  22552. priority?: number);
  22553. }
  22554. /**
  22555. * Defines an optimization used to reduce the size of render target textures
  22556. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22557. */
  22558. class TextureOptimization extends SceneOptimization {
  22559. /**
  22560. * Defines the priority of this optimization (0 by default which means first in the list)
  22561. */
  22562. priority: number;
  22563. /**
  22564. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  22565. */
  22566. maximumSize: number;
  22567. /**
  22568. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  22569. */
  22570. step: number;
  22571. /**
  22572. * Gets a string describing the action executed by the current optimization
  22573. * @returns description string
  22574. */
  22575. getDescription(): string;
  22576. /**
  22577. * Creates the TextureOptimization object
  22578. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  22579. * @param maximumSize defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  22580. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  22581. */
  22582. constructor(
  22583. /**
  22584. * Defines the priority of this optimization (0 by default which means first in the list)
  22585. */
  22586. priority?: number,
  22587. /**
  22588. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  22589. */
  22590. maximumSize?: number,
  22591. /**
  22592. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  22593. */
  22594. step?: number);
  22595. /**
  22596. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22597. * @param scene defines the current scene where to apply this optimization
  22598. * @param optimizer defines the current optimizer
  22599. * @returns true if everything that can be done was applied
  22600. */
  22601. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22602. }
  22603. /**
  22604. * Defines an optimization used to increase or decrease the rendering resolution
  22605. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22606. */
  22607. class HardwareScalingOptimization extends SceneOptimization {
  22608. /**
  22609. * Defines the priority of this optimization (0 by default which means first in the list)
  22610. */
  22611. priority: number;
  22612. /**
  22613. * Defines the maximum scale to use (2 by default)
  22614. */
  22615. maximumScale: number;
  22616. /**
  22617. * Defines the step to use between two passes (0.5 by default)
  22618. */
  22619. step: number;
  22620. private _currentScale;
  22621. private _directionOffset;
  22622. /**
  22623. * Gets a string describing the action executed by the current optimization
  22624. * @return description string
  22625. */
  22626. getDescription(): string;
  22627. /**
  22628. * Creates the HardwareScalingOptimization object
  22629. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  22630. * @param maximumScale defines the maximum scale to use (2 by default)
  22631. * @param step defines the step to use between two passes (0.5 by default)
  22632. */
  22633. constructor(
  22634. /**
  22635. * Defines the priority of this optimization (0 by default which means first in the list)
  22636. */
  22637. priority?: number,
  22638. /**
  22639. * Defines the maximum scale to use (2 by default)
  22640. */
  22641. maximumScale?: number,
  22642. /**
  22643. * Defines the step to use between two passes (0.5 by default)
  22644. */
  22645. step?: number);
  22646. /**
  22647. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22648. * @param scene defines the current scene where to apply this optimization
  22649. * @param optimizer defines the current optimizer
  22650. * @returns true if everything that can be done was applied
  22651. */
  22652. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22653. }
  22654. /**
  22655. * Defines an optimization used to remove shadows
  22656. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22657. */
  22658. class ShadowsOptimization extends SceneOptimization {
  22659. /**
  22660. * Gets a string describing the action executed by the current optimization
  22661. * @return description string
  22662. */
  22663. getDescription(): string;
  22664. /**
  22665. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22666. * @param scene defines the current scene where to apply this optimization
  22667. * @param optimizer defines the current optimizer
  22668. * @returns true if everything that can be done was applied
  22669. */
  22670. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22671. }
  22672. /**
  22673. * Defines an optimization used to turn post-processes off
  22674. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22675. */
  22676. class PostProcessesOptimization extends SceneOptimization {
  22677. /**
  22678. * Gets a string describing the action executed by the current optimization
  22679. * @return description string
  22680. */
  22681. getDescription(): string;
  22682. /**
  22683. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22684. * @param scene defines the current scene where to apply this optimization
  22685. * @param optimizer defines the current optimizer
  22686. * @returns true if everything that can be done was applied
  22687. */
  22688. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22689. }
  22690. /**
  22691. * Defines an optimization used to turn lens flares off
  22692. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22693. */
  22694. class LensFlaresOptimization extends SceneOptimization {
  22695. /**
  22696. * Gets a string describing the action executed by the current optimization
  22697. * @return description string
  22698. */
  22699. getDescription(): string;
  22700. /**
  22701. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22702. * @param scene defines the current scene where to apply this optimization
  22703. * @param optimizer defines the current optimizer
  22704. * @returns true if everything that can be done was applied
  22705. */
  22706. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22707. }
  22708. /**
  22709. * Defines an optimization based on user defined callback.
  22710. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22711. */
  22712. class CustomOptimization extends SceneOptimization {
  22713. /**
  22714. * Callback called to apply the custom optimization.
  22715. */
  22716. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  22717. /**
  22718. * Callback called to get custom description
  22719. */
  22720. onGetDescription: () => string;
  22721. /**
  22722. * Gets a string describing the action executed by the current optimization
  22723. * @returns description string
  22724. */
  22725. getDescription(): string;
  22726. /**
  22727. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22728. * @param scene defines the current scene where to apply this optimization
  22729. * @param optimizer defines the current optimizer
  22730. * @returns true if everything that can be done was applied
  22731. */
  22732. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22733. }
  22734. /**
  22735. * Defines an optimization used to turn particles off
  22736. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22737. */
  22738. class ParticlesOptimization extends SceneOptimization {
  22739. /**
  22740. * Gets a string describing the action executed by the current optimization
  22741. * @return description string
  22742. */
  22743. getDescription(): string;
  22744. /**
  22745. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22746. * @param scene defines the current scene where to apply this optimization
  22747. * @param optimizer defines the current optimizer
  22748. * @returns true if everything that can be done was applied
  22749. */
  22750. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22751. }
  22752. /**
  22753. * Defines an optimization used to turn render targets off
  22754. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22755. */
  22756. class RenderTargetsOptimization extends SceneOptimization {
  22757. /**
  22758. * Gets a string describing the action executed by the current optimization
  22759. * @return description string
  22760. */
  22761. getDescription(): string;
  22762. /**
  22763. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22764. * @param scene defines the current scene where to apply this optimization
  22765. * @param optimizer defines the current optimizer
  22766. * @returns true if everything that can be done was applied
  22767. */
  22768. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22769. }
  22770. /**
  22771. * Defines an optimization used to merge meshes with compatible materials
  22772. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22773. */
  22774. class MergeMeshesOptimization extends SceneOptimization {
  22775. private static _UpdateSelectionTree;
  22776. /**
  22777. * Gets or sets a boolean which defines if optimization octree has to be updated
  22778. */
  22779. /**
  22780. * Gets or sets a boolean which defines if optimization octree has to be updated
  22781. */
  22782. static UpdateSelectionTree: boolean;
  22783. /**
  22784. * Gets a string describing the action executed by the current optimization
  22785. * @return description string
  22786. */
  22787. getDescription(): string;
  22788. private _canBeMerged;
  22789. /**
  22790. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22791. * @param scene defines the current scene where to apply this optimization
  22792. * @param optimizer defines the current optimizer
  22793. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  22794. * @returns true if everything that can be done was applied
  22795. */
  22796. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  22797. }
  22798. /**
  22799. * Defines a list of options used by SceneOptimizer
  22800. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22801. */
  22802. class SceneOptimizerOptions {
  22803. /**
  22804. * Defines the target frame rate to reach (60 by default)
  22805. */
  22806. targetFrameRate: number;
  22807. /**
  22808. * Defines the interval between two checkes (2000ms by default)
  22809. */
  22810. trackerDuration: number;
  22811. /**
  22812. * Gets the list of optimizations to apply
  22813. */
  22814. optimizations: SceneOptimization[];
  22815. /**
  22816. * Creates a new list of options used by SceneOptimizer
  22817. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  22818. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  22819. */
  22820. constructor(
  22821. /**
  22822. * Defines the target frame rate to reach (60 by default)
  22823. */
  22824. targetFrameRate?: number,
  22825. /**
  22826. * Defines the interval between two checkes (2000ms by default)
  22827. */
  22828. trackerDuration?: number);
  22829. /**
  22830. * Add a new optimization
  22831. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  22832. * @returns the current SceneOptimizerOptions
  22833. */
  22834. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  22835. /**
  22836. * Add a new custom optimization
  22837. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  22838. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  22839. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  22840. * @returns the current SceneOptimizerOptions
  22841. */
  22842. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  22843. /**
  22844. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  22845. * @param targetFrameRate defines the target frame rate (60 by default)
  22846. * @returns a SceneOptimizerOptions object
  22847. */
  22848. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  22849. /**
  22850. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  22851. * @param targetFrameRate defines the target frame rate (60 by default)
  22852. * @returns a SceneOptimizerOptions object
  22853. */
  22854. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  22855. /**
  22856. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  22857. * @param targetFrameRate defines the target frame rate (60 by default)
  22858. * @returns a SceneOptimizerOptions object
  22859. */
  22860. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  22861. }
  22862. /**
  22863. * Class used to run optimizations in order to reach a target frame rate
  22864. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22865. */
  22866. class SceneOptimizer implements IDisposable {
  22867. private _isRunning;
  22868. private _options;
  22869. private _scene;
  22870. private _currentPriorityLevel;
  22871. private _targetFrameRate;
  22872. private _trackerDuration;
  22873. private _currentFrameRate;
  22874. private _sceneDisposeObserver;
  22875. private _improvementMode;
  22876. /**
  22877. * Defines an observable called when the optimizer reaches the target frame rate
  22878. */
  22879. onSuccessObservable: Observable<SceneOptimizer>;
  22880. /**
  22881. * Defines an observable called when the optimizer enables an optimization
  22882. */
  22883. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  22884. /**
  22885. * Defines an observable called when the optimizer is not able to reach the target frame rate
  22886. */
  22887. onFailureObservable: Observable<SceneOptimizer>;
  22888. /**
  22889. * Gets a boolean indicating if the optimizer is in improvement mode
  22890. */
  22891. readonly isInImprovementMode: boolean;
  22892. /**
  22893. * Gets the current priority level (0 at start)
  22894. */
  22895. readonly currentPriorityLevel: number;
  22896. /**
  22897. * Gets the current frame rate checked by the SceneOptimizer
  22898. */
  22899. readonly currentFrameRate: number;
  22900. /**
  22901. * Gets or sets the current target frame rate (60 by default)
  22902. */
  22903. /**
  22904. * Gets or sets the current target frame rate (60 by default)
  22905. */
  22906. targetFrameRate: number;
  22907. /**
  22908. * Gets or sets the current interval between two checks (every 2000ms by default)
  22909. */
  22910. /**
  22911. * Gets or sets the current interval between two checks (every 2000ms by default)
  22912. */
  22913. trackerDuration: number;
  22914. /**
  22915. * Gets the list of active optimizations
  22916. */
  22917. readonly optimizations: SceneOptimization[];
  22918. /**
  22919. * Creates a new SceneOptimizer
  22920. * @param scene defines the scene to work on
  22921. * @param options defines the options to use with the SceneOptimizer
  22922. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  22923. * @param improvementMode defines if the scene optimizer must run the maximum optimization while staying over a target frame instead of trying to reach the target framerate (false by default)
  22924. */
  22925. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  22926. /**
  22927. * Stops the current optimizer
  22928. */
  22929. stop(): void;
  22930. /**
  22931. * Reset the optimizer to initial step (current priority level = 0)
  22932. */
  22933. reset(): void;
  22934. /**
  22935. * Start the optimizer. By default it will try to reach a specific framerate
  22936. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  22937. */
  22938. start(): void;
  22939. private _checkCurrentState();
  22940. /**
  22941. * Release all resources
  22942. */
  22943. dispose(): void;
  22944. /**
  22945. * Helper function to create a SceneOptimizer with one single line of code
  22946. * @param scene defines the scene to work on
  22947. * @param options defines the options to use with the SceneOptimizer
  22948. * @param onSuccess defines a callback to call on success
  22949. * @param onFailure defines a callback to call on failure
  22950. * @returns the new SceneOptimizer object
  22951. */
  22952. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  22953. }
  22954. }
  22955. declare module BABYLON {
  22956. class SceneSerializer {
  22957. static ClearCache(): void;
  22958. static Serialize(scene: Scene): any;
  22959. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  22960. }
  22961. }
  22962. declare module BABYLON {
  22963. class SmartArray<T> {
  22964. data: Array<T>;
  22965. length: number;
  22966. protected _id: number;
  22967. [index: number]: T;
  22968. constructor(capacity: number);
  22969. push(value: T): void;
  22970. forEach(func: (content: T) => void): void;
  22971. sort(compareFn: (a: T, b: T) => number): void;
  22972. reset(): void;
  22973. dispose(): void;
  22974. concat(array: any): void;
  22975. indexOf(value: T): number;
  22976. contains(value: T): boolean;
  22977. private static _GlobalId;
  22978. }
  22979. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  22980. private _duplicateId;
  22981. [index: number]: T;
  22982. push(value: T): void;
  22983. pushNoDuplicate(value: T): boolean;
  22984. reset(): void;
  22985. concatWithNoDuplicate(array: any): void;
  22986. }
  22987. }
  22988. declare module BABYLON {
  22989. /**
  22990. * This class implement a typical dictionary using a string as key and the generic type T as value.
  22991. * The underlying implementation relies on an associative array to ensure the best performances.
  22992. * The value can be anything including 'null' but except 'undefined'
  22993. */
  22994. class StringDictionary<T> {
  22995. /**
  22996. * This will clear this dictionary and copy the content from the 'source' one.
  22997. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  22998. * @param source the dictionary to take the content from and copy to this dictionary
  22999. */
  23000. copyFrom(source: StringDictionary<T>): void;
  23001. /**
  23002. * Get a value based from its key
  23003. * @param key the given key to get the matching value from
  23004. * @return the value if found, otherwise undefined is returned
  23005. */
  23006. get(key: string): T | undefined;
  23007. /**
  23008. * Get a value from its key or add it if it doesn't exist.
  23009. * This method will ensure you that a given key/data will be present in the dictionary.
  23010. * @param key the given key to get the matching value from
  23011. * @param factory the factory that will create the value if the key is not present in the dictionary.
  23012. * The factory will only be invoked if there's no data for the given key.
  23013. * @return the value corresponding to the key.
  23014. */
  23015. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  23016. /**
  23017. * Get a value from its key if present in the dictionary otherwise add it
  23018. * @param key the key to get the value from
  23019. * @param val if there's no such key/value pair in the dictionary add it with this value
  23020. * @return the value corresponding to the key
  23021. */
  23022. getOrAdd(key: string, val: T): T;
  23023. /**
  23024. * Check if there's a given key in the dictionary
  23025. * @param key the key to check for
  23026. * @return true if the key is present, false otherwise
  23027. */
  23028. contains(key: string): boolean;
  23029. /**
  23030. * Add a new key and its corresponding value
  23031. * @param key the key to add
  23032. * @param value the value corresponding to the key
  23033. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  23034. */
  23035. add(key: string, value: T): boolean;
  23036. set(key: string, value: T): boolean;
  23037. /**
  23038. * Get the element of the given key and remove it from the dictionary
  23039. * @param key
  23040. */
  23041. getAndRemove(key: string): Nullable<T>;
  23042. /**
  23043. * Remove a key/value from the dictionary.
  23044. * @param key the key to remove
  23045. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  23046. */
  23047. remove(key: string): boolean;
  23048. /**
  23049. * Clear the whole content of the dictionary
  23050. */
  23051. clear(): void;
  23052. readonly count: number;
  23053. /**
  23054. * Execute a callback on each key/val of the dictionary.
  23055. * Note that you can remove any element in this dictionary in the callback implementation
  23056. * @param callback the callback to execute on a given key/value pair
  23057. */
  23058. forEach(callback: (key: string, val: T) => void): void;
  23059. /**
  23060. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  23061. * If the callback returns null or undefined the method will iterate to the next key/value pair
  23062. * Note that you can remove any element in this dictionary in the callback implementation
  23063. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  23064. */
  23065. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  23066. private _count;
  23067. private _data;
  23068. }
  23069. }
  23070. declare module BABYLON {
  23071. class Tags {
  23072. static EnableFor(obj: any): void;
  23073. static DisableFor(obj: any): void;
  23074. static HasTags(obj: any): boolean;
  23075. static GetTags(obj: any, asString?: boolean): any;
  23076. static AddTagsTo(obj: any, tagsString: string): void;
  23077. static _AddTagTo(obj: any, tag: string): void;
  23078. static RemoveTagsFrom(obj: any, tagsString: string): void;
  23079. static _RemoveTagFrom(obj: any, tag: string): void;
  23080. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  23081. }
  23082. }
  23083. declare module BABYLON {
  23084. class TextureTools {
  23085. /**
  23086. * Uses the GPU to create a copy texture rescaled at a given size
  23087. * @param texture Texture to copy from
  23088. * @param width Desired width
  23089. * @param height Desired height
  23090. * @return Generated texture
  23091. */
  23092. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  23093. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  23094. private static _environmentBRDFBase64Texture;
  23095. }
  23096. }
  23097. declare module BABYLON {
  23098. class TGATools {
  23099. private static _TYPE_INDEXED;
  23100. private static _TYPE_RGB;
  23101. private static _TYPE_GREY;
  23102. private static _TYPE_RLE_INDEXED;
  23103. private static _TYPE_RLE_RGB;
  23104. private static _TYPE_RLE_GREY;
  23105. private static _ORIGIN_MASK;
  23106. private static _ORIGIN_SHIFT;
  23107. private static _ORIGIN_BL;
  23108. private static _ORIGIN_BR;
  23109. private static _ORIGIN_UL;
  23110. private static _ORIGIN_UR;
  23111. static GetTGAHeader(data: Uint8Array): any;
  23112. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  23113. 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;
  23114. 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;
  23115. 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;
  23116. 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;
  23117. 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;
  23118. 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;
  23119. }
  23120. }
  23121. declare module BABYLON {
  23122. interface IAnimatable {
  23123. animations: Array<Animation>;
  23124. }
  23125. class LoadFileError extends Error {
  23126. request: XMLHttpRequest | undefined;
  23127. private static _setPrototypeOf;
  23128. constructor(message: string, request?: XMLHttpRequest | undefined);
  23129. }
  23130. class RetryStrategy {
  23131. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  23132. }
  23133. interface IFileRequest {
  23134. /**
  23135. * Raised when the request is complete (success or error).
  23136. */
  23137. onCompleteObservable: Observable<IFileRequest>;
  23138. /**
  23139. * Aborts the request for a file.
  23140. */
  23141. abort: () => void;
  23142. }
  23143. class Tools {
  23144. static BaseUrl: string;
  23145. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  23146. /**
  23147. * Default behaviour for cors in the application.
  23148. * It can be a string if the expected behavior is identical in the entire app.
  23149. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  23150. */
  23151. static CorsBehavior: string | ((url: string | string[]) => string);
  23152. static UseFallbackTexture: boolean;
  23153. /**
  23154. * Use this object to register external classes like custom textures or material
  23155. * to allow the laoders to instantiate them
  23156. */
  23157. static RegisteredExternalClasses: {
  23158. [key: string]: Object;
  23159. };
  23160. static fallbackTexture: string;
  23161. /**
  23162. * Interpolates between a and b via alpha
  23163. * @param a The lower value (returned when alpha = 0)
  23164. * @param b The upper value (returned when alpha = 1)
  23165. * @param alpha The interpolation-factor
  23166. * @return The mixed value
  23167. */
  23168. static Mix(a: number, b: number, alpha: number): number;
  23169. static Instantiate(className: string): any;
  23170. /**
  23171. * Provides a slice function that will work even on IE
  23172. * @param data defines the array to slice
  23173. * @returns the new sliced array
  23174. */
  23175. static Slice(data: FloatArray): FloatArray;
  23176. static SetImmediate(action: () => void): void;
  23177. static IsExponentOfTwo(value: number): boolean;
  23178. /**
  23179. * Find the next highest power of two.
  23180. * @param x Number to start search from.
  23181. * @return Next highest power of two.
  23182. */
  23183. static CeilingPOT(x: number): number;
  23184. /**
  23185. * Find the next lowest power of two.
  23186. * @param x Number to start search from.
  23187. * @return Next lowest power of two.
  23188. */
  23189. static FloorPOT(x: number): number;
  23190. /**
  23191. * Find the nearest power of two.
  23192. * @param x Number to start search from.
  23193. * @return Next nearest power of two.
  23194. */
  23195. static NearestPOT(x: number): number;
  23196. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  23197. static GetFilename(path: string): string;
  23198. /**
  23199. * Extracts the "folder" part of a path (everything before the filename).
  23200. * @param uri The URI to extract the info from
  23201. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  23202. * @returns The "folder" part of the path
  23203. */
  23204. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  23205. static GetDOMTextContent(element: HTMLElement): string;
  23206. static ToDegrees(angle: number): number;
  23207. static ToRadians(angle: number): number;
  23208. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  23209. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  23210. minimum: Vector3;
  23211. maximum: Vector3;
  23212. };
  23213. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  23214. minimum: Vector3;
  23215. maximum: Vector3;
  23216. };
  23217. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  23218. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  23219. minimum: Vector2;
  23220. maximum: Vector2;
  23221. };
  23222. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  23223. static GetPointerPrefix(): string;
  23224. /**
  23225. * @param func - the function to be called
  23226. * @param requester - the object that will request the next frame. Falls back to window.
  23227. */
  23228. static QueueNewFrame(func: () => void, requester?: any): number;
  23229. static RequestFullscreen(element: HTMLElement): void;
  23230. static ExitFullscreen(): void;
  23231. static SetCorsBehavior(url: string | string[], element: {
  23232. crossOrigin: string | null;
  23233. }): void;
  23234. static CleanUrl(url: string): string;
  23235. static PreprocessUrl: (url: string) => string;
  23236. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  23237. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, database?: Database, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  23238. /**
  23239. * Load a script (identified by an url). When the url returns, the
  23240. * content of this file is added into a new script element, attached to the DOM (body element)
  23241. */
  23242. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  23243. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (this: MSBaseReader, ev: ProgressEvent) => any): IFileRequest;
  23244. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (this: MSBaseReader, ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  23245. static FileAsURL(content: string): string;
  23246. static Format(value: number, decimals?: number): string;
  23247. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  23248. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  23249. static IsEmpty(obj: any): boolean;
  23250. static RegisterTopRootEvents(events: {
  23251. name: string;
  23252. handler: Nullable<(e: FocusEvent) => any>;
  23253. }[]): void;
  23254. static UnregisterTopRootEvents(events: {
  23255. name: string;
  23256. handler: Nullable<(e: FocusEvent) => any>;
  23257. }[]): void;
  23258. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  23259. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  23260. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  23261. /**
  23262. * Generates an image screenshot from the specified camera.
  23263. *
  23264. * @param engine The engine to use for rendering
  23265. * @param camera The camera to use for rendering
  23266. * @param size This parameter can be set to a single number or to an object with the
  23267. * following (optional) properties: precision, width, height. If a single number is passed,
  23268. * it will be used for both width and height. If an object is passed, the screenshot size
  23269. * will be derived from the parameters. The precision property is a multiplier allowing
  23270. * rendering at a higher or lower resolution.
  23271. * @param successCallback The callback receives a single parameter which contains the
  23272. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  23273. * src parameter of an <img> to display it.
  23274. * @param mimeType The MIME type of the screenshot image (default: image/png).
  23275. * Check your browser for supported MIME types.
  23276. * @param samples Texture samples (default: 1)
  23277. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  23278. * @param fileName A name for for the downloaded file.
  23279. * @constructor
  23280. */
  23281. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  23282. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  23283. /**
  23284. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23285. * Be aware Math.random() could cause collisions, but:
  23286. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  23287. */
  23288. static RandomId(): string;
  23289. /**
  23290. * Test if the given uri is a base64 string.
  23291. * @param uri The uri to test
  23292. * @return True if the uri is a base64 string or false otherwise.
  23293. */
  23294. static IsBase64(uri: string): boolean;
  23295. /**
  23296. * Decode the given base64 uri.
  23297. * @param uri The uri to decode
  23298. * @return The decoded base64 data.
  23299. */
  23300. static DecodeBase64(uri: string): ArrayBuffer;
  23301. private static _NoneLogLevel;
  23302. private static _MessageLogLevel;
  23303. private static _WarningLogLevel;
  23304. private static _ErrorLogLevel;
  23305. private static _LogCache;
  23306. static errorsCount: number;
  23307. static OnNewCacheEntry: (entry: string) => void;
  23308. static readonly NoneLogLevel: number;
  23309. static readonly MessageLogLevel: number;
  23310. static readonly WarningLogLevel: number;
  23311. static readonly ErrorLogLevel: number;
  23312. static readonly AllLogLevel: number;
  23313. private static _AddLogEntry(entry);
  23314. private static _FormatMessage(message);
  23315. private static _LogDisabled(message);
  23316. private static _LogEnabled(message);
  23317. private static _WarnDisabled(message);
  23318. private static _WarnEnabled(message);
  23319. private static _ErrorDisabled(message);
  23320. private static _ErrorEnabled(message);
  23321. static Log: (message: string) => void;
  23322. static Warn: (message: string) => void;
  23323. static Error: (message: string) => void;
  23324. static readonly LogCache: string;
  23325. static ClearLogCache(): void;
  23326. static LogLevels: number;
  23327. static IsWindowObjectExist(): boolean;
  23328. private static _PerformanceNoneLogLevel;
  23329. private static _PerformanceUserMarkLogLevel;
  23330. private static _PerformanceConsoleLogLevel;
  23331. private static _performance;
  23332. static readonly PerformanceNoneLogLevel: number;
  23333. static readonly PerformanceUserMarkLogLevel: number;
  23334. static readonly PerformanceConsoleLogLevel: number;
  23335. static PerformanceLogLevel: number;
  23336. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  23337. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  23338. static _StartUserMark(counterName: string, condition?: boolean): void;
  23339. static _EndUserMark(counterName: string, condition?: boolean): void;
  23340. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  23341. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  23342. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  23343. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  23344. static readonly Now: number;
  23345. /**
  23346. * This method will return the name of the class used to create the instance of the given object.
  23347. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  23348. * @param object the object to get the class name from
  23349. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  23350. */
  23351. static GetClassName(object: any, isType?: boolean): string;
  23352. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  23353. /**
  23354. * This method will return the name of the full name of the class, including its owning module (if any).
  23355. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified).
  23356. * @param object the object to get the class name from
  23357. * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified.
  23358. */
  23359. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  23360. /**
  23361. * This method can be used with hashCodeFromStream when your input is an array of values that are either: number, string, boolean or custom type implementing the getHashCode():number method.
  23362. * @param array
  23363. */
  23364. static arrayOrStringFeeder(array: any): (i: number) => number;
  23365. /**
  23366. * Compute the hashCode of a stream of number
  23367. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  23368. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  23369. * @return the hash code computed
  23370. */
  23371. static hashCodeFromStream(feeder: (index: number) => number): number;
  23372. /**
  23373. * Returns a promise that resolves after the given amount of time.
  23374. * @param delay Number of milliseconds to delay
  23375. * @returns Promise that resolves after the given amount of time
  23376. */
  23377. static DelayAsync(delay: number): Promise<void>;
  23378. }
  23379. /**
  23380. * This class is used to track a performance counter which is number based.
  23381. * The user has access to many properties which give statistics of different nature
  23382. *
  23383. * The implementer can track two kinds of Performance Counter: time and count
  23384. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  23385. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  23386. */
  23387. class PerfCounter {
  23388. static Enabled: boolean;
  23389. /**
  23390. * Returns the smallest value ever
  23391. */
  23392. readonly min: number;
  23393. /**
  23394. * Returns the biggest value ever
  23395. */
  23396. readonly max: number;
  23397. /**
  23398. * Returns the average value since the performance counter is running
  23399. */
  23400. readonly average: number;
  23401. /**
  23402. * Returns the average value of the last second the counter was monitored
  23403. */
  23404. readonly lastSecAverage: number;
  23405. /**
  23406. * Returns the current value
  23407. */
  23408. readonly current: number;
  23409. readonly total: number;
  23410. readonly count: number;
  23411. constructor();
  23412. /**
  23413. * Call this method to start monitoring a new frame.
  23414. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  23415. */
  23416. fetchNewFrame(): void;
  23417. /**
  23418. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  23419. * @param newCount the count value to add to the monitored count
  23420. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  23421. */
  23422. addCount(newCount: number, fetchResult: boolean): void;
  23423. /**
  23424. * Start monitoring this performance counter
  23425. */
  23426. beginMonitoring(): void;
  23427. /**
  23428. * Compute the time lapsed since the previous beginMonitoring() call.
  23429. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  23430. */
  23431. endMonitoring(newFrame?: boolean): void;
  23432. private _fetchResult();
  23433. private _startMonitoringTime;
  23434. private _min;
  23435. private _max;
  23436. private _average;
  23437. private _current;
  23438. private _totalValueCount;
  23439. private _totalAccumulated;
  23440. private _lastSecAverage;
  23441. private _lastSecAccumulated;
  23442. private _lastSecTime;
  23443. private _lastSecValueCount;
  23444. }
  23445. /**
  23446. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  23447. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  23448. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  23449. * @param name The name of the class, case should be preserved
  23450. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  23451. */
  23452. function className(name: string, module?: string): (target: Object) => void;
  23453. /**
  23454. * An implementation of a loop for asynchronous functions.
  23455. */
  23456. class AsyncLoop {
  23457. iterations: number;
  23458. private _fn;
  23459. private _successCallback;
  23460. index: number;
  23461. private _done;
  23462. /**
  23463. * Constroctor.
  23464. * @param iterations the number of iterations.
  23465. * @param _fn the function to run each iteration
  23466. * @param _successCallback the callback that will be called upon succesful execution
  23467. * @param offset starting offset.
  23468. */
  23469. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  23470. /**
  23471. * Execute the next iteration. Must be called after the last iteration was finished.
  23472. */
  23473. executeNext(): void;
  23474. /**
  23475. * Break the loop and run the success callback.
  23476. */
  23477. breakLoop(): void;
  23478. /**
  23479. * Helper function
  23480. */
  23481. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  23482. /**
  23483. * A for-loop that will run a given number of iterations synchronous and the rest async.
  23484. * @param iterations total number of iterations
  23485. * @param syncedIterations number of synchronous iterations in each async iteration.
  23486. * @param fn the function to call each iteration.
  23487. * @param callback a success call back that will be called when iterating stops.
  23488. * @param breakFunction a break condition (optional)
  23489. * @param timeout timeout settings for the setTimeout function. default - 0.
  23490. * @constructor
  23491. */
  23492. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  23493. }
  23494. }
  23495. declare module BABYLON {
  23496. enum JoystickAxis {
  23497. X = 0,
  23498. Y = 1,
  23499. Z = 2,
  23500. }
  23501. class VirtualJoystick {
  23502. reverseLeftRight: boolean;
  23503. reverseUpDown: boolean;
  23504. deltaPosition: Vector3;
  23505. pressed: boolean;
  23506. private static _globalJoystickIndex;
  23507. private static vjCanvas;
  23508. private static vjCanvasContext;
  23509. private static vjCanvasWidth;
  23510. private static vjCanvasHeight;
  23511. private static halfWidth;
  23512. private _action;
  23513. private _axisTargetedByLeftAndRight;
  23514. private _axisTargetedByUpAndDown;
  23515. private _joystickSensibility;
  23516. private _inversedSensibility;
  23517. private _joystickPointerID;
  23518. private _joystickColor;
  23519. private _joystickPointerPos;
  23520. private _joystickPreviousPointerPos;
  23521. private _joystickPointerStartPos;
  23522. private _deltaJoystickVector;
  23523. private _leftJoystick;
  23524. private _touches;
  23525. private _onPointerDownHandlerRef;
  23526. private _onPointerMoveHandlerRef;
  23527. private _onPointerUpHandlerRef;
  23528. private _onResize;
  23529. constructor(leftJoystick?: boolean);
  23530. setJoystickSensibility(newJoystickSensibility: number): void;
  23531. private _onPointerDown(e);
  23532. private _onPointerMove(e);
  23533. private _onPointerUp(e);
  23534. /**
  23535. * Change the color of the virtual joystick
  23536. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  23537. */
  23538. setJoystickColor(newColor: string): void;
  23539. setActionOnTouch(action: () => any): void;
  23540. setAxisForLeftRight(axis: JoystickAxis): void;
  23541. setAxisForUpDown(axis: JoystickAxis): void;
  23542. private _drawVirtualJoystick();
  23543. releaseCanvas(): void;
  23544. }
  23545. }
  23546. declare module BABYLON {
  23547. /**
  23548. * Helper class to push actions to a pool of workers.
  23549. */
  23550. class WorkerPool implements IDisposable {
  23551. private _workerInfos;
  23552. private _pendingActions;
  23553. /**
  23554. * Constructor
  23555. * @param workers Array of workers to use for actions
  23556. */
  23557. constructor(workers: Array<Worker>);
  23558. /**
  23559. * Terminates all workers and clears any pending actions.
  23560. */
  23561. dispose(): void;
  23562. /**
  23563. * Pushes an action to the worker pool. If all the workers are active, the action will be
  23564. * pended until a worker has completed its action.
  23565. * @param action The action to perform. Call onComplete when the action is complete.
  23566. */
  23567. push(action: (worker: Worker, onComplete: () => void) => void): void;
  23568. private _execute(workerInfo, action);
  23569. }
  23570. }
  23571. declare module BABYLON {
  23572. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  23573. readonly name: string;
  23574. private _zoomStopsAnimation;
  23575. private _idleRotationSpeed;
  23576. private _idleRotationWaitTime;
  23577. private _idleRotationSpinupTime;
  23578. /**
  23579. * Gets the flag that indicates if user zooming should stop animation.
  23580. */
  23581. /**
  23582. * Sets the flag that indicates if user zooming should stop animation.
  23583. */
  23584. zoomStopsAnimation: boolean;
  23585. /**
  23586. * Gets the default speed at which the camera rotates around the model.
  23587. */
  23588. /**
  23589. * Sets the default speed at which the camera rotates around the model.
  23590. */
  23591. idleRotationSpeed: number;
  23592. /**
  23593. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  23594. */
  23595. /**
  23596. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  23597. */
  23598. idleRotationWaitTime: number;
  23599. /**
  23600. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  23601. */
  23602. /**
  23603. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  23604. */
  23605. idleRotationSpinupTime: number;
  23606. /**
  23607. * Gets a value indicating if the camera is currently rotating because of this behavior
  23608. */
  23609. readonly rotationInProgress: boolean;
  23610. private _onPrePointerObservableObserver;
  23611. private _onAfterCheckInputsObserver;
  23612. private _attachedCamera;
  23613. private _isPointerDown;
  23614. private _lastFrameTime;
  23615. private _lastInteractionTime;
  23616. private _cameraRotationSpeed;
  23617. init(): void;
  23618. attach(camera: ArcRotateCamera): void;
  23619. detach(): void;
  23620. /**
  23621. * Returns true if user is scrolling.
  23622. * @return true if user is scrolling.
  23623. */
  23624. private _userIsZooming();
  23625. private _lastFrameRadius;
  23626. private _shouldAnimationStopForInteraction();
  23627. /**
  23628. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  23629. */
  23630. private _applyUserInteraction();
  23631. private _userIsMoving();
  23632. }
  23633. }
  23634. declare module BABYLON {
  23635. /**
  23636. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  23637. */
  23638. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  23639. readonly name: string;
  23640. /**
  23641. * The easing function used by animations
  23642. */
  23643. static EasingFunction: BackEase;
  23644. /**
  23645. * The easing mode used by animations
  23646. */
  23647. static EasingMode: number;
  23648. /**
  23649. * The duration of the animation, in milliseconds
  23650. */
  23651. transitionDuration: number;
  23652. /**
  23653. * Length of the distance animated by the transition when lower radius is reached
  23654. */
  23655. lowerRadiusTransitionRange: number;
  23656. /**
  23657. * Length of the distance animated by the transition when upper radius is reached
  23658. */
  23659. upperRadiusTransitionRange: number;
  23660. private _autoTransitionRange;
  23661. /**
  23662. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  23663. */
  23664. /**
  23665. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  23666. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  23667. */
  23668. autoTransitionRange: boolean;
  23669. private _attachedCamera;
  23670. private _onAfterCheckInputsObserver;
  23671. private _onMeshTargetChangedObserver;
  23672. init(): void;
  23673. attach(camera: ArcRotateCamera): void;
  23674. detach(): void;
  23675. private _radiusIsAnimating;
  23676. private _radiusBounceTransition;
  23677. private _animatables;
  23678. private _cachedWheelPrecision;
  23679. /**
  23680. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  23681. * @param radiusLimit The limit to check against.
  23682. * @return Bool to indicate if at limit.
  23683. */
  23684. private _isRadiusAtLimit(radiusLimit);
  23685. /**
  23686. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  23687. * @param radiusDelta The delta by which to animate to. Can be negative.
  23688. */
  23689. private _applyBoundRadiusAnimation(radiusDelta);
  23690. /**
  23691. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  23692. */
  23693. protected _clearAnimationLocks(): void;
  23694. /**
  23695. * Stops and removes all animations that have been applied to the camera
  23696. */
  23697. stopAllAnimations(): void;
  23698. }
  23699. }
  23700. declare module BABYLON {
  23701. class FramingBehavior implements Behavior<ArcRotateCamera> {
  23702. readonly name: string;
  23703. private _mode;
  23704. private _radiusScale;
  23705. private _positionScale;
  23706. private _defaultElevation;
  23707. private _elevationReturnTime;
  23708. private _elevationReturnWaitTime;
  23709. private _zoomStopsAnimation;
  23710. private _framingTime;
  23711. /**
  23712. * The easing function used by animations
  23713. */
  23714. static EasingFunction: ExponentialEase;
  23715. /**
  23716. * The easing mode used by animations
  23717. */
  23718. static EasingMode: number;
  23719. /**
  23720. * Gets current mode used by the behavior.
  23721. */
  23722. /**
  23723. * Sets the current mode used by the behavior
  23724. */
  23725. mode: number;
  23726. /**
  23727. * Gets the scale applied to the radius
  23728. */
  23729. /**
  23730. * Sets the scale applied to the radius (1 by default)
  23731. */
  23732. radiusScale: number;
  23733. /**
  23734. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  23735. */
  23736. /**
  23737. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  23738. */
  23739. positionScale: number;
  23740. /**
  23741. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  23742. * behaviour is triggered, in radians.
  23743. */
  23744. /**
  23745. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  23746. * behaviour is triggered, in radians.
  23747. */
  23748. defaultElevation: number;
  23749. /**
  23750. * Gets the time (in milliseconds) taken to return to the default beta position.
  23751. * Negative value indicates camera should not return to default.
  23752. */
  23753. /**
  23754. * Sets the time (in milliseconds) taken to return to the default beta position.
  23755. * Negative value indicates camera should not return to default.
  23756. */
  23757. elevationReturnTime: number;
  23758. /**
  23759. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  23760. */
  23761. /**
  23762. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  23763. */
  23764. elevationReturnWaitTime: number;
  23765. /**
  23766. * Gets the flag that indicates if user zooming should stop animation.
  23767. */
  23768. /**
  23769. * Sets the flag that indicates if user zooming should stop animation.
  23770. */
  23771. zoomStopsAnimation: boolean;
  23772. /**
  23773. * Gets the transition time when framing the mesh, in milliseconds
  23774. */
  23775. /**
  23776. * Sets the transition time when framing the mesh, in milliseconds
  23777. */
  23778. framingTime: number;
  23779. private _onPrePointerObservableObserver;
  23780. private _onAfterCheckInputsObserver;
  23781. private _onMeshTargetChangedObserver;
  23782. private _attachedCamera;
  23783. private _isPointerDown;
  23784. private _lastInteractionTime;
  23785. init(): void;
  23786. attach(camera: ArcRotateCamera): void;
  23787. detach(): void;
  23788. private _animatables;
  23789. private _betaIsAnimating;
  23790. private _betaTransition;
  23791. private _radiusTransition;
  23792. private _vectorTransition;
  23793. /**
  23794. * Targets the given mesh and updates zoom level accordingly.
  23795. * @param mesh The mesh to target.
  23796. * @param radius Optional. If a cached radius position already exists, overrides default.
  23797. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23798. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23799. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23800. */
  23801. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23802. /**
  23803. * Targets the given mesh with its children and updates zoom level accordingly.
  23804. * @param mesh The mesh to target.
  23805. * @param radius Optional. If a cached radius position already exists, overrides default.
  23806. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23807. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23808. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23809. */
  23810. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23811. /**
  23812. * Targets the given meshes with their children and updates zoom level accordingly.
  23813. * @param meshes The mesh to target.
  23814. * @param radius Optional. If a cached radius position already exists, overrides default.
  23815. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23816. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23817. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23818. */
  23819. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23820. /**
  23821. * Targets the given mesh and updates zoom level accordingly.
  23822. * @param mesh The mesh to target.
  23823. * @param radius Optional. If a cached radius position already exists, overrides default.
  23824. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23825. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23826. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23827. */
  23828. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23829. /**
  23830. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  23831. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  23832. * frustum width.
  23833. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  23834. * to fully enclose the mesh in the viewing frustum.
  23835. */
  23836. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  23837. /**
  23838. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  23839. * is automatically returned to its default position (expected to be above ground plane).
  23840. */
  23841. private _maintainCameraAboveGround();
  23842. /**
  23843. * Returns the frustum slope based on the canvas ratio and camera FOV
  23844. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  23845. */
  23846. private _getFrustumSlope();
  23847. /**
  23848. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  23849. */
  23850. private _clearAnimationLocks();
  23851. /**
  23852. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  23853. */
  23854. private _applyUserInteraction();
  23855. /**
  23856. * Stops and removes all animations that have been applied to the camera
  23857. */
  23858. stopAllAnimations(): void;
  23859. /**
  23860. * Gets a value indicating if the user is moving the camera
  23861. */
  23862. readonly isUserIsMoving: boolean;
  23863. /**
  23864. * The camera can move all the way towards the mesh.
  23865. */
  23866. static IgnoreBoundsSizeMode: number;
  23867. /**
  23868. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  23869. */
  23870. static FitFrustumSidesMode: number;
  23871. }
  23872. }
  23873. declare module BABYLON {
  23874. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  23875. camera: ArcRotateCamera;
  23876. gamepad: Nullable<Gamepad>;
  23877. private _onGamepadConnectedObserver;
  23878. private _onGamepadDisconnectedObserver;
  23879. gamepadRotationSensibility: number;
  23880. gamepadMoveSensibility: number;
  23881. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23882. detachControl(element: Nullable<HTMLElement>): void;
  23883. checkInputs(): void;
  23884. getClassName(): string;
  23885. getSimpleName(): string;
  23886. }
  23887. }
  23888. declare module BABYLON {
  23889. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  23890. camera: ArcRotateCamera;
  23891. private _keys;
  23892. keysUp: number[];
  23893. keysDown: number[];
  23894. keysLeft: number[];
  23895. keysRight: number[];
  23896. keysReset: number[];
  23897. panningSensibility: number;
  23898. zoomingSensibility: number;
  23899. useAltToZoom: boolean;
  23900. private _ctrlPressed;
  23901. private _altPressed;
  23902. private _onCanvasBlurObserver;
  23903. private _onKeyboardObserver;
  23904. private _engine;
  23905. private _scene;
  23906. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23907. detachControl(element: Nullable<HTMLElement>): void;
  23908. checkInputs(): void;
  23909. getClassName(): string;
  23910. getSimpleName(): string;
  23911. }
  23912. }
  23913. declare module BABYLON {
  23914. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  23915. camera: ArcRotateCamera;
  23916. private _wheel;
  23917. private _observer;
  23918. wheelPrecision: number;
  23919. /**
  23920. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  23921. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  23922. */
  23923. wheelDeltaPercentage: number;
  23924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23925. detachControl(element: Nullable<HTMLElement>): void;
  23926. getClassName(): string;
  23927. getSimpleName(): string;
  23928. }
  23929. }
  23930. declare module BABYLON {
  23931. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  23932. camera: ArcRotateCamera;
  23933. buttons: number[];
  23934. angularSensibilityX: number;
  23935. angularSensibilityY: number;
  23936. pinchPrecision: number;
  23937. /**
  23938. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  23939. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  23940. */
  23941. pinchDeltaPercentage: number;
  23942. panningSensibility: number;
  23943. multiTouchPanning: boolean;
  23944. multiTouchPanAndZoom: boolean;
  23945. private _isPanClick;
  23946. pinchInwards: boolean;
  23947. private _pointerInput;
  23948. private _observer;
  23949. private _onMouseMove;
  23950. private _onGestureStart;
  23951. private _onGesture;
  23952. private _MSGestureHandler;
  23953. private _onLostFocus;
  23954. private _onContextMenu;
  23955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23956. detachControl(element: Nullable<HTMLElement>): void;
  23957. getClassName(): string;
  23958. getSimpleName(): string;
  23959. }
  23960. }
  23961. declare module BABYLON {
  23962. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  23963. camera: ArcRotateCamera;
  23964. alphaCorrection: number;
  23965. betaCorrection: number;
  23966. gammaCorrection: number;
  23967. private _alpha;
  23968. private _gamma;
  23969. private _dirty;
  23970. private _deviceOrientationHandler;
  23971. constructor();
  23972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23973. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  23974. checkInputs(): void;
  23975. detachControl(element: Nullable<HTMLElement>): void;
  23976. getClassName(): string;
  23977. getSimpleName(): string;
  23978. }
  23979. }
  23980. declare module BABYLON {
  23981. /**
  23982. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  23983. * Screen rotation is taken into account.
  23984. */
  23985. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  23986. private _camera;
  23987. private _screenOrientationAngle;
  23988. private _constantTranform;
  23989. private _screenQuaternion;
  23990. private _alpha;
  23991. private _beta;
  23992. private _gamma;
  23993. constructor();
  23994. camera: FreeCamera;
  23995. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23996. private _orientationChanged;
  23997. private _deviceOrientation;
  23998. detachControl(element: Nullable<HTMLElement>): void;
  23999. checkInputs(): void;
  24000. getClassName(): string;
  24001. getSimpleName(): string;
  24002. }
  24003. }
  24004. declare module BABYLON {
  24005. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  24006. camera: FreeCamera;
  24007. gamepad: Nullable<Gamepad>;
  24008. private _onGamepadConnectedObserver;
  24009. private _onGamepadDisconnectedObserver;
  24010. gamepadAngularSensibility: number;
  24011. gamepadMoveSensibility: number;
  24012. private _cameraTransform;
  24013. private _deltaTransform;
  24014. private _vector3;
  24015. private _vector2;
  24016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24017. detachControl(element: Nullable<HTMLElement>): void;
  24018. checkInputs(): void;
  24019. getClassName(): string;
  24020. getSimpleName(): string;
  24021. }
  24022. }
  24023. declare module BABYLON {
  24024. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  24025. camera: FreeCamera;
  24026. private _keys;
  24027. private _onCanvasBlurObserver;
  24028. private _onKeyboardObserver;
  24029. private _engine;
  24030. private _scene;
  24031. keysUp: number[];
  24032. keysDown: number[];
  24033. keysLeft: number[];
  24034. keysRight: number[];
  24035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24036. detachControl(element: Nullable<HTMLElement>): void;
  24037. checkInputs(): void;
  24038. getClassName(): string;
  24039. _onLostFocus(e: FocusEvent): void;
  24040. getSimpleName(): string;
  24041. }
  24042. }
  24043. declare module BABYLON {
  24044. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24045. touchEnabled: boolean;
  24046. camera: FreeCamera;
  24047. buttons: number[];
  24048. angularSensibility: number;
  24049. private _pointerInput;
  24050. private _onMouseMove;
  24051. private _observer;
  24052. private previousPosition;
  24053. constructor(touchEnabled?: boolean);
  24054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24055. detachControl(element: Nullable<HTMLElement>): void;
  24056. getClassName(): string;
  24057. getSimpleName(): string;
  24058. }
  24059. }
  24060. declare module BABYLON {
  24061. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24062. camera: FreeCamera;
  24063. private _offsetX;
  24064. private _offsetY;
  24065. private _pointerPressed;
  24066. private _pointerInput;
  24067. private _observer;
  24068. private _onLostFocus;
  24069. touchAngularSensibility: number;
  24070. touchMoveSensibility: number;
  24071. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24072. detachControl(element: Nullable<HTMLElement>): void;
  24073. checkInputs(): void;
  24074. getClassName(): string;
  24075. getSimpleName(): string;
  24076. }
  24077. }
  24078. declare module BABYLON {
  24079. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  24080. camera: FreeCamera;
  24081. private _leftjoystick;
  24082. private _rightjoystick;
  24083. getLeftJoystick(): VirtualJoystick;
  24084. getRightJoystick(): VirtualJoystick;
  24085. checkInputs(): void;
  24086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24087. detachControl(element: Nullable<HTMLElement>): void;
  24088. getClassName(): string;
  24089. getSimpleName(): string;
  24090. }
  24091. }
  24092. declare module BABYLON {
  24093. class VRCameraMetrics {
  24094. hResolution: number;
  24095. vResolution: number;
  24096. hScreenSize: number;
  24097. vScreenSize: number;
  24098. vScreenCenter: number;
  24099. eyeToScreenDistance: number;
  24100. lensSeparationDistance: number;
  24101. interpupillaryDistance: number;
  24102. distortionK: number[];
  24103. chromaAbCorrection: number[];
  24104. postProcessScaleFactor: number;
  24105. lensCenterOffset: number;
  24106. compensateDistortion: boolean;
  24107. readonly aspectRatio: number;
  24108. readonly aspectRatioFov: number;
  24109. readonly leftHMatrix: Matrix;
  24110. readonly rightHMatrix: Matrix;
  24111. readonly leftPreViewMatrix: Matrix;
  24112. readonly rightPreViewMatrix: Matrix;
  24113. static GetDefault(): VRCameraMetrics;
  24114. }
  24115. }
  24116. declare module BABYLON {
  24117. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  24118. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  24119. getClassName(): string;
  24120. }
  24121. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  24122. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  24123. getClassName(): string;
  24124. }
  24125. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  24126. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  24127. getClassName(): string;
  24128. }
  24129. }
  24130. declare module BABYLON {
  24131. /**
  24132. * Options to modify the vr teleportation behavior.
  24133. */
  24134. interface VRTeleportationOptions {
  24135. /**
  24136. * The name of the mesh which should be used as the teleportation floor. (default: null)
  24137. */
  24138. floorMeshName?: string;
  24139. /**
  24140. * A list of meshes to be used as the teleportation floor. (default: empty)
  24141. */
  24142. floorMeshes?: Mesh[];
  24143. }
  24144. /**
  24145. * Options to modify the vr experience helper's behavior.
  24146. */
  24147. interface VRExperienceHelperOptions extends WebVROptions {
  24148. /**
  24149. * Create a DeviceOrientationCamera to be used as your out of vr camera.
  24150. */
  24151. createDeviceOrientationCamera?: boolean;
  24152. /**
  24153. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
  24154. */
  24155. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  24156. }
  24157. /**
  24158. * Helps to quickly add VR support to an existing scene.
  24159. * See http://doc.babylonjs.com/how_to/webvr_helper
  24160. */
  24161. class VRExperienceHelper {
  24162. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  24163. private _scene;
  24164. private _position;
  24165. private _btnVR;
  24166. private _btnVRDisplayed;
  24167. private _webVRsupported;
  24168. private _webVRready;
  24169. private _webVRrequesting;
  24170. private _webVRpresenting;
  24171. private _fullscreenVRpresenting;
  24172. private _canvas;
  24173. private _webVRCamera;
  24174. private _vrDeviceOrientationCamera;
  24175. private _deviceOrientationCamera;
  24176. private _existingCamera;
  24177. private _onKeyDown;
  24178. private _onVrDisplayPresentChange;
  24179. private _onVRDisplayChanged;
  24180. private _onVRRequestPresentStart;
  24181. private _onVRRequestPresentComplete;
  24182. /**
  24183. * Observable raised when entering VR.
  24184. */
  24185. onEnteringVRObservable: Observable<VRExperienceHelper>;
  24186. /**
  24187. * Observable raised when exiting VR.
  24188. */
  24189. onExitingVRObservable: Observable<VRExperienceHelper>;
  24190. /**
  24191. * Observable raised when controller mesh is loaded.
  24192. */
  24193. onControllerMeshLoadedObservable: Observable<WebVRController>;
  24194. /** Return this.onEnteringVRObservable
  24195. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  24196. */
  24197. readonly onEnteringVR: Observable<VRExperienceHelper>;
  24198. /** Return this.onExitingVRObservable
  24199. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  24200. */
  24201. readonly onExitingVR: Observable<VRExperienceHelper>;
  24202. /** Return this.onControllerMeshLoadedObservable
  24203. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  24204. */
  24205. readonly onControllerMeshLoaded: Observable<WebVRController>;
  24206. private _rayLength;
  24207. private _useCustomVRButton;
  24208. private _teleportationRequested;
  24209. private _teleportActive;
  24210. private _floorMeshName;
  24211. private _floorMeshesCollection;
  24212. private _rotationAllowed;
  24213. private _teleportBackwardsVector;
  24214. private _rotationRightAsked;
  24215. private _rotationLeftAsked;
  24216. private _teleportationTarget;
  24217. private _isDefaultTeleportationTarget;
  24218. private _postProcessMove;
  24219. private _teleportationFillColor;
  24220. private _teleportationBorderColor;
  24221. private _rotationAngle;
  24222. private _haloCenter;
  24223. private _cameraGazer;
  24224. private _padSensibilityUp;
  24225. private _padSensibilityDown;
  24226. private leftController;
  24227. private rightController;
  24228. /**
  24229. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  24230. */
  24231. onNewMeshSelected: Observable<AbstractMesh>;
  24232. /**
  24233. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  24234. */
  24235. onNewMeshPicked: Observable<PickingInfo>;
  24236. private _circleEase;
  24237. /**
  24238. * Observable raised before camera teleportation
  24239. */
  24240. onBeforeCameraTeleport: Observable<Vector3>;
  24241. /**
  24242. * Observable raised after camera teleportation
  24243. */
  24244. onAfterCameraTeleport: Observable<Vector3>;
  24245. /**
  24246. * Observable raised when current selected mesh gets unselected
  24247. */
  24248. onSelectedMeshUnselected: Observable<AbstractMesh>;
  24249. private _raySelectionPredicate;
  24250. /**
  24251. * To be optionaly changed by user to define custom ray selection
  24252. */
  24253. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  24254. /**
  24255. * To be optionaly changed by user to define custom selection logic (after ray selection)
  24256. */
  24257. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  24258. /**
  24259. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  24260. */
  24261. teleportationEnabled: boolean;
  24262. private _defaultHeight;
  24263. private _teleportationInitialized;
  24264. private _interactionsEnabled;
  24265. private _interactionsRequested;
  24266. private _displayGaze;
  24267. private _displayLaserPointer;
  24268. /**
  24269. * The mesh used to display where the user is going to teleport.
  24270. */
  24271. /**
  24272. * Sets the mesh to be used to display where the user is going to teleport.
  24273. */
  24274. teleportationTarget: Mesh;
  24275. /**
  24276. * The mesh used to display where the user is selecting,
  24277. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  24278. * See http://doc.babylonjs.com/resources/baking_transformations
  24279. */
  24280. gazeTrackerMesh: Mesh;
  24281. /**
  24282. * If the ray of the gaze should be displayed.
  24283. */
  24284. /**
  24285. * Sets if the ray of the gaze should be displayed.
  24286. */
  24287. displayGaze: boolean;
  24288. /**
  24289. * If the ray of the LaserPointer should be displayed.
  24290. */
  24291. /**
  24292. * Sets if the ray of the LaserPointer should be displayed.
  24293. */
  24294. displayLaserPointer: boolean;
  24295. /**
  24296. * The deviceOrientationCamera used as the camera when not in VR.
  24297. */
  24298. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  24299. /**
  24300. * Based on the current WebVR support, returns the current VR camera used.
  24301. */
  24302. readonly currentVRCamera: Nullable<Camera>;
  24303. /**
  24304. * The webVRCamera which is used when in VR.
  24305. */
  24306. readonly webVRCamera: WebVRFreeCamera;
  24307. /**
  24308. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  24309. */
  24310. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  24311. private readonly _teleportationRequestInitiated;
  24312. /**
  24313. * Instantiates a VRExperienceHelper.
  24314. * Helps to quickly add VR support to an existing scene.
  24315. * @param scene The scene the VRExperienceHelper belongs to.
  24316. * @param webVROptions Options to modify the vr experience helper's behavior.
  24317. */
  24318. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  24319. private _onDefaultMeshLoaded(webVRController);
  24320. private _onResize;
  24321. private _onFullscreenChange;
  24322. /**
  24323. * Gets a value indicating if we are currently in VR mode.
  24324. */
  24325. readonly isInVRMode: boolean;
  24326. private onVrDisplayPresentChange();
  24327. private onVRDisplayChanged(eventArgs);
  24328. private moveButtonToBottomRight();
  24329. private displayVRButton();
  24330. private updateButtonVisibility();
  24331. /**
  24332. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  24333. * Otherwise, will use the fullscreen API.
  24334. */
  24335. enterVR(): void;
  24336. /**
  24337. * Attempt to exit VR, or fullscreen.
  24338. */
  24339. exitVR(): void;
  24340. /**
  24341. * The position of the vr experience helper.
  24342. */
  24343. /**
  24344. * Sets the position of the vr experience helper.
  24345. */
  24346. position: Vector3;
  24347. /**
  24348. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  24349. */
  24350. enableInteractions(): void;
  24351. private beforeRender;
  24352. private _isTeleportationFloor(mesh);
  24353. /**
  24354. * Adds a floor mesh to be used for teleportation.
  24355. * @param floorMesh the mesh to be used for teleportation.
  24356. */
  24357. addFloorMesh(floorMesh: Mesh): void;
  24358. /**
  24359. * Removes a floor mesh from being used for teleportation.
  24360. * @param floorMesh the mesh to be removed.
  24361. */
  24362. removeFloorMesh(floorMesh: Mesh): void;
  24363. /**
  24364. * Enables interactions and teleportation using the VR controllers and gaze.
  24365. * @param vrTeleportationOptions options to modify teleportation behavior.
  24366. */
  24367. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  24368. private _onNewGamepadConnected;
  24369. private _tryEnableInteractionOnController;
  24370. private _onNewGamepadDisconnected;
  24371. private _enableInteractionOnController(controller);
  24372. private _checkTeleportWithRay(stateObject, gazer);
  24373. private _checkRotate(stateObject, gazer);
  24374. private _checkTeleportBackwards(stateObject, gazer);
  24375. private _enableTeleportationOnController(controller);
  24376. private _createTeleportationCircles();
  24377. private _displayTeleportationTarget();
  24378. private _hideTeleportationTarget();
  24379. private _rotateCamera(right);
  24380. private _moveTeleportationSelectorTo(hit, gazer);
  24381. private _workingVector;
  24382. private _workingQuaternion;
  24383. private _workingMatrix;
  24384. private _teleportCamera(location);
  24385. private _castRayAndSelectObject(gazer);
  24386. private _notifySelectedMeshUnselected(mesh);
  24387. /**
  24388. * Sets the color of the laser ray from the vr controllers.
  24389. * @param color new color for the ray.
  24390. */
  24391. changeLaserColor(color: Color3): void;
  24392. /**
  24393. * Sets the color of the ray from the vr headsets gaze.
  24394. * @param color new color for the ray.
  24395. */
  24396. changeGazeColor(color: Color3): void;
  24397. /**
  24398. * Exits VR and disposes of the vr experience helper
  24399. */
  24400. dispose(): void;
  24401. /**
  24402. * Gets the name of the VRExperienceHelper class
  24403. * @returns "VRExperienceHelper"
  24404. */
  24405. getClassName(): string;
  24406. }
  24407. }
  24408. declare var HMDVRDevice: any;
  24409. declare var VRDisplay: any;
  24410. declare var VRFrameData: any;
  24411. declare module BABYLON {
  24412. /**
  24413. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  24414. * IMPORTANT!! The data is right-hand data.
  24415. * @export
  24416. * @interface DevicePose
  24417. */
  24418. interface DevicePose {
  24419. /**
  24420. * The position of the device, values in array are [x,y,z].
  24421. */
  24422. readonly position?: Float32Array;
  24423. /**
  24424. * The linearVelocity of the device, values in array are [x,y,z].
  24425. */
  24426. readonly linearVelocity?: Float32Array;
  24427. /**
  24428. * The linearAcceleration of the device, values in array are [x,y,z].
  24429. */
  24430. readonly linearAcceleration?: Float32Array;
  24431. /**
  24432. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  24433. */
  24434. readonly orientation?: Float32Array;
  24435. /**
  24436. * The angularVelocity of the device, values in array are [x,y,z].
  24437. */
  24438. readonly angularVelocity?: Float32Array;
  24439. /**
  24440. * The angularAcceleration of the device, values in array are [x,y,z].
  24441. */
  24442. readonly angularAcceleration?: Float32Array;
  24443. }
  24444. /**
  24445. * Interface representing a pose controlled object in Babylon.
  24446. * A pose controlled object has both regular pose values as well as pose values
  24447. * from an external device such as a VR head mounted display
  24448. */
  24449. interface PoseControlled {
  24450. /**
  24451. * The position of the object in babylon space.
  24452. */
  24453. position: Vector3;
  24454. /**
  24455. * The rotation quaternion of the object in babylon space.
  24456. */
  24457. rotationQuaternion: Quaternion;
  24458. /**
  24459. * The position of the device in babylon space.
  24460. */
  24461. devicePosition?: Vector3;
  24462. /**
  24463. * The rotation quaternion of the device in babylon space.
  24464. */
  24465. deviceRotationQuaternion: Quaternion;
  24466. /**
  24467. * The raw pose coming from the device.
  24468. */
  24469. rawPose: Nullable<DevicePose>;
  24470. /**
  24471. * The scale of the device to be used when translating from device space to babylon space.
  24472. */
  24473. deviceScaleFactor: number;
  24474. /**
  24475. * Updates the poseControlled values based on the input device pose.
  24476. * @param poseData the pose data to update the object with
  24477. */
  24478. updateFromDevice(poseData: DevicePose): void;
  24479. }
  24480. /**
  24481. * Set of options to customize the webVRCamera
  24482. */
  24483. interface WebVROptions {
  24484. /**
  24485. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  24486. */
  24487. trackPosition?: boolean;
  24488. /**
  24489. * Sets the scale of the vrDevice in babylon space. (default: 1)
  24490. */
  24491. positionScale?: number;
  24492. /**
  24493. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  24494. */
  24495. displayName?: string;
  24496. /**
  24497. * Should the native controller meshes be initialized. (default: true)
  24498. */
  24499. controllerMeshes?: boolean;
  24500. /**
  24501. * Creating a default HemiLight only on controllers. (default: true)
  24502. */
  24503. defaultLightingOnControllers?: boolean;
  24504. /**
  24505. * If you don't want to use the default VR button of the helper. (default: false)
  24506. */
  24507. useCustomVRButton?: boolean;
  24508. /**
  24509. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  24510. */
  24511. customVRButton?: HTMLButtonElement;
  24512. /**
  24513. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  24514. */
  24515. rayLength?: number;
  24516. /**
  24517. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  24518. */
  24519. defaultHeight?: number;
  24520. }
  24521. /**
  24522. * This represents a WebVR camera.
  24523. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  24524. * @example http://doc.babylonjs.com/how_to/webvr_camera
  24525. */
  24526. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  24527. private webVROptions;
  24528. /**
  24529. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  24530. */
  24531. _vrDevice: any;
  24532. /**
  24533. * The rawPose of the vrDevice.
  24534. */
  24535. rawPose: Nullable<DevicePose>;
  24536. private _onVREnabled;
  24537. private _specsVersion;
  24538. private _attached;
  24539. private _frameData;
  24540. protected _descendants: Array<Node>;
  24541. private _deviceRoomPosition;
  24542. private _deviceRoomRotationQuaternion;
  24543. private _standingMatrix;
  24544. /**
  24545. * Represents device position in babylon space.
  24546. */
  24547. devicePosition: Vector3;
  24548. /**
  24549. * Represents device rotation in babylon space.
  24550. */
  24551. deviceRotationQuaternion: Quaternion;
  24552. /**
  24553. * The scale of the device to be used when translating from device space to babylon space.
  24554. */
  24555. deviceScaleFactor: number;
  24556. private _deviceToWorld;
  24557. private _worldToDevice;
  24558. /**
  24559. * References to the webVR controllers for the vrDevice.
  24560. */
  24561. controllers: Array<WebVRController>;
  24562. /**
  24563. * Emits an event when a controller is attached.
  24564. */
  24565. onControllersAttachedObservable: Observable<WebVRController[]>;
  24566. /**
  24567. * Emits an event when a controller's mesh has been loaded;
  24568. */
  24569. onControllerMeshLoadedObservable: Observable<WebVRController>;
  24570. /**
  24571. * If the rig cameras be used as parent instead of this camera.
  24572. */
  24573. rigParenting: boolean;
  24574. private _lightOnControllers;
  24575. private _defaultHeight?;
  24576. /**
  24577. * Instantiates a WebVRFreeCamera.
  24578. * @param name The name of the WebVRFreeCamera
  24579. * @param position The starting anchor position for the camera
  24580. * @param scene The scene the camera belongs to
  24581. * @param webVROptions a set of customizable options for the webVRCamera
  24582. */
  24583. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  24584. /**
  24585. * Gets the device distance from the ground in meters.
  24586. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  24587. */
  24588. deviceDistanceToRoomGround(): number;
  24589. /**
  24590. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  24591. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  24592. */
  24593. useStandingMatrix(callback?: (bool: boolean) => void): void;
  24594. /**
  24595. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  24596. * @returns A promise with a boolean set to if the standing matrix is supported.
  24597. */
  24598. useStandingMatrixAsync(): Promise<boolean>;
  24599. /**
  24600. * Disposes the camera
  24601. */
  24602. dispose(): void;
  24603. /**
  24604. * Gets a vrController by name.
  24605. * @param name The name of the controller to retreive
  24606. * @returns the controller matching the name specified or null if not found
  24607. */
  24608. getControllerByName(name: string): Nullable<WebVRController>;
  24609. private _leftController;
  24610. /**
  24611. * The controller corrisponding to the users left hand.
  24612. */
  24613. readonly leftController: Nullable<WebVRController>;
  24614. private _rightController;
  24615. /**
  24616. * The controller corrisponding to the users right hand.
  24617. */
  24618. readonly rightController: Nullable<WebVRController>;
  24619. /**
  24620. * Casts a ray forward from the vrCamera's gaze.
  24621. * @param length Length of the ray (default: 100)
  24622. * @returns the ray corrisponding to the gaze
  24623. */
  24624. getForwardRay(length?: number): Ray;
  24625. /**
  24626. * Updates the camera based on device's frame data
  24627. */
  24628. _checkInputs(): void;
  24629. /**
  24630. * Updates the poseControlled values based on the input device pose.
  24631. * @param poseData Pose coming from the device
  24632. */
  24633. updateFromDevice(poseData: DevicePose): void;
  24634. /**
  24635. * WebVR's attach control will start broadcasting frames to the device.
  24636. * Note that in certain browsers (chrome for example) this function must be called
  24637. * within a user-interaction callback. Example:
  24638. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  24639. *
  24640. * @param element html element to attach the vrDevice to
  24641. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  24642. */
  24643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24644. /**
  24645. * Detaches the camera from the html element and disables VR
  24646. *
  24647. * @param element html element to detach from
  24648. */
  24649. detachControl(element: HTMLElement): void;
  24650. /**
  24651. * @returns the name of this class
  24652. */
  24653. getClassName(): string;
  24654. /**
  24655. * Calls resetPose on the vrDisplay
  24656. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  24657. */
  24658. resetToCurrentRotation(): void;
  24659. /**
  24660. * Updates the rig cameras (left and right eye)
  24661. */
  24662. _updateRigCameras(): void;
  24663. private _workingVector;
  24664. private _oneVector;
  24665. private _workingMatrix;
  24666. private updateCacheCalled;
  24667. /**
  24668. * Updates the cached values of the camera
  24669. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  24670. */
  24671. _updateCache(ignoreParentClass?: boolean): void;
  24672. /**
  24673. * Updates the current device position and rotation in the babylon world
  24674. */
  24675. update(): void;
  24676. /**
  24677. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  24678. * @returns an identity matrix
  24679. */
  24680. _getViewMatrix(): Matrix;
  24681. /**
  24682. * This function is called by the two RIG cameras.
  24683. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  24684. */
  24685. protected _getWebVRViewMatrix(): Matrix;
  24686. protected _getWebVRProjectionMatrix(): Matrix;
  24687. private _onGamepadConnectedObserver;
  24688. private _onGamepadDisconnectedObserver;
  24689. /**
  24690. * Initializes the controllers and their meshes
  24691. */
  24692. initControllers(): void;
  24693. }
  24694. }
  24695. declare module BABYLON {
  24696. interface IOctreeContainer<T> {
  24697. blocks: Array<OctreeBlock<T>>;
  24698. }
  24699. class Octree<T> {
  24700. maxDepth: number;
  24701. blocks: Array<OctreeBlock<T>>;
  24702. dynamicContent: T[];
  24703. private _maxBlockCapacity;
  24704. private _selectionContent;
  24705. private _creationFunc;
  24706. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  24707. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  24708. addMesh(entry: T): void;
  24709. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  24710. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  24711. intersectsRay(ray: Ray): SmartArray<T>;
  24712. 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;
  24713. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  24714. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  24715. }
  24716. }
  24717. declare module BABYLON {
  24718. class OctreeBlock<T> {
  24719. entries: T[];
  24720. blocks: Array<OctreeBlock<T>>;
  24721. private _depth;
  24722. private _maxDepth;
  24723. private _capacity;
  24724. private _minPoint;
  24725. private _maxPoint;
  24726. private _boundingVectors;
  24727. private _creationFunc;
  24728. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  24729. readonly capacity: number;
  24730. readonly minPoint: Vector3;
  24731. readonly maxPoint: Vector3;
  24732. addEntry(entry: T): void;
  24733. addEntries(entries: T[]): void;
  24734. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  24735. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  24736. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  24737. createInnerBlocks(): void;
  24738. }
  24739. }
  24740. declare module BABYLON {
  24741. /**
  24742. * Google Daydream controller
  24743. */
  24744. class DaydreamController extends WebVRController {
  24745. /**
  24746. * Base Url for the controller model.
  24747. */
  24748. static MODEL_BASE_URL: string;
  24749. /**
  24750. * File name for the controller model.
  24751. */
  24752. static MODEL_FILENAME: string;
  24753. /**
  24754. * Gamepad Id prefix used to identify Daydream Controller.
  24755. */
  24756. static readonly GAMEPAD_ID_PREFIX: string;
  24757. constructor(vrGamepad: any);
  24758. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24759. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24760. }
  24761. }
  24762. declare module BABYLON {
  24763. class GearVRController extends WebVRController {
  24764. static MODEL_BASE_URL: string;
  24765. static MODEL_FILENAME: string;
  24766. static readonly GAMEPAD_ID_PREFIX: string;
  24767. private readonly _buttonIndexToObservableNameMap;
  24768. constructor(vrGamepad: any);
  24769. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24770. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24771. }
  24772. }
  24773. declare module BABYLON {
  24774. class GenericController extends WebVRController {
  24775. static readonly MODEL_BASE_URL: string;
  24776. static readonly MODEL_FILENAME: string;
  24777. constructor(vrGamepad: any);
  24778. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24779. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24780. }
  24781. }
  24782. declare module BABYLON {
  24783. class OculusTouchController extends WebVRController {
  24784. static MODEL_BASE_URL: string;
  24785. static MODEL_LEFT_FILENAME: string;
  24786. static MODEL_RIGHT_FILENAME: string;
  24787. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  24788. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  24789. constructor(vrGamepad: any);
  24790. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24791. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24792. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24793. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24794. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24795. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24796. }
  24797. }
  24798. declare module BABYLON {
  24799. enum PoseEnabledControllerType {
  24800. VIVE = 0,
  24801. OCULUS = 1,
  24802. WINDOWS = 2,
  24803. GEAR_VR = 3,
  24804. /**
  24805. * Google Daydream
  24806. */
  24807. DAYDREAM = 4,
  24808. GENERIC = 5,
  24809. }
  24810. interface MutableGamepadButton {
  24811. value: number;
  24812. touched: boolean;
  24813. pressed: boolean;
  24814. }
  24815. interface ExtendedGamepadButton extends GamepadButton {
  24816. readonly pressed: boolean;
  24817. readonly touched: boolean;
  24818. readonly value: number;
  24819. }
  24820. class PoseEnabledControllerHelper {
  24821. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  24822. }
  24823. class PoseEnabledController extends Gamepad implements PoseControlled {
  24824. private _deviceRoomPosition;
  24825. private _deviceRoomRotationQuaternion;
  24826. devicePosition: Vector3;
  24827. deviceRotationQuaternion: Quaternion;
  24828. deviceScaleFactor: number;
  24829. position: Vector3;
  24830. rotationQuaternion: Quaternion;
  24831. controllerType: PoseEnabledControllerType;
  24832. private _calculatedPosition;
  24833. private _calculatedRotation;
  24834. rawPose: DevicePose;
  24835. _mesh: Nullable<AbstractMesh>;
  24836. private _poseControlledCamera;
  24837. private _leftHandSystemQuaternion;
  24838. _deviceToWorld: Matrix;
  24839. /**
  24840. * Node to be used when casting a ray from the controller
  24841. */
  24842. _pointingPoseNode: Nullable<AbstractMesh>;
  24843. /**
  24844. * Name of the child mesh that can be used to cast a ray from the controller
  24845. */
  24846. static readonly POINTING_POSE: string;
  24847. constructor(browserGamepad: any);
  24848. private _workingMatrix;
  24849. update(): void;
  24850. updateFromDevice(poseData: DevicePose): void;
  24851. attachToMesh(mesh: AbstractMesh): void;
  24852. attachToPoseControlledCamera(camera: TargetCamera): void;
  24853. dispose(): void;
  24854. readonly mesh: Nullable<AbstractMesh>;
  24855. getForwardRay(length?: number): Ray;
  24856. }
  24857. }
  24858. declare module BABYLON {
  24859. class ViveController extends WebVRController {
  24860. static MODEL_BASE_URL: string;
  24861. static MODEL_FILENAME: string;
  24862. constructor(vrGamepad: any);
  24863. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24864. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24865. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24866. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24867. /**
  24868. * Vive mapping:
  24869. * 0: touchpad
  24870. * 1: trigger
  24871. * 2: left AND right buttons
  24872. * 3: menu button
  24873. */
  24874. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24875. }
  24876. }
  24877. declare module BABYLON {
  24878. abstract class WebVRController extends PoseEnabledController {
  24879. protected _defaultModel: AbstractMesh;
  24880. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  24881. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24882. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24883. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  24884. onPadValuesChangedObservable: Observable<StickValues>;
  24885. protected _buttons: Array<MutableGamepadButton>;
  24886. private _onButtonStateChange;
  24887. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  24888. pad: StickValues;
  24889. hand: string;
  24890. readonly defaultModel: AbstractMesh;
  24891. constructor(vrGamepad: any);
  24892. update(): void;
  24893. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24894. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24895. private _setButtonValue(newState, currentState, buttonIndex);
  24896. private _changes;
  24897. private _checkChanges(newState, currentState);
  24898. dispose(): void;
  24899. }
  24900. }
  24901. declare module BABYLON {
  24902. class WindowsMotionController extends WebVRController {
  24903. static MODEL_BASE_URL: string;
  24904. static MODEL_LEFT_FILENAME: string;
  24905. static MODEL_RIGHT_FILENAME: string;
  24906. static readonly GAMEPAD_ID_PREFIX: string;
  24907. private static readonly GAMEPAD_ID_PATTERN;
  24908. private _loadedMeshInfo;
  24909. private readonly _mapping;
  24910. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  24911. onTrackpadValuesChangedObservable: Observable<StickValues>;
  24912. trackpad: StickValues;
  24913. constructor(vrGamepad: any);
  24914. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24915. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24916. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24917. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24918. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24919. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  24920. /**
  24921. * Called once per frame by the engine.
  24922. */
  24923. update(): void;
  24924. /**
  24925. * Called once for each button that changed state since the last frame
  24926. * @param buttonIdx Which button index changed
  24927. * @param state New state of the button
  24928. * @param changes Which properties on the state changed since last frame
  24929. */
  24930. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24931. protected lerpButtonTransform(buttonName: string, buttonValue: number): void;
  24932. protected lerpAxisTransform(axis: number, axisValue: number): void;
  24933. /**
  24934. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  24935. * @param scene scene in which to add meshes
  24936. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  24937. */
  24938. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  24939. /**
  24940. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  24941. * can be transformed by button presses and axes values, based on this._mapping.
  24942. *
  24943. * @param scene scene in which the meshes exist
  24944. * @param meshes list of meshes that make up the controller model to process
  24945. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  24946. */
  24947. private processModel(scene, meshes);
  24948. private createMeshInfo(rootNode);
  24949. getForwardRay(length?: number): Ray;
  24950. dispose(): void;
  24951. }
  24952. }
  24953. declare module BABYLON {
  24954. /**
  24955. * Interface to implement to create a shadow generator compatible with BJS.
  24956. */
  24957. interface IShadowGenerator {
  24958. /**
  24959. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  24960. * @returns The render target texture if present otherwise, null
  24961. */
  24962. getShadowMap(): Nullable<RenderTargetTexture>;
  24963. /**
  24964. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  24965. * @returns The render target texture if the shadow map is present otherwise, null
  24966. */
  24967. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  24968. /**
  24969. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  24970. * @param subMesh The submesh we want to render in the shadow map
  24971. * @param useInstances Defines wether will draw in the map using instances
  24972. * @returns true if ready otherwise, false
  24973. */
  24974. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24975. /**
  24976. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  24977. * @param defines Defines of the material we want to update
  24978. * @param lightIndex Index of the light in the enabled light list of the material
  24979. */
  24980. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  24981. /**
  24982. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  24983. * defined in the generator but impacting the effect).
  24984. * It implies the unifroms available on the materials are the standard BJS ones.
  24985. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  24986. * @param effect The effect we are binfing the information for
  24987. */
  24988. bindShadowLight(lightIndex: string, effect: Effect): void;
  24989. /**
  24990. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  24991. * (eq to shadow prjection matrix * light transform matrix)
  24992. * @returns The transform matrix used to create the shadow map
  24993. */
  24994. getTransformMatrix(): Matrix;
  24995. /**
  24996. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  24997. * Cube and 2D textures for instance.
  24998. */
  24999. recreateShadowMap(): void;
  25000. /**
  25001. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  25002. * @param onCompiled Callback triggered at the and of the effects compilation
  25003. * @param options Sets of optional options forcing the compilation with different modes
  25004. */
  25005. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  25006. useInstances: boolean;
  25007. }>): void;
  25008. /**
  25009. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  25010. * @param options Sets of optional options forcing the compilation with different modes
  25011. * @returns A promise that resolves when the compilation completes
  25012. */
  25013. forceCompilationAsync(options?: Partial<{
  25014. useInstances: boolean;
  25015. }>): Promise<void>;
  25016. /**
  25017. * Serializes the shadow generator setup to a json object.
  25018. * @returns The serialized JSON object
  25019. */
  25020. serialize(): any;
  25021. /**
  25022. * Disposes the Shadow map and related Textures and effects.
  25023. */
  25024. dispose(): void;
  25025. }
  25026. /**
  25027. * Default implementation of @see IShadowGenerator.
  25028. * This is the main object responsible of generating shadows in the framework.
  25029. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  25030. */
  25031. class ShadowGenerator implements IShadowGenerator {
  25032. /**
  25033. * Shadow generator mode None: no filtering applied.
  25034. */
  25035. static readonly FILTER_NONE: number;
  25036. /**
  25037. * Shadow generator mode ESM: Exponential Shadow Mapping.
  25038. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  25039. */
  25040. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  25041. /**
  25042. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  25043. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  25044. */
  25045. static readonly FILTER_POISSONSAMPLING: number;
  25046. /**
  25047. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  25048. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  25049. */
  25050. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  25051. /**
  25052. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  25053. * edge artifacts on steep falloff.
  25054. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  25055. */
  25056. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  25057. /**
  25058. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  25059. * edge artifacts on steep falloff.
  25060. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  25061. */
  25062. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  25063. /**
  25064. * Shadow generator mode PCF: Percentage Closer Filtering
  25065. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  25066. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  25067. */
  25068. static readonly FILTER_PCF: number;
  25069. /**
  25070. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  25071. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  25072. * Contact Hardening
  25073. */
  25074. static readonly FILTER_PCSS: number;
  25075. /**
  25076. * Reserved for PCF and PCSS
  25077. * Highest Quality.
  25078. *
  25079. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  25080. *
  25081. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  25082. */
  25083. static readonly QUALITY_HIGH: number;
  25084. /**
  25085. * Reserved for PCF and PCSS
  25086. * Good tradeoff for quality/perf cross devices
  25087. *
  25088. * Execute PCF on a 3*3 kernel.
  25089. *
  25090. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  25091. */
  25092. static readonly QUALITY_MEDIUM: number;
  25093. /**
  25094. * Reserved for PCF and PCSS
  25095. * The lowest quality but the fastest.
  25096. *
  25097. * Execute PCF on a 1*1 kernel.
  25098. *
  25099. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  25100. */
  25101. static readonly QUALITY_LOW: number;
  25102. private _bias;
  25103. /**
  25104. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  25105. */
  25106. /**
  25107. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  25108. */
  25109. bias: number;
  25110. private _normalBias;
  25111. /**
  25112. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  25113. */
  25114. /**
  25115. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  25116. */
  25117. normalBias: number;
  25118. private _blurBoxOffset;
  25119. /**
  25120. * Gets the blur box offset: offset applied during the blur pass.
  25121. * Only usefull if useKernelBlur = false
  25122. */
  25123. /**
  25124. * Sets the blur box offset: offset applied during the blur pass.
  25125. * Only usefull if useKernelBlur = false
  25126. */
  25127. blurBoxOffset: number;
  25128. private _blurScale;
  25129. /**
  25130. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  25131. * 2 means half of the size.
  25132. */
  25133. /**
  25134. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  25135. * 2 means half of the size.
  25136. */
  25137. blurScale: number;
  25138. private _blurKernel;
  25139. /**
  25140. * Gets the blur kernel: kernel size of the blur pass.
  25141. * Only usefull if useKernelBlur = true
  25142. */
  25143. /**
  25144. * Sets the blur kernel: kernel size of the blur pass.
  25145. * Only usefull if useKernelBlur = true
  25146. */
  25147. blurKernel: number;
  25148. private _useKernelBlur;
  25149. /**
  25150. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  25151. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  25152. */
  25153. /**
  25154. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  25155. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  25156. */
  25157. useKernelBlur: boolean;
  25158. private _depthScale;
  25159. /**
  25160. * Gets the depth scale used in ESM mode.
  25161. */
  25162. /**
  25163. * Sets the depth scale used in ESM mode.
  25164. * This can override the scale stored on the light.
  25165. */
  25166. depthScale: number;
  25167. private _filter;
  25168. /**
  25169. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  25170. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  25171. */
  25172. /**
  25173. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  25174. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  25175. */
  25176. filter: number;
  25177. /**
  25178. * Gets if the current filter is set to Poisson Sampling.
  25179. */
  25180. /**
  25181. * Sets the current filter to Poisson Sampling.
  25182. */
  25183. usePoissonSampling: boolean;
  25184. /**
  25185. * Gets if the current filter is set to VSM.
  25186. * DEPRECATED. Should use useExponentialShadowMap instead.
  25187. */
  25188. /**
  25189. * Sets the current filter is to VSM.
  25190. * DEPRECATED. Should use useExponentialShadowMap instead.
  25191. */
  25192. useVarianceShadowMap: boolean;
  25193. /**
  25194. * Gets if the current filter is set to blurred VSM.
  25195. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  25196. */
  25197. /**
  25198. * Sets the current filter is to blurred VSM.
  25199. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  25200. */
  25201. useBlurVarianceShadowMap: boolean;
  25202. /**
  25203. * Gets if the current filter is set to ESM.
  25204. */
  25205. /**
  25206. * Sets the current filter is to ESM.
  25207. */
  25208. useExponentialShadowMap: boolean;
  25209. /**
  25210. * Gets if the current filter is set to filtered ESM.
  25211. */
  25212. /**
  25213. * Gets if the current filter is set to filtered ESM.
  25214. */
  25215. useBlurExponentialShadowMap: boolean;
  25216. /**
  25217. * Gets if the current filter is set to "close ESM" (using the inverse of the
  25218. * exponential to prevent steep falloff artifacts).
  25219. */
  25220. /**
  25221. * Sets the current filter to "close ESM" (using the inverse of the
  25222. * exponential to prevent steep falloff artifacts).
  25223. */
  25224. useCloseExponentialShadowMap: boolean;
  25225. /**
  25226. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  25227. * exponential to prevent steep falloff artifacts).
  25228. */
  25229. /**
  25230. * Sets the current filter to filtered "close ESM" (using the inverse of the
  25231. * exponential to prevent steep falloff artifacts).
  25232. */
  25233. useBlurCloseExponentialShadowMap: boolean;
  25234. /**
  25235. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  25236. */
  25237. /**
  25238. * Sets the current filter to "PCF" (percentage closer filtering).
  25239. */
  25240. usePercentageCloserFiltering: boolean;
  25241. private _filteringQuality;
  25242. /**
  25243. * Gets the PCF or PCSS Quality.
  25244. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  25245. */
  25246. /**
  25247. * Sets the PCF or PCSS Quality.
  25248. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  25249. */
  25250. filteringQuality: number;
  25251. /**
  25252. * Gets if the current filter is set to "PCSS" (contact hardening).
  25253. */
  25254. /**
  25255. * Sets the current filter to "PCSS" (contact hardening).
  25256. */
  25257. useContactHardeningShadow: boolean;
  25258. private _contactHardeningLightSizeUVRatio;
  25259. /**
  25260. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  25261. * Using a ratio helps keeping shape stability independently of the map size.
  25262. *
  25263. * It does not account for the light projection as it was having too much
  25264. * instability during the light setup or during light position changes.
  25265. *
  25266. * Only valid if useContactHardeningShadow is true.
  25267. */
  25268. /**
  25269. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  25270. * Using a ratio helps keeping shape stability independently of the map size.
  25271. *
  25272. * It does not account for the light projection as it was having too much
  25273. * instability during the light setup or during light position changes.
  25274. *
  25275. * Only valid if useContactHardeningShadow is true.
  25276. */
  25277. contactHardeningLightSizeUVRatio: number;
  25278. private _darkness;
  25279. /**
  25280. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  25281. * 0 means strongest and 1 would means no shadow.
  25282. * @returns the darkness.
  25283. */
  25284. getDarkness(): number;
  25285. /**
  25286. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  25287. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  25288. * @returns the shadow generator allowing fluent coding.
  25289. */
  25290. setDarkness(darkness: number): ShadowGenerator;
  25291. private _transparencyShadow;
  25292. /**
  25293. * Sets the ability to have transparent shadow (boolean).
  25294. * @param transparent True if transparent else False
  25295. * @returns the shadow generator allowing fluent coding
  25296. */
  25297. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  25298. private _shadowMap;
  25299. private _shadowMap2;
  25300. /**
  25301. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  25302. * @returns The render target texture if present otherwise, null
  25303. */
  25304. getShadowMap(): Nullable<RenderTargetTexture>;
  25305. /**
  25306. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  25307. * @returns The render target texture if the shadow map is present otherwise, null
  25308. */
  25309. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  25310. /**
  25311. * Helper function to add a mesh and its descendants to the list of shadow casters.
  25312. * @param mesh Mesh to add
  25313. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  25314. * @returns the Shadow Generator itself
  25315. */
  25316. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  25317. /**
  25318. * Helper function to remove a mesh and its descendants from the list of shadow casters
  25319. * @param mesh Mesh to remove
  25320. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  25321. * @returns the Shadow Generator itself
  25322. */
  25323. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  25324. /**
  25325. * Controls the extent to which the shadows fade out at the edge of the frustum
  25326. * Used only by directionals and spots
  25327. */
  25328. frustumEdgeFalloff: number;
  25329. private _light;
  25330. /**
  25331. * Returns the associated light object.
  25332. * @returns the light generating the shadow
  25333. */
  25334. getLight(): IShadowLight;
  25335. /**
  25336. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  25337. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  25338. * It might on the other hand introduce peter panning.
  25339. */
  25340. forceBackFacesOnly: boolean;
  25341. private _scene;
  25342. private _lightDirection;
  25343. private _effect;
  25344. private _viewMatrix;
  25345. private _projectionMatrix;
  25346. private _transformMatrix;
  25347. private _cachedPosition;
  25348. private _cachedDirection;
  25349. private _cachedDefines;
  25350. private _currentRenderID;
  25351. private _boxBlurPostprocess;
  25352. private _kernelBlurXPostprocess;
  25353. private _kernelBlurYPostprocess;
  25354. private _blurPostProcesses;
  25355. private _mapSize;
  25356. private _currentFaceIndex;
  25357. private _currentFaceIndexCache;
  25358. private _textureType;
  25359. private _defaultTextureMatrix;
  25360. /**
  25361. * Creates a ShadowGenerator object.
  25362. * A ShadowGenerator is the required tool to use the shadows.
  25363. * Each light casting shadows needs to use its own ShadowGenerator.
  25364. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  25365. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  25366. * @param light The light object generating the shadows.
  25367. * @param useFullFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  25368. */
  25369. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  25370. private _initializeGenerator();
  25371. private _initializeShadowMap();
  25372. private _initializeBlurRTTAndPostProcesses();
  25373. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  25374. private _renderSubMeshForShadowMap(subMesh);
  25375. private _applyFilterValues();
  25376. /**
  25377. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  25378. * @param onCompiled Callback triggered at the and of the effects compilation
  25379. * @param options Sets of optional options forcing the compilation with different modes
  25380. */
  25381. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  25382. useInstances: boolean;
  25383. }>): void;
  25384. /**
  25385. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  25386. * @param options Sets of optional options forcing the compilation with different modes
  25387. * @returns A promise that resolves when the compilation completes
  25388. */
  25389. forceCompilationAsync(options?: Partial<{
  25390. useInstances: boolean;
  25391. }>): Promise<void>;
  25392. /**
  25393. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  25394. * @param subMesh The submesh we want to render in the shadow map
  25395. * @param useInstances Defines wether will draw in the map using instances
  25396. * @returns true if ready otherwise, false
  25397. */
  25398. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25399. /**
  25400. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  25401. * @param defines Defines of the material we want to update
  25402. * @param lightIndex Index of the light in the enabled light list of the material
  25403. */
  25404. prepareDefines(defines: any, lightIndex: number): void;
  25405. /**
  25406. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  25407. * defined in the generator but impacting the effect).
  25408. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  25409. * @param effect The effect we are binfing the information for
  25410. */
  25411. bindShadowLight(lightIndex: string, effect: Effect): void;
  25412. /**
  25413. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  25414. * (eq to shadow prjection matrix * light transform matrix)
  25415. * @returns The transform matrix used to create the shadow map
  25416. */
  25417. getTransformMatrix(): Matrix;
  25418. /**
  25419. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  25420. * Cube and 2D textures for instance.
  25421. */
  25422. recreateShadowMap(): void;
  25423. private _disposeBlurPostProcesses();
  25424. private _disposeRTTandPostProcesses();
  25425. /**
  25426. * Disposes the ShadowGenerator.
  25427. * Returns nothing.
  25428. */
  25429. dispose(): void;
  25430. /**
  25431. * Serializes the shadow generator setup to a json object.
  25432. * @returns The serialized JSON object
  25433. */
  25434. serialize(): any;
  25435. /**
  25436. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  25437. * @param parsedShadowGenerator The JSON object to parse
  25438. * @param scene The scene to create the shadow map for
  25439. * @returns The parsed shadow generator
  25440. */
  25441. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  25442. }
  25443. }
  25444. declare module BABYLON {
  25445. }
  25446. declare module BABYLON {
  25447. /**
  25448. * Background material used to create an efficient environement around your scene.
  25449. */
  25450. class BackgroundMaterial extends PushMaterial {
  25451. /**
  25452. * Standard reflectance value at parallel view angle.
  25453. */
  25454. static StandardReflectance0: number;
  25455. /**
  25456. * Standard reflectance value at grazing angle.
  25457. */
  25458. static StandardReflectance90: number;
  25459. protected _primaryColor: Color3;
  25460. /**
  25461. * Key light Color (multiply against the R channel of the environement texture)
  25462. */
  25463. primaryColor: Color3;
  25464. protected _primaryLevel: float;
  25465. /**
  25466. * Key light Level (allowing HDR output of the background)
  25467. */
  25468. primaryLevel: float;
  25469. protected _secondaryColor: Color3;
  25470. /**
  25471. * Secondary light Color (multiply against the G channel of the environement texture)
  25472. */
  25473. secondaryColor: Color3;
  25474. protected _secondaryLevel: float;
  25475. /**
  25476. * Secondary light Level (allowing HDR output of the background)
  25477. */
  25478. secondaryLevel: float;
  25479. protected _tertiaryColor: Color3;
  25480. /**
  25481. * Tertiary light Color (multiply against the B channel of the environement texture)
  25482. */
  25483. tertiaryColor: Color3;
  25484. protected _tertiaryLevel: float;
  25485. /**
  25486. * Tertiary light Level (allowing HDR output of the background)
  25487. */
  25488. tertiaryLevel: float;
  25489. protected _reflectionTexture: Nullable<BaseTexture>;
  25490. /**
  25491. * Reflection Texture used in the material.
  25492. * Should be author in a specific way for the best result (refer to the documentation).
  25493. */
  25494. reflectionTexture: Nullable<BaseTexture>;
  25495. protected _reflectionBlur: float;
  25496. /**
  25497. * Reflection Texture level of blur.
  25498. *
  25499. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  25500. * texture twice.
  25501. */
  25502. reflectionBlur: float;
  25503. protected _diffuseTexture: Nullable<BaseTexture>;
  25504. /**
  25505. * Diffuse Texture used in the material.
  25506. * Should be author in a specific way for the best result (refer to the documentation).
  25507. */
  25508. diffuseTexture: Nullable<BaseTexture>;
  25509. protected _shadowLights: Nullable<IShadowLight[]>;
  25510. /**
  25511. * Specify the list of lights casting shadow on the material.
  25512. * All scene shadow lights will be included if null.
  25513. */
  25514. shadowLights: Nullable<IShadowLight[]>;
  25515. protected _shadowBlurScale: int;
  25516. /**
  25517. * For the lights having a blurred shadow generator, this can add a second blur pass in order to reach
  25518. * soft lighting on the background.
  25519. */
  25520. shadowBlurScale: int;
  25521. protected _shadowLevel: float;
  25522. /**
  25523. * Helps adjusting the shadow to a softer level if required.
  25524. * 0 means black shadows and 1 means no shadows.
  25525. */
  25526. shadowLevel: float;
  25527. protected _sceneCenter: Vector3;
  25528. /**
  25529. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  25530. * It is usually zero but might be interesting to modify according to your setup.
  25531. */
  25532. sceneCenter: Vector3;
  25533. protected _opacityFresnel: boolean;
  25534. /**
  25535. * This helps specifying that the material is falling off to the sky box at grazing angle.
  25536. * This helps ensuring a nice transition when the camera goes under the ground.
  25537. */
  25538. opacityFresnel: boolean;
  25539. protected _reflectionFresnel: boolean;
  25540. /**
  25541. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  25542. * This helps adding a mirror texture on the ground.
  25543. */
  25544. reflectionFresnel: boolean;
  25545. protected _reflectionFalloffDistance: number;
  25546. /**
  25547. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  25548. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  25549. */
  25550. reflectionFalloffDistance: number;
  25551. protected _reflectionAmount: number;
  25552. /**
  25553. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  25554. */
  25555. reflectionAmount: number;
  25556. protected _reflectionReflectance0: number;
  25557. /**
  25558. * This specifies the weight of the reflection at grazing angle.
  25559. */
  25560. reflectionReflectance0: number;
  25561. protected _reflectionReflectance90: number;
  25562. /**
  25563. * This specifies the weight of the reflection at a perpendicular point of view.
  25564. */
  25565. reflectionReflectance90: number;
  25566. /**
  25567. * Sets the reflection reflectance fresnel values according to the default standard
  25568. * empirically know to work well :-)
  25569. */
  25570. reflectionStandardFresnelWeight: number;
  25571. protected _useRGBColor: boolean;
  25572. /**
  25573. * Helps to directly use the maps channels instead of their level.
  25574. */
  25575. useRGBColor: boolean;
  25576. protected _enableNoise: boolean;
  25577. /**
  25578. * This helps reducing the banding effect that could occur on the background.
  25579. */
  25580. enableNoise: boolean;
  25581. /**
  25582. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  25583. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  25584. * Recommended to be keep at 1.0 except for special cases.
  25585. */
  25586. fovMultiplier: number;
  25587. private _fovMultiplier;
  25588. /**
  25589. * Enable the FOV adjustment feature controlled by fovMultiplier.
  25590. * @type {boolean}
  25591. */
  25592. useEquirectangularFOV: boolean;
  25593. private _maxSimultaneousLights;
  25594. /**
  25595. * Number of Simultaneous lights allowed on the material.
  25596. */
  25597. maxSimultaneousLights: int;
  25598. /**
  25599. * Default configuration related to image processing available in the Background Material.
  25600. */
  25601. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25602. /**
  25603. * Keep track of the image processing observer to allow dispose and replace.
  25604. */
  25605. private _imageProcessingObserver;
  25606. /**
  25607. * Attaches a new image processing configuration to the PBR Material.
  25608. * @param configuration (if null the scene configuration will be use)
  25609. */
  25610. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25611. /**
  25612. * Gets the image processing configuration used either in this material.
  25613. */
  25614. /**
  25615. * Sets the Default image processing configuration used either in the this material.
  25616. *
  25617. * If sets to null, the scene one is in use.
  25618. */
  25619. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  25620. /**
  25621. * Gets wether the color curves effect is enabled.
  25622. */
  25623. /**
  25624. * Sets wether the color curves effect is enabled.
  25625. */
  25626. cameraColorCurvesEnabled: boolean;
  25627. /**
  25628. * Gets wether the color grading effect is enabled.
  25629. */
  25630. /**
  25631. * Gets wether the color grading effect is enabled.
  25632. */
  25633. cameraColorGradingEnabled: boolean;
  25634. /**
  25635. * Gets wether tonemapping is enabled or not.
  25636. */
  25637. /**
  25638. * Sets wether tonemapping is enabled or not
  25639. */
  25640. cameraToneMappingEnabled: boolean;
  25641. /**
  25642. * The camera exposure used on this material.
  25643. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25644. * This corresponds to a photographic exposure.
  25645. */
  25646. /**
  25647. * The camera exposure used on this material.
  25648. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25649. * This corresponds to a photographic exposure.
  25650. */
  25651. cameraExposure: float;
  25652. /**
  25653. * Gets The camera contrast used on this material.
  25654. */
  25655. /**
  25656. * Sets The camera contrast used on this material.
  25657. */
  25658. cameraContrast: float;
  25659. /**
  25660. * Gets the Color Grading 2D Lookup Texture.
  25661. */
  25662. /**
  25663. * Sets the Color Grading 2D Lookup Texture.
  25664. */
  25665. cameraColorGradingTexture: Nullable<BaseTexture>;
  25666. /**
  25667. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25668. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25669. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  25670. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25671. */
  25672. /**
  25673. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25674. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25675. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  25676. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25677. */
  25678. cameraColorCurves: Nullable<ColorCurves>;
  25679. /**
  25680. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  25681. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  25682. */
  25683. switchToBGR: boolean;
  25684. private _renderTargets;
  25685. private _reflectionControls;
  25686. /**
  25687. * Instantiates a Background Material in the given scene
  25688. * @param name The friendly name of the material
  25689. * @param scene The scene to add the material to
  25690. */
  25691. constructor(name: string, scene: Scene);
  25692. /**
  25693. * The entire material has been created in order to prevent overdraw.
  25694. * @returns false
  25695. */
  25696. needAlphaTesting(): boolean;
  25697. /**
  25698. * The entire material has been created in order to prevent overdraw.
  25699. * @returns true if blending is enable
  25700. */
  25701. needAlphaBlending(): boolean;
  25702. /**
  25703. * Checks wether the material is ready to be rendered for a given mesh.
  25704. * @param mesh The mesh to render
  25705. * @param subMesh The submesh to check against
  25706. * @param useInstances Specify wether or not the material is used with instances
  25707. * @returns true if all the dependencies are ready (Textures, Effects...)
  25708. */
  25709. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25710. /**
  25711. * Build the uniform buffer used in the material.
  25712. */
  25713. buildUniformLayout(): void;
  25714. /**
  25715. * Unbind the material.
  25716. */
  25717. unbind(): void;
  25718. /**
  25719. * Bind only the world matrix to the material.
  25720. * @param world The world matrix to bind.
  25721. */
  25722. bindOnlyWorldMatrix(world: Matrix): void;
  25723. /**
  25724. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  25725. * @param world The world matrix to bind.
  25726. * @param subMesh The submesh to bind for.
  25727. */
  25728. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25729. /**
  25730. * Dispose the material.
  25731. * @param forceDisposeEffect Force disposal of the associated effect.
  25732. * @param forceDisposeTextures Force disposal of the associated textures.
  25733. */
  25734. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25735. /**
  25736. * Clones the material.
  25737. * @param name The cloned name.
  25738. * @returns The cloned material.
  25739. */
  25740. clone(name: string): BackgroundMaterial;
  25741. /**
  25742. * Serializes the current material to its JSON representation.
  25743. * @returns The JSON representation.
  25744. */
  25745. serialize(): any;
  25746. /**
  25747. * Gets the class name of the material
  25748. * @returns "BackgroundMaterial"
  25749. */
  25750. getClassName(): string;
  25751. /**
  25752. * Parse a JSON input to create back a background material.
  25753. * @param source The JSON data to parse
  25754. * @param scene The scene to create the parsed material in
  25755. * @param rootUrl The root url of the assets the material depends upon
  25756. * @returns the instantiated BackgroundMaterial.
  25757. */
  25758. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  25759. }
  25760. }
  25761. declare module BABYLON {
  25762. /**
  25763. * The Physically based material base class of BJS.
  25764. *
  25765. * This offers the main features of a standard PBR material.
  25766. * For more information, please refer to the documentation :
  25767. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  25768. */
  25769. abstract class PBRBaseMaterial extends PushMaterial {
  25770. /**
  25771. * Intensity of the direct lights e.g. the four lights available in your scene.
  25772. * This impacts both the direct diffuse and specular highlights.
  25773. */
  25774. protected _directIntensity: number;
  25775. /**
  25776. * Intensity of the emissive part of the material.
  25777. * This helps controlling the emissive effect without modifying the emissive color.
  25778. */
  25779. protected _emissiveIntensity: number;
  25780. /**
  25781. * Intensity of the environment e.g. how much the environment will light the object
  25782. * either through harmonics for rough material or through the refelction for shiny ones.
  25783. */
  25784. protected _environmentIntensity: number;
  25785. /**
  25786. * This is a special control allowing the reduction of the specular highlights coming from the
  25787. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  25788. */
  25789. protected _specularIntensity: number;
  25790. /**
  25791. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  25792. */
  25793. private _lightingInfos;
  25794. /**
  25795. * Debug Control allowing disabling the bump map on this material.
  25796. */
  25797. protected _disableBumpMap: boolean;
  25798. /**
  25799. * AKA Diffuse Texture in standard nomenclature.
  25800. */
  25801. protected _albedoTexture: BaseTexture;
  25802. /**
  25803. * AKA Occlusion Texture in other nomenclature.
  25804. */
  25805. protected _ambientTexture: BaseTexture;
  25806. /**
  25807. * AKA Occlusion Texture Intensity in other nomenclature.
  25808. */
  25809. protected _ambientTextureStrength: number;
  25810. /**
  25811. * Stores the alpha values in a texture.
  25812. */
  25813. protected _opacityTexture: BaseTexture;
  25814. /**
  25815. * Stores the reflection values in a texture.
  25816. */
  25817. protected _reflectionTexture: BaseTexture;
  25818. /**
  25819. * Stores the refraction values in a texture.
  25820. */
  25821. protected _refractionTexture: BaseTexture;
  25822. /**
  25823. * Stores the emissive values in a texture.
  25824. */
  25825. protected _emissiveTexture: BaseTexture;
  25826. /**
  25827. * AKA Specular texture in other nomenclature.
  25828. */
  25829. protected _reflectivityTexture: BaseTexture;
  25830. /**
  25831. * Used to switch from specular/glossiness to metallic/roughness workflow.
  25832. */
  25833. protected _metallicTexture: BaseTexture;
  25834. /**
  25835. * Specifies the metallic scalar of the metallic/roughness workflow.
  25836. * Can also be used to scale the metalness values of the metallic texture.
  25837. */
  25838. protected _metallic: number;
  25839. /**
  25840. * Specifies the roughness scalar of the metallic/roughness workflow.
  25841. * Can also be used to scale the roughness values of the metallic texture.
  25842. */
  25843. protected _roughness: number;
  25844. /**
  25845. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  25846. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  25847. */
  25848. protected _microSurfaceTexture: BaseTexture;
  25849. /**
  25850. * Stores surface normal data used to displace a mesh in a texture.
  25851. */
  25852. protected _bumpTexture: BaseTexture;
  25853. /**
  25854. * Stores the pre-calculated light information of a mesh in a texture.
  25855. */
  25856. protected _lightmapTexture: BaseTexture;
  25857. /**
  25858. * The color of a material in ambient lighting.
  25859. */
  25860. protected _ambientColor: Color3;
  25861. /**
  25862. * AKA Diffuse Color in other nomenclature.
  25863. */
  25864. protected _albedoColor: Color3;
  25865. /**
  25866. * AKA Specular Color in other nomenclature.
  25867. */
  25868. protected _reflectivityColor: Color3;
  25869. /**
  25870. * The color applied when light is reflected from a material.
  25871. */
  25872. protected _reflectionColor: Color3;
  25873. /**
  25874. * The color applied when light is emitted from a material.
  25875. */
  25876. protected _emissiveColor: Color3;
  25877. /**
  25878. * AKA Glossiness in other nomenclature.
  25879. */
  25880. protected _microSurface: number;
  25881. /**
  25882. * source material index of refraction (IOR)' / 'destination material IOR.
  25883. */
  25884. protected _indexOfRefraction: number;
  25885. /**
  25886. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  25887. */
  25888. protected _invertRefractionY: boolean;
  25889. /**
  25890. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25891. * Materials half opaque for instance using refraction could benefit from this control.
  25892. */
  25893. protected _linkRefractionWithTransparency: boolean;
  25894. /**
  25895. * Specifies that the material will use the light map as a show map.
  25896. */
  25897. protected _useLightmapAsShadowmap: boolean;
  25898. /**
  25899. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  25900. * makes the reflect vector face the model (under horizon).
  25901. */
  25902. protected _useHorizonOcclusion: boolean;
  25903. /**
  25904. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  25905. * too much the area relying on ambient texture to define their ambient occlusion.
  25906. */
  25907. protected _useRadianceOcclusion: boolean;
  25908. /**
  25909. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  25910. */
  25911. protected _useAlphaFromAlbedoTexture: boolean;
  25912. /**
  25913. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  25914. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  25915. */
  25916. protected _useSpecularOverAlpha: boolean;
  25917. /**
  25918. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  25919. */
  25920. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  25921. /**
  25922. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  25923. */
  25924. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  25925. /**
  25926. * Specifies if the metallic texture contains the roughness information in its green channel.
  25927. */
  25928. protected _useRoughnessFromMetallicTextureGreen: boolean;
  25929. /**
  25930. * Specifies if the metallic texture contains the metallness information in its blue channel.
  25931. */
  25932. protected _useMetallnessFromMetallicTextureBlue: boolean;
  25933. /**
  25934. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  25935. */
  25936. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  25937. /**
  25938. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  25939. */
  25940. protected _useAmbientInGrayScale: boolean;
  25941. /**
  25942. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  25943. * The material will try to infer what glossiness each pixel should be.
  25944. */
  25945. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  25946. /**
  25947. * BJS is using an harcoded light falloff based on a manually sets up range.
  25948. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  25949. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  25950. */
  25951. protected _usePhysicalLightFalloff: boolean;
  25952. /**
  25953. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  25954. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  25955. */
  25956. protected _useRadianceOverAlpha: boolean;
  25957. /**
  25958. * Allows using an object space normal map (instead of tangent space).
  25959. */
  25960. protected _useObjectSpaceNormalMap: boolean;
  25961. /**
  25962. * Allows using the bump map in parallax mode.
  25963. */
  25964. protected _useParallax: boolean;
  25965. /**
  25966. * Allows using the bump map in parallax occlusion mode.
  25967. */
  25968. protected _useParallaxOcclusion: boolean;
  25969. /**
  25970. * Controls the scale bias of the parallax mode.
  25971. */
  25972. protected _parallaxScaleBias: number;
  25973. /**
  25974. * If sets to true, disables all the lights affecting the material.
  25975. */
  25976. protected _disableLighting: boolean;
  25977. /**
  25978. * Number of Simultaneous lights allowed on the material.
  25979. */
  25980. protected _maxSimultaneousLights: number;
  25981. /**
  25982. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25983. */
  25984. protected _invertNormalMapX: boolean;
  25985. /**
  25986. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25987. */
  25988. protected _invertNormalMapY: boolean;
  25989. /**
  25990. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25991. */
  25992. protected _twoSidedLighting: boolean;
  25993. /**
  25994. * Defines the alpha limits in alpha test mode.
  25995. */
  25996. protected _alphaCutOff: number;
  25997. /**
  25998. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25999. */
  26000. protected _forceAlphaTest: boolean;
  26001. /**
  26002. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26003. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26004. */
  26005. protected _useAlphaFresnel: boolean;
  26006. /**
  26007. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26008. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26009. */
  26010. protected _useLinearAlphaFresnel: boolean;
  26011. /**
  26012. * The transparency mode of the material.
  26013. */
  26014. protected _transparencyMode: Nullable<number>;
  26015. /**
  26016. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  26017. * from cos thetav and roughness:
  26018. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  26019. */
  26020. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  26021. /**
  26022. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26023. */
  26024. protected _forceIrradianceInFragment: boolean;
  26025. /**
  26026. * Force normal to face away from face.
  26027. */
  26028. protected _forceNormalForward: boolean;
  26029. /**
  26030. * Default configuration related to image processing available in the PBR Material.
  26031. */
  26032. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26033. /**
  26034. * Keep track of the image processing observer to allow dispose and replace.
  26035. */
  26036. private _imageProcessingObserver;
  26037. /**
  26038. * Attaches a new image processing configuration to the PBR Material.
  26039. * @param configuration
  26040. */
  26041. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26042. /**
  26043. * Stores the available render targets.
  26044. */
  26045. private _renderTargets;
  26046. /**
  26047. * Sets the global ambient color for the material used in lighting calculations.
  26048. */
  26049. private _globalAmbientColor;
  26050. /**
  26051. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  26052. */
  26053. private _useLogarithmicDepth;
  26054. /**
  26055. * If set to true, no lighting calculations will be applied.
  26056. */
  26057. private _unlit;
  26058. /**
  26059. * Instantiates a new PBRMaterial instance.
  26060. *
  26061. * @param name The material name
  26062. * @param scene The scene the material will be use in.
  26063. */
  26064. constructor(name: string, scene: Scene);
  26065. /**
  26066. * Gets the name of the material class.
  26067. */
  26068. getClassName(): string;
  26069. /**
  26070. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26071. */
  26072. /**
  26073. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26074. */
  26075. useLogarithmicDepth: boolean;
  26076. /**
  26077. * Gets the current transparency mode.
  26078. */
  26079. /**
  26080. * Sets the transparency mode of the material.
  26081. */
  26082. transparencyMode: Nullable<number>;
  26083. /**
  26084. * Returns true if alpha blending should be disabled.
  26085. */
  26086. private readonly _disableAlphaBlending;
  26087. /**
  26088. * Specifies whether or not this material should be rendered in alpha blend mode.
  26089. */
  26090. needAlphaBlending(): boolean;
  26091. /**
  26092. * Specifies if the mesh will require alpha blending.
  26093. * @param mesh - BJS mesh.
  26094. */
  26095. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  26096. /**
  26097. * Specifies whether or not this material should be rendered in alpha test mode.
  26098. */
  26099. needAlphaTesting(): boolean;
  26100. /**
  26101. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  26102. */
  26103. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  26104. /**
  26105. * Gets the texture used for the alpha test.
  26106. */
  26107. getAlphaTestTexture(): BaseTexture;
  26108. /**
  26109. * Stores the reflectivity values based on metallic roughness workflow.
  26110. */
  26111. private static _scaledReflectivity;
  26112. /**
  26113. * Specifies that the submesh is ready to be used.
  26114. * @param mesh - BJS mesh.
  26115. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  26116. * @param useInstances - Specifies that instances should be used.
  26117. * @returns - boolean indicating that the submesh is ready or not.
  26118. */
  26119. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26120. /**
  26121. * Specifies if the material uses metallic roughness workflow.
  26122. * @returns boolean specifiying if the material uses metallic roughness workflow.
  26123. */
  26124. isMetallicWorkflow(): boolean;
  26125. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  26126. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  26127. /**
  26128. * Force shader compilation
  26129. */
  26130. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  26131. clipPlane: boolean;
  26132. }>): void;
  26133. /**
  26134. * Initializes the uniform buffer layout for the shader.
  26135. */
  26136. buildUniformLayout(): void;
  26137. /**
  26138. * Unbinds the textures.
  26139. */
  26140. unbind(): void;
  26141. /**
  26142. * Binds the submesh data.
  26143. * @param world - The world matrix.
  26144. * @param mesh - The BJS mesh.
  26145. * @param subMesh - A submesh of the BJS mesh.
  26146. */
  26147. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26148. /**
  26149. * Returns the animatable textures.
  26150. * @returns - Array of animatable textures.
  26151. */
  26152. getAnimatables(): IAnimatable[];
  26153. /**
  26154. * Returns the texture used for reflections.
  26155. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  26156. */
  26157. private _getReflectionTexture();
  26158. /**
  26159. * Returns the texture used for refraction or null if none is used.
  26160. * @returns - Refection texture if present. If no refraction texture and refraction
  26161. * is linked with transparency, returns environment texture. Otherwise, returns null.
  26162. */
  26163. private _getRefractionTexture();
  26164. /**
  26165. * Disposes the resources of the material.
  26166. * @param forceDisposeEffect - Forces the disposal of effects.
  26167. * @param forceDisposeTextures - Forces the disposal of all textures.
  26168. */
  26169. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26170. }
  26171. }
  26172. declare module BABYLON {
  26173. /**
  26174. * The Physically based simple base material of BJS.
  26175. *
  26176. * This enables better naming and convention enforcements on top of the pbrMaterial.
  26177. * It is used as the base class for both the specGloss and metalRough conventions.
  26178. */
  26179. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  26180. /**
  26181. * Number of Simultaneous lights allowed on the material.
  26182. */
  26183. maxSimultaneousLights: number;
  26184. /**
  26185. * If sets to true, disables all the lights affecting the material.
  26186. */
  26187. disableLighting: boolean;
  26188. /**
  26189. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  26190. */
  26191. environmentTexture: BaseTexture;
  26192. /**
  26193. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26194. */
  26195. invertNormalMapX: boolean;
  26196. /**
  26197. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26198. */
  26199. invertNormalMapY: boolean;
  26200. /**
  26201. * Normal map used in the model.
  26202. */
  26203. normalTexture: BaseTexture;
  26204. /**
  26205. * Emissivie color used to self-illuminate the model.
  26206. */
  26207. emissiveColor: Color3;
  26208. /**
  26209. * Emissivie texture used to self-illuminate the model.
  26210. */
  26211. emissiveTexture: BaseTexture;
  26212. /**
  26213. * Occlusion Channel Strenght.
  26214. */
  26215. occlusionStrength: number;
  26216. /**
  26217. * Occlusion Texture of the material (adding extra occlusion effects).
  26218. */
  26219. occlusionTexture: BaseTexture;
  26220. /**
  26221. * Defines the alpha limits in alpha test mode.
  26222. */
  26223. alphaCutOff: number;
  26224. /**
  26225. * Gets the current double sided mode.
  26226. */
  26227. /**
  26228. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26229. */
  26230. doubleSided: boolean;
  26231. lightmapTexture: BaseTexture;
  26232. useLightmapAsShadowmap: boolean;
  26233. /**
  26234. * Return the active textures of the material.
  26235. */
  26236. getActiveTextures(): BaseTexture[];
  26237. hasTexture(texture: BaseTexture): boolean;
  26238. /**
  26239. * Instantiates a new PBRMaterial instance.
  26240. *
  26241. * @param name The material name
  26242. * @param scene The scene the material will be use in.
  26243. */
  26244. constructor(name: string, scene: Scene);
  26245. getClassName(): string;
  26246. }
  26247. }
  26248. declare module BABYLON {
  26249. /**
  26250. * The Physically based material of BJS.
  26251. *
  26252. * This offers the main features of a standard PBR material.
  26253. * For more information, please refer to the documentation :
  26254. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  26255. */
  26256. class PBRMaterial extends PBRBaseMaterial {
  26257. private static _PBRMATERIAL_OPAQUE;
  26258. /**
  26259. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26260. */
  26261. static readonly PBRMATERIAL_OPAQUE: number;
  26262. /**
  26263. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26264. */
  26265. private static _PBRMATERIAL_ALPHATEST;
  26266. /**
  26267. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26268. */
  26269. static readonly PBRMATERIAL_ALPHATEST: number;
  26270. /**
  26271. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26272. */
  26273. private static _PBRMATERIAL_ALPHABLEND;
  26274. /**
  26275. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26276. */
  26277. static readonly PBRMATERIAL_ALPHABLEND: number;
  26278. /**
  26279. * Represents the value for Alpha Test and Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26280. * They are also discarded below the alpha cutoff threshold to improve performances.
  26281. */
  26282. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  26283. /**
  26284. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26285. * They are also discarded below the alpha cutoff threshold to improve performances.
  26286. */
  26287. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26288. /**
  26289. * Intensity of the direct lights e.g. the four lights available in your scene.
  26290. * This impacts both the direct diffuse and specular highlights.
  26291. */
  26292. directIntensity: number;
  26293. /**
  26294. * Intensity of the emissive part of the material.
  26295. * This helps controlling the emissive effect without modifying the emissive color.
  26296. */
  26297. emissiveIntensity: number;
  26298. /**
  26299. * Intensity of the environment e.g. how much the environment will light the object
  26300. * either through harmonics for rough material or through the refelction for shiny ones.
  26301. */
  26302. environmentIntensity: number;
  26303. /**
  26304. * This is a special control allowing the reduction of the specular highlights coming from the
  26305. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26306. */
  26307. specularIntensity: number;
  26308. /**
  26309. * Debug Control allowing disabling the bump map on this material.
  26310. */
  26311. disableBumpMap: boolean;
  26312. /**
  26313. * AKA Diffuse Texture in standard nomenclature.
  26314. */
  26315. albedoTexture: BaseTexture;
  26316. /**
  26317. * AKA Occlusion Texture in other nomenclature.
  26318. */
  26319. ambientTexture: BaseTexture;
  26320. /**
  26321. * AKA Occlusion Texture Intensity in other nomenclature.
  26322. */
  26323. ambientTextureStrength: number;
  26324. /**
  26325. * Stores the alpha values in a texture.
  26326. */
  26327. opacityTexture: BaseTexture;
  26328. /**
  26329. * Stores the reflection values in a texture.
  26330. */
  26331. reflectionTexture: Nullable<BaseTexture>;
  26332. /**
  26333. * Stores the emissive values in a texture.
  26334. */
  26335. emissiveTexture: BaseTexture;
  26336. /**
  26337. * AKA Specular texture in other nomenclature.
  26338. */
  26339. reflectivityTexture: BaseTexture;
  26340. /**
  26341. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26342. */
  26343. metallicTexture: BaseTexture;
  26344. /**
  26345. * Specifies the metallic scalar of the metallic/roughness workflow.
  26346. * Can also be used to scale the metalness values of the metallic texture.
  26347. */
  26348. metallic: number;
  26349. /**
  26350. * Specifies the roughness scalar of the metallic/roughness workflow.
  26351. * Can also be used to scale the roughness values of the metallic texture.
  26352. */
  26353. roughness: number;
  26354. /**
  26355. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  26356. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26357. */
  26358. microSurfaceTexture: BaseTexture;
  26359. /**
  26360. * Stores surface normal data used to displace a mesh in a texture.
  26361. */
  26362. bumpTexture: BaseTexture;
  26363. /**
  26364. * Stores the pre-calculated light information of a mesh in a texture.
  26365. */
  26366. lightmapTexture: BaseTexture;
  26367. /**
  26368. * Stores the refracted light information in a texture.
  26369. */
  26370. refractionTexture: BaseTexture;
  26371. /**
  26372. * The color of a material in ambient lighting.
  26373. */
  26374. ambientColor: Color3;
  26375. /**
  26376. * AKA Diffuse Color in other nomenclature.
  26377. */
  26378. albedoColor: Color3;
  26379. /**
  26380. * AKA Specular Color in other nomenclature.
  26381. */
  26382. reflectivityColor: Color3;
  26383. /**
  26384. * The color reflected from the material.
  26385. */
  26386. reflectionColor: Color3;
  26387. /**
  26388. * The color emitted from the material.
  26389. */
  26390. emissiveColor: Color3;
  26391. /**
  26392. * AKA Glossiness in other nomenclature.
  26393. */
  26394. microSurface: number;
  26395. /**
  26396. * source material index of refraction (IOR)' / 'destination material IOR.
  26397. */
  26398. indexOfRefraction: number;
  26399. /**
  26400. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  26401. */
  26402. invertRefractionY: boolean;
  26403. /**
  26404. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26405. * Materials half opaque for instance using refraction could benefit from this control.
  26406. */
  26407. linkRefractionWithTransparency: boolean;
  26408. useLightmapAsShadowmap: boolean;
  26409. /**
  26410. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26411. */
  26412. useAlphaFromAlbedoTexture: boolean;
  26413. /**
  26414. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26415. */
  26416. forceAlphaTest: boolean;
  26417. /**
  26418. * Defines the alpha limits in alpha test mode.
  26419. */
  26420. alphaCutOff: number;
  26421. /**
  26422. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  26423. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26424. */
  26425. useSpecularOverAlpha: boolean;
  26426. /**
  26427. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26428. */
  26429. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26430. /**
  26431. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26432. */
  26433. useRoughnessFromMetallicTextureAlpha: boolean;
  26434. /**
  26435. * Specifies if the metallic texture contains the roughness information in its green channel.
  26436. */
  26437. useRoughnessFromMetallicTextureGreen: boolean;
  26438. /**
  26439. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26440. */
  26441. useMetallnessFromMetallicTextureBlue: boolean;
  26442. /**
  26443. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26444. */
  26445. useAmbientOcclusionFromMetallicTextureRed: boolean;
  26446. /**
  26447. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26448. */
  26449. useAmbientInGrayScale: boolean;
  26450. /**
  26451. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26452. * The material will try to infer what glossiness each pixel should be.
  26453. */
  26454. useAutoMicroSurfaceFromReflectivityMap: boolean;
  26455. /**
  26456. * BJS is using an harcoded light falloff based on a manually sets up range.
  26457. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  26458. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  26459. */
  26460. usePhysicalLightFalloff: boolean;
  26461. /**
  26462. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26463. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26464. */
  26465. useRadianceOverAlpha: boolean;
  26466. /**
  26467. * Allows using an object space normal map (instead of tangent space).
  26468. */
  26469. useObjectSpaceNormalMap: boolean;
  26470. /**
  26471. * Allows using the bump map in parallax mode.
  26472. */
  26473. useParallax: boolean;
  26474. /**
  26475. * Allows using the bump map in parallax occlusion mode.
  26476. */
  26477. useParallaxOcclusion: boolean;
  26478. /**
  26479. * Controls the scale bias of the parallax mode.
  26480. */
  26481. parallaxScaleBias: number;
  26482. /**
  26483. * If sets to true, disables all the lights affecting the material.
  26484. */
  26485. disableLighting: boolean;
  26486. /**
  26487. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26488. */
  26489. forceIrradianceInFragment: boolean;
  26490. /**
  26491. * Number of Simultaneous lights allowed on the material.
  26492. */
  26493. maxSimultaneousLights: number;
  26494. /**
  26495. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26496. */
  26497. invertNormalMapX: boolean;
  26498. /**
  26499. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26500. */
  26501. invertNormalMapY: boolean;
  26502. /**
  26503. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26504. */
  26505. twoSidedLighting: boolean;
  26506. /**
  26507. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26508. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26509. */
  26510. useAlphaFresnel: boolean;
  26511. /**
  26512. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26513. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26514. */
  26515. useLinearAlphaFresnel: boolean;
  26516. /**
  26517. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26518. * And/Or occlude the blended part.
  26519. */
  26520. environmentBRDFTexture: Nullable<BaseTexture>;
  26521. /**
  26522. * Force normal to face away from face.
  26523. */
  26524. forceNormalForward: boolean;
  26525. /**
  26526. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26527. * makes the reflect vector face the model (under horizon).
  26528. */
  26529. useHorizonOcclusion: boolean;
  26530. /**
  26531. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26532. * too much the area relying on ambient texture to define their ambient occlusion.
  26533. */
  26534. useRadianceOcclusion: boolean;
  26535. /**
  26536. * If set to true, no lighting calculations will be applied.
  26537. */
  26538. unlit: boolean;
  26539. /**
  26540. * Gets the image processing configuration used either in this material.
  26541. */
  26542. /**
  26543. * Sets the Default image processing configuration used either in the this material.
  26544. *
  26545. * If sets to null, the scene one is in use.
  26546. */
  26547. imageProcessingConfiguration: ImageProcessingConfiguration;
  26548. /**
  26549. * Gets wether the color curves effect is enabled.
  26550. */
  26551. /**
  26552. * Sets wether the color curves effect is enabled.
  26553. */
  26554. cameraColorCurvesEnabled: boolean;
  26555. /**
  26556. * Gets wether the color grading effect is enabled.
  26557. */
  26558. /**
  26559. * Gets wether the color grading effect is enabled.
  26560. */
  26561. cameraColorGradingEnabled: boolean;
  26562. /**
  26563. * Gets wether tonemapping is enabled or not.
  26564. */
  26565. /**
  26566. * Sets wether tonemapping is enabled or not
  26567. */
  26568. cameraToneMappingEnabled: boolean;
  26569. /**
  26570. * The camera exposure used on this material.
  26571. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26572. * This corresponds to a photographic exposure.
  26573. */
  26574. /**
  26575. * The camera exposure used on this material.
  26576. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26577. * This corresponds to a photographic exposure.
  26578. */
  26579. cameraExposure: number;
  26580. /**
  26581. * Gets The camera contrast used on this material.
  26582. */
  26583. /**
  26584. * Sets The camera contrast used on this material.
  26585. */
  26586. cameraContrast: number;
  26587. /**
  26588. * Gets the Color Grading 2D Lookup Texture.
  26589. */
  26590. /**
  26591. * Sets the Color Grading 2D Lookup Texture.
  26592. */
  26593. cameraColorGradingTexture: Nullable<BaseTexture>;
  26594. /**
  26595. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26596. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26597. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  26598. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26599. */
  26600. /**
  26601. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26602. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26603. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  26604. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26605. */
  26606. cameraColorCurves: Nullable<ColorCurves>;
  26607. /**
  26608. * Instantiates a new PBRMaterial instance.
  26609. *
  26610. * @param name The material name
  26611. * @param scene The scene the material will be use in.
  26612. */
  26613. constructor(name: string, scene: Scene);
  26614. /**
  26615. * Returns the name of this material class.
  26616. */
  26617. getClassName(): string;
  26618. /**
  26619. * Returns an array of the actively used textures.
  26620. * @returns - Array of BaseTextures
  26621. */
  26622. getActiveTextures(): BaseTexture[];
  26623. /**
  26624. * Checks to see if a texture is used in the material.
  26625. * @param texture - Base texture to use.
  26626. * @returns - Boolean specifying if a texture is used in the material.
  26627. */
  26628. hasTexture(texture: BaseTexture): boolean;
  26629. /**
  26630. * Makes a duplicate of the current material.
  26631. * @param name - name to use for the new material.
  26632. */
  26633. clone(name: string): PBRMaterial;
  26634. /**
  26635. * Serializes this PBR Material.
  26636. * @returns - An object with the serialized material.
  26637. */
  26638. serialize(): any;
  26639. /**
  26640. * Parses a PBR Material from a serialized object.
  26641. * @param source - Serialized object.
  26642. * @param scene - BJS scene instance.
  26643. * @param rootUrl - url for the scene object
  26644. * @returns - PBRMaterial
  26645. */
  26646. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  26647. }
  26648. }
  26649. declare module BABYLON {
  26650. /**
  26651. * The PBR material of BJS following the metal roughness convention.
  26652. *
  26653. * This fits to the PBR convention in the GLTF definition:
  26654. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  26655. */
  26656. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  26657. /**
  26658. * The base color has two different interpretations depending on the value of metalness.
  26659. * When the material is a metal, the base color is the specific measured reflectance value
  26660. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  26661. * of the material.
  26662. */
  26663. baseColor: Color3;
  26664. /**
  26665. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  26666. * well as opacity information in the alpha channel.
  26667. */
  26668. baseTexture: BaseTexture;
  26669. /**
  26670. * Specifies the metallic scalar value of the material.
  26671. * Can also be used to scale the metalness values of the metallic texture.
  26672. */
  26673. metallic: number;
  26674. /**
  26675. * Specifies the roughness scalar value of the material.
  26676. * Can also be used to scale the roughness values of the metallic texture.
  26677. */
  26678. roughness: number;
  26679. /**
  26680. * Texture containing both the metallic value in the B channel and the
  26681. * roughness value in the G channel to keep better precision.
  26682. */
  26683. metallicRoughnessTexture: BaseTexture;
  26684. /**
  26685. * Instantiates a new PBRMetalRoughnessMaterial instance.
  26686. *
  26687. * @param name The material name
  26688. * @param scene The scene the material will be use in.
  26689. */
  26690. constructor(name: string, scene: Scene);
  26691. /**
  26692. * Return the currrent class name of the material.
  26693. */
  26694. getClassName(): string;
  26695. /**
  26696. * Return the active textures of the material.
  26697. */
  26698. getActiveTextures(): BaseTexture[];
  26699. /**
  26700. * Checks to see if a texture is used in the material.
  26701. * @param texture - Base texture to use.
  26702. * @returns - Boolean specifying if a texture is used in the material.
  26703. */
  26704. hasTexture(texture: BaseTexture): boolean;
  26705. /**
  26706. * Makes a duplicate of the current material.
  26707. * @param name - name to use for the new material.
  26708. */
  26709. clone(name: string): PBRMetallicRoughnessMaterial;
  26710. /**
  26711. * Serialize the material to a parsable JSON object.
  26712. */
  26713. serialize(): any;
  26714. /**
  26715. * Parses a JSON object correponding to the serialize function.
  26716. */
  26717. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  26718. }
  26719. }
  26720. declare module BABYLON {
  26721. /**
  26722. * The PBR material of BJS following the specular glossiness convention.
  26723. *
  26724. * This fits to the PBR convention in the GLTF definition:
  26725. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  26726. */
  26727. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  26728. /**
  26729. * Specifies the diffuse color of the material.
  26730. */
  26731. diffuseColor: Color3;
  26732. /**
  26733. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  26734. * channel.
  26735. */
  26736. diffuseTexture: BaseTexture;
  26737. /**
  26738. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  26739. */
  26740. specularColor: Color3;
  26741. /**
  26742. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  26743. */
  26744. glossiness: number;
  26745. /**
  26746. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  26747. */
  26748. specularGlossinessTexture: BaseTexture;
  26749. /**
  26750. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  26751. *
  26752. * @param name The material name
  26753. * @param scene The scene the material will be use in.
  26754. */
  26755. constructor(name: string, scene: Scene);
  26756. /**
  26757. * Return the currrent class name of the material.
  26758. */
  26759. getClassName(): string;
  26760. /**
  26761. * Return the active textures of the material.
  26762. */
  26763. getActiveTextures(): BaseTexture[];
  26764. /**
  26765. * Checks to see if a texture is used in the material.
  26766. * @param texture - Base texture to use.
  26767. * @returns - Boolean specifying if a texture is used in the material.
  26768. */
  26769. hasTexture(texture: BaseTexture): boolean;
  26770. /**
  26771. * Makes a duplicate of the current material.
  26772. * @param name - name to use for the new material.
  26773. */
  26774. clone(name: string): PBRSpecularGlossinessMaterial;
  26775. /**
  26776. * Serialize the material to a parsable JSON object.
  26777. */
  26778. serialize(): any;
  26779. /**
  26780. * Parses a JSON object correponding to the serialize function.
  26781. */
  26782. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  26783. }
  26784. }
  26785. declare module BABYLON {
  26786. class BaseTexture {
  26787. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26788. name: string;
  26789. private _hasAlpha;
  26790. hasAlpha: boolean;
  26791. getAlphaFromRGB: boolean;
  26792. level: number;
  26793. coordinatesIndex: number;
  26794. private _coordinatesMode;
  26795. /**
  26796. * How a texture is mapped.
  26797. *
  26798. * | Value | Type | Description |
  26799. * | ----- | ----------------------------------- | ----------- |
  26800. * | 0 | EXPLICIT_MODE | |
  26801. * | 1 | SPHERICAL_MODE | |
  26802. * | 2 | PLANAR_MODE | |
  26803. * | 3 | CUBIC_MODE | |
  26804. * | 4 | PROJECTION_MODE | |
  26805. * | 5 | SKYBOX_MODE | |
  26806. * | 6 | INVCUBIC_MODE | |
  26807. * | 7 | EQUIRECTANGULAR_MODE | |
  26808. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26809. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26810. */
  26811. coordinatesMode: number;
  26812. /**
  26813. * | Value | Type | Description |
  26814. * | ----- | ------------------ | ----------- |
  26815. * | 0 | CLAMP_ADDRESSMODE | |
  26816. * | 1 | WRAP_ADDRESSMODE | |
  26817. * | 2 | MIRROR_ADDRESSMODE | |
  26818. */
  26819. wrapU: number;
  26820. /**
  26821. * | Value | Type | Description |
  26822. * | ----- | ------------------ | ----------- |
  26823. * | 0 | CLAMP_ADDRESSMODE | |
  26824. * | 1 | WRAP_ADDRESSMODE | |
  26825. * | 2 | MIRROR_ADDRESSMODE | |
  26826. */
  26827. wrapV: number;
  26828. /**
  26829. * | Value | Type | Description |
  26830. * | ----- | ------------------ | ----------- |
  26831. * | 0 | CLAMP_ADDRESSMODE | |
  26832. * | 1 | WRAP_ADDRESSMODE | |
  26833. * | 2 | MIRROR_ADDRESSMODE | |
  26834. */
  26835. wrapR: number;
  26836. anisotropicFilteringLevel: number;
  26837. isCube: boolean;
  26838. is3D: boolean;
  26839. gammaSpace: boolean;
  26840. invertZ: boolean;
  26841. lodLevelInAlpha: boolean;
  26842. lodGenerationOffset: number;
  26843. lodGenerationScale: number;
  26844. isRenderTarget: boolean;
  26845. readonly uid: string;
  26846. toString(): string;
  26847. getClassName(): string;
  26848. animations: Animation[];
  26849. /**
  26850. * An event triggered when the texture is disposed.
  26851. * @type {BABYLON.Observable}
  26852. */
  26853. onDisposeObservable: Observable<BaseTexture>;
  26854. private _onDisposeObserver;
  26855. onDispose: () => void;
  26856. delayLoadState: number;
  26857. private _scene;
  26858. _texture: Nullable<InternalTexture>;
  26859. private _uid;
  26860. readonly isBlocking: boolean;
  26861. constructor(scene: Nullable<Scene>);
  26862. getScene(): Nullable<Scene>;
  26863. getTextureMatrix(): Matrix;
  26864. getReflectionTextureMatrix(): Matrix;
  26865. getInternalTexture(): Nullable<InternalTexture>;
  26866. isReadyOrNotBlocking(): boolean;
  26867. isReady(): boolean;
  26868. getSize(): ISize;
  26869. getBaseSize(): ISize;
  26870. scale(ratio: number): void;
  26871. readonly canRescale: boolean;
  26872. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  26873. _rebuild(): void;
  26874. delayLoad(): void;
  26875. clone(): Nullable<BaseTexture>;
  26876. readonly textureType: number;
  26877. readonly textureFormat: number;
  26878. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  26879. releaseInternalTexture(): void;
  26880. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26881. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26882. readonly _lodTextureMid: Nullable<BaseTexture>;
  26883. readonly _lodTextureLow: Nullable<BaseTexture>;
  26884. dispose(): void;
  26885. serialize(): any;
  26886. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26887. }
  26888. }
  26889. declare module BABYLON {
  26890. /**
  26891. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  26892. * It can help converting any input color in a desired output one. This can then be used to create effects
  26893. * from sepia, black and white to sixties or futuristic rendering...
  26894. *
  26895. * The only supported format is currently 3dl.
  26896. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  26897. */
  26898. class ColorGradingTexture extends BaseTexture {
  26899. /**
  26900. * The current texture matrix. (will always be identity in color grading texture)
  26901. */
  26902. private _textureMatrix;
  26903. /**
  26904. * The texture URL.
  26905. */
  26906. url: string;
  26907. /**
  26908. * Empty line regex stored for GC.
  26909. */
  26910. private static _noneEmptyLineRegex;
  26911. private _engine;
  26912. /**
  26913. * Instantiates a ColorGradingTexture from the following parameters.
  26914. *
  26915. * @param url The location of the color gradind data (currently only supporting 3dl)
  26916. * @param scene The scene the texture will be used in
  26917. */
  26918. constructor(url: string, scene: Scene);
  26919. /**
  26920. * Returns the texture matrix used in most of the material.
  26921. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  26922. */
  26923. getTextureMatrix(): Matrix;
  26924. /**
  26925. * Occurs when the file being loaded is a .3dl LUT file.
  26926. */
  26927. private load3dlTexture();
  26928. /**
  26929. * Starts the loading process of the texture.
  26930. */
  26931. private loadTexture();
  26932. /**
  26933. * Clones the color gradind texture.
  26934. */
  26935. clone(): ColorGradingTexture;
  26936. /**
  26937. * Called during delayed load for textures.
  26938. */
  26939. delayLoad(): void;
  26940. /**
  26941. * Parses a color grading texture serialized by Babylon.
  26942. * @param parsedTexture The texture information being parsedTexture
  26943. * @param scene The scene to load the texture in
  26944. * @param rootUrl The root url of the data assets to load
  26945. * @return A color gradind texture
  26946. */
  26947. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  26948. /**
  26949. * Serializes the LUT texture to json format.
  26950. */
  26951. serialize(): any;
  26952. }
  26953. }
  26954. declare module BABYLON {
  26955. class CubeTexture extends BaseTexture {
  26956. url: string;
  26957. coordinatesMode: number;
  26958. /**
  26959. * Gets or sets the center of the bounding box associated with the cube texture
  26960. * It must define where the camera used to render the texture was set
  26961. */
  26962. boundingBoxPosition: Vector3;
  26963. private _boundingBoxSize;
  26964. /**
  26965. * Gets or sets the size of the bounding box associated with the cube texture
  26966. * When defined, the cubemap will switch to local mode
  26967. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  26968. * @example https://www.babylonjs-playground.com/#RNASML
  26969. */
  26970. boundingBoxSize: Vector3;
  26971. private _noMipmap;
  26972. private _files;
  26973. private _extensions;
  26974. private _textureMatrix;
  26975. private _format;
  26976. private _prefiltered;
  26977. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  26978. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  26979. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any);
  26980. delayLoad(): void;
  26981. getReflectionTextureMatrix(): Matrix;
  26982. setReflectionTextureMatrix(value: Matrix): void;
  26983. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  26984. clone(): CubeTexture;
  26985. }
  26986. }
  26987. declare module BABYLON {
  26988. class DynamicTexture extends Texture {
  26989. private _generateMipMaps;
  26990. private _canvas;
  26991. private _context;
  26992. private _engine;
  26993. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  26994. readonly canRescale: boolean;
  26995. private _recreate(textureSize);
  26996. scale(ratio: number): void;
  26997. scaleTo(width: number, height: number): void;
  26998. getContext(): CanvasRenderingContext2D;
  26999. clear(): void;
  27000. update(invertY?: boolean): void;
  27001. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  27002. clone(): DynamicTexture;
  27003. _rebuild(): void;
  27004. }
  27005. }
  27006. declare module BABYLON {
  27007. /**
  27008. * This represents a texture coming from an HDR input.
  27009. *
  27010. * The only supported format is currently panorama picture stored in RGBE format.
  27011. * Example of such files can be found on HDRLib: http://hdrlib.com/
  27012. */
  27013. class HDRCubeTexture extends BaseTexture {
  27014. private static _facesMapping;
  27015. private _useInGammaSpace;
  27016. private _generateHarmonics;
  27017. private _noMipmap;
  27018. private _textureMatrix;
  27019. private _size;
  27020. private _usePMREMGenerator;
  27021. private _isBABYLONPreprocessed;
  27022. private _onLoad;
  27023. private _onError;
  27024. /**
  27025. * The texture URL.
  27026. */
  27027. url: string;
  27028. /**
  27029. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  27030. */
  27031. coordinatesMode: number;
  27032. /**
  27033. * Specifies wether the texture has been generated through the PMREMGenerator tool.
  27034. * This is usefull at run time to apply the good shader.
  27035. */
  27036. isPMREM: boolean;
  27037. protected _isBlocking: boolean;
  27038. /**
  27039. * Gets wether or not the texture is blocking during loading.
  27040. */
  27041. /**
  27042. * Sets wether or not the texture is blocking during loading.
  27043. */
  27044. isBlocking: boolean;
  27045. /**
  27046. * Gets or sets the center of the bounding box associated with the cube texture
  27047. * It must define where the camera used to render the texture was set
  27048. */
  27049. boundingBoxPosition: Vector3;
  27050. private _boundingBoxSize;
  27051. /**
  27052. * Gets or sets the size of the bounding box associated with the cube texture
  27053. * When defined, the cubemap will switch to local mode
  27054. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  27055. * @example https://www.babylonjs-playground.com/#RNASML
  27056. */
  27057. boundingBoxSize: Vector3;
  27058. /**
  27059. * Instantiates an HDRTexture from the following parameters.
  27060. *
  27061. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  27062. * @param scene The scene the texture will be used in
  27063. * @param size The cubemap desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
  27064. * @param noMipmap Forces to not generate the mipmap if true
  27065. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  27066. * @param useInGammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  27067. * @param usePMREMGenerator Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
  27068. */
  27069. constructor(url: string, scene: Scene, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  27070. /**
  27071. * Occurs when the file is a preprocessed .babylon.hdr file.
  27072. */
  27073. private loadBabylonTexture();
  27074. /**
  27075. * Occurs when the file is raw .hdr file.
  27076. */
  27077. private loadHDRTexture();
  27078. /**
  27079. * Starts the loading process of the texture.
  27080. */
  27081. private loadTexture();
  27082. clone(): HDRCubeTexture;
  27083. delayLoad(): void;
  27084. getReflectionTextureMatrix(): Matrix;
  27085. setReflectionTextureMatrix(value: Matrix): void;
  27086. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  27087. serialize(): any;
  27088. /**
  27089. * Saves as a file the data contained in the texture in a binary format.
  27090. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  27091. * as the spherical used in the lighting.
  27092. * @param url The HDR file url.
  27093. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  27094. * @param onError Method called if any error happens during download.
  27095. * @return The packed binary data.
  27096. */
  27097. static generateBabylonHDROnDisk(url: string, size: number, onError?: Nullable<(() => void)>): void;
  27098. /**
  27099. * Serializes the data contained in the texture in a binary format.
  27100. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  27101. * as the spherical used in the lighting.
  27102. * @param url The HDR file url.
  27103. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  27104. * @param onError Method called if any error happens during download.
  27105. * @return The packed binary data.
  27106. */
  27107. static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer: ArrayBuffer) => void), onError?: Nullable<(() => void)>): void;
  27108. }
  27109. }
  27110. declare module BABYLON {
  27111. /**
  27112. * Class used to store data associated with WebGL texture data for the engine
  27113. * This class should not be used directly
  27114. */
  27115. class InternalTexture implements IInternalTextureTracker {
  27116. /**
  27117. * The source of the texture data is unknown
  27118. */
  27119. static DATASOURCE_UNKNOWN: number;
  27120. /**
  27121. * Texture data comes from an URL
  27122. */
  27123. static DATASOURCE_URL: number;
  27124. /**
  27125. * Texture data is only used for temporary storage
  27126. */
  27127. static DATASOURCE_TEMP: number;
  27128. /**
  27129. * Texture data comes from raw data (ArrayBuffer)
  27130. */
  27131. static DATASOURCE_RAW: number;
  27132. /**
  27133. * Texture content is dynamic (video or dynamic texture)
  27134. */
  27135. static DATASOURCE_DYNAMIC: number;
  27136. /**
  27137. * Texture content is generated by rendering to it
  27138. */
  27139. static DATASOURCE_RENDERTARGET: number;
  27140. /**
  27141. * Texture content is part of a multi render target process
  27142. */
  27143. static DATASOURCE_MULTIRENDERTARGET: number;
  27144. /**
  27145. * Texture data comes from a cube data file
  27146. */
  27147. static DATASOURCE_CUBE: number;
  27148. /**
  27149. * Texture data comes from a raw cube data
  27150. */
  27151. static DATASOURCE_CUBERAW: number;
  27152. /**
  27153. * Texture data come from a prefiltered cube data file
  27154. */
  27155. static DATASOURCE_CUBEPREFILTERED: number;
  27156. /**
  27157. * Texture content is raw 3D data
  27158. */
  27159. static DATASOURCE_RAW3D: number;
  27160. /**
  27161. * Texture content is a depth texture
  27162. */
  27163. static DATASOURCE_DEPTHTEXTURE: number;
  27164. /**
  27165. * Defines if the texture is ready
  27166. */
  27167. isReady: boolean;
  27168. /**
  27169. * Defines if the texture is a cube texture
  27170. */
  27171. isCube: boolean;
  27172. /**
  27173. * Defines if the texture contains 3D data
  27174. */
  27175. is3D: boolean;
  27176. /**
  27177. * Gets the URL used to load this texture
  27178. */
  27179. url: string;
  27180. /**
  27181. * Gets the sampling mode of the texture
  27182. */
  27183. samplingMode: number;
  27184. /**
  27185. * Gets a boolean indicating if the texture needs mipmaps generation
  27186. */
  27187. generateMipMaps: boolean;
  27188. /**
  27189. * Gets the number of samples used by the texture (WebGL2+ only)
  27190. */
  27191. samples: number;
  27192. /**
  27193. * Gets the type of the texture
  27194. */
  27195. type: number;
  27196. /**
  27197. * Gets the format of the texture
  27198. */
  27199. format: number;
  27200. /**
  27201. * Observable called when the texture is loaded
  27202. */
  27203. onLoadedObservable: Observable<InternalTexture>;
  27204. /**
  27205. * Gets the width of the texture
  27206. */
  27207. width: number;
  27208. /**
  27209. * Gets the height of the texture
  27210. */
  27211. height: number;
  27212. /**
  27213. * Gets the depth of the texture
  27214. */
  27215. depth: number;
  27216. /**
  27217. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27218. */
  27219. baseWidth: number;
  27220. /**
  27221. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27222. */
  27223. baseHeight: number;
  27224. /**
  27225. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27226. */
  27227. baseDepth: number;
  27228. /**
  27229. * Gets a boolean indicating if the texture is inverted on Y axis
  27230. */
  27231. invertY: boolean;
  27232. /**
  27233. * Gets or set the previous tracker in the list
  27234. */
  27235. previous: Nullable<IInternalTextureTracker>;
  27236. /**
  27237. * Gets or set the next tracker in the list
  27238. */
  27239. next: Nullable<IInternalTextureTracker>;
  27240. /** @ignore */
  27241. _initialSlot: number;
  27242. /** @ignore */
  27243. _designatedSlot: number;
  27244. /** @ignore */
  27245. _dataSource: number;
  27246. /** @ignore */
  27247. _buffer: Nullable<ArrayBuffer | HTMLImageElement>;
  27248. /** @ignore */
  27249. _bufferView: Nullable<ArrayBufferView>;
  27250. /** @ignore */
  27251. _bufferViewArray: Nullable<ArrayBufferView[]>;
  27252. /** @ignore */
  27253. _size: number;
  27254. /** @ignore */
  27255. _extension: string;
  27256. /** @ignore */
  27257. _files: Nullable<string[]>;
  27258. /** @ignore */
  27259. _workingCanvas: HTMLCanvasElement;
  27260. /** @ignore */
  27261. _workingContext: CanvasRenderingContext2D;
  27262. /** @ignore */
  27263. _framebuffer: Nullable<WebGLFramebuffer>;
  27264. /** @ignore */
  27265. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  27266. /** @ignore */
  27267. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  27268. /** @ignore */
  27269. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  27270. /** @ignore */
  27271. _attachments: Nullable<number[]>;
  27272. /** @ignore */
  27273. _cachedCoordinatesMode: Nullable<number>;
  27274. /** @ignore */
  27275. _cachedWrapU: Nullable<number>;
  27276. /** @ignore */
  27277. _cachedWrapV: Nullable<number>;
  27278. /** @ignore */
  27279. _cachedWrapR: Nullable<number>;
  27280. /** @ignore */
  27281. _cachedAnisotropicFilteringLevel: Nullable<number>;
  27282. /** @ignore */
  27283. _isDisabled: boolean;
  27284. /** @ignore */
  27285. _compression: Nullable<string>;
  27286. /** @ignore */
  27287. _generateStencilBuffer: boolean;
  27288. /** @ignore */
  27289. _generateDepthBuffer: boolean;
  27290. /** @ignore */
  27291. _comparisonFunction: number;
  27292. /** @ignore */
  27293. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  27294. /** @ignore */
  27295. _lodGenerationScale: number;
  27296. /** @ignore */
  27297. _lodGenerationOffset: number;
  27298. /** @ignore */
  27299. _lodTextureHigh: BaseTexture;
  27300. /** @ignore */
  27301. _lodTextureMid: BaseTexture;
  27302. /** @ignore */
  27303. _lodTextureLow: BaseTexture;
  27304. /** @ignore */
  27305. _webGLTexture: Nullable<WebGLTexture>;
  27306. /** @ignore */
  27307. _references: number;
  27308. private _engine;
  27309. /**
  27310. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  27311. */
  27312. readonly dataSource: number;
  27313. /**
  27314. * Creates a new InternalTexture
  27315. * @param engine defines the engine to use
  27316. * @param dataSource defines the type of data that will be used
  27317. */
  27318. constructor(engine: Engine, dataSource: number);
  27319. /**
  27320. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  27321. */
  27322. incrementReferences(): void;
  27323. /**
  27324. * Change the size of the texture (not the size of the content)
  27325. * @param width defines the new width
  27326. * @param height defines the new height
  27327. * @param depth defines the new depth (1 by default)
  27328. */
  27329. updateSize(width: int, height: int, depth?: int): void;
  27330. /** @ignore */
  27331. _rebuild(): void;
  27332. private _swapAndDie(target);
  27333. /**
  27334. * Dispose the current allocated resources
  27335. */
  27336. dispose(): void;
  27337. }
  27338. }
  27339. declare module BABYLON {
  27340. /**
  27341. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  27342. */
  27343. interface IInternalTextureTracker {
  27344. /**
  27345. * Gets or set the previous tracker in the list
  27346. */
  27347. previous: Nullable<IInternalTextureTracker>;
  27348. /**
  27349. * Gets or set the next tracker in the list
  27350. */
  27351. next: Nullable<IInternalTextureTracker>;
  27352. }
  27353. /**
  27354. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  27355. */
  27356. class DummyInternalTextureTracker {
  27357. /**
  27358. * Gets or set the previous tracker in the list
  27359. */
  27360. previous: Nullable<IInternalTextureTracker>;
  27361. /**
  27362. * Gets or set the next tracker in the list
  27363. */
  27364. next: Nullable<IInternalTextureTracker>;
  27365. }
  27366. }
  27367. declare module BABYLON {
  27368. class MirrorTexture extends RenderTargetTexture {
  27369. mirrorPlane: Plane;
  27370. private _transformMatrix;
  27371. private _mirrorMatrix;
  27372. private _savedViewMatrix;
  27373. private _blurX;
  27374. private _blurY;
  27375. private _adaptiveBlurKernel;
  27376. private _blurKernelX;
  27377. private _blurKernelY;
  27378. private _blurRatio;
  27379. blurRatio: number;
  27380. adaptiveBlurKernel: number;
  27381. blurKernel: number;
  27382. blurKernelX: number;
  27383. blurKernelY: number;
  27384. private _autoComputeBlurKernel();
  27385. protected _onRatioRescale(): void;
  27386. constructor(name: string, size: number | {
  27387. width: number;
  27388. height: number;
  27389. } | {
  27390. ratio: number;
  27391. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  27392. private _preparePostProcesses();
  27393. clone(): MirrorTexture;
  27394. serialize(): any;
  27395. }
  27396. }
  27397. declare module BABYLON {
  27398. interface IMultiRenderTargetOptions {
  27399. generateMipMaps?: boolean;
  27400. types?: number[];
  27401. samplingModes?: number[];
  27402. generateDepthBuffer?: boolean;
  27403. generateStencilBuffer?: boolean;
  27404. generateDepthTexture?: boolean;
  27405. textureCount?: number;
  27406. doNotChangeAspectRatio?: boolean;
  27407. defaultType?: number;
  27408. }
  27409. class MultiRenderTarget extends RenderTargetTexture {
  27410. private _internalTextures;
  27411. private _textures;
  27412. readonly isSupported: boolean;
  27413. private _multiRenderTargetOptions;
  27414. readonly textures: Texture[];
  27415. readonly depthTexture: Texture;
  27416. wrapU: number;
  27417. wrapV: number;
  27418. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  27419. _rebuild(): void;
  27420. private _createInternalTextures();
  27421. private _createTextures();
  27422. samples: number;
  27423. resize(size: any): void;
  27424. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  27425. dispose(): void;
  27426. releaseInternalTextures(): void;
  27427. }
  27428. }
  27429. declare module BABYLON {
  27430. class RawTexture extends Texture {
  27431. format: number;
  27432. private _engine;
  27433. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  27434. update(data: ArrayBufferView): void;
  27435. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  27436. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  27437. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  27438. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  27439. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  27440. }
  27441. }
  27442. declare module BABYLON {
  27443. /**
  27444. * Creates a refraction texture used by refraction channel of the standard material.
  27445. * @param name the texture name
  27446. * @param size size of the underlying texture
  27447. * @param scene root scene
  27448. */
  27449. class RefractionTexture extends RenderTargetTexture {
  27450. refractionPlane: Plane;
  27451. depth: number;
  27452. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  27453. clone(): RefractionTexture;
  27454. serialize(): any;
  27455. }
  27456. }
  27457. declare module BABYLON {
  27458. class RenderTargetTexture extends Texture {
  27459. isCube: boolean;
  27460. static _REFRESHRATE_RENDER_ONCE: number;
  27461. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  27462. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  27463. static readonly REFRESHRATE_RENDER_ONCE: number;
  27464. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  27465. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  27466. /**
  27467. * Use this predicate to dynamically define the list of mesh you want to render.
  27468. * If set, the renderList property will be overwritten.
  27469. */
  27470. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  27471. /**
  27472. * Use this list to define the list of mesh you want to render.
  27473. */
  27474. renderList: Nullable<Array<AbstractMesh>>;
  27475. renderParticles: boolean;
  27476. renderSprites: boolean;
  27477. coordinatesMode: number;
  27478. activeCamera: Nullable<Camera>;
  27479. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  27480. useCameraPostProcesses: boolean;
  27481. ignoreCameraViewport: boolean;
  27482. private _postProcessManager;
  27483. private _postProcesses;
  27484. private _resizeObserver;
  27485. /**
  27486. * An event triggered when the texture is unbind.
  27487. * @type {BABYLON.Observable}
  27488. */
  27489. onBeforeBindObservable: Observable<RenderTargetTexture>;
  27490. /**
  27491. * An event triggered when the texture is unbind.
  27492. * @type {BABYLON.Observable}
  27493. */
  27494. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  27495. private _onAfterUnbindObserver;
  27496. onAfterUnbind: () => void;
  27497. /**
  27498. * An event triggered before rendering the texture
  27499. * @type {BABYLON.Observable}
  27500. */
  27501. onBeforeRenderObservable: Observable<number>;
  27502. private _onBeforeRenderObserver;
  27503. onBeforeRender: (faceIndex: number) => void;
  27504. /**
  27505. * An event triggered after rendering the texture
  27506. * @type {BABYLON.Observable}
  27507. */
  27508. onAfterRenderObservable: Observable<number>;
  27509. private _onAfterRenderObserver;
  27510. onAfterRender: (faceIndex: number) => void;
  27511. /**
  27512. * An event triggered after the texture clear
  27513. * @type {BABYLON.Observable}
  27514. */
  27515. onClearObservable: Observable<Engine>;
  27516. private _onClearObserver;
  27517. onClear: (Engine: Engine) => void;
  27518. clearColor: Color4;
  27519. protected _size: number | {
  27520. width: number;
  27521. height: number;
  27522. };
  27523. protected _initialSizeParameter: number | {
  27524. width: number;
  27525. height: number;
  27526. } | {
  27527. ratio: number;
  27528. };
  27529. protected _sizeRatio: Nullable<number>;
  27530. _generateMipMaps: boolean;
  27531. protected _renderingManager: RenderingManager;
  27532. _waitingRenderList: string[];
  27533. protected _doNotChangeAspectRatio: boolean;
  27534. protected _currentRefreshId: number;
  27535. protected _refreshRate: number;
  27536. protected _textureMatrix: Matrix;
  27537. protected _samples: number;
  27538. protected _renderTargetOptions: RenderTargetCreationOptions;
  27539. readonly renderTargetOptions: RenderTargetCreationOptions;
  27540. protected _engine: Engine;
  27541. protected _onRatioRescale(): void;
  27542. /**
  27543. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  27544. * It must define where the camera used to render the texture is set
  27545. */
  27546. boundingBoxPosition: Vector3;
  27547. private _boundingBoxSize;
  27548. /**
  27549. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  27550. * When defined, the cubemap will switch to local mode
  27551. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  27552. * @example https://www.babylonjs-playground.com/#RNASML
  27553. */
  27554. boundingBoxSize: Vector3;
  27555. /**
  27556. * In case the RTT has been created with a depth texture, get the associated
  27557. * depth texture.
  27558. * Otherwise, return null.
  27559. */
  27560. depthStencilTexture: Nullable<InternalTexture>;
  27561. /**
  27562. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  27563. * or used a shadow, depth texture...
  27564. * @param name The friendly name of the texture
  27565. * @param size The size of the RTT (number if square, or {with: number, height:number} or {ratio:} to define a ratio from the main scene)
  27566. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  27567. * @param generateMipMaps True if mip maps need to be generated after render.
  27568. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  27569. * @param type The type of the buffer in the RTT (int, half float, float...)
  27570. * @param isCube True if a cube texture needs to be created
  27571. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  27572. * @param generateDepthBuffer True to generate a depth buffer
  27573. * @param generateStencilBuffer True to generate a stencil buffer
  27574. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  27575. */
  27576. constructor(name: string, size: number | {
  27577. width: number;
  27578. height: number;
  27579. } | {
  27580. ratio: number;
  27581. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  27582. /**
  27583. * Creates a depth stencil texture.
  27584. * This is only available in WebGL 2 or with the depth texture extension available.
  27585. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  27586. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  27587. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  27588. */
  27589. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  27590. private _processSizeParameter(size);
  27591. samples: number;
  27592. resetRefreshCounter(): void;
  27593. refreshRate: number;
  27594. addPostProcess(postProcess: PostProcess): void;
  27595. clearPostProcesses(dispose?: boolean): void;
  27596. removePostProcess(postProcess: PostProcess): void;
  27597. _shouldRender(): boolean;
  27598. getRenderSize(): number;
  27599. getRenderWidth(): number;
  27600. getRenderHeight(): number;
  27601. readonly canRescale: boolean;
  27602. scale(ratio: number): void;
  27603. getReflectionTextureMatrix(): Matrix;
  27604. resize(size: number | {
  27605. width: number;
  27606. height: number;
  27607. } | {
  27608. ratio: number;
  27609. }): void;
  27610. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  27611. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  27612. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  27613. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  27614. /**
  27615. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  27616. * This allowed control for front to back rendering or reversly depending of the special needs.
  27617. *
  27618. * @param renderingGroupId The rendering group id corresponding to its index
  27619. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  27620. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  27621. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  27622. */
  27623. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  27624. /**
  27625. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  27626. *
  27627. * @param renderingGroupId The rendering group id corresponding to its index
  27628. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  27629. */
  27630. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  27631. clone(): RenderTargetTexture;
  27632. serialize(): any;
  27633. disposeFramebufferObjects(): void;
  27634. dispose(): void;
  27635. _rebuild(): void;
  27636. /**
  27637. * Clear the info related to rendering groups preventing retention point in material dispose.
  27638. */
  27639. freeRenderingGroups(): void;
  27640. }
  27641. }
  27642. declare module BABYLON {
  27643. class Texture extends BaseTexture {
  27644. static NEAREST_SAMPLINGMODE: number;
  27645. static NEAREST_NEAREST_MIPLINEAR: number;
  27646. static BILINEAR_SAMPLINGMODE: number;
  27647. static LINEAR_LINEAR_MIPNEAREST: number;
  27648. static TRILINEAR_SAMPLINGMODE: number;
  27649. static LINEAR_LINEAR_MIPLINEAR: number;
  27650. static NEAREST_NEAREST_MIPNEAREST: number;
  27651. static NEAREST_LINEAR_MIPNEAREST: number;
  27652. static NEAREST_LINEAR_MIPLINEAR: number;
  27653. static NEAREST_LINEAR: number;
  27654. static NEAREST_NEAREST: number;
  27655. static LINEAR_NEAREST_MIPNEAREST: number;
  27656. static LINEAR_NEAREST_MIPLINEAR: number;
  27657. static LINEAR_LINEAR: number;
  27658. static LINEAR_NEAREST: number;
  27659. static EXPLICIT_MODE: number;
  27660. static SPHERICAL_MODE: number;
  27661. static PLANAR_MODE: number;
  27662. static CUBIC_MODE: number;
  27663. static PROJECTION_MODE: number;
  27664. static SKYBOX_MODE: number;
  27665. static INVCUBIC_MODE: number;
  27666. static EQUIRECTANGULAR_MODE: number;
  27667. static FIXED_EQUIRECTANGULAR_MODE: number;
  27668. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27669. static CLAMP_ADDRESSMODE: number;
  27670. static WRAP_ADDRESSMODE: number;
  27671. static MIRROR_ADDRESSMODE: number;
  27672. /**
  27673. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  27674. */
  27675. static UseSerializedUrlIfAny: boolean;
  27676. url: Nullable<string>;
  27677. uOffset: number;
  27678. vOffset: number;
  27679. uScale: number;
  27680. vScale: number;
  27681. uAng: number;
  27682. vAng: number;
  27683. wAng: number;
  27684. readonly noMipmap: boolean;
  27685. private _noMipmap;
  27686. _invertY: boolean;
  27687. private _rowGenerationMatrix;
  27688. private _cachedTextureMatrix;
  27689. private _projectionModeMatrix;
  27690. private _t0;
  27691. private _t1;
  27692. private _t2;
  27693. private _cachedUOffset;
  27694. private _cachedVOffset;
  27695. private _cachedUScale;
  27696. private _cachedVScale;
  27697. private _cachedUAng;
  27698. private _cachedVAng;
  27699. private _cachedWAng;
  27700. private _cachedProjectionMatrixId;
  27701. private _cachedCoordinatesMode;
  27702. _samplingMode: number;
  27703. private _buffer;
  27704. private _deleteBuffer;
  27705. protected _format: Nullable<number>;
  27706. private _delayedOnLoad;
  27707. private _delayedOnError;
  27708. protected _onLoadObservable: Nullable<Observable<Texture>>;
  27709. protected _isBlocking: boolean;
  27710. isBlocking: boolean;
  27711. readonly samplingMode: number;
  27712. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: any, deleteBuffer?: boolean, format?: number);
  27713. updateURL(url: string): void;
  27714. delayLoad(): void;
  27715. updateSamplingMode(samplingMode: number): void;
  27716. private _prepareRowForTextureGeneration(x, y, z, t);
  27717. getTextureMatrix(): Matrix;
  27718. getReflectionTextureMatrix(): Matrix;
  27719. clone(): Texture;
  27720. readonly onLoadObservable: Observable<Texture>;
  27721. serialize(): any;
  27722. getClassName(): string;
  27723. dispose(): void;
  27724. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  27725. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  27726. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  27727. }
  27728. }
  27729. declare module BABYLON {
  27730. /**
  27731. * Settings for finer control over video usage
  27732. */
  27733. interface VideoTextureSettings {
  27734. /**
  27735. * Applies `autoplay` to video, if specified
  27736. */
  27737. autoPlay?: boolean;
  27738. /**
  27739. * Applies `loop` to video, if specified
  27740. */
  27741. loop?: boolean;
  27742. /**
  27743. * Automatically updates internal texture from video at every frame in the render loop
  27744. */
  27745. autoUpdateTexture: boolean;
  27746. }
  27747. class VideoTexture extends Texture {
  27748. /**
  27749. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27750. */
  27751. readonly autoUpdateTexture: boolean;
  27752. /**
  27753. * The video instance used by the texture internally
  27754. */
  27755. readonly video: HTMLVideoElement;
  27756. private _generateMipMaps;
  27757. private _engine;
  27758. /**
  27759. * Creates a video texture.
  27760. * Sample : https://doc.babylonjs.com/how_to/video_texture
  27761. * @param {string | null} name optional name, will detect from video source, if not defined
  27762. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  27763. * @param {BABYLON.Scene} scene is obviously the current scene.
  27764. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27765. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  27766. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27767. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  27768. */
  27769. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27770. private _getName(src);
  27771. private _getVideo(src);
  27772. private _createInternalTexture;
  27773. private reset;
  27774. /**
  27775. * Internal method to initiate `update`.
  27776. */
  27777. _rebuild(): void;
  27778. /**
  27779. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27780. */
  27781. update(): void;
  27782. /**
  27783. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27784. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27785. */
  27786. updateTexture(isVisible: boolean): void;
  27787. protected _updateInternalTexture: (e?: Event | undefined) => void;
  27788. /**
  27789. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27790. * @param url New url.
  27791. */
  27792. updateURL(url: string): void;
  27793. dispose(): void;
  27794. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27795. minWidth: number;
  27796. maxWidth: number;
  27797. minHeight: number;
  27798. maxHeight: number;
  27799. deviceId: string;
  27800. }): void;
  27801. }
  27802. }
  27803. declare var DracoDecoderModule: any;
  27804. declare module BABYLON {
  27805. /**
  27806. * Draco compression (https://google.github.io/draco/)
  27807. */
  27808. class DracoCompression implements IDisposable {
  27809. private _workerPool;
  27810. /**
  27811. * Gets the url to the draco decoder if available.
  27812. */
  27813. static DecoderUrl: Nullable<string>;
  27814. /**
  27815. * Constructor
  27816. * @param numWorkers The number of workers for async operations
  27817. */
  27818. constructor(numWorkers?: number);
  27819. /**
  27820. * Stop all async operations and release resources.
  27821. */
  27822. dispose(): void;
  27823. /**
  27824. * Decode Draco compressed mesh data to vertex data.
  27825. * @param data The array buffer view for the Draco compression data
  27826. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  27827. * @returns A promise that resolves with the decoded vertex data
  27828. */
  27829. decodeMeshAsync(data: ArrayBufferView, attributes: {
  27830. [kind: string]: number;
  27831. }): Promise<VertexData>;
  27832. /**
  27833. * The worker function that gets converted to a blob url to pass into a worker.
  27834. */
  27835. private static _Worker();
  27836. private static _GetDefaultDecoderUrl();
  27837. }
  27838. }
  27839. declare module BABYLON {
  27840. /**
  27841. * Particle emitter emitting particles from the inside of a box.
  27842. * It emits the particles randomly between 2 given directions.
  27843. */
  27844. class BoxParticleEmitter implements IParticleEmitterType {
  27845. /**
  27846. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  27847. */
  27848. direction1: Vector3;
  27849. /**
  27850. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  27851. */
  27852. direction2: Vector3;
  27853. /**
  27854. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  27855. */
  27856. minEmitBox: Vector3;
  27857. /**
  27858. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  27859. */
  27860. maxEmitBox: Vector3;
  27861. /**
  27862. * Creates a new instance of @see BoxParticleEmitter
  27863. */
  27864. constructor();
  27865. /**
  27866. * Called by the particle System when the direction is computed for the created particle.
  27867. * @param emitPower is the power of the particle (speed)
  27868. * @param worldMatrix is the world matrix of the particle system
  27869. * @param directionToUpdate is the direction vector to update with the result
  27870. * @param particle is the particle we are computed the direction for
  27871. */
  27872. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  27873. /**
  27874. * Called by the particle System when the position is computed for the created particle.
  27875. * @param worldMatrix is the world matrix of the particle system
  27876. * @param positionToUpdate is the position vector to update with the result
  27877. * @param particle is the particle we are computed the position for
  27878. */
  27879. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  27880. /**
  27881. * Clones the current emitter and returns a copy of it
  27882. * @returns the new emitter
  27883. */
  27884. clone(): BoxParticleEmitter;
  27885. /**
  27886. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  27887. * @param effect defines the update shader
  27888. */
  27889. applyToShader(effect: Effect): void;
  27890. /**
  27891. * Returns a string to use to update the GPU particles update shader
  27892. * @returns a string containng the defines string
  27893. */
  27894. getEffectDefines(): string;
  27895. /**
  27896. * Returns the string "BoxEmitter"
  27897. * @returns a string containing the class name
  27898. */
  27899. getClassName(): string;
  27900. /**
  27901. * Serializes the particle system to a JSON object.
  27902. * @returns the JSON object
  27903. */
  27904. serialize(): any;
  27905. /**
  27906. * Parse properties from a JSON object
  27907. * @param serializationObject defines the JSON object
  27908. */
  27909. parse(serializationObject: any): void;
  27910. }
  27911. }
  27912. declare module BABYLON {
  27913. /**
  27914. * Particle emitter emitting particles from the inside of a cone.
  27915. * It emits the particles alongside the cone volume from the base to the particle.
  27916. * The emission direction might be randomized.
  27917. */
  27918. class ConeParticleEmitter implements IParticleEmitterType {
  27919. /**
  27920. * The radius of the emission cone.
  27921. */
  27922. angle: number;
  27923. /**
  27924. * The cone base angle.
  27925. */
  27926. directionRandomizer: number;
  27927. private _radius;
  27928. private _height;
  27929. /**
  27930. * Gets the radius of the emission cone.
  27931. */
  27932. /**
  27933. * Sets the radius of the emission cone.
  27934. */
  27935. radius: number;
  27936. /**
  27937. * Creates a new instance of @see ConeParticleEmitter
  27938. * @param radius the radius of the emission cone (1 by default)
  27939. * @param angles the cone base angle (PI by default)
  27940. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  27941. */
  27942. constructor(radius?: number,
  27943. /**
  27944. * The radius of the emission cone.
  27945. */
  27946. angle?: number,
  27947. /**
  27948. * The cone base angle.
  27949. */
  27950. directionRandomizer?: number);
  27951. /**
  27952. * Called by the particle System when the direction is computed for the created particle.
  27953. * @param emitPower is the power of the particle (speed)
  27954. * @param worldMatrix is the world matrix of the particle system
  27955. * @param directionToUpdate is the direction vector to update with the result
  27956. * @param particle is the particle we are computed the direction for
  27957. */
  27958. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  27959. /**
  27960. * Called by the particle System when the position is computed for the created particle.
  27961. * @param worldMatrix is the world matrix of the particle system
  27962. * @param positionToUpdate is the position vector to update with the result
  27963. * @param particle is the particle we are computed the position for
  27964. */
  27965. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  27966. /**
  27967. * Clones the current emitter and returns a copy of it
  27968. * @returns the new emitter
  27969. */
  27970. clone(): ConeParticleEmitter;
  27971. /**
  27972. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  27973. * @param effect defines the update shader
  27974. */
  27975. applyToShader(effect: Effect): void;
  27976. /**
  27977. * Returns a string to use to update the GPU particles update shader
  27978. * @returns a string containng the defines string
  27979. */
  27980. getEffectDefines(): string;
  27981. /**
  27982. * Returns the string "BoxEmitter"
  27983. * @returns a string containing the class name
  27984. */
  27985. getClassName(): string;
  27986. /**
  27987. * Serializes the particle system to a JSON object.
  27988. * @returns the JSON object
  27989. */
  27990. serialize(): any;
  27991. /**
  27992. * Parse properties from a JSON object
  27993. * @param serializationObject defines the JSON object
  27994. */
  27995. parse(serializationObject: any): void;
  27996. }
  27997. }
  27998. declare module BABYLON {
  27999. /**
  28000. * Particle emitter represents a volume emitting particles.
  28001. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  28002. */
  28003. interface IParticleEmitterType {
  28004. /**
  28005. * Called by the particle System when the direction is computed for the created particle.
  28006. * @param emitPower is the power of the particle (speed)
  28007. * @param worldMatrix is the world matrix of the particle system
  28008. * @param directionToUpdate is the direction vector to update with the result
  28009. * @param particle is the particle we are computed the direction for
  28010. */
  28011. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  28012. /**
  28013. * Called by the particle System when the position is computed for the created particle.
  28014. * @param worldMatrix is the world matrix of the particle system
  28015. * @param positionToUpdate is the position vector to update with the result
  28016. * @param particle is the particle we are computed the position for
  28017. */
  28018. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  28019. /**
  28020. * Clones the current emitter and returns a copy of it
  28021. * @returns the new emitter
  28022. */
  28023. clone(): IParticleEmitterType;
  28024. /**
  28025. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  28026. * @param effect defines the update shader
  28027. */
  28028. applyToShader(effect: Effect): void;
  28029. /**
  28030. * Returns a string to use to update the GPU particles update shader
  28031. * @returns the effect defines string
  28032. */
  28033. getEffectDefines(): string;
  28034. /**
  28035. * Returns a string representing the class name
  28036. * @returns a string containing the class name
  28037. */
  28038. getClassName(): string;
  28039. /**
  28040. * Serializes the particle system to a JSON object.
  28041. * @returns the JSON object
  28042. */
  28043. serialize(): any;
  28044. /**
  28045. * Parse properties from a JSON object
  28046. * @param serializationObject defines the JSON object
  28047. */
  28048. parse(serializationObject: any): void;
  28049. }
  28050. }
  28051. declare module BABYLON {
  28052. /**
  28053. * Particle emitter emitting particles from the inside of a sphere.
  28054. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  28055. */
  28056. class SphereParticleEmitter implements IParticleEmitterType {
  28057. /**
  28058. * The radius of the emission sphere.
  28059. */
  28060. radius: number;
  28061. /**
  28062. * How much to randomize the particle direction [0-1].
  28063. */
  28064. directionRandomizer: number;
  28065. /**
  28066. * Creates a new instance of @see SphereParticleEmitter
  28067. * @param radius the radius of the emission sphere (1 by default)
  28068. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  28069. */
  28070. constructor(
  28071. /**
  28072. * The radius of the emission sphere.
  28073. */
  28074. radius?: number,
  28075. /**
  28076. * How much to randomize the particle direction [0-1].
  28077. */
  28078. directionRandomizer?: number);
  28079. /**
  28080. * Called by the particle System when the direction is computed for the created particle.
  28081. * @param emitPower is the power of the particle (speed)
  28082. * @param worldMatrix is the world matrix of the particle system
  28083. * @param directionToUpdate is the direction vector to update with the result
  28084. * @param particle is the particle we are computed the direction for
  28085. */
  28086. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  28087. /**
  28088. * Called by the particle System when the position is computed for the created particle.
  28089. * @param worldMatrix is the world matrix of the particle system
  28090. * @param positionToUpdate is the position vector to update with the result
  28091. * @param particle is the particle we are computed the position for
  28092. */
  28093. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  28094. /**
  28095. * Clones the current emitter and returns a copy of it
  28096. * @returns the new emitter
  28097. */
  28098. clone(): SphereParticleEmitter;
  28099. /**
  28100. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  28101. * @param effect defines the update shader
  28102. */
  28103. applyToShader(effect: Effect): void;
  28104. /**
  28105. * Returns a string to use to update the GPU particles update shader
  28106. * @returns a string containng the defines string
  28107. */
  28108. getEffectDefines(): string;
  28109. /**
  28110. * Returns the string "SphereParticleEmitter"
  28111. * @returns a string containing the class name
  28112. */
  28113. getClassName(): string;
  28114. /**
  28115. * Serializes the particle system to a JSON object.
  28116. * @returns the JSON object
  28117. */
  28118. serialize(): any;
  28119. /**
  28120. * Parse properties from a JSON object
  28121. * @param serializationObject defines the JSON object
  28122. */
  28123. parse(serializationObject: any): void;
  28124. }
  28125. /**
  28126. * Particle emitter emitting particles from the inside of a sphere.
  28127. * It emits the particles randomly between two vectors.
  28128. */
  28129. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  28130. /**
  28131. * The min limit of the emission direction.
  28132. */
  28133. direction1: Vector3;
  28134. /**
  28135. * The max limit of the emission direction.
  28136. */
  28137. direction2: Vector3;
  28138. /**
  28139. * Creates a new instance of @see SphereDirectedParticleEmitter
  28140. * @param radius the radius of the emission sphere (1 by default)
  28141. * @param direction1 the min limit of the emission direction (up vector by default)
  28142. * @param direction2 the max limit of the emission direction (up vector by default)
  28143. */
  28144. constructor(radius?: number,
  28145. /**
  28146. * The min limit of the emission direction.
  28147. */
  28148. direction1?: Vector3,
  28149. /**
  28150. * The max limit of the emission direction.
  28151. */
  28152. direction2?: Vector3);
  28153. /**
  28154. * Called by the particle System when the direction is computed for the created particle.
  28155. * @param emitPower is the power of the particle (speed)
  28156. * @param worldMatrix is the world matrix of the particle system
  28157. * @param directionToUpdate is the direction vector to update with the result
  28158. * @param particle is the particle we are computed the direction for
  28159. */
  28160. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  28161. /**
  28162. * Clones the current emitter and returns a copy of it
  28163. * @returns the new emitter
  28164. */
  28165. clone(): SphereDirectedParticleEmitter;
  28166. /**
  28167. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  28168. * @param effect defines the update shader
  28169. */
  28170. applyToShader(effect: Effect): void;
  28171. /**
  28172. * Returns a string to use to update the GPU particles update shader
  28173. * @returns a string containng the defines string
  28174. */
  28175. getEffectDefines(): string;
  28176. /**
  28177. * Returns the string "SphereDirectedParticleEmitter"
  28178. * @returns a string containing the class name
  28179. */
  28180. getClassName(): string;
  28181. /**
  28182. * Serializes the particle system to a JSON object.
  28183. * @returns the JSON object
  28184. */
  28185. serialize(): any;
  28186. /**
  28187. * Parse properties from a JSON object
  28188. * @param serializationObject defines the JSON object
  28189. */
  28190. parse(serializationObject: any): void;
  28191. }
  28192. }
  28193. declare module BABYLON {
  28194. class CannonJSPlugin implements IPhysicsEnginePlugin {
  28195. private _useDeltaForWorldStep;
  28196. world: any;
  28197. name: string;
  28198. private _physicsMaterials;
  28199. private _fixedTimeStep;
  28200. BJSCANNON: any;
  28201. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  28202. setGravity(gravity: Vector3): void;
  28203. setTimeStep(timeStep: number): void;
  28204. getTimeStep(): number;
  28205. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28206. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28207. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28208. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28209. private _processChildMeshes(mainImpostor);
  28210. removePhysicsBody(impostor: PhysicsImpostor): void;
  28211. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  28212. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  28213. private _addMaterial(name, friction, restitution);
  28214. private _checkWithEpsilon(value);
  28215. private _createShape(impostor);
  28216. private _createHeightmap(object, pointDepth?);
  28217. private _minus90X;
  28218. private _plus90X;
  28219. private _tmpPosition;
  28220. private _tmpDeltaPosition;
  28221. private _tmpUnityRotation;
  28222. private _updatePhysicsBodyTransformation(impostor);
  28223. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28224. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28225. isSupported(): boolean;
  28226. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  28227. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  28228. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28229. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28230. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28231. getBodyMass(impostor: PhysicsImpostor): number;
  28232. getBodyFriction(impostor: PhysicsImpostor): number;
  28233. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28234. getBodyRestitution(impostor: PhysicsImpostor): number;
  28235. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28236. sleepBody(impostor: PhysicsImpostor): void;
  28237. wakeUpBody(impostor: PhysicsImpostor): void;
  28238. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28239. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  28240. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  28241. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28242. getRadius(impostor: PhysicsImpostor): number;
  28243. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28244. dispose(): void;
  28245. private _extendNamespace();
  28246. }
  28247. }
  28248. declare module BABYLON {
  28249. class OimoJSPlugin implements IPhysicsEnginePlugin {
  28250. world: any;
  28251. name: string;
  28252. BJSOIMO: any;
  28253. constructor(iterations?: number);
  28254. setGravity(gravity: Vector3): void;
  28255. setTimeStep(timeStep: number): void;
  28256. getTimeStep(): number;
  28257. private _tmpImpostorsArray;
  28258. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28259. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28260. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28261. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28262. private _tmpPositionVector;
  28263. removePhysicsBody(impostor: PhysicsImpostor): void;
  28264. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  28265. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  28266. isSupported(): boolean;
  28267. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28268. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28269. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  28270. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  28271. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28272. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28273. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28274. getBodyMass(impostor: PhysicsImpostor): number;
  28275. getBodyFriction(impostor: PhysicsImpostor): number;
  28276. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28277. getBodyRestitution(impostor: PhysicsImpostor): number;
  28278. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28279. sleepBody(impostor: PhysicsImpostor): void;
  28280. wakeUpBody(impostor: PhysicsImpostor): void;
  28281. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28282. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28283. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28284. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28285. getRadius(impostor: PhysicsImpostor): number;
  28286. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28287. dispose(): void;
  28288. }
  28289. }
  28290. declare module BABYLON {
  28291. /**
  28292. * This represents a set of one or more post processes in Babylon.
  28293. * A post process can be used to apply a shader to a texture after it is rendered.
  28294. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  28295. */
  28296. class PostProcessRenderEffect {
  28297. private _postProcesses;
  28298. private _getPostProcesses;
  28299. private _singleInstance;
  28300. private _cameras;
  28301. private _indicesForCamera;
  28302. /**
  28303. * Name of the effect
  28304. */
  28305. _name: string;
  28306. /**
  28307. * Instantiates a post process render effect.
  28308. * A post process can be used to apply a shader to a texture after it is rendered.
  28309. * @param engine The engine the effect is tied to
  28310. * @param name The name of the effect
  28311. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  28312. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  28313. */
  28314. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  28315. /**
  28316. * Checks if all the post processes in the effect are supported.
  28317. */
  28318. readonly isSupported: boolean;
  28319. /**
  28320. * Updates the current state of the effect
  28321. */
  28322. _update(): void;
  28323. /**
  28324. * Attaches the effect on cameras
  28325. * @param cameras The camera to attach to.
  28326. */
  28327. _attachCameras(cameras: Camera): void;
  28328. /**
  28329. * Attaches the effect on cameras
  28330. * @param cameras The camera to attach to.
  28331. */
  28332. _attachCameras(cameras: Camera[]): void;
  28333. /**
  28334. * Detatches the effect on cameras
  28335. * @param cameras The camera to detatch from.
  28336. */
  28337. _detachCameras(cameras: Camera): void;
  28338. /**
  28339. * Detatches the effect on cameras
  28340. * @param cameras The camera to detatch from.
  28341. */
  28342. _detachCameras(cameras: Camera[]): void;
  28343. /**
  28344. * Enables the effect on given cameras
  28345. * @param cameras The camera to enable.
  28346. */
  28347. _enable(cameras: Camera): void;
  28348. /**
  28349. * Enables the effect on given cameras
  28350. * @param cameras The camera to enable.
  28351. */
  28352. _enable(cameras: Nullable<Camera[]>): void;
  28353. /**
  28354. * Disables the effect on the given cameras
  28355. * @param cameras The camera to disable.
  28356. */
  28357. _disable(cameras: Camera): void;
  28358. /**
  28359. * Disables the effect on the given cameras
  28360. * @param cameras The camera to disable.
  28361. */
  28362. _disable(cameras: Nullable<Camera[]>): void;
  28363. /**
  28364. * Gets a list of the post processes contained in the effect.
  28365. * @param camera The camera to get the post processes on.
  28366. * @returns The list of the post processes in the effect.
  28367. */
  28368. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  28369. }
  28370. }
  28371. declare module BABYLON {
  28372. class PostProcessRenderPipeline {
  28373. private engine;
  28374. private _renderEffects;
  28375. private _renderEffectsForIsolatedPass;
  28376. protected _cameras: Camera[];
  28377. _name: string;
  28378. constructor(engine: Engine, name: string);
  28379. getClassName(): string;
  28380. readonly isSupported: boolean;
  28381. addEffect(renderEffect: PostProcessRenderEffect): void;
  28382. _rebuild(): void;
  28383. _enableEffect(renderEffectName: string, cameras: Camera): void;
  28384. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  28385. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  28386. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  28387. _attachCameras(cameras: Camera, unique: boolean): void;
  28388. _attachCameras(cameras: Camera[], unique: boolean): void;
  28389. _detachCameras(cameras: Camera): void;
  28390. _detachCameras(cameras: Nullable<Camera[]>): void;
  28391. _update(): void;
  28392. _reset(): void;
  28393. protected _enableMSAAOnFirstPostProcess(): boolean;
  28394. dispose(): void;
  28395. }
  28396. }
  28397. declare module BABYLON {
  28398. class PostProcessRenderPipelineManager {
  28399. private _renderPipelines;
  28400. constructor();
  28401. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  28402. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  28403. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  28404. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  28405. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  28406. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  28407. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  28408. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  28409. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  28410. update(): void;
  28411. _rebuild(): void;
  28412. dispose(): void;
  28413. }
  28414. }
  28415. declare module BABYLON {
  28416. /**
  28417. * Helper class dealing with the extraction of spherical polynomial dataArray
  28418. * from a cube map.
  28419. */
  28420. class CubeMapToSphericalPolynomialTools {
  28421. private static FileFaces;
  28422. /**
  28423. * Converts a texture to the according Spherical Polynomial data.
  28424. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28425. *
  28426. * @param texture The texture to extract the information from.
  28427. * @return The Spherical Polynomial data.
  28428. */
  28429. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28430. /**
  28431. * Converts a cubemap to the according Spherical Polynomial data.
  28432. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28433. *
  28434. * @param cubeInfo The Cube map to extract the information from.
  28435. * @return The Spherical Polynomial data.
  28436. */
  28437. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28438. }
  28439. }
  28440. declare module BABYLON {
  28441. /**
  28442. * Header information of HDR texture files.
  28443. */
  28444. interface HDRInfo {
  28445. /**
  28446. * The height of the texture in pixels.
  28447. */
  28448. height: number;
  28449. /**
  28450. * The width of the texture in pixels.
  28451. */
  28452. width: number;
  28453. /**
  28454. * The index of the beginning of the data in the binary file.
  28455. */
  28456. dataPosition: number;
  28457. }
  28458. /**
  28459. * This groups tools to convert HDR texture to native colors array.
  28460. */
  28461. class HDRTools {
  28462. private static Ldexp(mantissa, exponent);
  28463. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  28464. private static readStringLine(uint8array, startIndex);
  28465. /**
  28466. * Reads header information from an RGBE texture stored in a native array.
  28467. * More information on this format are available here:
  28468. * https://en.wikipedia.org/wiki/RGBE_image_format
  28469. *
  28470. * @param uint8array The binary file stored in native array.
  28471. * @return The header information.
  28472. */
  28473. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  28474. /**
  28475. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  28476. * This RGBE texture needs to store the information as a panorama.
  28477. *
  28478. * More information on this format are available here:
  28479. * https://en.wikipedia.org/wiki/RGBE_image_format
  28480. *
  28481. * @param buffer The binary file stored in an array buffer.
  28482. * @param size The expected size of the extracted cubemap.
  28483. * @return The Cube Map information.
  28484. */
  28485. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  28486. /**
  28487. * Returns the pixels data extracted from an RGBE texture.
  28488. * This pixels will be stored left to right up to down in the R G B order in one array.
  28489. *
  28490. * More information on this format are available here:
  28491. * https://en.wikipedia.org/wiki/RGBE_image_format
  28492. *
  28493. * @param uint8array The binary file stored in an array buffer.
  28494. * @param hdrInfo The header information of the file.
  28495. * @return The pixels data in RGB right to left up to down order.
  28496. */
  28497. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  28498. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  28499. }
  28500. }
  28501. declare module BABYLON {
  28502. /**
  28503. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28504. */
  28505. interface CubeMapInfo {
  28506. /**
  28507. * The pixel array for the front face.
  28508. * This is stored in format, left to right, up to down format.
  28509. */
  28510. front: Nullable<ArrayBufferView>;
  28511. /**
  28512. * The pixel array for the back face.
  28513. * This is stored in format, left to right, up to down format.
  28514. */
  28515. back: Nullable<ArrayBufferView>;
  28516. /**
  28517. * The pixel array for the left face.
  28518. * This is stored in format, left to right, up to down format.
  28519. */
  28520. left: Nullable<ArrayBufferView>;
  28521. /**
  28522. * The pixel array for the right face.
  28523. * This is stored in format, left to right, up to down format.
  28524. */
  28525. right: Nullable<ArrayBufferView>;
  28526. /**
  28527. * The pixel array for the up face.
  28528. * This is stored in format, left to right, up to down format.
  28529. */
  28530. up: Nullable<ArrayBufferView>;
  28531. /**
  28532. * The pixel array for the down face.
  28533. * This is stored in format, left to right, up to down format.
  28534. */
  28535. down: Nullable<ArrayBufferView>;
  28536. /**
  28537. * The size of the cubemap stored.
  28538. *
  28539. * Each faces will be size * size pixels.
  28540. */
  28541. size: number;
  28542. /**
  28543. * The format of the texture.
  28544. *
  28545. * RGBA, RGB.
  28546. */
  28547. format: number;
  28548. /**
  28549. * The type of the texture data.
  28550. *
  28551. * UNSIGNED_INT, FLOAT.
  28552. */
  28553. type: number;
  28554. /**
  28555. * Specifies whether the texture is in gamma space.
  28556. */
  28557. gammaSpace: boolean;
  28558. }
  28559. /**
  28560. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  28561. */
  28562. class PanoramaToCubeMapTools {
  28563. private static FACE_FRONT;
  28564. private static FACE_BACK;
  28565. private static FACE_RIGHT;
  28566. private static FACE_LEFT;
  28567. private static FACE_DOWN;
  28568. private static FACE_UP;
  28569. /**
  28570. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28571. *
  28572. * @param float32Array The source data.
  28573. * @param inputWidth The width of the input panorama.
  28574. * @param inputhHeight The height of the input panorama.
  28575. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28576. * @return The cubemap data
  28577. */
  28578. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28579. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  28580. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  28581. }
  28582. }
  28583. declare module BABYLON {
  28584. class CustomProceduralTexture extends ProceduralTexture {
  28585. private _animate;
  28586. private _time;
  28587. private _config;
  28588. private _texturePath;
  28589. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  28590. private loadJson(jsonUrl);
  28591. isReady(): boolean;
  28592. render(useCameraPostProcess?: boolean): void;
  28593. updateTextures(): void;
  28594. updateShaderUniforms(): void;
  28595. animate: boolean;
  28596. }
  28597. }
  28598. declare module BABYLON {
  28599. class ProceduralTexture extends Texture {
  28600. isCube: boolean;
  28601. private _size;
  28602. _generateMipMaps: boolean;
  28603. isEnabled: boolean;
  28604. private _currentRefreshId;
  28605. private _refreshRate;
  28606. onGenerated: () => void;
  28607. private _vertexBuffers;
  28608. private _indexBuffer;
  28609. private _effect;
  28610. private _uniforms;
  28611. private _samplers;
  28612. private _fragment;
  28613. _textures: {
  28614. [key: string]: Texture;
  28615. };
  28616. private _floats;
  28617. private _floatsArrays;
  28618. private _colors3;
  28619. private _colors4;
  28620. private _vectors2;
  28621. private _vectors3;
  28622. private _matrices;
  28623. private _fallbackTexture;
  28624. private _fallbackTextureUsed;
  28625. private _engine;
  28626. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  28627. private _createIndexBuffer();
  28628. _rebuild(): void;
  28629. reset(): void;
  28630. isReady(): boolean;
  28631. resetRefreshCounter(): void;
  28632. setFragment(fragment: any): void;
  28633. refreshRate: number;
  28634. _shouldRender(): boolean;
  28635. getRenderSize(): number;
  28636. resize(size: number, generateMipMaps: boolean): void;
  28637. private _checkUniform(uniformName);
  28638. setTexture(name: string, texture: Texture): ProceduralTexture;
  28639. setFloat(name: string, value: number): ProceduralTexture;
  28640. setFloats(name: string, value: number[]): ProceduralTexture;
  28641. setColor3(name: string, value: Color3): ProceduralTexture;
  28642. setColor4(name: string, value: Color4): ProceduralTexture;
  28643. setVector2(name: string, value: Vector2): ProceduralTexture;
  28644. setVector3(name: string, value: Vector3): ProceduralTexture;
  28645. setMatrix(name: string, value: Matrix): ProceduralTexture;
  28646. render(useCameraPostProcess?: boolean): void;
  28647. clone(): ProceduralTexture;
  28648. dispose(): void;
  28649. }
  28650. }
  28651. declare module BABYLON {
  28652. /**
  28653. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  28654. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  28655. */
  28656. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  28657. private _scene;
  28658. private _originalCameras;
  28659. /**
  28660. * ID of the sharpen post process,
  28661. */
  28662. readonly SharpenPostProcessId: string;
  28663. /**
  28664. * ID of the pass post process used for bloom,
  28665. */
  28666. readonly PassPostProcessId: string;
  28667. /**
  28668. * ID of the highlight post process used for bloom,
  28669. */
  28670. readonly HighLightsPostProcessId: string;
  28671. /**
  28672. * ID of the blurX post process used for bloom,
  28673. */
  28674. readonly BlurXPostProcessId: string;
  28675. /**
  28676. * ID of the blurY post process used for bloom,
  28677. */
  28678. readonly BlurYPostProcessId: string;
  28679. /**
  28680. * ID of the copy back post process used for bloom,
  28681. */
  28682. readonly CopyBackPostProcessId: string;
  28683. /**
  28684. * ID of the image processing post process;
  28685. */
  28686. readonly ImageProcessingPostProcessId: string;
  28687. /**
  28688. * ID of the Fast Approximate Anti-Aliasing post process;
  28689. */
  28690. readonly FxaaPostProcessId: string;
  28691. /**
  28692. * ID of the final merge post process;
  28693. */
  28694. readonly FinalMergePostProcessId: string;
  28695. /**
  28696. * ID of the chromatic aberration post process,
  28697. */
  28698. readonly ChromaticAberrationPostProcessId: string;
  28699. /**
  28700. * Sharpen post process which will apply a sharpen convolution to enhance edges
  28701. */
  28702. sharpen: SharpenPostProcess;
  28703. private _sharpenEffect;
  28704. /**
  28705. * First pass of bloom to capture the original image texture for later use.
  28706. */
  28707. pass: PassPostProcess;
  28708. /**
  28709. * Second pass of bloom used to brighten bright portions of the image.
  28710. */
  28711. highlights: HighlightsPostProcess;
  28712. /**
  28713. * BlurX post process used in coordination with blurY to guassian blur the highlighted image.
  28714. */
  28715. blurX: BlurPostProcess;
  28716. /**
  28717. * BlurY post process used in coordination with blurX to guassian blur the highlighted image.
  28718. */
  28719. blurY: BlurPostProcess;
  28720. /**
  28721. * Final pass run for bloom to copy the resulting bloom texture back to screen.
  28722. */
  28723. copyBack: PassPostProcess;
  28724. /**
  28725. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  28726. */
  28727. depthOfField: DepthOfFieldEffect;
  28728. /**
  28729. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  28730. */
  28731. fxaa: FxaaPostProcess;
  28732. /**
  28733. * Image post processing pass used to perform operations such as tone mapping or color grading.
  28734. */
  28735. imageProcessing: ImageProcessingPostProcess;
  28736. /**
  28737. * Final post process to merge results of all previous passes
  28738. */
  28739. finalMerge: PassPostProcess;
  28740. /**
  28741. * Chromatic aberration post process which will shift rgb colors in the image
  28742. */
  28743. chromaticAberration: ChromaticAberrationPostProcess;
  28744. private _chromaticAberrationEffect;
  28745. /**
  28746. * Animations which can be used to tweak settings over a period of time
  28747. */
  28748. animations: Animation[];
  28749. private _sharpenEnabled;
  28750. private _bloomEnabled;
  28751. private _depthOfFieldEnabled;
  28752. private _depthOfFieldBlurLevel;
  28753. private _fxaaEnabled;
  28754. private _msaaEnabled;
  28755. private _imageProcessingEnabled;
  28756. private _defaultPipelineTextureType;
  28757. private _bloomScale;
  28758. private _chromaticAberrationEnabled;
  28759. private _buildAllowed;
  28760. /**
  28761. * Enable or disable the sharpen process from the pipeline
  28762. */
  28763. sharpenEnabled: boolean;
  28764. /**
  28765. * Specifies the size of the bloom blur kernel, relative to the final output size
  28766. */
  28767. bloomKernel: number;
  28768. /**
  28769. * Specifies the weight of the bloom in the final rendering
  28770. */
  28771. private _bloomWeight;
  28772. private _hdr;
  28773. /**
  28774. * The strength of the bloom.
  28775. */
  28776. bloomWeight: number;
  28777. /**
  28778. * The scale of the bloom, lower value will provide better performance.
  28779. */
  28780. bloomScale: number;
  28781. /**
  28782. * Enable or disable the bloom from the pipeline
  28783. */
  28784. bloomEnabled: boolean;
  28785. /**
  28786. * If the depth of field is enabled.
  28787. */
  28788. depthOfFieldEnabled: boolean;
  28789. /**
  28790. * Blur level of the depth of field effect. (Higher blur will effect performance)
  28791. */
  28792. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  28793. /**
  28794. * If the anti aliasing is enabled.
  28795. */
  28796. fxaaEnabled: boolean;
  28797. /**
  28798. * If the multisample anti-aliasing is enabled.
  28799. */
  28800. msaaEnabled: boolean;
  28801. /**
  28802. * If image processing is enabled.
  28803. */
  28804. imageProcessingEnabled: boolean;
  28805. /**
  28806. * Enable or disable the chromaticAberration process from the pipeline
  28807. */
  28808. chromaticAberrationEnabled: boolean;
  28809. /**
  28810. * @constructor
  28811. * @param {string} name - The rendering pipeline name
  28812. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  28813. * @param {any} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  28814. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  28815. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
  28816. */
  28817. constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild?: boolean);
  28818. /**
  28819. * Force the compilation of the entire pipeline.
  28820. */
  28821. prepare(): void;
  28822. private _prevPostProcess;
  28823. private _prevPrevPostProcess;
  28824. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  28825. private _buildPipeline();
  28826. private _disposePostProcesses(disposeNonRecreated?);
  28827. /**
  28828. * Dispose of the pipeline and stop all post processes
  28829. */
  28830. dispose(): void;
  28831. /**
  28832. * Serialize the rendering pipeline (Used when exporting)
  28833. * @returns the serialized object
  28834. */
  28835. serialize(): any;
  28836. /**
  28837. * Parse the serialized pipeline
  28838. * @param source Source pipeline.
  28839. * @param scene The scene to load the pipeline to.
  28840. * @param rootUrl The URL of the serialized pipeline.
  28841. * @returns An instantiated pipeline from the serialized object.
  28842. */
  28843. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  28844. }
  28845. }
  28846. declare module BABYLON {
  28847. class LensRenderingPipeline extends PostProcessRenderPipeline {
  28848. /**
  28849. * The chromatic aberration PostProcess id in the pipeline
  28850. * @type {string}
  28851. */
  28852. LensChromaticAberrationEffect: string;
  28853. /**
  28854. * The highlights enhancing PostProcess id in the pipeline
  28855. * @type {string}
  28856. */
  28857. HighlightsEnhancingEffect: string;
  28858. /**
  28859. * The depth-of-field PostProcess id in the pipeline
  28860. * @type {string}
  28861. */
  28862. LensDepthOfFieldEffect: string;
  28863. private _scene;
  28864. private _depthTexture;
  28865. private _grainTexture;
  28866. private _chromaticAberrationPostProcess;
  28867. private _highlightsPostProcess;
  28868. private _depthOfFieldPostProcess;
  28869. private _edgeBlur;
  28870. private _grainAmount;
  28871. private _chromaticAberration;
  28872. private _distortion;
  28873. private _highlightsGain;
  28874. private _highlightsThreshold;
  28875. private _dofDistance;
  28876. private _dofAperture;
  28877. private _dofDarken;
  28878. private _dofPentagon;
  28879. private _blurNoise;
  28880. /**
  28881. * @constructor
  28882. *
  28883. * Effect parameters are as follow:
  28884. * {
  28885. * chromatic_aberration: number; // from 0 to x (1 for realism)
  28886. * edge_blur: number; // from 0 to x (1 for realism)
  28887. * distortion: number; // from 0 to x (1 for realism)
  28888. * grain_amount: number; // from 0 to 1
  28889. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  28890. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  28891. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  28892. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  28893. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  28894. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  28895. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  28896. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  28897. * }
  28898. * Note: if an effect parameter is unset, effect is disabled
  28899. *
  28900. * @param {string} name - The rendering pipeline name
  28901. * @param {object} parameters - An object containing all parameters (see above)
  28902. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  28903. * @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)
  28904. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  28905. */
  28906. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  28907. setEdgeBlur(amount: number): void;
  28908. disableEdgeBlur(): void;
  28909. setGrainAmount(amount: number): void;
  28910. disableGrain(): void;
  28911. setChromaticAberration(amount: number): void;
  28912. disableChromaticAberration(): void;
  28913. setEdgeDistortion(amount: number): void;
  28914. disableEdgeDistortion(): void;
  28915. setFocusDistance(amount: number): void;
  28916. disableDepthOfField(): void;
  28917. setAperture(amount: number): void;
  28918. setDarkenOutOfFocus(amount: number): void;
  28919. enablePentagonBokeh(): void;
  28920. disablePentagonBokeh(): void;
  28921. enableNoiseBlur(): void;
  28922. disableNoiseBlur(): void;
  28923. setHighlightsGain(amount: number): void;
  28924. setHighlightsThreshold(amount: number): void;
  28925. disableHighlights(): void;
  28926. /**
  28927. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  28928. */
  28929. dispose(disableDepthRender?: boolean): void;
  28930. private _createChromaticAberrationPostProcess(ratio);
  28931. private _createHighlightsPostProcess(ratio);
  28932. private _createDepthOfFieldPostProcess(ratio);
  28933. private _createGrainTexture();
  28934. }
  28935. }
  28936. declare module BABYLON {
  28937. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  28938. /**
  28939. * The PassPostProcess id in the pipeline that contains the original scene color
  28940. * @type {string}
  28941. */
  28942. SSAOOriginalSceneColorEffect: string;
  28943. /**
  28944. * The SSAO PostProcess id in the pipeline
  28945. * @type {string}
  28946. */
  28947. SSAORenderEffect: string;
  28948. /**
  28949. * The horizontal blur PostProcess id in the pipeline
  28950. * @type {string}
  28951. */
  28952. SSAOBlurHRenderEffect: string;
  28953. /**
  28954. * The vertical blur PostProcess id in the pipeline
  28955. * @type {string}
  28956. */
  28957. SSAOBlurVRenderEffect: string;
  28958. /**
  28959. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  28960. * @type {string}
  28961. */
  28962. SSAOCombineRenderEffect: string;
  28963. /**
  28964. * The output strength of the SSAO post-process. Default value is 1.0.
  28965. * @type {number}
  28966. */
  28967. totalStrength: number;
  28968. /**
  28969. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  28970. * @type {number}
  28971. */
  28972. maxZ: number;
  28973. /**
  28974. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  28975. * @type {number}
  28976. */
  28977. minZAspect: number;
  28978. /**
  28979. * Number of samples used for the SSAO calculations. Default value is 8
  28980. * @type {number}
  28981. */
  28982. private _samples;
  28983. /**
  28984. * Dynamically generated sphere sampler.
  28985. * @type {number[]}
  28986. */
  28987. private _sampleSphere;
  28988. /**
  28989. * Blur filter offsets
  28990. * @type {number[]}
  28991. */
  28992. private _samplerOffsets;
  28993. samples: number;
  28994. /**
  28995. * Are we using bilateral blur ?
  28996. * @type {boolean}
  28997. */
  28998. private _expensiveBlur;
  28999. expensiveBlur: boolean;
  29000. /**
  29001. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  29002. * @type {number}
  29003. */
  29004. radius: number;
  29005. /**
  29006. * The base color of the SSAO post-process
  29007. * The final result is "base + ssao" between [0, 1]
  29008. * @type {number}
  29009. */
  29010. base: number;
  29011. /**
  29012. * Support test.
  29013. * @type {boolean}
  29014. */
  29015. static readonly IsSupported: boolean;
  29016. private _scene;
  29017. private _depthTexture;
  29018. private _normalTexture;
  29019. private _randomTexture;
  29020. private _originalColorPostProcess;
  29021. private _ssaoPostProcess;
  29022. private _blurHPostProcess;
  29023. private _blurVPostProcess;
  29024. private _ssaoCombinePostProcess;
  29025. private _firstUpdate;
  29026. /**
  29027. * @constructor
  29028. * @param {string} name - The rendering pipeline name
  29029. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  29030. * @param {any} ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, blurRatio: 1.0 }
  29031. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  29032. */
  29033. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  29034. /**
  29035. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  29036. */
  29037. dispose(disableGeometryBufferRenderer?: boolean): void;
  29038. private _createBlurPostProcess(ssaoRatio, blurRatio);
  29039. _rebuild(): void;
  29040. private _generateHemisphere();
  29041. private _createSSAOPostProcess(ratio);
  29042. private _createSSAOCombinePostProcess(ratio);
  29043. private _createRandomTexture();
  29044. }
  29045. }
  29046. declare module BABYLON {
  29047. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  29048. /**
  29049. * The PassPostProcess id in the pipeline that contains the original scene color
  29050. * @type {string}
  29051. */
  29052. SSAOOriginalSceneColorEffect: string;
  29053. /**
  29054. * The SSAO PostProcess id in the pipeline
  29055. * @type {string}
  29056. */
  29057. SSAORenderEffect: string;
  29058. /**
  29059. * The horizontal blur PostProcess id in the pipeline
  29060. * @type {string}
  29061. */
  29062. SSAOBlurHRenderEffect: string;
  29063. /**
  29064. * The vertical blur PostProcess id in the pipeline
  29065. * @type {string}
  29066. */
  29067. SSAOBlurVRenderEffect: string;
  29068. /**
  29069. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  29070. * @type {string}
  29071. */
  29072. SSAOCombineRenderEffect: string;
  29073. /**
  29074. * The output strength of the SSAO post-process. Default value is 1.0.
  29075. * @type {number}
  29076. */
  29077. totalStrength: number;
  29078. /**
  29079. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  29080. * @type {number}
  29081. */
  29082. radius: number;
  29083. /**
  29084. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  29085. * Must not be equal to fallOff and superior to fallOff.
  29086. * Default value is 0.975
  29087. * @type {number}
  29088. */
  29089. area: number;
  29090. /**
  29091. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  29092. * Must not be equal to area and inferior to area.
  29093. * Default value is 0.0
  29094. * @type {number}
  29095. */
  29096. fallOff: number;
  29097. /**
  29098. * The base color of the SSAO post-process
  29099. * The final result is "base + ssao" between [0, 1]
  29100. * @type {number}
  29101. */
  29102. base: number;
  29103. private _scene;
  29104. private _depthTexture;
  29105. private _randomTexture;
  29106. private _originalColorPostProcess;
  29107. private _ssaoPostProcess;
  29108. private _blurHPostProcess;
  29109. private _blurVPostProcess;
  29110. private _ssaoCombinePostProcess;
  29111. private _firstUpdate;
  29112. /**
  29113. * @constructor
  29114. * @param {string} name - The rendering pipeline name
  29115. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  29116. * @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 }
  29117. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  29118. */
  29119. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  29120. /**
  29121. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  29122. */
  29123. dispose(disableDepthRender?: boolean): void;
  29124. private _createBlurPostProcess(ratio);
  29125. _rebuild(): void;
  29126. private _createSSAOPostProcess(ratio);
  29127. private _createSSAOCombinePostProcess(ratio);
  29128. private _createRandomTexture();
  29129. }
  29130. }
  29131. declare module BABYLON {
  29132. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  29133. /**
  29134. * Public members
  29135. */
  29136. originalPostProcess: Nullable<PostProcess>;
  29137. downSampleX4PostProcess: Nullable<PostProcess>;
  29138. brightPassPostProcess: Nullable<PostProcess>;
  29139. blurHPostProcesses: PostProcess[];
  29140. blurVPostProcesses: PostProcess[];
  29141. textureAdderPostProcess: Nullable<PostProcess>;
  29142. volumetricLightPostProcess: Nullable<PostProcess>;
  29143. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  29144. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  29145. volumetricLightMergePostProces: Nullable<PostProcess>;
  29146. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  29147. luminancePostProcess: Nullable<PostProcess>;
  29148. luminanceDownSamplePostProcesses: PostProcess[];
  29149. hdrPostProcess: Nullable<PostProcess>;
  29150. textureAdderFinalPostProcess: Nullable<PostProcess>;
  29151. lensFlareFinalPostProcess: Nullable<PostProcess>;
  29152. hdrFinalPostProcess: Nullable<PostProcess>;
  29153. lensFlarePostProcess: Nullable<PostProcess>;
  29154. lensFlareComposePostProcess: Nullable<PostProcess>;
  29155. motionBlurPostProcess: Nullable<PostProcess>;
  29156. depthOfFieldPostProcess: Nullable<PostProcess>;
  29157. brightThreshold: number;
  29158. blurWidth: number;
  29159. horizontalBlur: boolean;
  29160. exposure: number;
  29161. lensTexture: Nullable<Texture>;
  29162. volumetricLightCoefficient: number;
  29163. volumetricLightPower: number;
  29164. volumetricLightBlurScale: number;
  29165. sourceLight: Nullable<SpotLight | DirectionalLight>;
  29166. hdrMinimumLuminance: number;
  29167. hdrDecreaseRate: number;
  29168. hdrIncreaseRate: number;
  29169. lensColorTexture: Nullable<Texture>;
  29170. lensFlareStrength: number;
  29171. lensFlareGhostDispersal: number;
  29172. lensFlareHaloWidth: number;
  29173. lensFlareDistortionStrength: number;
  29174. lensStarTexture: Nullable<Texture>;
  29175. lensFlareDirtTexture: Nullable<Texture>;
  29176. depthOfFieldDistance: number;
  29177. depthOfFieldBlurWidth: number;
  29178. motionStrength: number;
  29179. animations: Animation[];
  29180. /**
  29181. * Private members
  29182. */
  29183. private _scene;
  29184. private _currentDepthOfFieldSource;
  29185. private _basePostProcess;
  29186. private _hdrCurrentLuminance;
  29187. private _floatTextureType;
  29188. private _ratio;
  29189. private _bloomEnabled;
  29190. private _depthOfFieldEnabled;
  29191. private _vlsEnabled;
  29192. private _lensFlareEnabled;
  29193. private _hdrEnabled;
  29194. private _motionBlurEnabled;
  29195. private _motionBlurSamples;
  29196. private _volumetricLightStepsCount;
  29197. BloomEnabled: boolean;
  29198. DepthOfFieldEnabled: boolean;
  29199. LensFlareEnabled: boolean;
  29200. HDREnabled: boolean;
  29201. VLSEnabled: boolean;
  29202. MotionBlurEnabled: boolean;
  29203. volumetricLightStepsCount: number;
  29204. motionBlurSamples: number;
  29205. /**
  29206. * @constructor
  29207. * @param {string} name - The rendering pipeline name
  29208. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  29209. * @param {any} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  29210. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  29211. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  29212. */
  29213. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  29214. private _buildPipeline();
  29215. private _createDownSampleX4PostProcess(scene, ratio);
  29216. private _createBrightPassPostProcess(scene, ratio);
  29217. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  29218. private _createTextureAdderPostProcess(scene, ratio);
  29219. private _createVolumetricLightPostProcess(scene, ratio);
  29220. private _createLuminancePostProcesses(scene, textureType);
  29221. private _createHdrPostProcess(scene, ratio);
  29222. private _createLensFlarePostProcess(scene, ratio);
  29223. private _createDepthOfFieldPostProcess(scene, ratio);
  29224. private _createMotionBlurPostProcess(scene, ratio);
  29225. private _getDepthTexture();
  29226. private _disposePostProcesses();
  29227. dispose(): void;
  29228. serialize(): any;
  29229. /**
  29230. * Static members
  29231. */
  29232. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  29233. static LuminanceSteps: number;
  29234. }
  29235. }