babylon.d.ts 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515
  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. private _syncRoot;
  2115. animationStarted: boolean;
  2116. /**
  2117. * Gets the root Animatable used to synchronize and normalize animations
  2118. */
  2119. readonly syncRoot: Animatable;
  2120. /**
  2121. * Gets the current frame of the first RuntimeAnimation
  2122. * Used to synchronize Animatables
  2123. */
  2124. readonly masterFrame: number;
  2125. /**
  2126. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2127. */
  2128. weight: number;
  2129. /**
  2130. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2131. */
  2132. speedRatio: number;
  2133. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  2134. /**
  2135. * Synchronize and normalize current Animatable with a source Animatable.
  2136. * This is useful when using animation weights and when animations are not of the same length
  2137. * @param root defines the root Animatable to synchronize with
  2138. * @returns the current Animatable
  2139. */
  2140. syncWith(root: Animatable): Animatable;
  2141. getAnimations(): RuntimeAnimation[];
  2142. appendAnimations(target: any, animations: Animation[]): void;
  2143. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  2144. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  2145. reset(): void;
  2146. enableBlending(blendingSpeed: number): void;
  2147. disableBlending(): void;
  2148. goToFrame(frame: number): void;
  2149. pause(): void;
  2150. restart(): void;
  2151. stop(animationName?: string): void;
  2152. _animate(delay: number): boolean;
  2153. }
  2154. }
  2155. declare module BABYLON {
  2156. class AnimationRange {
  2157. name: string;
  2158. from: number;
  2159. to: number;
  2160. constructor(name: string, from: number, to: number);
  2161. clone(): AnimationRange;
  2162. }
  2163. /**
  2164. * Composed of a frame, and an action function
  2165. */
  2166. class AnimationEvent {
  2167. frame: number;
  2168. action: () => void;
  2169. onlyOnce: boolean | undefined;
  2170. isDone: boolean;
  2171. constructor(frame: number, action: () => void, onlyOnce?: boolean | undefined);
  2172. }
  2173. class PathCursor {
  2174. private path;
  2175. private _onchange;
  2176. value: number;
  2177. animations: Animation[];
  2178. constructor(path: Path2);
  2179. getPoint(): Vector3;
  2180. moveAhead(step?: number): PathCursor;
  2181. moveBack(step?: number): PathCursor;
  2182. move(step: number): PathCursor;
  2183. private ensureLimits();
  2184. private raiseOnChange();
  2185. onchange(f: (cursor: PathCursor) => void): PathCursor;
  2186. }
  2187. interface IAnimationKey {
  2188. frame: number;
  2189. value: any;
  2190. inTangent?: any;
  2191. outTangent?: any;
  2192. interpolation?: AnimationKeyInterpolation;
  2193. }
  2194. enum AnimationKeyInterpolation {
  2195. /**
  2196. * Do not interpolate between keys and use the start key value only. Tangents are ignored.
  2197. */
  2198. STEP = 1,
  2199. }
  2200. class Animation {
  2201. name: string;
  2202. targetProperty: string;
  2203. framePerSecond: number;
  2204. dataType: number;
  2205. loopMode: number | undefined;
  2206. enableBlending: boolean | undefined;
  2207. static AllowMatricesInterpolation: boolean;
  2208. private _keys;
  2209. private _easingFunction;
  2210. _runtimeAnimations: RuntimeAnimation[];
  2211. private _events;
  2212. targetPropertyPath: string[];
  2213. blendingSpeed: number;
  2214. private _ranges;
  2215. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  2216. /**
  2217. * Sets up an animation.
  2218. * @param property the property to animate
  2219. * @param animationType the animation type to apply
  2220. * @param easingFunction the easing function used in the animation
  2221. * @returns The created animation
  2222. */
  2223. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  2224. /**
  2225. * Create and start an animation on a node
  2226. * @param {string} name defines the name of the global animation that will be run on all nodes
  2227. * @param {BABYLON.Node} node defines the root node where the animation will take place
  2228. * @param {string} targetProperty defines property to animate
  2229. * @param {number} framePerSecond defines the number of frame per second yo use
  2230. * @param {number} totalFrame defines the number of frames in total
  2231. * @param {any} from defines the initial value
  2232. * @param {any} to defines the final value
  2233. * @param {number} loopMode defines which loop mode you want to use (off by default)
  2234. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  2235. * @param onAnimationEnd defines the callback to call when animation end
  2236. * @returns the animatable created for this animation
  2237. */
  2238. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  2239. /**
  2240. * Create and start an animation on a node and its descendants
  2241. * @param {string} name defines the name of the global animation that will be run on all nodes
  2242. * @param {BABYLON.Node} node defines the root node where the animation will take place
  2243. * @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.
  2244. * @param {string} targetProperty defines property to animate
  2245. * @param {number} framePerSecond defines the number of frame per second yo use
  2246. * @param {number} totalFrame defines the number of frames in total
  2247. * @param {any} from defines the initial value
  2248. * @param {any} to defines the final value
  2249. * @param {number} loopMode defines which loop mode you want to use (off by default)
  2250. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  2251. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  2252. * @returns the list of animatables created for all nodes
  2253. * @example https://www.babylonjs-playground.com/#MH0VLI
  2254. */
  2255. 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[]>;
  2256. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  2257. /**
  2258. * Transition property of the Camera to the target Value.
  2259. * @param property The property to transition
  2260. * @param targetValue The target Value of the property
  2261. * @param host The object where the property to animate belongs
  2262. * @param scene Scene used to run the animation
  2263. * @param frameRate Framerate (in frame/s) to use
  2264. * @param transition The transition type we want to use
  2265. * @param duration The duration of the animation, in milliseconds
  2266. * @param onAnimationEnd Call back trigger at the end of the animation.
  2267. */
  2268. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  2269. /**
  2270. * Return the array of runtime animations currently using this animation
  2271. */
  2272. readonly runtimeAnimations: RuntimeAnimation[];
  2273. readonly hasRunningRuntimeAnimations: boolean;
  2274. constructor(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number | undefined, enableBlending?: boolean | undefined);
  2275. /**
  2276. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  2277. */
  2278. toString(fullDetails?: boolean): string;
  2279. /**
  2280. * Add an event to this animation.
  2281. */
  2282. addEvent(event: AnimationEvent): void;
  2283. /**
  2284. * Remove all events found at the given frame
  2285. * @param frame
  2286. */
  2287. removeEvents(frame: number): void;
  2288. getEvents(): AnimationEvent[];
  2289. createRange(name: string, from: number, to: number): void;
  2290. deleteRange(name: string, deleteFrames?: boolean): void;
  2291. getRange(name: string): Nullable<AnimationRange>;
  2292. getKeys(): Array<IAnimationKey>;
  2293. getHighestFrame(): number;
  2294. getEasingFunction(): IEasingFunction;
  2295. setEasingFunction(easingFunction: EasingFunction): void;
  2296. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  2297. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  2298. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  2299. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  2300. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  2301. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  2302. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  2303. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  2304. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  2305. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  2306. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  2307. clone(): Animation;
  2308. setKeys(values: Array<IAnimationKey>): void;
  2309. serialize(): any;
  2310. private static _ANIMATIONTYPE_FLOAT;
  2311. private static _ANIMATIONTYPE_VECTOR3;
  2312. private static _ANIMATIONTYPE_QUATERNION;
  2313. private static _ANIMATIONTYPE_MATRIX;
  2314. private static _ANIMATIONTYPE_COLOR3;
  2315. private static _ANIMATIONTYPE_VECTOR2;
  2316. private static _ANIMATIONTYPE_SIZE;
  2317. private static _ANIMATIONLOOPMODE_RELATIVE;
  2318. private static _ANIMATIONLOOPMODE_CYCLE;
  2319. private static _ANIMATIONLOOPMODE_CONSTANT;
  2320. static readonly ANIMATIONTYPE_FLOAT: number;
  2321. static readonly ANIMATIONTYPE_VECTOR3: number;
  2322. static readonly ANIMATIONTYPE_VECTOR2: number;
  2323. static readonly ANIMATIONTYPE_SIZE: number;
  2324. static readonly ANIMATIONTYPE_QUATERNION: number;
  2325. static readonly ANIMATIONTYPE_MATRIX: number;
  2326. static readonly ANIMATIONTYPE_COLOR3: number;
  2327. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  2328. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  2329. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  2330. static Parse(parsedAnimation: any): Animation;
  2331. static AppendSerializedAnimations(source: IAnimatable, destination: any): any;
  2332. }
  2333. }
  2334. declare module BABYLON {
  2335. /**
  2336. * This class defines the direct association between an animation and a target
  2337. */
  2338. class TargetedAnimation {
  2339. animation: Animation;
  2340. target: any;
  2341. }
  2342. /**
  2343. * Use this class to create coordinated animations on multiple targets
  2344. */
  2345. class AnimationGroup implements IDisposable {
  2346. name: string;
  2347. private _scene;
  2348. private _targetedAnimations;
  2349. private _animatables;
  2350. private _from;
  2351. private _to;
  2352. private _isStarted;
  2353. private _speedRatio;
  2354. onAnimationEndObservable: Observable<TargetedAnimation>;
  2355. /**
  2356. * Define if the animations are started
  2357. */
  2358. readonly isStarted: boolean;
  2359. /**
  2360. * Gets or sets the speed ratio to use for all animations
  2361. */
  2362. /**
  2363. * Gets or sets the speed ratio to use for all animations
  2364. */
  2365. speedRatio: number;
  2366. /**
  2367. * Gets the targeted animations for this animation group
  2368. */
  2369. readonly targetedAnimations: Array<TargetedAnimation>;
  2370. /**
  2371. * returning the list of animatables controlled by this animation group.
  2372. */
  2373. readonly animatables: Array<Animatable>;
  2374. constructor(name: string, scene?: Nullable<Scene>);
  2375. /**
  2376. * Add an animation (with its target) in the group
  2377. * @param animation defines the animation we want to add
  2378. * @param target defines the target of the animation
  2379. * @returns the {BABYLON.TargetedAnimation} object
  2380. */
  2381. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  2382. /**
  2383. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  2384. * It can add constant keys at begin or end
  2385. * @param beginFrame defines the new begin frame for all animations. It can't be bigger than the smallest begin frame of all animations
  2386. * @param endFrame defines the new end frame for all animations. It can't be smaller than the largest end frame of all animations
  2387. */
  2388. normalize(beginFrame?: number, endFrame?: number): AnimationGroup;
  2389. /**
  2390. * Start all animations on given targets
  2391. * @param loop defines if animations must loop
  2392. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  2393. * @param from defines the from key (optional)
  2394. * @param to defines the to key (optional)
  2395. * @returns the current animation group
  2396. */
  2397. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  2398. /**
  2399. * Pause all animations
  2400. */
  2401. pause(): AnimationGroup;
  2402. /**
  2403. * Play all animations to initial state
  2404. * This function will start() the animations if they were not started or will restart() them if they were paused
  2405. * @param loop defines if animations must loop
  2406. */
  2407. play(loop?: boolean): AnimationGroup;
  2408. /**
  2409. * Reset all animations to initial state
  2410. */
  2411. reset(): AnimationGroup;
  2412. /**
  2413. * Restart animations from key 0
  2414. */
  2415. restart(): AnimationGroup;
  2416. /**
  2417. * Stop all animations
  2418. */
  2419. stop(): AnimationGroup;
  2420. /**
  2421. * Goes to a specific frame in this animation group
  2422. *
  2423. * @param frame the frame number to go to
  2424. * @return the animationGroup
  2425. */
  2426. goToFrame(frame: number): AnimationGroup;
  2427. /**
  2428. * Dispose all associated resources
  2429. */
  2430. dispose(): void;
  2431. }
  2432. }
  2433. declare module BABYLON {
  2434. /**
  2435. * Class used to override all child animations of a given target
  2436. */
  2437. class AnimationPropertiesOverride {
  2438. /**
  2439. * Gets or sets a value indicating if animation blending must be used
  2440. */
  2441. enableBlending: boolean;
  2442. /**
  2443. * Gets or sets the blending speed to use when enableBlending is true
  2444. */
  2445. blendingSpeed: number;
  2446. /**
  2447. * Gets or sets the default loop mode to use
  2448. */
  2449. loopMode: number;
  2450. }
  2451. }
  2452. declare module BABYLON {
  2453. interface IEasingFunction {
  2454. ease(gradient: number): number;
  2455. }
  2456. class EasingFunction implements IEasingFunction {
  2457. private static _EASINGMODE_EASEIN;
  2458. private static _EASINGMODE_EASEOUT;
  2459. private static _EASINGMODE_EASEINOUT;
  2460. static readonly EASINGMODE_EASEIN: number;
  2461. static readonly EASINGMODE_EASEOUT: number;
  2462. static readonly EASINGMODE_EASEINOUT: number;
  2463. private _easingMode;
  2464. setEasingMode(easingMode: number): void;
  2465. getEasingMode(): number;
  2466. easeInCore(gradient: number): number;
  2467. ease(gradient: number): number;
  2468. }
  2469. class CircleEase extends EasingFunction implements IEasingFunction {
  2470. easeInCore(gradient: number): number;
  2471. }
  2472. class BackEase extends EasingFunction implements IEasingFunction {
  2473. amplitude: number;
  2474. constructor(amplitude?: number);
  2475. easeInCore(gradient: number): number;
  2476. }
  2477. class BounceEase extends EasingFunction implements IEasingFunction {
  2478. bounces: number;
  2479. bounciness: number;
  2480. constructor(bounces?: number, bounciness?: number);
  2481. easeInCore(gradient: number): number;
  2482. }
  2483. class CubicEase extends EasingFunction implements IEasingFunction {
  2484. easeInCore(gradient: number): number;
  2485. }
  2486. class ElasticEase extends EasingFunction implements IEasingFunction {
  2487. oscillations: number;
  2488. springiness: number;
  2489. constructor(oscillations?: number, springiness?: number);
  2490. easeInCore(gradient: number): number;
  2491. }
  2492. class ExponentialEase extends EasingFunction implements IEasingFunction {
  2493. exponent: number;
  2494. constructor(exponent?: number);
  2495. easeInCore(gradient: number): number;
  2496. }
  2497. class PowerEase extends EasingFunction implements IEasingFunction {
  2498. power: number;
  2499. constructor(power?: number);
  2500. easeInCore(gradient: number): number;
  2501. }
  2502. class QuadraticEase extends EasingFunction implements IEasingFunction {
  2503. easeInCore(gradient: number): number;
  2504. }
  2505. class QuarticEase extends EasingFunction implements IEasingFunction {
  2506. easeInCore(gradient: number): number;
  2507. }
  2508. class QuinticEase extends EasingFunction implements IEasingFunction {
  2509. easeInCore(gradient: number): number;
  2510. }
  2511. class SineEase extends EasingFunction implements IEasingFunction {
  2512. easeInCore(gradient: number): number;
  2513. }
  2514. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  2515. x1: number;
  2516. y1: number;
  2517. x2: number;
  2518. y2: number;
  2519. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  2520. easeInCore(gradient: number): number;
  2521. }
  2522. }
  2523. declare module BABYLON {
  2524. class RuntimeAnimation {
  2525. private _currentFrame;
  2526. private _animation;
  2527. private _target;
  2528. private _host;
  2529. private _originalValue;
  2530. private _originalBlendValue;
  2531. private _offsetsCache;
  2532. private _highLimitsCache;
  2533. private _stopped;
  2534. private _blendingFactor;
  2535. private _scene;
  2536. private _currentValue;
  2537. private _activeTarget;
  2538. private _targetPath;
  2539. private _weight;
  2540. /**
  2541. * Gets the current frame
  2542. */
  2543. readonly currentFrame: number;
  2544. /**
  2545. * Gets the weight of the runtime animation
  2546. */
  2547. readonly weight: number;
  2548. /**
  2549. * Gets the original value of the runtime animation
  2550. */
  2551. readonly originalValue: any;
  2552. /**
  2553. * Gets the current value of the runtime animation
  2554. */
  2555. readonly currentValue: any;
  2556. /**
  2557. * Gets the path where to store the animated value in the target
  2558. */
  2559. readonly targetPath: string;
  2560. /**
  2561. * Gets the actual target of the runtime animation
  2562. */
  2563. readonly target: any;
  2564. /**
  2565. * Create a new RuntimeAnimation object
  2566. * @param target defines the target of the animation
  2567. * @param animation defines the source {BABYLON.Animation} object
  2568. * @param scene defines the hosting scene
  2569. * @param host defines the initiating Animatable
  2570. */
  2571. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  2572. readonly animation: Animation;
  2573. reset(): void;
  2574. isStopped(): boolean;
  2575. dispose(): void;
  2576. private _getKeyValue(value);
  2577. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  2578. /**
  2579. * Affect the interpolated value to the target
  2580. * @param currentValue defines the value computed by the animation
  2581. * @param weight defines the weight to apply to this value
  2582. */
  2583. setValue(currentValue: any, weight?: number): void;
  2584. private _getCorrectLoopMode();
  2585. /**
  2586. * Move the current animation to a given frame
  2587. * @param frame defines the frame to move to
  2588. */
  2589. goToFrame(frame: number): void;
  2590. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  2591. private _ratioOffset;
  2592. private _previousDelay;
  2593. private _previousRatio;
  2594. /**
  2595. * Execute the current animation
  2596. * @param delay defines the delay to add to the current frame
  2597. * @param from defines the lower bound of the animation range
  2598. * @param to defines the upper bound of the animation range
  2599. * @param loop defines if the current animation must loop
  2600. * @param speedRatio defines the current speed ratio
  2601. * @param weight defines the weight of the animation (default is -1 so no weight)
  2602. * @returns a boolean indicating if the animation has ended
  2603. */
  2604. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  2605. }
  2606. }
  2607. declare module BABYLON {
  2608. class Analyser {
  2609. SMOOTHING: number;
  2610. FFT_SIZE: number;
  2611. BARGRAPHAMPLITUDE: number;
  2612. DEBUGCANVASPOS: {
  2613. x: number;
  2614. y: number;
  2615. };
  2616. DEBUGCANVASSIZE: {
  2617. width: number;
  2618. height: number;
  2619. };
  2620. private _byteFreqs;
  2621. private _byteTime;
  2622. private _floatFreqs;
  2623. private _webAudioAnalyser;
  2624. private _debugCanvas;
  2625. private _debugCanvasContext;
  2626. private _scene;
  2627. private _registerFunc;
  2628. private _audioEngine;
  2629. constructor(scene: Scene);
  2630. getFrequencyBinCount(): number;
  2631. getByteFrequencyData(): Uint8Array;
  2632. getByteTimeDomainData(): Uint8Array;
  2633. getFloatFrequencyData(): Uint8Array;
  2634. drawDebugCanvas(): void;
  2635. stopDebugCanvas(): void;
  2636. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  2637. dispose(): void;
  2638. }
  2639. }
  2640. declare module BABYLON {
  2641. class AudioEngine {
  2642. private _audioContext;
  2643. private _audioContextInitialized;
  2644. canUseWebAudio: boolean;
  2645. masterGain: GainNode;
  2646. private _connectedAnalyser;
  2647. WarnedWebAudioUnsupported: boolean;
  2648. unlocked: boolean;
  2649. onAudioUnlocked: () => any;
  2650. isMP3supported: boolean;
  2651. isOGGsupported: boolean;
  2652. readonly audioContext: Nullable<AudioContext>;
  2653. constructor();
  2654. private _unlockiOSaudio();
  2655. private _initializeAudioContext();
  2656. dispose(): void;
  2657. getGlobalVolume(): number;
  2658. setGlobalVolume(newVolume: number): void;
  2659. connectToAnalyser(analyser: Analyser): void;
  2660. }
  2661. }
  2662. declare module BABYLON {
  2663. class Sound {
  2664. name: string;
  2665. autoplay: boolean;
  2666. loop: boolean;
  2667. useCustomAttenuation: boolean;
  2668. soundTrackId: number;
  2669. spatialSound: boolean;
  2670. refDistance: number;
  2671. rolloffFactor: number;
  2672. maxDistance: number;
  2673. distanceModel: string;
  2674. private _panningModel;
  2675. onended: () => any;
  2676. private _playbackRate;
  2677. private _streaming;
  2678. private _startTime;
  2679. private _startOffset;
  2680. private _position;
  2681. private _localDirection;
  2682. private _volume;
  2683. private _isReadyToPlay;
  2684. isPlaying: boolean;
  2685. isPaused: boolean;
  2686. private _isDirectional;
  2687. private _readyToPlayCallback;
  2688. private _audioBuffer;
  2689. private _soundSource;
  2690. private _streamingSource;
  2691. private _soundPanner;
  2692. private _soundGain;
  2693. private _inputAudioNode;
  2694. private _ouputAudioNode;
  2695. private _coneInnerAngle;
  2696. private _coneOuterAngle;
  2697. private _coneOuterGain;
  2698. private _scene;
  2699. private _connectedMesh;
  2700. private _customAttenuationFunction;
  2701. private _registerFunc;
  2702. private _isOutputConnected;
  2703. private _htmlAudioElement;
  2704. private _urlType;
  2705. /**
  2706. * Create a sound and attach it to a scene
  2707. * @param name Name of your sound
  2708. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  2709. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  2710. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  2711. */
  2712. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  2713. dispose(): void;
  2714. isReady(): boolean;
  2715. private _soundLoaded(audioData);
  2716. setAudioBuffer(audioBuffer: AudioBuffer): void;
  2717. updateOptions(options: any): void;
  2718. private _createSpatialParameters();
  2719. private _updateSpatialParameters();
  2720. switchPanningModelToHRTF(): void;
  2721. switchPanningModelToEqualPower(): void;
  2722. private _switchPanningModel();
  2723. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  2724. /**
  2725. * Transform this sound into a directional source
  2726. * @param coneInnerAngle Size of the inner cone in degree
  2727. * @param coneOuterAngle Size of the outer cone in degree
  2728. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  2729. */
  2730. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  2731. setPosition(newPosition: Vector3): void;
  2732. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  2733. private _updateDirection();
  2734. updateDistanceFromListener(): void;
  2735. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  2736. /**
  2737. * Play the sound
  2738. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  2739. * @param offset (optional) Start the sound setting it at a specific time
  2740. */
  2741. play(time?: number, offset?: number): void;
  2742. private _onended();
  2743. /**
  2744. * Stop the sound
  2745. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  2746. */
  2747. stop(time?: number): void;
  2748. pause(): void;
  2749. setVolume(newVolume: number, time?: number): void;
  2750. setPlaybackRate(newPlaybackRate: number): void;
  2751. getVolume(): number;
  2752. attachToMesh(meshToConnectTo: AbstractMesh): void;
  2753. detachFromMesh(): void;
  2754. private _onRegisterAfterWorldMatrixUpdate(node);
  2755. clone(): Nullable<Sound>;
  2756. getAudioBuffer(): AudioBuffer | null;
  2757. serialize(): any;
  2758. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  2759. }
  2760. }
  2761. declare module BABYLON {
  2762. class SoundTrack {
  2763. private _outputAudioNode;
  2764. private _scene;
  2765. id: number;
  2766. soundCollection: Array<Sound>;
  2767. private _isMainTrack;
  2768. private _connectedAnalyser;
  2769. private _options;
  2770. private _isInitialized;
  2771. constructor(scene: Scene, options?: any);
  2772. private _initializeSoundTrackAudioGraph();
  2773. dispose(): void;
  2774. AddSound(sound: Sound): void;
  2775. RemoveSound(sound: Sound): void;
  2776. setVolume(newVolume: number): void;
  2777. switchPanningModelToHRTF(): void;
  2778. switchPanningModelToEqualPower(): void;
  2779. connectToAnalyser(analyser: Analyser): void;
  2780. }
  2781. }
  2782. declare module BABYLON {
  2783. interface Behavior<T extends Node> {
  2784. name: string;
  2785. init(): void;
  2786. attach(node: T): void;
  2787. detach(): void;
  2788. }
  2789. }
  2790. declare module BABYLON {
  2791. class Bone extends Node {
  2792. name: string;
  2793. private static _tmpVecs;
  2794. private static _tmpQuat;
  2795. private static _tmpMats;
  2796. children: Bone[];
  2797. animations: Animation[];
  2798. length: number;
  2799. _index: Nullable<number>;
  2800. private _skeleton;
  2801. private _localMatrix;
  2802. private _restPose;
  2803. private _baseMatrix;
  2804. private _worldTransform;
  2805. private _absoluteTransform;
  2806. private _invertedAbsoluteTransform;
  2807. private _parent;
  2808. private _scaleMatrix;
  2809. private _scaleVector;
  2810. private _negateScaleChildren;
  2811. private _scalingDeterminant;
  2812. _matrix: Matrix;
  2813. constructor(name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  2814. getSkeleton(): Skeleton;
  2815. getParent(): Nullable<Bone>;
  2816. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  2817. getLocalMatrix(): Matrix;
  2818. getBaseMatrix(): Matrix;
  2819. getRestPose(): Matrix;
  2820. returnToRest(): void;
  2821. getWorldMatrix(): Matrix;
  2822. getInvertedAbsoluteTransform(): Matrix;
  2823. getAbsoluteTransform(): Matrix;
  2824. position: Vector3;
  2825. rotation: Vector3;
  2826. rotationQuaternion: Quaternion;
  2827. scaling: Vector3;
  2828. /**
  2829. * Gets the animation properties override
  2830. */
  2831. readonly animationPropertiesOverride: AnimationPropertiesOverride;
  2832. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean): void;
  2833. _updateDifferenceMatrix(rootMatrix?: Matrix): void;
  2834. markAsDirty(): void;
  2835. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  2836. /**
  2837. * Translate the bone in local or world space.
  2838. * @param vec The amount to translate the bone.
  2839. * @param space The space that the translation is in.
  2840. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2841. */
  2842. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2843. /**
  2844. * Set the postion of the bone in local or world space.
  2845. * @param position The position to set the bone.
  2846. * @param space The space that the position is in.
  2847. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2848. */
  2849. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2850. /**
  2851. * Set the absolute postion of the bone (world space).
  2852. * @param position The position to set the bone.
  2853. * @param mesh The mesh that this bone is attached to.
  2854. */
  2855. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  2856. /**
  2857. * Set the scale of the bone on the x, y and z axes.
  2858. * @param x The scale of the bone on the x axis.
  2859. * @param x The scale of the bone on the y axis.
  2860. * @param z The scale of the bone on the z axis.
  2861. * @param scaleChildren Set this to true if children of the bone should be scaled.
  2862. */
  2863. setScale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  2864. /**
  2865. * Scale the bone on the x, y and z axes.
  2866. * @param x The amount to scale the bone on the x axis.
  2867. * @param x The amount to scale the bone on the y axis.
  2868. * @param z The amount to scale the bone on the z axis.
  2869. * @param scaleChildren Set this to true if children of the bone should be scaled.
  2870. */
  2871. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  2872. /**
  2873. * Set the yaw, pitch, and roll of the bone in local or world space.
  2874. * @param yaw The rotation of the bone on the y axis.
  2875. * @param pitch The rotation of the bone on the x axis.
  2876. * @param roll The rotation of the bone on the z axis.
  2877. * @param space The space that the axes of rotation are in.
  2878. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2879. */
  2880. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  2881. /**
  2882. * Rotate the bone on an axis in local or world space.
  2883. * @param axis The axis to rotate the bone on.
  2884. * @param amount The amount to rotate the bone.
  2885. * @param space The space that the axis is in.
  2886. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2887. */
  2888. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  2889. /**
  2890. * Set the rotation of the bone to a particular axis angle in local or world space.
  2891. * @param axis The axis to rotate the bone on.
  2892. * @param angle The angle that the bone should be rotated to.
  2893. * @param space The space that the axis is in.
  2894. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2895. */
  2896. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  2897. /**
  2898. * Set the euler rotation of the bone in local of world space.
  2899. * @param rotation The euler rotation that the bone should be set to.
  2900. * @param space The space that the rotation is in.
  2901. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2902. */
  2903. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2904. /**
  2905. * Set the quaternion rotation of the bone in local of world space.
  2906. * @param quat The quaternion rotation that the bone should be set to.
  2907. * @param space The space that the rotation is in.
  2908. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2909. */
  2910. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  2911. /**
  2912. * Set the rotation matrix of the bone in local of world space.
  2913. * @param rotMat The rotation matrix that the bone should be set to.
  2914. * @param space The space that the rotation is in.
  2915. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2916. */
  2917. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  2918. private _rotateWithMatrix(rmat, space?, mesh?);
  2919. private _getNegativeRotationToRef(rotMatInv, space?, mesh?);
  2920. /**
  2921. * Get the scale of the bone
  2922. * @returns the scale of the bone
  2923. */
  2924. getScale(): Vector3;
  2925. /**
  2926. * Copy the scale of the bone to a vector3.
  2927. * @param result The vector3 to copy the scale to
  2928. */
  2929. getScaleToRef(result: Vector3): void;
  2930. /**
  2931. * Get the position of the bone in local or world space.
  2932. * @param space The space that the returned position is in.
  2933. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2934. * @returns The position of the bone
  2935. */
  2936. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  2937. /**
  2938. * Copy the position of the bone to a vector3 in local or world space.
  2939. * @param space The space that the returned position is in.
  2940. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2941. * @param result The vector3 to copy the position to.
  2942. */
  2943. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  2944. /**
  2945. * Get the absolute position of the bone (world space).
  2946. * @param mesh The mesh that this bone is attached to.
  2947. * @returns The absolute position of the bone
  2948. */
  2949. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  2950. /**
  2951. * Copy the absolute position of the bone (world space) to the result param.
  2952. * @param mesh The mesh that this bone is attached to.
  2953. * @param result The vector3 to copy the absolute position to.
  2954. */
  2955. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  2956. /**
  2957. * Compute the absolute transforms of this bone and its children.
  2958. */
  2959. computeAbsoluteTransforms(): void;
  2960. private _syncScaleVector();
  2961. /**
  2962. * Get the world direction from an axis that is in the local space of the bone.
  2963. * @param localAxis The local direction that is used to compute the world direction.
  2964. * @param mesh The mesh that this bone is attached to.
  2965. * @returns The world direction
  2966. */
  2967. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2968. /**
  2969. * Copy the world direction to a vector3 from an axis that is in the local space of the bone.
  2970. * @param localAxis The local direction that is used to compute the world direction.
  2971. * @param mesh The mesh that this bone is attached to.
  2972. * @param result The vector3 that the world direction will be copied to.
  2973. */
  2974. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2975. /**
  2976. * Get the euler rotation of the bone in local or world space.
  2977. * @param space The space that the rotation should be in.
  2978. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2979. * @returns The euler rotation
  2980. */
  2981. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  2982. /**
  2983. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space.
  2984. * @param space The space that the rotation should be in.
  2985. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2986. * @param result The vector3 that the rotation should be copied to.
  2987. */
  2988. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2989. /**
  2990. * Get the quaternion rotation of the bone in either local or world space.
  2991. * @param space The space that the rotation should be in.
  2992. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2993. * @returns The quaternion rotation
  2994. */
  2995. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  2996. /**
  2997. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space.
  2998. * @param space The space that the rotation should be in.
  2999. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3000. * @param result The quaternion that the rotation should be copied to.
  3001. */
  3002. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  3003. /**
  3004. * Get the rotation matrix of the bone in local or world space.
  3005. * @param space The space that the rotation should be in.
  3006. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3007. * @returns The rotation matrix
  3008. */
  3009. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  3010. /**
  3011. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space.
  3012. * @param space The space that the rotation should be in.
  3013. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3014. * @param result The quaternion that the rotation should be copied to.
  3015. */
  3016. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  3017. /**
  3018. * Get the world position of a point that is in the local space of the bone.
  3019. * @param position The local position
  3020. * @param mesh The mesh that this bone is attached to.
  3021. * @returns The world position
  3022. */
  3023. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  3024. /**
  3025. * Get the world position of a point that is in the local space of the bone and copy it to the result param.
  3026. * @param position The local position
  3027. * @param mesh The mesh that this bone is attached to.
  3028. * @param result The vector3 that the world position should be copied to.
  3029. */
  3030. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  3031. /**
  3032. * Get the local position of a point that is in world space.
  3033. * @param position The world position
  3034. * @param mesh The mesh that this bone is attached to.
  3035. * @returns The local position
  3036. */
  3037. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  3038. /**
  3039. * Get the local position of a point that is in world space and copy it to the result param.
  3040. * @param position The world position
  3041. * @param mesh The mesh that this bone is attached to.
  3042. * @param result The vector3 that the local position should be copied to.
  3043. */
  3044. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  3045. }
  3046. }
  3047. declare module BABYLON {
  3048. class BoneIKController {
  3049. private static _tmpVecs;
  3050. private static _tmpQuat;
  3051. private static _tmpMats;
  3052. targetMesh: AbstractMesh;
  3053. poleTargetMesh: AbstractMesh;
  3054. poleTargetBone: Nullable<Bone>;
  3055. targetPosition: Vector3;
  3056. poleTargetPosition: Vector3;
  3057. poleTargetLocalOffset: Vector3;
  3058. poleAngle: number;
  3059. mesh: AbstractMesh;
  3060. slerpAmount: number;
  3061. private _bone1Quat;
  3062. private _bone1Mat;
  3063. private _bone2Ang;
  3064. private _bone1;
  3065. private _bone2;
  3066. private _bone1Length;
  3067. private _bone2Length;
  3068. private _maxAngle;
  3069. private _maxReach;
  3070. private _rightHandedSystem;
  3071. private _bendAxis;
  3072. private _slerping;
  3073. private _adjustRoll;
  3074. maxAngle: number;
  3075. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  3076. targetMesh?: AbstractMesh;
  3077. poleTargetMesh?: AbstractMesh;
  3078. poleTargetBone?: Bone;
  3079. poleTargetLocalOffset?: Vector3;
  3080. poleAngle?: number;
  3081. bendAxis?: Vector3;
  3082. maxAngle?: number;
  3083. slerpAmount?: number;
  3084. });
  3085. private _setMaxAngle(ang);
  3086. update(): void;
  3087. }
  3088. }
  3089. declare module BABYLON {
  3090. class BoneLookController {
  3091. private static _tmpVecs;
  3092. private static _tmpQuat;
  3093. private static _tmpMats;
  3094. /**
  3095. * The target Vector3 that the bone will look at.
  3096. */
  3097. target: Vector3;
  3098. /**
  3099. * The mesh that the bone is attached to.
  3100. */
  3101. mesh: AbstractMesh;
  3102. /**
  3103. * The bone that will be looking to the target.
  3104. */
  3105. bone: Bone;
  3106. /**
  3107. * The up axis of the coordinate system that is used when the bone is rotated.
  3108. */
  3109. upAxis: Vector3;
  3110. /**
  3111. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  3112. */
  3113. upAxisSpace: Space;
  3114. /**
  3115. * Used to make an adjustment to the yaw of the bone.
  3116. */
  3117. adjustYaw: number;
  3118. /**
  3119. * Used to make an adjustment to the pitch of the bone.
  3120. */
  3121. adjustPitch: number;
  3122. /**
  3123. * Used to make an adjustment to the roll of the bone.
  3124. */
  3125. adjustRoll: number;
  3126. /**
  3127. * 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).
  3128. */
  3129. slerpAmount: number;
  3130. private _minYaw;
  3131. private _maxYaw;
  3132. private _minPitch;
  3133. private _maxPitch;
  3134. private _minYawSin;
  3135. private _minYawCos;
  3136. private _maxYawSin;
  3137. private _maxYawCos;
  3138. private _midYawConstraint;
  3139. private _minPitchTan;
  3140. private _maxPitchTan;
  3141. private _boneQuat;
  3142. private _slerping;
  3143. private _transformYawPitch;
  3144. private _transformYawPitchInv;
  3145. private _firstFrameSkipped;
  3146. private _yawRange;
  3147. private _fowardAxis;
  3148. /**
  3149. * Get/set the minimum yaw angle that the bone can look to.
  3150. */
  3151. minYaw: number;
  3152. /**
  3153. * Get/set the maximum yaw angle that the bone can look to.
  3154. */
  3155. maxYaw: number;
  3156. /**
  3157. * Get/set the minimum pitch angle that the bone can look to.
  3158. */
  3159. minPitch: number;
  3160. /**
  3161. * Get/set the maximum pitch angle that the bone can look to.
  3162. */
  3163. maxPitch: number;
  3164. /**
  3165. * Create a BoneLookController
  3166. * @param mesh the mesh that the bone belongs to
  3167. * @param bone the bone that will be looking to the target
  3168. * @param target the target Vector3 to look at
  3169. * @param settings optional settings:
  3170. * - maxYaw: the maximum angle the bone will yaw to
  3171. * - minYaw: the minimum angle the bone will yaw to
  3172. * - maxPitch: the maximum angle the bone will pitch to
  3173. * - minPitch: the minimum angle the bone will yaw to
  3174. * - slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  3175. * - upAxis: the up axis of the coordinate system
  3176. * - upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  3177. * - yawAxis: set yawAxis if the bone does not yaw on the y axis
  3178. * - pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  3179. * - adjustYaw: used to make an adjustment to the yaw of the bone
  3180. * - adjustPitch: used to make an adjustment to the pitch of the bone
  3181. * - adjustRoll: used to make an adjustment to the roll of the bone
  3182. **/
  3183. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  3184. maxYaw?: number;
  3185. minYaw?: number;
  3186. maxPitch?: number;
  3187. minPitch?: number;
  3188. slerpAmount?: number;
  3189. upAxis?: Vector3;
  3190. upAxisSpace?: Space;
  3191. yawAxis?: Vector3;
  3192. pitchAxis?: Vector3;
  3193. adjustYaw?: number;
  3194. adjustPitch?: number;
  3195. adjustRoll?: number;
  3196. });
  3197. /**
  3198. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender()).
  3199. */
  3200. update(): void;
  3201. private _getAngleDiff(ang1, ang2);
  3202. private _getAngleBetween(ang1, ang2);
  3203. private _isAngleBetween(ang, ang1, ang2);
  3204. }
  3205. }
  3206. declare module BABYLON {
  3207. class Skeleton implements IAnimatable {
  3208. name: string;
  3209. id: string;
  3210. bones: Bone[];
  3211. dimensionsAtRest: Vector3;
  3212. needInitialSkinMatrix: boolean;
  3213. animations: Array<Animation>;
  3214. private _scene;
  3215. private _isDirty;
  3216. private _transformMatrices;
  3217. private _meshesWithPoseMatrix;
  3218. private _animatables;
  3219. private _identity;
  3220. private _synchronizedWithMesh;
  3221. private _ranges;
  3222. private _lastAbsoluteTransformsUpdateId;
  3223. /**
  3224. * Specifies if the skeleton should be serialized.
  3225. */
  3226. doNotSerialize: boolean;
  3227. /**
  3228. * Gets or sets the animation properties override
  3229. */
  3230. animationPropertiesOverride: AnimationPropertiesOverride;
  3231. /**
  3232. * An event triggered before computing the skeleton's matrices
  3233. * @type {BABYLON.Observable}
  3234. */
  3235. onBeforeComputeObservable: Observable<Skeleton>;
  3236. constructor(name: string, id: string, scene: Scene);
  3237. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  3238. getScene(): Scene;
  3239. /**
  3240. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3241. */
  3242. toString(fullDetails?: boolean): string;
  3243. /**
  3244. * Get bone's index searching by name
  3245. * @param {string} name is bone's name to search for
  3246. * @return {number} Indice of the bone. Returns -1 if not found
  3247. */
  3248. getBoneIndexByName(name: string): number;
  3249. createAnimationRange(name: string, from: number, to: number): void;
  3250. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  3251. getAnimationRange(name: string): Nullable<AnimationRange>;
  3252. /**
  3253. * Returns as an Array, all AnimationRanges defined on this skeleton
  3254. */
  3255. getAnimationRanges(): Nullable<AnimationRange>[];
  3256. /**
  3257. * note: This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  3258. */
  3259. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  3260. returnToRest(): void;
  3261. private _getHighestAnimationFrame();
  3262. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  3263. _markAsDirty(): void;
  3264. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  3265. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  3266. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  3267. prepare(): void;
  3268. getAnimatables(): IAnimatable[];
  3269. clone(name: string, id: string): Skeleton;
  3270. enableBlending(blendingSpeed?: number): void;
  3271. dispose(): void;
  3272. serialize(): any;
  3273. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  3274. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  3275. getPoseMatrix(): Nullable<Matrix>;
  3276. sortBones(): void;
  3277. private _sortBones(index, bones, visited);
  3278. }
  3279. }
  3280. declare module BABYLON {
  3281. class BoundingBox implements ICullable {
  3282. minimum: Vector3;
  3283. maximum: Vector3;
  3284. vectors: Vector3[];
  3285. center: Vector3;
  3286. centerWorld: Vector3;
  3287. extendSize: Vector3;
  3288. extendSizeWorld: Vector3;
  3289. directions: Vector3[];
  3290. vectorsWorld: Vector3[];
  3291. minimumWorld: Vector3;
  3292. maximumWorld: Vector3;
  3293. private _worldMatrix;
  3294. constructor(minimum: Vector3, maximum: Vector3);
  3295. getWorldMatrix(): Matrix;
  3296. setWorldMatrix(matrix: Matrix): BoundingBox;
  3297. _update(world: Matrix): void;
  3298. isInFrustum(frustumPlanes: Plane[]): boolean;
  3299. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  3300. intersectsPoint(point: Vector3): boolean;
  3301. intersectsSphere(sphere: BoundingSphere): boolean;
  3302. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  3303. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  3304. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  3305. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  3306. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  3307. }
  3308. }
  3309. declare module BABYLON {
  3310. interface ICullable {
  3311. isInFrustum(frustumPlanes: Plane[]): boolean;
  3312. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  3313. }
  3314. class BoundingInfo implements ICullable {
  3315. minimum: Vector3;
  3316. maximum: Vector3;
  3317. boundingBox: BoundingBox;
  3318. boundingSphere: BoundingSphere;
  3319. private _isLocked;
  3320. constructor(minimum: Vector3, maximum: Vector3);
  3321. isLocked: boolean;
  3322. update(world: Matrix): void;
  3323. /**
  3324. * Recreate the bounding info to be centered around a specific point given a specific extend.
  3325. * @param center New center of the bounding info
  3326. * @param extend New extend of the bounding info
  3327. */
  3328. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  3329. isInFrustum(frustumPlanes: Plane[]): boolean;
  3330. /**
  3331. * Gets the world distance between the min and max points of the bounding box
  3332. */
  3333. readonly diagonalLength: number;
  3334. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  3335. _checkCollision(collider: Collider): boolean;
  3336. intersectsPoint(point: Vector3): boolean;
  3337. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  3338. }
  3339. }
  3340. declare module BABYLON {
  3341. class BoundingSphere {
  3342. minimum: Vector3;
  3343. maximum: Vector3;
  3344. center: Vector3;
  3345. radius: number;
  3346. centerWorld: Vector3;
  3347. radiusWorld: number;
  3348. private _tempRadiusVector;
  3349. constructor(minimum: Vector3, maximum: Vector3);
  3350. _update(world: Matrix): void;
  3351. isInFrustum(frustumPlanes: Plane[]): boolean;
  3352. intersectsPoint(point: Vector3): boolean;
  3353. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  3354. }
  3355. }
  3356. declare module BABYLON {
  3357. class Ray {
  3358. origin: Vector3;
  3359. direction: Vector3;
  3360. length: number;
  3361. private _edge1;
  3362. private _edge2;
  3363. private _pvec;
  3364. private _tvec;
  3365. private _qvec;
  3366. private _tmpRay;
  3367. constructor(origin: Vector3, direction: Vector3, length?: number);
  3368. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  3369. intersectsBox(box: BoundingBox): boolean;
  3370. intersectsSphere(sphere: BoundingSphere): boolean;
  3371. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  3372. intersectsPlane(plane: Plane): Nullable<number>;
  3373. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  3374. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  3375. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  3376. private static smallnum;
  3377. private static rayl;
  3378. /**
  3379. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  3380. * @param sega the first point of the segment to test the intersection against
  3381. * @param segb the second point of the segment to test the intersection against
  3382. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  3383. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  3384. */
  3385. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  3386. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  3387. static Zero(): Ray;
  3388. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  3389. /**
  3390. * 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
  3391. * transformed to the given world matrix.
  3392. * @param origin The origin point
  3393. * @param end The end point
  3394. * @param world a matrix to transform the ray to. Default is the identity matrix.
  3395. */
  3396. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  3397. static Transform(ray: Ray, matrix: Matrix): Ray;
  3398. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  3399. }
  3400. }
  3401. declare module BABYLON {
  3402. class ArcRotateCamera extends TargetCamera {
  3403. alpha: number;
  3404. beta: number;
  3405. radius: number;
  3406. protected _target: Vector3;
  3407. protected _targetHost: Nullable<AbstractMesh>;
  3408. target: Vector3;
  3409. inertialAlphaOffset: number;
  3410. inertialBetaOffset: number;
  3411. inertialRadiusOffset: number;
  3412. lowerAlphaLimit: Nullable<number>;
  3413. upperAlphaLimit: Nullable<number>;
  3414. lowerBetaLimit: number;
  3415. upperBetaLimit: number;
  3416. lowerRadiusLimit: Nullable<number>;
  3417. upperRadiusLimit: Nullable<number>;
  3418. inertialPanningX: number;
  3419. inertialPanningY: number;
  3420. pinchToPanMaxDistance: number;
  3421. panningDistanceLimit: Nullable<number>;
  3422. panningOriginTarget: Vector3;
  3423. panningInertia: number;
  3424. angularSensibilityX: number;
  3425. angularSensibilityY: number;
  3426. pinchPrecision: number;
  3427. pinchDeltaPercentage: number;
  3428. panningSensibility: number;
  3429. keysUp: number[];
  3430. keysDown: number[];
  3431. keysLeft: number[];
  3432. keysRight: number[];
  3433. wheelPrecision: number;
  3434. wheelDeltaPercentage: number;
  3435. zoomOnFactor: number;
  3436. targetScreenOffset: Vector2;
  3437. allowUpsideDown: boolean;
  3438. _viewMatrix: Matrix;
  3439. _useCtrlForPanning: boolean;
  3440. _panningMouseButton: number;
  3441. inputs: ArcRotateCameraInputsManager;
  3442. _reset: () => void;
  3443. panningAxis: Vector3;
  3444. protected _localDirection: Vector3;
  3445. protected _transformedDirection: Vector3;
  3446. private _bouncingBehavior;
  3447. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  3448. useBouncingBehavior: boolean;
  3449. private _framingBehavior;
  3450. readonly framingBehavior: Nullable<FramingBehavior>;
  3451. useFramingBehavior: boolean;
  3452. private _autoRotationBehavior;
  3453. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  3454. useAutoRotationBehavior: boolean;
  3455. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  3456. onCollide: (collidedMesh: AbstractMesh) => void;
  3457. checkCollisions: boolean;
  3458. collisionRadius: Vector3;
  3459. protected _collider: Collider;
  3460. protected _previousPosition: Vector3;
  3461. protected _collisionVelocity: Vector3;
  3462. protected _newPosition: Vector3;
  3463. protected _previousAlpha: number;
  3464. protected _previousBeta: number;
  3465. protected _previousRadius: number;
  3466. protected _collisionTriggered: boolean;
  3467. protected _targetBoundingCenter: Nullable<Vector3>;
  3468. private _computationVector;
  3469. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
  3470. _initCache(): void;
  3471. _updateCache(ignoreParentClass?: boolean): void;
  3472. protected _getTargetPosition(): Vector3;
  3473. /**
  3474. * Store current camera state (fov, position, etc..)
  3475. */
  3476. private _storedAlpha;
  3477. private _storedBeta;
  3478. private _storedRadius;
  3479. private _storedTarget;
  3480. storeState(): Camera;
  3481. /**
  3482. * Restored camera state. You must call storeState() first
  3483. */
  3484. _restoreStateValues(): boolean;
  3485. _isSynchronizedViewMatrix(): boolean;
  3486. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  3487. detachControl(element: HTMLElement): void;
  3488. _checkInputs(): void;
  3489. protected _checkLimits(): void;
  3490. rebuildAnglesAndRadius(): void;
  3491. setPosition(position: Vector3): void;
  3492. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  3493. _getViewMatrix(): Matrix;
  3494. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  3495. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  3496. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  3497. min: Vector3;
  3498. max: Vector3;
  3499. distance: number;
  3500. }, doNotUpdateMaxZ?: boolean): void;
  3501. /**
  3502. * @override
  3503. * Override Camera.createRigCamera
  3504. */
  3505. createRigCamera(name: string, cameraIndex: number): Camera;
  3506. /**
  3507. * @override
  3508. * Override Camera._updateRigCameras
  3509. */
  3510. _updateRigCameras(): void;
  3511. dispose(): void;
  3512. getClassName(): string;
  3513. }
  3514. }
  3515. declare module BABYLON {
  3516. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  3517. constructor(camera: ArcRotateCamera);
  3518. addMouseWheel(): ArcRotateCameraInputsManager;
  3519. addPointers(): ArcRotateCameraInputsManager;
  3520. addKeyboard(): ArcRotateCameraInputsManager;
  3521. addGamepad(): ArcRotateCameraInputsManager;
  3522. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  3523. }
  3524. }
  3525. declare module BABYLON {
  3526. class Camera extends Node {
  3527. inputs: CameraInputsManager<Camera>;
  3528. private static _PERSPECTIVE_CAMERA;
  3529. private static _ORTHOGRAPHIC_CAMERA;
  3530. private static _FOVMODE_VERTICAL_FIXED;
  3531. private static _FOVMODE_HORIZONTAL_FIXED;
  3532. private static _RIG_MODE_NONE;
  3533. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  3534. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  3535. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  3536. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  3537. private static _RIG_MODE_VR;
  3538. private static _RIG_MODE_WEBVR;
  3539. static readonly PERSPECTIVE_CAMERA: number;
  3540. static readonly ORTHOGRAPHIC_CAMERA: number;
  3541. /**
  3542. * This is the default FOV mode for perspective cameras.
  3543. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  3544. *
  3545. */
  3546. static readonly FOVMODE_VERTICAL_FIXED: number;
  3547. /**
  3548. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  3549. *
  3550. */
  3551. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  3552. static readonly RIG_MODE_NONE: number;
  3553. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  3554. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  3555. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  3556. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  3557. static readonly RIG_MODE_VR: number;
  3558. static readonly RIG_MODE_WEBVR: number;
  3559. static ForceAttachControlToAlwaysPreventDefault: boolean;
  3560. static UseAlternateWebVRRendering: boolean;
  3561. position: Vector3;
  3562. /**
  3563. * The vector the camera should consider as up.
  3564. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  3565. */
  3566. upVector: Vector3;
  3567. orthoLeft: Nullable<number>;
  3568. orthoRight: Nullable<number>;
  3569. orthoBottom: Nullable<number>;
  3570. orthoTop: Nullable<number>;
  3571. /**
  3572. * FOV is set in Radians. (default is 0.8)
  3573. */
  3574. fov: number;
  3575. minZ: number;
  3576. maxZ: number;
  3577. inertia: number;
  3578. mode: number;
  3579. isIntermediate: boolean;
  3580. viewport: Viewport;
  3581. /**
  3582. * Restricts the camera to viewing objects with the same layerMask.
  3583. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  3584. */
  3585. layerMask: number;
  3586. /**
  3587. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  3588. */
  3589. fovMode: number;
  3590. cameraRigMode: number;
  3591. interaxialDistance: number;
  3592. isStereoscopicSideBySide: boolean;
  3593. _cameraRigParams: any;
  3594. _rigCameras: Camera[];
  3595. _rigPostProcess: Nullable<PostProcess>;
  3596. protected _webvrViewMatrix: Matrix;
  3597. _skipRendering: boolean;
  3598. _alternateCamera: Camera;
  3599. customRenderTargets: RenderTargetTexture[];
  3600. onViewMatrixChangedObservable: Observable<Camera>;
  3601. onProjectionMatrixChangedObservable: Observable<Camera>;
  3602. onAfterCheckInputsObservable: Observable<Camera>;
  3603. onRestoreStateObservable: Observable<Camera>;
  3604. private _computedViewMatrix;
  3605. _projectionMatrix: Matrix;
  3606. private _doNotComputeProjectionMatrix;
  3607. private _worldMatrix;
  3608. _postProcesses: Nullable<PostProcess>[];
  3609. private _transformMatrix;
  3610. _activeMeshes: SmartArray<AbstractMesh>;
  3611. private _globalPosition;
  3612. private _frustumPlanes;
  3613. private _refreshFrustumPlanes;
  3614. constructor(name: string, position: Vector3, scene: Scene);
  3615. private _storedFov;
  3616. private _stateStored;
  3617. /**
  3618. * Store current camera state (fov, position, etc..)
  3619. */
  3620. storeState(): Camera;
  3621. /**
  3622. * Restores the camera state values if it has been stored. You must call storeState() first
  3623. */
  3624. protected _restoreStateValues(): boolean;
  3625. /**
  3626. * Restored camera state. You must call storeState() first
  3627. */
  3628. restoreState(): boolean;
  3629. getClassName(): string;
  3630. /**
  3631. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3632. */
  3633. toString(fullDetails?: boolean): string;
  3634. readonly globalPosition: Vector3;
  3635. getActiveMeshes(): SmartArray<AbstractMesh>;
  3636. isActiveMesh(mesh: Mesh): boolean;
  3637. _initCache(): void;
  3638. _updateCache(ignoreParentClass?: boolean): void;
  3639. _isSynchronized(): boolean;
  3640. _isSynchronizedViewMatrix(): boolean;
  3641. _isSynchronizedProjectionMatrix(): boolean;
  3642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3643. detachControl(element: HTMLElement): void;
  3644. update(): void;
  3645. _checkInputs(): void;
  3646. readonly rigCameras: Camera[];
  3647. readonly rigPostProcess: Nullable<PostProcess>;
  3648. /**
  3649. * Internal, gets the first post proces.
  3650. * @returns the first post process to be run on this camera.
  3651. */
  3652. _getFirstPostProcess(): Nullable<PostProcess>;
  3653. private _cascadePostProcessesToRigCams();
  3654. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  3655. detachPostProcess(postProcess: PostProcess): void;
  3656. getWorldMatrix(): Matrix;
  3657. _getViewMatrix(): Matrix;
  3658. getViewMatrix(force?: boolean): Matrix;
  3659. freezeProjectionMatrix(projection?: Matrix): void;
  3660. unfreezeProjectionMatrix(): void;
  3661. getProjectionMatrix(force?: boolean): Matrix;
  3662. getTranformationMatrix(): Matrix;
  3663. private updateFrustumPlanes();
  3664. isInFrustum(target: ICullable): boolean;
  3665. isCompletelyInFrustum(target: ICullable): boolean;
  3666. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  3667. /**
  3668. * Releases resources associated with this node.
  3669. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  3670. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  3671. */
  3672. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  3673. readonly leftCamera: Nullable<FreeCamera>;
  3674. readonly rightCamera: Nullable<FreeCamera>;
  3675. getLeftTarget(): Nullable<Vector3>;
  3676. getRightTarget(): Nullable<Vector3>;
  3677. setCameraRigMode(mode: number, rigParams: any): void;
  3678. private _getVRProjectionMatrix();
  3679. protected _updateCameraRotationMatrix(): void;
  3680. protected _updateWebVRCameraRotationMatrix(): void;
  3681. /**
  3682. * This function MUST be overwritten by the different WebVR cameras available.
  3683. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  3684. */
  3685. protected _getWebVRProjectionMatrix(): Matrix;
  3686. /**
  3687. * This function MUST be overwritten by the different WebVR cameras available.
  3688. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  3689. */
  3690. protected _getWebVRViewMatrix(): Matrix;
  3691. setCameraRigParameter(name: string, value: any): void;
  3692. /**
  3693. * needs to be overridden by children so sub has required properties to be copied
  3694. */
  3695. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  3696. /**
  3697. * May need to be overridden by children
  3698. */
  3699. _updateRigCameras(): void;
  3700. _setupInputs(): void;
  3701. serialize(): any;
  3702. clone(name: string): Camera;
  3703. getDirection(localAxis: Vector3): Vector3;
  3704. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  3705. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  3706. computeWorldMatrix(): Matrix;
  3707. static Parse(parsedCamera: any, scene: Scene): Camera;
  3708. }
  3709. }
  3710. declare module BABYLON {
  3711. var CameraInputTypes: {};
  3712. interface ICameraInput<TCamera extends Camera> {
  3713. camera: Nullable<TCamera>;
  3714. getClassName(): string;
  3715. getSimpleName(): string;
  3716. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  3717. detachControl: (element: Nullable<HTMLElement>) => void;
  3718. checkInputs?: () => void;
  3719. }
  3720. interface CameraInputsMap<TCamera extends Camera> {
  3721. [name: string]: ICameraInput<TCamera>;
  3722. [idx: number]: ICameraInput<TCamera>;
  3723. }
  3724. class CameraInputsManager<TCamera extends Camera> {
  3725. attached: CameraInputsMap<TCamera>;
  3726. attachedElement: Nullable<HTMLElement>;
  3727. noPreventDefault: boolean;
  3728. camera: TCamera;
  3729. checkInputs: () => void;
  3730. constructor(camera: TCamera);
  3731. /**
  3732. * Add an input method to a camera.
  3733. * builtin inputs example: camera.inputs.addGamepad();
  3734. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  3735. * @param input camera input method
  3736. */
  3737. add(input: ICameraInput<TCamera>): void;
  3738. /**
  3739. * Remove a specific input method from a camera
  3740. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  3741. * @param inputToRemove camera input method
  3742. */
  3743. remove(inputToRemove: ICameraInput<TCamera>): void;
  3744. removeByType(inputType: string): void;
  3745. private _addCheckInputs(fn);
  3746. attachInput(input: ICameraInput<TCamera>): void;
  3747. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  3748. detachElement(element: HTMLElement, disconnect?: boolean): void;
  3749. rebuildInputCheck(): void;
  3750. /**
  3751. * Remove all attached input methods from a camera
  3752. */
  3753. clear(): void;
  3754. serialize(serializedCamera: any): void;
  3755. parse(parsedCamera: any): void;
  3756. }
  3757. }
  3758. declare module BABYLON {
  3759. /**
  3760. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  3761. * being tilted forward or back and left or right.
  3762. */
  3763. class DeviceOrientationCamera extends FreeCamera {
  3764. private _initialQuaternion;
  3765. private _quaternionCache;
  3766. /**
  3767. * Creates a new device orientation camera. @see DeviceOrientationCamera
  3768. * @param name The name of the camera
  3769. * @param position The start position camera
  3770. * @param scene The scene the camera belongs to
  3771. */
  3772. constructor(name: string, position: Vector3, scene: Scene);
  3773. /**
  3774. * Gets the current instance class name ("DeviceOrientationCamera").
  3775. * This helps avoiding instanceof at run time.
  3776. * @returns the class name
  3777. */
  3778. getClassName(): string;
  3779. /**
  3780. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  3781. */
  3782. _checkInputs(): void;
  3783. /**
  3784. * Reset the camera to its default orientation on the specified axis only.
  3785. * @param axis The axis to reset
  3786. */
  3787. resetToCurrentRotation(axis?: Axis): void;
  3788. }
  3789. }
  3790. declare module BABYLON {
  3791. class FollowCamera extends TargetCamera {
  3792. radius: number;
  3793. rotationOffset: number;
  3794. heightOffset: number;
  3795. cameraAcceleration: number;
  3796. maxCameraSpeed: number;
  3797. lockedTarget: Nullable<AbstractMesh>;
  3798. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  3799. private getRadians(degrees);
  3800. private follow(cameraTarget);
  3801. _checkInputs(): void;
  3802. getClassName(): string;
  3803. }
  3804. class ArcFollowCamera extends TargetCamera {
  3805. alpha: number;
  3806. beta: number;
  3807. radius: number;
  3808. target: Nullable<AbstractMesh>;
  3809. private _cartesianCoordinates;
  3810. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  3811. private follow();
  3812. _checkInputs(): void;
  3813. getClassName(): string;
  3814. }
  3815. }
  3816. declare module BABYLON {
  3817. class FreeCamera extends TargetCamera {
  3818. ellipsoid: Vector3;
  3819. ellipsoidOffset: Vector3;
  3820. checkCollisions: boolean;
  3821. applyGravity: boolean;
  3822. inputs: FreeCameraInputsManager;
  3823. /**
  3824. * Gets the input sensibility for a mouse input. (default is 2000.0)
  3825. * Higher values reduce sensitivity.
  3826. */
  3827. /**
  3828. * Sets the input sensibility for a mouse input. (default is 2000.0)
  3829. * Higher values reduce sensitivity.
  3830. */
  3831. angularSensibility: number;
  3832. keysUp: number[];
  3833. keysDown: number[];
  3834. keysLeft: number[];
  3835. keysRight: number[];
  3836. onCollide: (collidedMesh: AbstractMesh) => void;
  3837. private _collider;
  3838. private _needMoveForGravity;
  3839. private _oldPosition;
  3840. private _diffPosition;
  3841. private _newPosition;
  3842. _localDirection: Vector3;
  3843. _transformedDirection: Vector3;
  3844. constructor(name: string, position: Vector3, scene: Scene);
  3845. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3846. detachControl(element: HTMLElement): void;
  3847. private _collisionMask;
  3848. collisionMask: number;
  3849. _collideWithWorld(displacement: Vector3): void;
  3850. private _onCollisionPositionChange;
  3851. _checkInputs(): void;
  3852. _decideIfNeedsToMove(): boolean;
  3853. _updatePosition(): void;
  3854. dispose(): void;
  3855. getClassName(): string;
  3856. }
  3857. }
  3858. declare module BABYLON {
  3859. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  3860. constructor(camera: FreeCamera);
  3861. addKeyboard(): FreeCameraInputsManager;
  3862. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  3863. addGamepad(): FreeCameraInputsManager;
  3864. addDeviceOrientation(): FreeCameraInputsManager;
  3865. addTouch(): FreeCameraInputsManager;
  3866. addVirtualJoystick(): FreeCameraInputsManager;
  3867. }
  3868. }
  3869. declare module BABYLON {
  3870. class GamepadCamera extends UniversalCamera {
  3871. gamepadAngularSensibility: number;
  3872. gamepadMoveSensibility: number;
  3873. constructor(name: string, position: Vector3, scene: Scene);
  3874. getClassName(): string;
  3875. }
  3876. }
  3877. declare module BABYLON {
  3878. class AnaglyphFreeCamera extends FreeCamera {
  3879. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3880. getClassName(): string;
  3881. }
  3882. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  3883. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  3884. getClassName(): string;
  3885. }
  3886. class AnaglyphGamepadCamera extends GamepadCamera {
  3887. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3888. getClassName(): string;
  3889. }
  3890. class AnaglyphUniversalCamera extends UniversalCamera {
  3891. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3892. getClassName(): string;
  3893. }
  3894. class StereoscopicFreeCamera extends FreeCamera {
  3895. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3896. getClassName(): string;
  3897. }
  3898. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  3899. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3900. getClassName(): string;
  3901. }
  3902. class StereoscopicGamepadCamera extends GamepadCamera {
  3903. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3904. getClassName(): string;
  3905. }
  3906. class StereoscopicUniversalCamera extends UniversalCamera {
  3907. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3908. getClassName(): string;
  3909. }
  3910. }
  3911. declare module BABYLON {
  3912. class TargetCamera extends Camera {
  3913. cameraDirection: Vector3;
  3914. cameraRotation: Vector2;
  3915. rotation: Vector3;
  3916. rotationQuaternion: Quaternion;
  3917. speed: number;
  3918. noRotationConstraint: boolean;
  3919. lockedTarget: any;
  3920. _currentTarget: Vector3;
  3921. _viewMatrix: Matrix;
  3922. _camMatrix: Matrix;
  3923. _cameraTransformMatrix: Matrix;
  3924. _cameraRotationMatrix: Matrix;
  3925. private _rigCamTransformMatrix;
  3926. _referencePoint: Vector3;
  3927. private _currentUpVector;
  3928. _transformedReferencePoint: Vector3;
  3929. _lookAtTemp: Matrix;
  3930. _tempMatrix: Matrix;
  3931. _reset: () => void;
  3932. constructor(name: string, position: Vector3, scene: Scene);
  3933. getFrontPosition(distance: number): Vector3;
  3934. _getLockedTargetPosition(): Nullable<Vector3>;
  3935. /**
  3936. * Store current camera state (fov, position, etc..)
  3937. */
  3938. private _storedPosition;
  3939. private _storedRotation;
  3940. private _storedRotationQuaternion;
  3941. storeState(): Camera;
  3942. /**
  3943. * Restored camera state. You must call storeState() first
  3944. */
  3945. _restoreStateValues(): boolean;
  3946. _initCache(): void;
  3947. _updateCache(ignoreParentClass?: boolean): void;
  3948. _isSynchronizedViewMatrix(): boolean;
  3949. _computeLocalCameraSpeed(): number;
  3950. setTarget(target: Vector3): void;
  3951. /**
  3952. * Return the current target position of the camera. This value is expressed in local space.
  3953. */
  3954. getTarget(): Vector3;
  3955. _decideIfNeedsToMove(): boolean;
  3956. _updatePosition(): void;
  3957. _checkInputs(): void;
  3958. protected _updateCameraRotationMatrix(): void;
  3959. _getViewMatrix(): Matrix;
  3960. /**
  3961. * @override
  3962. * Override Camera.createRigCamera
  3963. */
  3964. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  3965. /**
  3966. * @override
  3967. * Override Camera._updateRigCameras
  3968. */
  3969. _updateRigCameras(): void;
  3970. private _getRigCamPosition(halfSpace, result);
  3971. getClassName(): string;
  3972. }
  3973. }
  3974. declare module BABYLON {
  3975. class TouchCamera extends FreeCamera {
  3976. touchAngularSensibility: number;
  3977. touchMoveSensibility: number;
  3978. constructor(name: string, position: Vector3, scene: Scene);
  3979. getClassName(): string;
  3980. _setupInputs(): void;
  3981. }
  3982. }
  3983. declare module BABYLON {
  3984. class UniversalCamera extends TouchCamera {
  3985. gamepadAngularSensibility: number;
  3986. gamepadMoveSensibility: number;
  3987. constructor(name: string, position: Vector3, scene: Scene);
  3988. getClassName(): string;
  3989. }
  3990. }
  3991. declare module BABYLON {
  3992. class VirtualJoysticksCamera extends FreeCamera {
  3993. constructor(name: string, position: Vector3, scene: Scene);
  3994. getClassName(): string;
  3995. }
  3996. }
  3997. declare module BABYLON {
  3998. class DebugLayer {
  3999. private _scene;
  4000. static InspectorURL: string;
  4001. private _inspector;
  4002. private BJSINSPECTOR;
  4003. constructor(scene: Scene);
  4004. /** Creates the inspector window. */
  4005. private _createInspector(config?);
  4006. isVisible(): boolean;
  4007. hide(): void;
  4008. show(config?: {
  4009. popup?: boolean;
  4010. initialTab?: number;
  4011. parentElement?: HTMLElement;
  4012. newColors?: {
  4013. backgroundColor?: string;
  4014. backgroundColorLighter?: string;
  4015. backgroundColorLighter2?: string;
  4016. backgroundColorLighter3?: string;
  4017. color?: string;
  4018. colorTop?: string;
  4019. colorBot?: string;
  4020. };
  4021. }): void;
  4022. }
  4023. }
  4024. declare module BABYLON {
  4025. class Debug {
  4026. static AxesViewer: {
  4027. new (scene: Scene, scaleLines?: number): {
  4028. _xline: Vector3[];
  4029. _yline: Vector3[];
  4030. _zline: Vector3[];
  4031. _xmesh: Nullable<LinesMesh>;
  4032. _ymesh: Nullable<LinesMesh>;
  4033. _zmesh: Nullable<LinesMesh>;
  4034. scene: Nullable<Scene>;
  4035. scaleLines: number;
  4036. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  4037. dispose(): void;
  4038. };
  4039. };
  4040. static BoneAxesViewer: {
  4041. new (scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number): {
  4042. mesh: Nullable<Mesh>;
  4043. bone: Nullable<Bone>;
  4044. pos: Vector3;
  4045. xaxis: Vector3;
  4046. yaxis: Vector3;
  4047. zaxis: Vector3;
  4048. update(): void;
  4049. dispose(): void;
  4050. _xline: Vector3[];
  4051. _yline: Vector3[];
  4052. _zline: Vector3[];
  4053. _xmesh: Nullable<LinesMesh>;
  4054. _ymesh: Nullable<LinesMesh>;
  4055. _zmesh: Nullable<LinesMesh>;
  4056. scene: Nullable<Scene>;
  4057. scaleLines: number;
  4058. };
  4059. };
  4060. static PhysicsViewer: {
  4061. new (scene: Scene): {
  4062. _impostors: Nullable<PhysicsImpostor>[];
  4063. _meshes: Nullable<AbstractMesh>[];
  4064. _scene: Nullable<Scene>;
  4065. _numMeshes: number;
  4066. _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  4067. _renderFunction: () => void;
  4068. _debugBoxMesh: Mesh;
  4069. _debugSphereMesh: Mesh;
  4070. _debugMaterial: StandardMaterial;
  4071. _updateDebugMeshes(): void;
  4072. showImpostor(impostor: PhysicsImpostor): void;
  4073. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  4074. _getDebugMaterial(scene: Scene): Material;
  4075. _getDebugBoxMesh(scene: Scene): AbstractMesh;
  4076. _getDebugSphereMesh(scene: Scene): AbstractMesh;
  4077. _getDebugMesh(impostor: PhysicsImpostor, scene: Scene): Nullable<AbstractMesh>;
  4078. dispose(): void;
  4079. };
  4080. };
  4081. static SkeletonViewer: {
  4082. new (skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number): {
  4083. color: Color3;
  4084. _scene: Scene;
  4085. _debugLines: Vector3[][];
  4086. _debugMesh: Nullable<LinesMesh>;
  4087. _isEnabled: boolean;
  4088. _renderFunction: () => void;
  4089. skeleton: Skeleton;
  4090. mesh: AbstractMesh;
  4091. autoUpdateBonesMatrices: boolean;
  4092. renderingGroupId: number;
  4093. isEnabled: boolean;
  4094. _getBonePosition(position: Vector3, bone: Bone, meshMat: Matrix, x?: number, y?: number, z?: number): void;
  4095. _getLinesForBonesWithLength(bones: Bone[], meshMat: Matrix): void;
  4096. _getLinesForBonesNoLength(bones: Bone[], meshMat: Matrix): void;
  4097. update(): void;
  4098. dispose(): void;
  4099. };
  4100. };
  4101. }
  4102. }
  4103. declare module BABYLON {
  4104. class RayHelper {
  4105. ray: Nullable<Ray>;
  4106. private _renderPoints;
  4107. private _renderLine;
  4108. private _renderFunction;
  4109. private _scene;
  4110. private _updateToMeshFunction;
  4111. private _attachedToMesh;
  4112. private _meshSpaceDirection;
  4113. private _meshSpaceOrigin;
  4114. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  4115. constructor(ray: Ray);
  4116. show(scene: Scene, color: Color3): void;
  4117. hide(): void;
  4118. private _render();
  4119. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  4120. detachFromMesh(): void;
  4121. private _updateToMesh();
  4122. dispose(): void;
  4123. }
  4124. }
  4125. declare module BABYLON {
  4126. class InstancingAttributeInfo {
  4127. /**
  4128. * Index/offset of the attribute in the vertex shader
  4129. */
  4130. index: number;
  4131. /**
  4132. * size of the attribute, 1, 2, 3 or 4
  4133. */
  4134. attributeSize: number;
  4135. /**
  4136. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  4137. * default is FLOAT
  4138. */
  4139. attribyteType: number;
  4140. /**
  4141. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  4142. */
  4143. normalized: boolean;
  4144. /**
  4145. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  4146. */
  4147. offset: number;
  4148. /**
  4149. * Name of the GLSL attribute, for debugging purpose only
  4150. */
  4151. attributeName: string;
  4152. }
  4153. /**
  4154. * Define options used to create a render target texture
  4155. */
  4156. class RenderTargetCreationOptions {
  4157. /**
  4158. * Specifies is mipmaps must be generated
  4159. */
  4160. generateMipMaps?: boolean;
  4161. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4162. generateDepthBuffer?: boolean;
  4163. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4164. generateStencilBuffer?: boolean;
  4165. /** Defines texture type (int by default) */
  4166. type?: number;
  4167. /** Defines sampling mode (trilinear by default) */
  4168. samplingMode?: number;
  4169. /** Defines format (RGBA by default) */
  4170. format?: number;
  4171. }
  4172. /**
  4173. * Define options used to create a depth texture
  4174. */
  4175. class DepthTextureCreationOptions {
  4176. /** Specifies whether or not a stencil should be allocated in the texture */
  4177. generateStencil?: boolean;
  4178. /** Specifies whether or not bilinear filtering is enable on the texture */
  4179. bilinearFiltering?: boolean;
  4180. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  4181. comparisonFunction?: number;
  4182. /** Specifies if the created texture is a cube texture */
  4183. isCube?: boolean;
  4184. }
  4185. /**
  4186. * Regroup several parameters relative to the browser in use
  4187. */
  4188. class EngineCapabilities {
  4189. /** The maximum textures image */
  4190. maxTexturesImageUnits: number;
  4191. maxVertexTextureImageUnits: number;
  4192. maxCombinedTexturesImageUnits: number;
  4193. /** The maximum texture size */
  4194. maxTextureSize: number;
  4195. maxCubemapTextureSize: number;
  4196. maxRenderTextureSize: number;
  4197. maxVertexAttribs: number;
  4198. maxVaryingVectors: number;
  4199. maxVertexUniformVectors: number;
  4200. maxFragmentUniformVectors: number;
  4201. standardDerivatives: boolean;
  4202. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  4203. pvrtc: any;
  4204. etc1: any;
  4205. etc2: any;
  4206. astc: any;
  4207. textureFloat: boolean;
  4208. vertexArrayObject: boolean;
  4209. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  4210. maxAnisotropy: number;
  4211. instancedArrays: boolean;
  4212. uintIndices: boolean;
  4213. highPrecisionShaderSupported: boolean;
  4214. fragmentDepthSupported: boolean;
  4215. textureFloatLinearFiltering: boolean;
  4216. textureFloatRender: boolean;
  4217. textureHalfFloat: boolean;
  4218. textureHalfFloatLinearFiltering: boolean;
  4219. textureHalfFloatRender: boolean;
  4220. textureLOD: boolean;
  4221. drawBuffersExtension: boolean;
  4222. depthTextureExtension: boolean;
  4223. colorBufferFloat: boolean;
  4224. timerQuery: EXT_disjoint_timer_query;
  4225. canUseTimestampForTimerQuery: boolean;
  4226. }
  4227. interface EngineOptions extends WebGLContextAttributes {
  4228. limitDeviceRatio?: number;
  4229. autoEnableWebVR?: boolean;
  4230. disableWebGL2Support?: boolean;
  4231. audioEngine?: boolean;
  4232. deterministicLockstep?: boolean;
  4233. lockstepMaxSteps?: number;
  4234. doNotHandleContextLost?: boolean;
  4235. }
  4236. interface IDisplayChangedEventArgs {
  4237. vrDisplay: Nullable<any>;
  4238. vrSupported: boolean;
  4239. }
  4240. /**
  4241. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
  4242. */
  4243. class Engine {
  4244. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  4245. static ExceptionList: ({
  4246. key: string;
  4247. capture: string;
  4248. captureConstraint: number;
  4249. targets: string[];
  4250. } | {
  4251. key: string;
  4252. capture: null;
  4253. captureConstraint: null;
  4254. targets: string[];
  4255. })[];
  4256. static Instances: Engine[];
  4257. static readonly LastCreatedEngine: Nullable<Engine>;
  4258. static readonly LastCreatedScene: Nullable<Scene>;
  4259. /**
  4260. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  4261. */
  4262. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  4263. private static _ALPHA_DISABLE;
  4264. private static _ALPHA_ADD;
  4265. private static _ALPHA_COMBINE;
  4266. private static _ALPHA_SUBTRACT;
  4267. private static _ALPHA_MULTIPLY;
  4268. private static _ALPHA_MAXIMIZED;
  4269. private static _ALPHA_ONEONE;
  4270. private static _ALPHA_PREMULTIPLIED;
  4271. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  4272. private static _ALPHA_INTERPOLATE;
  4273. private static _ALPHA_SCREENMODE;
  4274. private static _DELAYLOADSTATE_NONE;
  4275. private static _DELAYLOADSTATE_LOADED;
  4276. private static _DELAYLOADSTATE_LOADING;
  4277. private static _DELAYLOADSTATE_NOTLOADED;
  4278. private static _TEXTUREFORMAT_ALPHA;
  4279. private static _TEXTUREFORMAT_LUMINANCE;
  4280. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  4281. private static _TEXTUREFORMAT_RGB;
  4282. private static _TEXTUREFORMAT_RGBA;
  4283. private static _TEXTUREFORMAT_R32F;
  4284. private static _TEXTUREFORMAT_RG32F;
  4285. private static _TEXTUREFORMAT_RGB32F;
  4286. private static _TEXTUREFORMAT_RGBA32F;
  4287. private static _TEXTURETYPE_UNSIGNED_INT;
  4288. private static _TEXTURETYPE_FLOAT;
  4289. private static _TEXTURETYPE_HALF_FLOAT;
  4290. private static _NEVER;
  4291. private static _ALWAYS;
  4292. private static _LESS;
  4293. private static _EQUAL;
  4294. private static _LEQUAL;
  4295. private static _GREATER;
  4296. private static _GEQUAL;
  4297. private static _NOTEQUAL;
  4298. static readonly NEVER: number;
  4299. static readonly ALWAYS: number;
  4300. static readonly LESS: number;
  4301. static readonly EQUAL: number;
  4302. static readonly LEQUAL: number;
  4303. static readonly GREATER: number;
  4304. static readonly GEQUAL: number;
  4305. static readonly NOTEQUAL: number;
  4306. private static _KEEP;
  4307. private static _REPLACE;
  4308. private static _INCR;
  4309. private static _DECR;
  4310. private static _INVERT;
  4311. private static _INCR_WRAP;
  4312. private static _DECR_WRAP;
  4313. static readonly KEEP: number;
  4314. static readonly REPLACE: number;
  4315. static readonly INCR: number;
  4316. static readonly DECR: number;
  4317. static readonly INVERT: number;
  4318. static readonly INCR_WRAP: number;
  4319. static readonly DECR_WRAP: number;
  4320. static readonly ALPHA_DISABLE: number;
  4321. static readonly ALPHA_ONEONE: number;
  4322. static readonly ALPHA_ADD: number;
  4323. static readonly ALPHA_COMBINE: number;
  4324. static readonly ALPHA_SUBTRACT: number;
  4325. static readonly ALPHA_MULTIPLY: number;
  4326. static readonly ALPHA_MAXIMIZED: number;
  4327. static readonly ALPHA_PREMULTIPLIED: number;
  4328. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4329. static readonly ALPHA_INTERPOLATE: number;
  4330. static readonly ALPHA_SCREENMODE: number;
  4331. static readonly DELAYLOADSTATE_NONE: number;
  4332. static readonly DELAYLOADSTATE_LOADED: number;
  4333. static readonly DELAYLOADSTATE_LOADING: number;
  4334. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4335. static readonly TEXTUREFORMAT_ALPHA: number;
  4336. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4337. /**
  4338. * R32F
  4339. */
  4340. static readonly TEXTUREFORMAT_R32F: number;
  4341. /**
  4342. * RG32F
  4343. */
  4344. static readonly TEXTUREFORMAT_RG32F: number;
  4345. /**
  4346. * RGB32F
  4347. */
  4348. static readonly TEXTUREFORMAT_RGB32F: number;
  4349. /**
  4350. * RGBA32F
  4351. */
  4352. static readonly TEXTUREFORMAT_RGBA32F: number;
  4353. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4354. static readonly TEXTUREFORMAT_RGB: number;
  4355. static readonly TEXTUREFORMAT_RGBA: number;
  4356. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4357. static readonly TEXTURETYPE_FLOAT: number;
  4358. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4359. private static _SCALEMODE_FLOOR;
  4360. private static _SCALEMODE_NEAREST;
  4361. private static _SCALEMODE_CEILING;
  4362. static readonly SCALEMODE_FLOOR: number;
  4363. static readonly SCALEMODE_NEAREST: number;
  4364. static readonly SCALEMODE_CEILING: number;
  4365. static readonly Version: string;
  4366. static CollisionsEpsilon: number;
  4367. static CodeRepository: string;
  4368. static ShadersRepository: string;
  4369. forcePOTTextures: boolean;
  4370. isFullscreen: boolean;
  4371. isPointerLock: boolean;
  4372. cullBackFaces: boolean;
  4373. renderEvenInBackground: boolean;
  4374. preventCacheWipeBetweenFrames: boolean;
  4375. enableOfflineSupport: boolean;
  4376. scenes: Scene[];
  4377. postProcesses: PostProcess[];
  4378. /**
  4379. * Observable event triggered each time the rendering canvas is resized
  4380. */
  4381. onResizeObservable: Observable<Engine>;
  4382. /**
  4383. * Observable event triggered each time the canvas loses focus
  4384. */
  4385. onCanvasBlurObservable: Observable<Engine>;
  4386. /**
  4387. * Observable event triggered each time the canvas gains focus
  4388. */
  4389. onCanvasFocusObservable: Observable<Engine>;
  4390. /**
  4391. * Observable event triggered each time the canvas receives pointerout event
  4392. */
  4393. onCanvasPointerOutObservable: Observable<PointerEvent>;
  4394. /**
  4395. * Observable event triggered before each texture is initialized
  4396. */
  4397. onBeforeTextureInitObservable: Observable<Texture>;
  4398. private _vrDisplay;
  4399. private _vrSupported;
  4400. private _oldSize;
  4401. private _oldHardwareScaleFactor;
  4402. private _vrExclusivePointerMode;
  4403. private _webVRInitPromise;
  4404. readonly isInVRExclusivePointerMode: boolean;
  4405. disableUniformBuffers: boolean;
  4406. _uniformBuffers: UniformBuffer[];
  4407. readonly supportsUniformBuffers: boolean;
  4408. /**
  4409. * Observable raised when the engine begins a new frame
  4410. */
  4411. onBeginFrameObservable: Observable<Engine>;
  4412. /**
  4413. * Observable raised when the engine ends the current frame
  4414. */
  4415. onEndFrameObservable: Observable<Engine>;
  4416. /**
  4417. * Observable raised when the engine is about to compile a shader
  4418. */
  4419. onBeforeShaderCompilationObservable: Observable<Engine>;
  4420. /**
  4421. * Observable raised when the engine has jsut compiled a shader
  4422. */
  4423. onAfterShaderCompilationObservable: Observable<Engine>;
  4424. private _gl;
  4425. private _renderingCanvas;
  4426. private _windowIsBackground;
  4427. private _webGLVersion;
  4428. readonly needPOTTextures: boolean;
  4429. private _badOS;
  4430. readonly badOS: boolean;
  4431. private _badDesktopOS;
  4432. readonly badDesktopOS: boolean;
  4433. /**
  4434. * Gets or sets a value indicating if we want to disable texture binding optmization.
  4435. * This could be required on some buggy drivers which wants to have textures bound in a progressive order
  4436. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is.
  4437. */
  4438. disableTextureBindingOptimization: boolean;
  4439. static audioEngine: AudioEngine;
  4440. private _onFocus;
  4441. private _onBlur;
  4442. private _onCanvasPointerOut;
  4443. private _onCanvasBlur;
  4444. private _onCanvasFocus;
  4445. private _onFullscreenChange;
  4446. private _onPointerLockChange;
  4447. private _onVRDisplayPointerRestricted;
  4448. private _onVRDisplayPointerUnrestricted;
  4449. private _onVrDisplayConnect;
  4450. private _onVrDisplayDisconnect;
  4451. private _onVrDisplayPresentChange;
  4452. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  4453. onVRRequestPresentComplete: Observable<boolean>;
  4454. onVRRequestPresentStart: Observable<Engine>;
  4455. private _hardwareScalingLevel;
  4456. protected _caps: EngineCapabilities;
  4457. private _pointerLockRequested;
  4458. private _isStencilEnable;
  4459. private _colorWrite;
  4460. private _loadingScreen;
  4461. _drawCalls: PerfCounter;
  4462. _textureCollisions: PerfCounter;
  4463. private _glVersion;
  4464. private _glRenderer;
  4465. private _glVendor;
  4466. private _videoTextureSupported;
  4467. private _renderingQueueLaunched;
  4468. private _activeRenderLoops;
  4469. private _deterministicLockstep;
  4470. private _lockstepMaxSteps;
  4471. onContextLostObservable: Observable<Engine>;
  4472. onContextRestoredObservable: Observable<Engine>;
  4473. private _onContextLost;
  4474. private _onContextRestored;
  4475. private _contextWasLost;
  4476. private _doNotHandleContextLost;
  4477. private _performanceMonitor;
  4478. private _fps;
  4479. private _deltaTime;
  4480. /**
  4481. * Turn this value on if you want to pause FPS computation when in background
  4482. */
  4483. disablePerformanceMonitorInBackground: boolean;
  4484. readonly performanceMonitor: PerformanceMonitor;
  4485. protected _depthCullingState: _DepthCullingState;
  4486. protected _stencilState: _StencilState;
  4487. protected _alphaState: _AlphaState;
  4488. protected _alphaMode: number;
  4489. private _internalTexturesCache;
  4490. protected _activeChannel: number;
  4491. private _currentTextureChannel;
  4492. protected _boundTexturesCache: {
  4493. [key: string]: Nullable<InternalTexture>;
  4494. };
  4495. protected _currentEffect: Nullable<Effect>;
  4496. protected _currentProgram: Nullable<WebGLProgram>;
  4497. private _compiledEffects;
  4498. private _vertexAttribArraysEnabled;
  4499. protected _cachedViewport: Nullable<Viewport>;
  4500. private _cachedVertexArrayObject;
  4501. protected _cachedVertexBuffers: any;
  4502. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  4503. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  4504. protected _currentRenderTarget: Nullable<InternalTexture>;
  4505. private _uintIndicesCurrentlySet;
  4506. private _currentBoundBuffer;
  4507. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  4508. private _currentBufferPointers;
  4509. private _currentInstanceLocations;
  4510. private _currentInstanceBuffers;
  4511. private _textureUnits;
  4512. private _firstBoundInternalTextureTracker;
  4513. private _lastBoundInternalTextureTracker;
  4514. private _workingCanvas;
  4515. private _workingContext;
  4516. private _rescalePostProcess;
  4517. private _dummyFramebuffer;
  4518. private _externalData;
  4519. private _bindedRenderFunction;
  4520. private _vaoRecordInProgress;
  4521. private _mustWipeVertexAttributes;
  4522. private _emptyTexture;
  4523. private _emptyCubeTexture;
  4524. private _emptyTexture3D;
  4525. private _frameHandler;
  4526. private _nextFreeTextureSlots;
  4527. private _maxSimultaneousTextures;
  4528. private _activeRequests;
  4529. private _texturesSupported;
  4530. private _textureFormatInUse;
  4531. readonly texturesSupported: Array<string>;
  4532. readonly textureFormatInUse: Nullable<string>;
  4533. readonly currentViewport: Nullable<Viewport>;
  4534. readonly emptyTexture: InternalTexture;
  4535. readonly emptyTexture3D: InternalTexture;
  4536. readonly emptyCubeTexture: InternalTexture;
  4537. /**
  4538. * @constructor
  4539. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  4540. * @param antialias defines enable antialiasing (default: false)
  4541. * @param options defines further options to be sent to the getContext() function
  4542. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  4543. */
  4544. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  4545. private _rebuildInternalTextures();
  4546. private _rebuildEffects();
  4547. private _rebuildBuffers();
  4548. private _initGLContext();
  4549. readonly webGLVersion: number;
  4550. /**
  4551. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  4552. */
  4553. readonly isStencilEnable: boolean;
  4554. private _prepareWorkingCanvas();
  4555. resetTextureCache(): void;
  4556. isDeterministicLockStep(): boolean;
  4557. getLockstepMaxSteps(): number;
  4558. getGlInfo(): {
  4559. vendor: string;
  4560. renderer: string;
  4561. version: string;
  4562. };
  4563. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  4564. getRenderWidth(useScreen?: boolean): number;
  4565. getRenderHeight(useScreen?: boolean): number;
  4566. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  4567. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  4568. setHardwareScalingLevel(level: number): void;
  4569. getHardwareScalingLevel(): number;
  4570. getLoadedTexturesCache(): InternalTexture[];
  4571. getCaps(): EngineCapabilities;
  4572. /** The number of draw calls submitted last frame */
  4573. readonly drawCalls: number;
  4574. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  4575. getDepthFunction(): Nullable<number>;
  4576. setDepthFunction(depthFunc: number): void;
  4577. setDepthFunctionToGreater(): void;
  4578. setDepthFunctionToGreaterOrEqual(): void;
  4579. setDepthFunctionToLess(): void;
  4580. setDepthFunctionToLessOrEqual(): void;
  4581. getStencilBuffer(): boolean;
  4582. setStencilBuffer(enable: boolean): void;
  4583. getStencilMask(): number;
  4584. setStencilMask(mask: number): void;
  4585. getStencilFunction(): number;
  4586. getStencilFunctionReference(): number;
  4587. getStencilFunctionMask(): number;
  4588. setStencilFunction(stencilFunc: number): void;
  4589. setStencilFunctionReference(reference: number): void;
  4590. setStencilFunctionMask(mask: number): void;
  4591. getStencilOperationFail(): number;
  4592. getStencilOperationDepthFail(): number;
  4593. getStencilOperationPass(): number;
  4594. setStencilOperationFail(operation: number): void;
  4595. setStencilOperationDepthFail(operation: number): void;
  4596. setStencilOperationPass(operation: number): void;
  4597. setDitheringState(value: boolean): void;
  4598. setRasterizerState(value: boolean): void;
  4599. /**
  4600. * stop executing a render loop function and remove it from the execution array
  4601. * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
  4602. */
  4603. stopRenderLoop(renderFunction?: () => void): void;
  4604. _renderLoop(): void;
  4605. /**
  4606. * Register and execute a render loop. The engine can have more than one render function.
  4607. * @param {Function} renderFunction - the function to continuously execute starting the next render loop.
  4608. * @example
  4609. * engine.runRenderLoop(function () {
  4610. * scene.render()
  4611. * })
  4612. */
  4613. runRenderLoop(renderFunction: () => void): void;
  4614. /**
  4615. * Toggle full screen mode.
  4616. * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
  4617. * @param {any} options - an options object to be sent to the requestFullscreen function
  4618. */
  4619. switchFullscreen(requestPointerLock: boolean): void;
  4620. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  4621. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  4622. /**
  4623. * Set the WebGL's viewport
  4624. * @param {BABYLON.Viewport} viewport - the viewport element to be used.
  4625. * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
  4626. * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
  4627. */
  4628. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  4629. /**
  4630. * Directly set the WebGL Viewport
  4631. * The x, y, width & height are directly passed to the WebGL call
  4632. * @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.
  4633. */
  4634. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  4635. beginFrame(): void;
  4636. endFrame(): void;
  4637. /**
  4638. * resize the view according to the canvas' size.
  4639. * @example
  4640. * window.addEventListener("resize", function () {
  4641. * engine.resize();
  4642. * });
  4643. */
  4644. resize(): void;
  4645. /**
  4646. * force a specific size of the canvas
  4647. * @param {number} width - the new canvas' width
  4648. * @param {number} height - the new canvas' height
  4649. */
  4650. setSize(width: number, height: number): void;
  4651. isVRDevicePresent(): boolean;
  4652. getVRDevice(): any;
  4653. /**
  4654. * Initializes a webVR display and starts listening to display change events.
  4655. * The onVRDisplayChangedObservable will be notified upon these changes.
  4656. * @returns The onVRDisplayChangedObservable.
  4657. */
  4658. initWebVR(): Observable<IDisplayChangedEventArgs>;
  4659. /**
  4660. * Initializes a webVR display and starts listening to display change events.
  4661. * The onVRDisplayChangedObservable will be notified upon these changes.
  4662. * @returns A promise containing a VRDisplay and if vr is supported.
  4663. */
  4664. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  4665. enableVR(): void;
  4666. disableVR(): void;
  4667. private _onVRFullScreenTriggered;
  4668. private _getVRDisplaysAsync();
  4669. /**
  4670. * Binds the frame buffer to the specified texture.
  4671. * @param texture The texture to render to or null for the default canvas
  4672. * @param faceIndex The face of the texture to render to in case of cube texture
  4673. * @param requiredWidth The width of the target to render to
  4674. * @param requiredHeight The height of the target to render to
  4675. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  4676. * @param depthStencilTexture The depth stencil texture to use to render
  4677. */
  4678. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  4679. private bindUnboundFramebuffer(framebuffer);
  4680. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4681. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4682. generateMipMapsForCubemap(texture: InternalTexture): void;
  4683. flushFramebuffer(): void;
  4684. restoreDefaultFramebuffer(): void;
  4685. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  4686. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  4687. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  4688. private _resetVertexBufferBinding();
  4689. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4690. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4691. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  4692. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  4693. private _resetIndexBufferBinding();
  4694. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  4695. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  4696. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  4697. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  4698. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  4699. private bindIndexBuffer(buffer);
  4700. private bindBuffer(buffer, target);
  4701. updateArrayBuffer(data: Float32Array): void;
  4702. private vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  4703. private _bindIndexBufferWithCache(indexBuffer);
  4704. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  4705. recordVertexArrayObject(vertexBuffers: {
  4706. [key: string]: VertexBuffer;
  4707. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  4708. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  4709. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  4710. private _unbindVertexArrayObject();
  4711. bindBuffers(vertexBuffers: {
  4712. [key: string]: Nullable<VertexBuffer>;
  4713. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  4714. unbindInstanceAttributes(): void;
  4715. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  4716. _releaseBuffer(buffer: WebGLBuffer): boolean;
  4717. createInstancesBuffer(capacity: number): WebGLBuffer;
  4718. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  4719. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  4720. applyStates(): void;
  4721. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  4722. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4723. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4724. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  4725. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4726. private _drawMode(fillMode);
  4727. _releaseEffect(effect: Effect): void;
  4728. _deleteProgram(program: WebGLProgram): void;
  4729. /**
  4730. * @param baseName The base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  4731. * @param samplers An array of string used to represent textures
  4732. */
  4733. 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;
  4734. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  4735. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  4736. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  4737. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  4738. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  4739. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  4740. enableEffect(effect: Nullable<Effect>): void;
  4741. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4742. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4743. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4744. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4745. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4746. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4747. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4748. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4749. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4750. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4751. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4752. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4753. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  4754. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  4755. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  4756. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  4757. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  4758. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  4759. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  4760. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  4761. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  4762. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  4763. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  4764. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  4765. /**
  4766. * Sets a Color4 on a uniform variable
  4767. * @param uniform defines the uniform location
  4768. * @param color4 defines the value to be set
  4769. */
  4770. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  4771. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  4772. setZOffset(value: number): void;
  4773. getZOffset(): number;
  4774. setDepthBuffer(enable: boolean): void;
  4775. getDepthWrite(): boolean;
  4776. setDepthWrite(enable: boolean): void;
  4777. setColorWrite(enable: boolean): void;
  4778. getColorWrite(): boolean;
  4779. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  4780. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  4781. getAlphaMode(): number;
  4782. wipeCaches(bruteForce?: boolean): void;
  4783. /**
  4784. * Set the compressed texture format to use, based on the formats you have, and the formats
  4785. * supported by the hardware / browser.
  4786. *
  4787. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  4788. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  4789. * to API arguments needed to compressed textures. This puts the burden on the container
  4790. * generator to house the arcane code for determining these for current & future formats.
  4791. *
  4792. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  4793. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  4794. *
  4795. * Note: The result of this call is not taken into account when a texture is base64.
  4796. *
  4797. * @param {Array<string>} formatsAvailable- The list of those format families you have created
  4798. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  4799. *
  4800. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  4801. * @returns The extension selected.
  4802. */
  4803. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  4804. _createTexture(): WebGLTexture;
  4805. /**
  4806. * Usually called from BABYLON.Texture.ts. Passed information to create a WebGLTexture.
  4807. * @param {string} urlArg- This contains one of the following:
  4808. * 1. A conventional http URL, e.g. 'http://...' or 'file://...'
  4809. * 2. A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  4810. * 3. An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  4811. *
  4812. * @param {boolean} noMipmap- When true, no mipmaps shall be generated. Ignored for compressed textures. They must be in the file.
  4813. * @param {boolean} invertY- When true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file.
  4814. * @param {Scene} scene- Needed for loading to the correct scene.
  4815. * @param {number} samplingMode- Mode with should be used sample / access the texture. Default: TRILINEAR
  4816. * @param {callback} onLoad- Optional callback to be called upon successful completion.
  4817. * @param {callback} onError- Optional callback to be called upon failure.
  4818. * @param {ArrayBuffer | HTMLImageElement} buffer- A source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
  4819. * @param {WebGLTexture} fallback- An internal argument in case the function must be called again, due to etc1 not having alpha capabilities.
  4820. * @param {number} format- Internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures.
  4821. *
  4822. * @returns {WebGLTexture} for assignment back into BABYLON.Texture
  4823. */
  4824. 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;
  4825. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  4826. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  4827. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  4828. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  4829. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  4830. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  4831. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  4832. /**
  4833. * Updates a depth texture Comparison Mode and Function.
  4834. * If the comparison Function is equal to 0, the mode will be set to none.
  4835. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  4836. * @param texture The texture to set the comparison function for
  4837. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  4838. */
  4839. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  4840. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  4841. /**
  4842. * Creates a depth stencil texture.
  4843. * This is only available in WebGL 2 or with the depth texture extension available.
  4844. * @param size The size of face edge in the texture.
  4845. * @param options The options defining the texture.
  4846. * @returns The texture
  4847. */
  4848. createDepthStencilTexture(size: number | {
  4849. width: number;
  4850. height: number;
  4851. }, options: DepthTextureCreationOptions): InternalTexture;
  4852. /**
  4853. * Creates a depth stencil texture.
  4854. * This is only available in WebGL 2 or with the depth texture extension available.
  4855. * @param size The size of face edge in the texture.
  4856. * @param options The options defining the texture.
  4857. * @returns The texture
  4858. */
  4859. private _createDepthStencilTexture(size, options);
  4860. /**
  4861. * Creates a depth stencil cube texture.
  4862. * This is only available in WebGL 2.
  4863. * @param size The size of face edge in the cube texture.
  4864. * @param options The options defining the cube texture.
  4865. * @returns The cube texture
  4866. */
  4867. private _createDepthStencilCubeTexture(size, options);
  4868. /**
  4869. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  4870. * @param renderTarget The render target to set the frame buffer for
  4871. */
  4872. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  4873. createRenderTargetTexture(size: number | {
  4874. width: number;
  4875. height: number;
  4876. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  4877. createMultipleRenderTarget(size: any, options: any): InternalTexture[];
  4878. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  4879. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  4880. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  4881. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  4882. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  4883. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  4884. 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;
  4885. 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;
  4886. private setCubeMapTextureParams(gl, loadMipmap);
  4887. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  4888. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  4889. 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;
  4890. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  4891. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  4892. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  4893. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  4894. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  4895. _releaseFramebufferObjects(texture: InternalTexture): void;
  4896. _releaseTexture(texture: InternalTexture): void;
  4897. private setProgram(program);
  4898. private _boundUniforms;
  4899. bindSamplers(effect: Effect): void;
  4900. private _moveBoundTextureOnTop(internalTexture);
  4901. private _getCorrectTextureChannel(channel, internalTexture);
  4902. private _linkTrackers(previous, next);
  4903. private _removeDesignatedSlot(internalTexture);
  4904. private _activateCurrentTexture();
  4905. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean): void;
  4906. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  4907. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  4908. /**
  4909. * Binds the output of the passed in post process to the texture channel specified
  4910. * @param channel The channel the texture should be bound to
  4911. * @param postProcess The post process which's output should be bound
  4912. */
  4913. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  4914. unbindAllTextures(): void;
  4915. /**
  4916. * Sets a texture to the according uniform.
  4917. * @param channel The texture channel
  4918. * @param uniform The uniform to set
  4919. * @param texture The texture to apply
  4920. */
  4921. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  4922. /**
  4923. * Sets a depth stencil texture from a render target to the according uniform.
  4924. * @param channel The texture channel
  4925. * @param uniform The uniform to set
  4926. * @param texture The render target texture containing the depth stencil texture to apply
  4927. */
  4928. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  4929. private _bindSamplerUniformToChannel(sourceSlot, destination);
  4930. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  4931. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  4932. _setAnisotropicLevel(key: number, texture: BaseTexture): void;
  4933. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  4934. /**
  4935. * Add an externaly attached data from its key.
  4936. * This method call will fail and return false, if such key already exists.
  4937. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  4938. * @param key the unique key that identifies the data
  4939. * @param data the data object to associate to the key for this Engine instance
  4940. * @return true if no such key were already present and the data was added successfully, false otherwise
  4941. */
  4942. addExternalData<T>(key: string, data: T): boolean;
  4943. /**
  4944. * Get an externaly attached data from its key
  4945. * @param key the unique key that identifies the data
  4946. * @return the associated data, if present (can be null), or undefined if not present
  4947. */
  4948. getExternalData<T>(key: string): T;
  4949. /**
  4950. * Get an externaly attached data from its key, create it using a factory if it's not already present
  4951. * @param key the unique key that identifies the data
  4952. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  4953. * @return the associated data, can be null if the factory returned null.
  4954. */
  4955. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  4956. /**
  4957. * Remove an externaly attached data from the Engine instance
  4958. * @param key the unique key that identifies the data
  4959. * @return true if the data was successfully removed, false if it doesn't exist
  4960. */
  4961. removeExternalData(key: string): boolean;
  4962. unbindAllAttributes(): void;
  4963. releaseEffects(): void;
  4964. dispose(): void;
  4965. displayLoadingUI(): void;
  4966. hideLoadingUI(): void;
  4967. loadingScreen: ILoadingScreen;
  4968. loadingUIText: string;
  4969. loadingUIBackgroundColor: string;
  4970. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  4971. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  4972. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  4973. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  4974. getError(): number;
  4975. getFps(): number;
  4976. getDeltaTime(): number;
  4977. private _measureFps();
  4978. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  4979. private _canRenderToFloatFramebuffer();
  4980. private _canRenderToHalfFloatFramebuffer();
  4981. private _canRenderToFramebuffer(type);
  4982. _getWebGLTextureType(type: number): number;
  4983. private _getInternalFormat(format);
  4984. /** @ignore */
  4985. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  4986. _getRGBAMultiSampleBufferFormat(type: number): number;
  4987. createQuery(): WebGLQuery;
  4988. deleteQuery(query: WebGLQuery): Engine;
  4989. isQueryResultAvailable(query: WebGLQuery): boolean;
  4990. getQueryResult(query: WebGLQuery): number;
  4991. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  4992. endOcclusionQuery(algorithmType: number): Engine;
  4993. private _createTimeQuery();
  4994. private _deleteTimeQuery(query);
  4995. private _getTimeQueryResult(query);
  4996. private _getTimeQueryAvailability(query);
  4997. private _currentNonTimestampToken;
  4998. startTimeQuery(): Nullable<_TimeToken>;
  4999. endTimeQuery(token: _TimeToken): int;
  5000. private getGlAlgorithmType(algorithmType);
  5001. createTransformFeedback(): WebGLTransformFeedback;
  5002. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  5003. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  5004. beginTransformFeedback(usePoints?: boolean): void;
  5005. endTransformFeedback(): void;
  5006. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  5007. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  5008. _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;
  5009. /** @ignore */
  5010. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  5011. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  5012. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  5013. static isSupported(): boolean;
  5014. }
  5015. }
  5016. declare module BABYLON {
  5017. class NullEngineOptions {
  5018. renderWidth: number;
  5019. renderHeight: number;
  5020. textureSize: number;
  5021. deterministicLockstep: boolean;
  5022. lockstepMaxSteps: number;
  5023. }
  5024. /**
  5025. * The null engine class provides support for headless version of babylon.js.
  5026. * This can be used in server side scenario or for testing purposes
  5027. */
  5028. class NullEngine extends Engine {
  5029. private _options;
  5030. isDeterministicLockStep(): boolean;
  5031. getLockstepMaxSteps(): number;
  5032. getHardwareScalingLevel(): number;
  5033. constructor(options?: NullEngineOptions);
  5034. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  5035. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  5036. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  5037. getRenderWidth(useScreen?: boolean): number;
  5038. getRenderHeight(useScreen?: boolean): number;
  5039. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  5040. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  5041. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  5042. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  5043. bindSamplers(effect: Effect): void;
  5044. enableEffect(effect: Effect): void;
  5045. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  5046. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  5047. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  5048. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  5049. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  5050. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  5051. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  5052. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  5053. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  5054. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  5055. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  5056. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  5057. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  5058. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  5059. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  5060. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  5061. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  5062. setFloat(uniform: WebGLUniformLocation, value: number): void;
  5063. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  5064. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  5065. setBool(uniform: WebGLUniformLocation, bool: number): void;
  5066. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  5067. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  5068. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  5069. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  5070. bindBuffers(vertexBuffers: {
  5071. [key: string]: VertexBuffer;
  5072. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  5073. wipeCaches(bruteForce?: boolean): void;
  5074. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  5075. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  5076. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  5077. _createTexture(): WebGLTexture;
  5078. 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;
  5079. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  5080. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  5081. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  5082. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  5083. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  5084. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  5085. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  5086. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  5087. _bindTexture(channel: number, texture: InternalTexture): void;
  5088. _releaseBuffer(buffer: WebGLBuffer): boolean;
  5089. }
  5090. }
  5091. interface WebGLRenderingContext {
  5092. readonly RASTERIZER_DISCARD: number;
  5093. readonly DEPTH_COMPONENT24: number;
  5094. readonly TEXTURE_3D: number;
  5095. readonly TEXTURE_2D_ARRAY: number;
  5096. readonly TEXTURE_COMPARE_FUNC: number;
  5097. readonly TEXTURE_COMPARE_MODE: number;
  5098. readonly COMPARE_REF_TO_TEXTURE: number;
  5099. readonly TEXTURE_WRAP_R: number;
  5100. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  5101. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  5102. 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;
  5103. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  5104. readonly TRANSFORM_FEEDBACK: number;
  5105. readonly INTERLEAVED_ATTRIBS: number;
  5106. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  5107. createTransformFeedback(): WebGLTransformFeedback;
  5108. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  5109. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  5110. beginTransformFeedback(primitiveMode: number): void;
  5111. endTransformFeedback(): void;
  5112. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  5113. }
  5114. interface ImageBitmap {
  5115. readonly width: number;
  5116. readonly height: number;
  5117. close(): void;
  5118. }
  5119. interface WebGLQuery extends WebGLObject {
  5120. }
  5121. declare var WebGLQuery: {
  5122. prototype: WebGLQuery;
  5123. new (): WebGLQuery;
  5124. };
  5125. interface WebGLSampler extends WebGLObject {
  5126. }
  5127. declare var WebGLSampler: {
  5128. prototype: WebGLSampler;
  5129. new (): WebGLSampler;
  5130. };
  5131. interface WebGLSync extends WebGLObject {
  5132. }
  5133. declare var WebGLSync: {
  5134. prototype: WebGLSync;
  5135. new (): WebGLSync;
  5136. };
  5137. interface WebGLTransformFeedback extends WebGLObject {
  5138. }
  5139. declare var WebGLTransformFeedback: {
  5140. prototype: WebGLTransformFeedback;
  5141. new (): WebGLTransformFeedback;
  5142. };
  5143. interface WebGLVertexArrayObject extends WebGLObject {
  5144. }
  5145. declare var WebGLVertexArrayObject: {
  5146. prototype: WebGLVertexArrayObject;
  5147. new (): WebGLVertexArrayObject;
  5148. };
  5149. declare module BABYLON {
  5150. class Collider {
  5151. /** Define if a collision was found */
  5152. collisionFound: boolean;
  5153. /**
  5154. * Define last intersection point in local space
  5155. */
  5156. intersectionPoint: Vector3;
  5157. /**
  5158. * Define last collided mesh
  5159. */
  5160. collidedMesh: Nullable<AbstractMesh>;
  5161. private _collisionPoint;
  5162. private _planeIntersectionPoint;
  5163. private _tempVector;
  5164. private _tempVector2;
  5165. private _tempVector3;
  5166. private _tempVector4;
  5167. private _edge;
  5168. private _baseToVertex;
  5169. private _destinationPoint;
  5170. private _slidePlaneNormal;
  5171. private _displacementVector;
  5172. _radius: Vector3;
  5173. _retry: number;
  5174. private _velocity;
  5175. private _basePoint;
  5176. private _epsilon;
  5177. _velocityWorldLength: number;
  5178. _basePointWorld: Vector3;
  5179. private _velocityWorld;
  5180. private _normalizedVelocity;
  5181. _initialVelocity: Vector3;
  5182. _initialPosition: Vector3;
  5183. private _nearestDistance;
  5184. private _collisionMask;
  5185. collisionMask: number;
  5186. /**
  5187. * Gets the plane normal used to compute the sliding response (in local space)
  5188. */
  5189. readonly slidePlaneNormal: Vector3;
  5190. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5191. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5192. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5193. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5194. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5195. _getResponse(pos: Vector3, vel: Vector3): void;
  5196. }
  5197. }
  5198. declare module BABYLON {
  5199. var CollisionWorker: string;
  5200. interface ICollisionCoordinator {
  5201. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5202. init(scene: Scene): void;
  5203. destroy(): void;
  5204. onMeshAdded(mesh: AbstractMesh): void;
  5205. onMeshUpdated(mesh: AbstractMesh): void;
  5206. onMeshRemoved(mesh: AbstractMesh): void;
  5207. onGeometryAdded(geometry: Geometry): void;
  5208. onGeometryUpdated(geometry: Geometry): void;
  5209. onGeometryDeleted(geometry: Geometry): void;
  5210. }
  5211. interface SerializedMesh {
  5212. id: string;
  5213. name: string;
  5214. uniqueId: number;
  5215. geometryId: Nullable<string>;
  5216. sphereCenter: Array<number>;
  5217. sphereRadius: number;
  5218. boxMinimum: Array<number>;
  5219. boxMaximum: Array<number>;
  5220. worldMatrixFromCache: any;
  5221. subMeshes: Array<SerializedSubMesh>;
  5222. checkCollisions: boolean;
  5223. }
  5224. interface SerializedSubMesh {
  5225. position: number;
  5226. verticesStart: number;
  5227. verticesCount: number;
  5228. indexStart: number;
  5229. indexCount: number;
  5230. hasMaterial: boolean;
  5231. sphereCenter: Array<number>;
  5232. sphereRadius: number;
  5233. boxMinimum: Array<number>;
  5234. boxMaximum: Array<number>;
  5235. }
  5236. /**
  5237. * Interface describing the value associated with a geometry
  5238. */
  5239. interface SerializedGeometry {
  5240. /**
  5241. * Defines the unique ID of the geometry
  5242. */
  5243. id: string;
  5244. /**
  5245. * Defines the array containing the positions
  5246. */
  5247. positions: Float32Array;
  5248. /**
  5249. * Defines the array containing the indices
  5250. */
  5251. indices: Uint32Array;
  5252. /**
  5253. * Defines the array containing the normals
  5254. */
  5255. normals: Float32Array;
  5256. }
  5257. interface BabylonMessage {
  5258. taskType: WorkerTaskType;
  5259. payload: InitPayload | CollidePayload | UpdatePayload;
  5260. }
  5261. interface SerializedColliderToWorker {
  5262. position: Array<number>;
  5263. velocity: Array<number>;
  5264. radius: Array<number>;
  5265. }
  5266. enum WorkerTaskType {
  5267. INIT = 0,
  5268. UPDATE = 1,
  5269. COLLIDE = 2,
  5270. }
  5271. interface WorkerReply {
  5272. error: WorkerReplyType;
  5273. taskType: WorkerTaskType;
  5274. payload?: any;
  5275. }
  5276. interface CollisionReplyPayload {
  5277. newPosition: Array<number>;
  5278. collisionId: number;
  5279. collidedMeshUniqueId: number;
  5280. }
  5281. interface InitPayload {
  5282. }
  5283. interface CollidePayload {
  5284. collisionId: number;
  5285. collider: SerializedColliderToWorker;
  5286. maximumRetry: number;
  5287. excludedMeshUniqueId: Nullable<number>;
  5288. }
  5289. interface UpdatePayload {
  5290. updatedMeshes: {
  5291. [n: number]: SerializedMesh;
  5292. };
  5293. updatedGeometries: {
  5294. [s: string]: SerializedGeometry;
  5295. };
  5296. removedMeshes: Array<number>;
  5297. removedGeometries: Array<string>;
  5298. }
  5299. enum WorkerReplyType {
  5300. SUCCESS = 0,
  5301. UNKNOWN_ERROR = 1,
  5302. }
  5303. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5304. private _scene;
  5305. private _scaledPosition;
  5306. private _scaledVelocity;
  5307. private _collisionsCallbackArray;
  5308. private _init;
  5309. private _runningUpdated;
  5310. private _worker;
  5311. private _addUpdateMeshesList;
  5312. private _addUpdateGeometriesList;
  5313. private _toRemoveMeshesArray;
  5314. private _toRemoveGeometryArray;
  5315. constructor();
  5316. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5317. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5318. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5319. init(scene: Scene): void;
  5320. destroy(): void;
  5321. onMeshAdded(mesh: AbstractMesh): void;
  5322. onMeshUpdated: (transformNode: TransformNode) => void;
  5323. onMeshRemoved(mesh: AbstractMesh): void;
  5324. onGeometryAdded(geometry: Geometry): void;
  5325. onGeometryUpdated: (geometry: Geometry) => void;
  5326. onGeometryDeleted(geometry: Geometry): void;
  5327. private _afterRender;
  5328. private _onMessageFromWorker;
  5329. }
  5330. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5331. private _scene;
  5332. private _scaledPosition;
  5333. private _scaledVelocity;
  5334. private _finalPosition;
  5335. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5336. init(scene: Scene): void;
  5337. destroy(): void;
  5338. onMeshAdded(mesh: AbstractMesh): void;
  5339. onMeshUpdated(mesh: AbstractMesh): void;
  5340. onMeshRemoved(mesh: AbstractMesh): void;
  5341. onGeometryAdded(geometry: Geometry): void;
  5342. onGeometryUpdated(geometry: Geometry): void;
  5343. onGeometryDeleted(geometry: Geometry): void;
  5344. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5345. }
  5346. }
  5347. declare function importScripts(...urls: string[]): void;
  5348. declare const safePostMessage: any;
  5349. declare module BABYLON {
  5350. var WorkerIncluded: boolean;
  5351. class CollisionCache {
  5352. private _meshes;
  5353. private _geometries;
  5354. getMeshes(): {
  5355. [n: number]: SerializedMesh;
  5356. };
  5357. getGeometries(): {
  5358. [s: number]: SerializedGeometry;
  5359. };
  5360. getMesh(id: any): SerializedMesh;
  5361. addMesh(mesh: SerializedMesh): void;
  5362. removeMesh(uniqueId: number): void;
  5363. getGeometry(id: string): SerializedGeometry;
  5364. addGeometry(geometry: SerializedGeometry): void;
  5365. removeGeometry(id: string): void;
  5366. }
  5367. class CollideWorker {
  5368. collider: Collider;
  5369. private _collisionCache;
  5370. private finalPosition;
  5371. private collisionsScalingMatrix;
  5372. private collisionTranformationMatrix;
  5373. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5374. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5375. private checkCollision(mesh);
  5376. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5377. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5378. private checkSubmeshCollision(subMesh);
  5379. }
  5380. interface ICollisionDetector {
  5381. onInit(payload: InitPayload): void;
  5382. onUpdate(payload: UpdatePayload): void;
  5383. onCollision(payload: CollidePayload): void;
  5384. }
  5385. class CollisionDetectorTransferable implements ICollisionDetector {
  5386. private _collisionCache;
  5387. onInit(payload: InitPayload): void;
  5388. onUpdate(payload: UpdatePayload): void;
  5389. onCollision(payload: CollidePayload): void;
  5390. }
  5391. }
  5392. declare module BABYLON {
  5393. class IntersectionInfo {
  5394. bu: Nullable<number>;
  5395. bv: Nullable<number>;
  5396. distance: number;
  5397. faceId: number;
  5398. subMeshId: number;
  5399. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5400. }
  5401. class PickingInfo {
  5402. hit: boolean;
  5403. distance: number;
  5404. pickedPoint: Nullable<Vector3>;
  5405. pickedMesh: Nullable<AbstractMesh>;
  5406. bu: number;
  5407. bv: number;
  5408. faceId: number;
  5409. subMeshId: number;
  5410. pickedSprite: Nullable<Sprite>;
  5411. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5412. getTextureCoordinates(): Nullable<Vector2>;
  5413. }
  5414. }
  5415. declare module BABYLON {
  5416. class KeyboardEventTypes {
  5417. static _KEYDOWN: number;
  5418. static _KEYUP: number;
  5419. static readonly KEYDOWN: number;
  5420. static readonly KEYUP: number;
  5421. }
  5422. class KeyboardInfo {
  5423. type: number;
  5424. event: KeyboardEvent;
  5425. constructor(type: number, event: KeyboardEvent);
  5426. }
  5427. /**
  5428. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  5429. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  5430. */
  5431. class KeyboardInfoPre extends KeyboardInfo {
  5432. constructor(type: number, event: KeyboardEvent);
  5433. skipOnPointerObservable: boolean;
  5434. }
  5435. }
  5436. declare module BABYLON {
  5437. class PointerEventTypes {
  5438. static _POINTERDOWN: number;
  5439. static _POINTERUP: number;
  5440. static _POINTERMOVE: number;
  5441. static _POINTERWHEEL: number;
  5442. static _POINTERPICK: number;
  5443. static _POINTERTAP: number;
  5444. static _POINTERDOUBLETAP: number;
  5445. static readonly POINTERDOWN: number;
  5446. static readonly POINTERUP: number;
  5447. static readonly POINTERMOVE: number;
  5448. static readonly POINTERWHEEL: number;
  5449. static readonly POINTERPICK: number;
  5450. static readonly POINTERTAP: number;
  5451. static readonly POINTERDOUBLETAP: number;
  5452. }
  5453. class PointerInfoBase {
  5454. type: number;
  5455. event: PointerEvent | MouseWheelEvent;
  5456. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  5457. }
  5458. /**
  5459. * This class is used to store pointer related info for the onPrePointerObservable event.
  5460. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  5461. */
  5462. class PointerInfoPre extends PointerInfoBase {
  5463. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  5464. localPosition: Vector2;
  5465. skipOnPointerObservable: boolean;
  5466. }
  5467. /**
  5468. * This type contains all the data related to a pointer event in Babylon.js.
  5469. * 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.
  5470. */
  5471. class PointerInfo extends PointerInfoBase {
  5472. pickInfo: Nullable<PickingInfo>;
  5473. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  5474. }
  5475. }
  5476. declare module BABYLON {
  5477. class StickValues {
  5478. x: number;
  5479. y: number;
  5480. constructor(x: number, y: number);
  5481. }
  5482. interface GamepadButtonChanges {
  5483. changed: boolean;
  5484. pressChanged: boolean;
  5485. touchChanged: boolean;
  5486. valueChanged: boolean;
  5487. }
  5488. class Gamepad {
  5489. id: string;
  5490. index: number;
  5491. browserGamepad: any;
  5492. type: number;
  5493. private _leftStick;
  5494. private _rightStick;
  5495. _isConnected: boolean;
  5496. private _leftStickAxisX;
  5497. private _leftStickAxisY;
  5498. private _rightStickAxisX;
  5499. private _rightStickAxisY;
  5500. private _onleftstickchanged;
  5501. private _onrightstickchanged;
  5502. static GAMEPAD: number;
  5503. static GENERIC: number;
  5504. static XBOX: number;
  5505. static POSE_ENABLED: number;
  5506. protected _invertLeftStickY: boolean;
  5507. readonly isConnected: boolean;
  5508. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  5509. onleftstickchanged(callback: (values: StickValues) => void): void;
  5510. onrightstickchanged(callback: (values: StickValues) => void): void;
  5511. leftStick: StickValues;
  5512. rightStick: StickValues;
  5513. update(): void;
  5514. dispose(): void;
  5515. }
  5516. class GenericPad extends Gamepad {
  5517. private _buttons;
  5518. private _onbuttondown;
  5519. private _onbuttonup;
  5520. onButtonDownObservable: Observable<number>;
  5521. onButtonUpObservable: Observable<number>;
  5522. onbuttondown(callback: (buttonPressed: number) => void): void;
  5523. onbuttonup(callback: (buttonReleased: number) => void): void;
  5524. constructor(id: string, index: number, browserGamepad: any);
  5525. private _setButtonValue(newValue, currentValue, buttonIndex);
  5526. update(): void;
  5527. dispose(): void;
  5528. }
  5529. }
  5530. declare module BABYLON {
  5531. class GamepadManager {
  5532. private _scene;
  5533. private _babylonGamepads;
  5534. private _oneGamepadConnected;
  5535. _isMonitoring: boolean;
  5536. private _gamepadEventSupported;
  5537. private _gamepadSupport;
  5538. onGamepadConnectedObservable: Observable<Gamepad>;
  5539. onGamepadDisconnectedObservable: Observable<Gamepad>;
  5540. private _onGamepadConnectedEvent;
  5541. private _onGamepadDisconnectedEvent;
  5542. constructor(_scene?: Scene | undefined);
  5543. readonly gamepads: Gamepad[];
  5544. getGamepadByType(type?: number): Nullable<Gamepad>;
  5545. dispose(): void;
  5546. private _addNewGamepad(gamepad);
  5547. private _startMonitoringGamepads();
  5548. private _stopMonitoringGamepads();
  5549. _checkGamepadsStatus(): void;
  5550. private _updateGamepadObjects();
  5551. }
  5552. }
  5553. declare module BABYLON {
  5554. enum Xbox360Button {
  5555. A = 0,
  5556. B = 1,
  5557. X = 2,
  5558. Y = 3,
  5559. Start = 4,
  5560. Back = 5,
  5561. LB = 6,
  5562. RB = 7,
  5563. LeftStick = 8,
  5564. RightStick = 9,
  5565. }
  5566. enum Xbox360Dpad {
  5567. Up = 0,
  5568. Down = 1,
  5569. Left = 2,
  5570. Right = 3,
  5571. }
  5572. class Xbox360Pad extends Gamepad {
  5573. private _leftTrigger;
  5574. private _rightTrigger;
  5575. private _onlefttriggerchanged;
  5576. private _onrighttriggerchanged;
  5577. private _onbuttondown;
  5578. private _onbuttonup;
  5579. private _ondpaddown;
  5580. private _ondpadup;
  5581. onButtonDownObservable: Observable<Xbox360Button>;
  5582. onButtonUpObservable: Observable<Xbox360Button>;
  5583. onPadDownObservable: Observable<Xbox360Dpad>;
  5584. onPadUpObservable: Observable<Xbox360Dpad>;
  5585. private _buttonA;
  5586. private _buttonB;
  5587. private _buttonX;
  5588. private _buttonY;
  5589. private _buttonBack;
  5590. private _buttonStart;
  5591. private _buttonLB;
  5592. private _buttonRB;
  5593. private _buttonLeftStick;
  5594. private _buttonRightStick;
  5595. private _dPadUp;
  5596. private _dPadDown;
  5597. private _dPadLeft;
  5598. private _dPadRight;
  5599. private _isXboxOnePad;
  5600. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  5601. onlefttriggerchanged(callback: (value: number) => void): void;
  5602. onrighttriggerchanged(callback: (value: number) => void): void;
  5603. leftTrigger: number;
  5604. rightTrigger: number;
  5605. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  5606. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  5607. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  5608. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  5609. private _setButtonValue(newValue, currentValue, buttonType);
  5610. private _setDPadValue(newValue, currentValue, buttonType);
  5611. buttonA: number;
  5612. buttonB: number;
  5613. buttonX: number;
  5614. buttonY: number;
  5615. buttonStart: number;
  5616. buttonBack: number;
  5617. buttonLB: number;
  5618. buttonRB: number;
  5619. buttonLeftStick: number;
  5620. buttonRightStick: number;
  5621. dPadUp: number;
  5622. dPadDown: number;
  5623. dPadLeft: number;
  5624. dPadRight: number;
  5625. update(): void;
  5626. dispose(): void;
  5627. }
  5628. }
  5629. declare module BABYLON {
  5630. /**
  5631. * Represents the different options available during the creation of
  5632. * a Environment helper.
  5633. *
  5634. * This can control the default ground, skybox and image processing setup of your scene.
  5635. */
  5636. interface IEnvironmentHelperOptions {
  5637. /**
  5638. * Specifies wether or not to create a ground.
  5639. * True by default.
  5640. */
  5641. createGround: boolean;
  5642. /**
  5643. * Specifies the ground size.
  5644. * 15 by default.
  5645. */
  5646. groundSize: number;
  5647. /**
  5648. * The texture used on the ground for the main color.
  5649. * Comes from the BabylonJS CDN by default.
  5650. *
  5651. * Remarks: Can be either a texture or a url.
  5652. */
  5653. groundTexture: string | BaseTexture;
  5654. /**
  5655. * The color mixed in the ground texture by default.
  5656. * BabylonJS clearColor by default.
  5657. */
  5658. groundColor: Color3;
  5659. /**
  5660. * Specifies the ground opacity.
  5661. * 1 by default.
  5662. */
  5663. groundOpacity: number;
  5664. /**
  5665. * Enables the ground to receive shadows.
  5666. * True by default.
  5667. */
  5668. enableGroundShadow: boolean;
  5669. /**
  5670. * Helps preventing the shadow to be fully black on the ground.
  5671. * 0.5 by default.
  5672. */
  5673. groundShadowLevel: number;
  5674. /**
  5675. * Creates a mirror texture attach to the ground.
  5676. * false by default.
  5677. */
  5678. enableGroundMirror: boolean;
  5679. /**
  5680. * Specifies the ground mirror size ratio.
  5681. * 0.3 by default as the default kernel is 64.
  5682. */
  5683. groundMirrorSizeRatio: number;
  5684. /**
  5685. * Specifies the ground mirror blur kernel size.
  5686. * 64 by default.
  5687. */
  5688. groundMirrorBlurKernel: number;
  5689. /**
  5690. * Specifies the ground mirror visibility amount.
  5691. * 1 by default
  5692. */
  5693. groundMirrorAmount: number;
  5694. /**
  5695. * Specifies the ground mirror reflectance weight.
  5696. * This uses the standard weight of the background material to setup the fresnel effect
  5697. * of the mirror.
  5698. * 1 by default.
  5699. */
  5700. groundMirrorFresnelWeight: number;
  5701. /**
  5702. * Specifies the ground mirror Falloff distance.
  5703. * This can helps reducing the size of the reflection.
  5704. * 0 by Default.
  5705. */
  5706. groundMirrorFallOffDistance: number;
  5707. /**
  5708. * Specifies the ground mirror texture type.
  5709. * Unsigned Int by Default.
  5710. */
  5711. groundMirrorTextureType: number;
  5712. /**
  5713. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  5714. * the shown objects.
  5715. */
  5716. groundYBias: number;
  5717. /**
  5718. * Specifies wether or not to create a skybox.
  5719. * True by default.
  5720. */
  5721. createSkybox: boolean;
  5722. /**
  5723. * Specifies the skybox size.
  5724. * 20 by default.
  5725. */
  5726. skyboxSize: number;
  5727. /**
  5728. * The texture used on the skybox for the main color.
  5729. * Comes from the BabylonJS CDN by default.
  5730. *
  5731. * Remarks: Can be either a texture or a url.
  5732. */
  5733. skyboxTexture: string | BaseTexture;
  5734. /**
  5735. * The color mixed in the skybox texture by default.
  5736. * BabylonJS clearColor by default.
  5737. */
  5738. skyboxColor: Color3;
  5739. /**
  5740. * The background rotation around the Y axis of the scene.
  5741. * This helps aligning the key lights of your scene with the background.
  5742. * 0 by default.
  5743. */
  5744. backgroundYRotation: number;
  5745. /**
  5746. * Compute automatically the size of the elements to best fit with the scene.
  5747. */
  5748. sizeAuto: boolean;
  5749. /**
  5750. * Default position of the rootMesh if autoSize is not true.
  5751. */
  5752. rootPosition: Vector3;
  5753. /**
  5754. * Sets up the image processing in the scene.
  5755. * true by default.
  5756. */
  5757. setupImageProcessing: boolean;
  5758. /**
  5759. * The texture used as your environment texture in the scene.
  5760. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  5761. *
  5762. * Remarks: Can be either a texture or a url.
  5763. */
  5764. environmentTexture: string | BaseTexture;
  5765. /**
  5766. * The value of the exposure to apply to the scene.
  5767. * 0.6 by default if setupImageProcessing is true.
  5768. */
  5769. cameraExposure: number;
  5770. /**
  5771. * The value of the contrast to apply to the scene.
  5772. * 1.6 by default if setupImageProcessing is true.
  5773. */
  5774. cameraContrast: number;
  5775. /**
  5776. * Specifies wether or not tonemapping should be enabled in the scene.
  5777. * true by default if setupImageProcessing is true.
  5778. */
  5779. toneMappingEnabled: boolean;
  5780. }
  5781. /**
  5782. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  5783. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  5784. * It also helps with the default setup of your imageProcessing configuration.
  5785. */
  5786. class EnvironmentHelper {
  5787. /**
  5788. * Default ground texture URL.
  5789. */
  5790. private static _groundTextureCDNUrl;
  5791. /**
  5792. * Default skybox texture URL.
  5793. */
  5794. private static _skyboxTextureCDNUrl;
  5795. /**
  5796. * Default environment texture URL.
  5797. */
  5798. private static _environmentTextureCDNUrl;
  5799. /**
  5800. * Creates the default options for the helper.
  5801. */
  5802. private static _getDefaultOptions();
  5803. private _rootMesh;
  5804. /**
  5805. * Gets the root mesh created by the helper.
  5806. */
  5807. readonly rootMesh: Mesh;
  5808. private _skybox;
  5809. /**
  5810. * Gets the skybox created by the helper.
  5811. */
  5812. readonly skybox: Nullable<Mesh>;
  5813. private _skyboxTexture;
  5814. /**
  5815. * Gets the skybox texture created by the helper.
  5816. */
  5817. readonly skyboxTexture: Nullable<BaseTexture>;
  5818. private _skyboxMaterial;
  5819. /**
  5820. * Gets the skybox material created by the helper.
  5821. */
  5822. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  5823. private _ground;
  5824. /**
  5825. * Gets the ground mesh created by the helper.
  5826. */
  5827. readonly ground: Nullable<Mesh>;
  5828. private _groundTexture;
  5829. /**
  5830. * Gets the ground texture created by the helper.
  5831. */
  5832. readonly groundTexture: Nullable<BaseTexture>;
  5833. private _groundMirror;
  5834. /**
  5835. * Gets the ground mirror created by the helper.
  5836. */
  5837. readonly groundMirror: Nullable<MirrorTexture>;
  5838. /**
  5839. * Gets the ground mirror render list to helps pushing the meshes
  5840. * you wish in the ground reflection.
  5841. */
  5842. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  5843. private _groundMaterial;
  5844. /**
  5845. * Gets the ground material created by the helper.
  5846. */
  5847. readonly groundMaterial: Nullable<BackgroundMaterial>;
  5848. /**
  5849. * Stores the creation options.
  5850. */
  5851. private readonly _scene;
  5852. private _options;
  5853. /**
  5854. * This observable will be notified with any error during the creation of the environment,
  5855. * mainly texture creation errors.
  5856. */
  5857. onErrorObservable: Observable<{
  5858. message?: string;
  5859. exception?: any;
  5860. }>;
  5861. /**
  5862. * constructor
  5863. * @param options
  5864. * @param scene The scene to add the material to
  5865. */
  5866. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  5867. /**
  5868. * Updates the background according to the new options
  5869. * @param options
  5870. */
  5871. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  5872. /**
  5873. * Sets the primary color of all the available elements.
  5874. * @param color
  5875. */
  5876. setMainColor(color: Color3): void;
  5877. /**
  5878. * Setup the image processing according to the specified options.
  5879. */
  5880. private _setupImageProcessing();
  5881. /**
  5882. * Setup the environment texture according to the specified options.
  5883. */
  5884. private _setupEnvironmentTexture();
  5885. /**
  5886. * Setup the background according to the specified options.
  5887. */
  5888. private _setupBackground();
  5889. /**
  5890. * Get the scene sizes according to the setup.
  5891. */
  5892. private _getSceneSize();
  5893. /**
  5894. * Setup the ground according to the specified options.
  5895. */
  5896. private _setupGround(sceneSize);
  5897. /**
  5898. * Setup the ground material according to the specified options.
  5899. */
  5900. private _setupGroundMaterial();
  5901. /**
  5902. * Setup the ground diffuse texture according to the specified options.
  5903. */
  5904. private _setupGroundDiffuseTexture();
  5905. /**
  5906. * Setup the ground mirror texture according to the specified options.
  5907. */
  5908. private _setupGroundMirrorTexture(sceneSize);
  5909. /**
  5910. * Setup the ground to receive the mirror texture.
  5911. */
  5912. private _setupMirrorInGroundMaterial();
  5913. /**
  5914. * Setup the skybox according to the specified options.
  5915. */
  5916. private _setupSkybox(sceneSize);
  5917. /**
  5918. * Setup the skybox material according to the specified options.
  5919. */
  5920. private _setupSkyboxMaterial();
  5921. /**
  5922. * Setup the skybox reflection texture according to the specified options.
  5923. */
  5924. private _setupSkyboxReflectionTexture();
  5925. private _errorHandler;
  5926. /**
  5927. * Dispose all the elements created by the Helper.
  5928. */
  5929. dispose(): void;
  5930. }
  5931. }
  5932. declare module BABYLON {
  5933. /**
  5934. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  5935. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  5936. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  5937. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  5938. */
  5939. class VideoDome extends Node {
  5940. /**
  5941. * The video texture being displayed on the sphere
  5942. */
  5943. protected _videoTexture: VideoTexture;
  5944. /**
  5945. * The skybox material
  5946. */
  5947. protected _material: BackgroundMaterial;
  5948. /**
  5949. * The surface used for the skybox
  5950. */
  5951. protected _mesh: Mesh;
  5952. /**
  5953. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  5954. * Also see the options.resolution property.
  5955. */
  5956. fovMultiplier: number;
  5957. /**
  5958. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  5959. * @param name Element's name, child elements will append suffixes for their own names.
  5960. * @param urlsOrVideo
  5961. * @param options An object containing optional or exposed sub element properties:
  5962. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  5963. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  5964. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  5965. * @param options **loop=true** Automatically loop video on end.
  5966. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  5967. */
  5968. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  5969. resolution?: number;
  5970. clickToPlay?: boolean;
  5971. autoPlay?: boolean;
  5972. loop?: boolean;
  5973. size?: number;
  5974. }, scene: Scene);
  5975. /**
  5976. * Releases resources associated with this node.
  5977. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5978. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5979. */
  5980. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5981. }
  5982. }
  5983. declare module BABYLON {
  5984. /**
  5985. * Effect layer options. This helps customizing the behaviour
  5986. * of the effect layer.
  5987. */
  5988. interface IEffectLayerOptions {
  5989. /**
  5990. * Multiplication factor apply to the canvas size to compute the render target size
  5991. * used to generated the objects (the smaller the faster).
  5992. */
  5993. mainTextureRatio: number;
  5994. /**
  5995. * Enforces a fixed size texture to ensure effect stability across devices.
  5996. */
  5997. mainTextureFixedSize?: number;
  5998. /**
  5999. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  6000. */
  6001. alphaBlendingMode: number;
  6002. /**
  6003. * The camera attached to the layer.
  6004. */
  6005. camera: Nullable<Camera>;
  6006. }
  6007. /**
  6008. * The effect layer Helps adding post process effect blended with the main pass.
  6009. *
  6010. * This can be for instance use to generate glow or higlight effects on the scene.
  6011. *
  6012. * The effect layer class can not be used directly and is intented to inherited from to be
  6013. * customized per effects.
  6014. */
  6015. abstract class EffectLayer {
  6016. /** The Friendly of the effect in the scene */
  6017. name: string;
  6018. private _vertexBuffers;
  6019. private _indexBuffer;
  6020. private _cachedDefines;
  6021. private _effectLayerMapGenerationEffect;
  6022. private _effectLayerOptions;
  6023. private _mergeEffect;
  6024. protected _scene: Scene;
  6025. protected _engine: Engine;
  6026. protected _maxSize: number;
  6027. protected _mainTextureDesiredSize: ISize;
  6028. protected _mainTexture: RenderTargetTexture;
  6029. protected _shouldRender: boolean;
  6030. protected _postProcesses: PostProcess[];
  6031. protected _textures: BaseTexture[];
  6032. protected _emissiveTextureAndColor: {
  6033. texture: Nullable<BaseTexture>;
  6034. color: Color4;
  6035. };
  6036. /**
  6037. * The clear color of the texture used to generate the glow map.
  6038. */
  6039. neutralColor: Color4;
  6040. /**
  6041. * Specifies wether the highlight layer is enabled or not.
  6042. */
  6043. isEnabled: boolean;
  6044. /**
  6045. * Gets the camera attached to the layer.
  6046. */
  6047. readonly camera: Nullable<Camera>;
  6048. /**
  6049. * An event triggered when the effect layer has been disposed.
  6050. */
  6051. onDisposeObservable: Observable<EffectLayer>;
  6052. /**
  6053. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  6054. */
  6055. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  6056. /**
  6057. * An event triggered when the generated texture is being merged in the scene.
  6058. */
  6059. onBeforeComposeObservable: Observable<EffectLayer>;
  6060. /**
  6061. * An event triggered when the generated texture has been merged in the scene.
  6062. */
  6063. onAfterComposeObservable: Observable<EffectLayer>;
  6064. /**
  6065. * An event triggered when the efffect layer changes its size.
  6066. */
  6067. onSizeChangedObservable: Observable<EffectLayer>;
  6068. /**
  6069. * Instantiates a new effect Layer and references it in the scene.
  6070. * @param name The name of the layer
  6071. * @param scene The scene to use the layer in
  6072. */
  6073. constructor(
  6074. /** The Friendly of the effect in the scene */
  6075. name: string, scene: Scene);
  6076. /**
  6077. * Get the effect name of the layer.
  6078. * @return The effect name
  6079. */
  6080. abstract getEffectName(): string;
  6081. /**
  6082. * Checks for the readiness of the element composing the layer.
  6083. * @param subMesh the mesh to check for
  6084. * @param useInstances specify wether or not to use instances to render the mesh
  6085. * @return true if ready otherwise, false
  6086. */
  6087. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  6088. /**
  6089. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  6090. * @returns true if the effect requires stencil during the main canvas render pass.
  6091. */
  6092. abstract needStencil(): boolean;
  6093. /**
  6094. * Create the merge effect. This is the shader use to blit the information back
  6095. * to the main canvas at the end of the scene rendering.
  6096. * @returns The effect containing the shader used to merge the effect on the main canvas
  6097. */
  6098. protected abstract _createMergeEffect(): Effect;
  6099. /**
  6100. * Creates the render target textures and post processes used in the effect layer.
  6101. */
  6102. protected abstract _createTextureAndPostProcesses(): void;
  6103. /**
  6104. * Implementation specific of rendering the generating effect on the main canvas.
  6105. * @param effect The effect used to render through
  6106. */
  6107. protected abstract _internalRender(effect: Effect): void;
  6108. /**
  6109. * Sets the required values for both the emissive texture and and the main color.
  6110. */
  6111. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  6112. /**
  6113. * Free any resources and references associated to a mesh.
  6114. * Internal use
  6115. * @param mesh The mesh to free.
  6116. */
  6117. abstract _disposeMesh(mesh: Mesh): void;
  6118. /**
  6119. * Initializes the effect layer with the required options.
  6120. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  6121. */
  6122. protected _init(options: Partial<IEffectLayerOptions>): void;
  6123. /**
  6124. * Generates the index buffer of the full screen quad blending to the main canvas.
  6125. */
  6126. private _generateIndexBuffer();
  6127. /**
  6128. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  6129. */
  6130. private _genrateVertexBuffer();
  6131. /**
  6132. * Sets the main texture desired size which is the closest power of two
  6133. * of the engine canvas size.
  6134. */
  6135. private _setMainTextureSize();
  6136. /**
  6137. * Creates the main texture for the effect layer.
  6138. */
  6139. protected _createMainTexture(): void;
  6140. /**
  6141. * Checks for the readiness of the element composing the layer.
  6142. * @param subMesh the mesh to check for
  6143. * @param useInstances specify wether or not to use instances to render the mesh
  6144. * @param emissiveTexture the associated emissive texture used to generate the glow
  6145. * @return true if ready otherwise, false
  6146. */
  6147. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  6148. /**
  6149. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  6150. */
  6151. render(): void;
  6152. /**
  6153. * Determine if a given mesh will be used in the current effect.
  6154. * @param mesh mesh to test
  6155. * @returns true if the mesh will be used
  6156. */
  6157. hasMesh(mesh: AbstractMesh): boolean;
  6158. /**
  6159. * Returns true if the layer contains information to display, otherwise false.
  6160. * @returns true if the glow layer should be rendered
  6161. */
  6162. shouldRender(): boolean;
  6163. /**
  6164. * Returns true if the mesh should render, otherwise false.
  6165. * @param mesh The mesh to render
  6166. * @returns true if it should render otherwise false
  6167. */
  6168. protected _shouldRenderMesh(mesh: Mesh): boolean;
  6169. /**
  6170. * Returns true if the mesh should render, otherwise false.
  6171. * @param mesh The mesh to render
  6172. * @returns true if it should render otherwise false
  6173. */
  6174. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  6175. /**
  6176. * Renders the submesh passed in parameter to the generation map.
  6177. */
  6178. protected _renderSubMesh(subMesh: SubMesh): void;
  6179. /**
  6180. * Rebuild the required buffers.
  6181. * @ignore Internal use only.
  6182. */
  6183. _rebuild(): void;
  6184. /**
  6185. * Dispose only the render target textures and post process.
  6186. */
  6187. private _disposeTextureAndPostProcesses();
  6188. /**
  6189. * Dispose the highlight layer and free resources.
  6190. */
  6191. dispose(): void;
  6192. }
  6193. }
  6194. declare module BABYLON {
  6195. /**
  6196. * Glow layer options. This helps customizing the behaviour
  6197. * of the glow layer.
  6198. */
  6199. interface IGlowLayerOptions {
  6200. /**
  6201. * Multiplication factor apply to the canvas size to compute the render target size
  6202. * used to generated the glowing objects (the smaller the faster).
  6203. */
  6204. mainTextureRatio: number;
  6205. /**
  6206. * Enforces a fixed size texture to ensure resize independant blur.
  6207. */
  6208. mainTextureFixedSize?: number;
  6209. /**
  6210. * How big is the kernel of the blur texture.
  6211. */
  6212. blurKernelSize: number;
  6213. /**
  6214. * The camera attached to the layer.
  6215. */
  6216. camera: Nullable<Camera>;
  6217. /**
  6218. * Enable MSAA by chosing the number of samples.
  6219. */
  6220. mainTextureSamples?: number;
  6221. }
  6222. /**
  6223. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  6224. *
  6225. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  6226. * glowy meshes to your scene.
  6227. *
  6228. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  6229. */
  6230. class GlowLayer extends EffectLayer {
  6231. name: string;
  6232. /**
  6233. * Effect Name of the layer.
  6234. */
  6235. static readonly EffectName: string;
  6236. /**
  6237. * The default blur kernel size used for the glow.
  6238. */
  6239. static DefaultBlurKernelSize: number;
  6240. /**
  6241. * The default texture size ratio used for the glow.
  6242. */
  6243. static DefaultTextureRatio: number;
  6244. /**
  6245. * Gets the kernel size of the blur.
  6246. */
  6247. /**
  6248. * Sets the kernel size of the blur.
  6249. */
  6250. blurKernelSize: number;
  6251. /**
  6252. * Gets the glow intensity.
  6253. */
  6254. /**
  6255. * Sets the glow intensity.
  6256. */
  6257. intensity: number;
  6258. private _options;
  6259. private _intensity;
  6260. private _horizontalBlurPostprocess1;
  6261. private _verticalBlurPostprocess1;
  6262. private _horizontalBlurPostprocess2;
  6263. private _verticalBlurPostprocess2;
  6264. private _blurTexture1;
  6265. private _blurTexture2;
  6266. private _postProcesses1;
  6267. private _postProcesses2;
  6268. private _includedOnlyMeshes;
  6269. private _excludedMeshes;
  6270. /**
  6271. * Callback used to let the user override the color selection on a per mesh basis
  6272. */
  6273. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  6274. /**
  6275. * Callback used to let the user override the texture selection on a per mesh basis
  6276. */
  6277. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  6278. /**
  6279. * Instantiates a new glow Layer and references it to the scene.
  6280. * @param name The name of the layer
  6281. * @param scene The scene to use the layer in
  6282. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  6283. */
  6284. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  6285. /**
  6286. * Get the effect name of the layer.
  6287. * @return The effect name
  6288. */
  6289. getEffectName(): string;
  6290. /**
  6291. * Create the merge effect. This is the shader use to blit the information back
  6292. * to the main canvas at the end of the scene rendering.
  6293. */
  6294. protected _createMergeEffect(): Effect;
  6295. /**
  6296. * Creates the render target textures and post processes used in the glow layer.
  6297. */
  6298. protected _createTextureAndPostProcesses(): void;
  6299. /**
  6300. * Checks for the readiness of the element composing the layer.
  6301. * @param subMesh the mesh to check for
  6302. * @param useInstances specify wether or not to use instances to render the mesh
  6303. * @param emissiveTexture the associated emissive texture used to generate the glow
  6304. * @return true if ready otherwise, false
  6305. */
  6306. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  6307. /**
  6308. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  6309. */
  6310. needStencil(): boolean;
  6311. /**
  6312. * Implementation specific of rendering the generating effect on the main canvas.
  6313. * @param effect The effect used to render through
  6314. */
  6315. protected _internalRender(effect: Effect): void;
  6316. /**
  6317. * Sets the required values for both the emissive texture and and the main color.
  6318. */
  6319. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  6320. /**
  6321. * Returns true if the mesh should render, otherwise false.
  6322. * @param mesh The mesh to render
  6323. * @returns true if it should render otherwise false
  6324. */
  6325. protected _shouldRenderMesh(mesh: Mesh): boolean;
  6326. /**
  6327. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  6328. * @param mesh The mesh to exclude from the glow layer
  6329. */
  6330. addExcludedMesh(mesh: Mesh): void;
  6331. /**
  6332. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  6333. * @param mesh The mesh to remove
  6334. */
  6335. removeExcludedMesh(mesh: Mesh): void;
  6336. /**
  6337. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  6338. * @param mesh The mesh to include in the glow layer
  6339. */
  6340. addIncludedOnlyMesh(mesh: Mesh): void;
  6341. /**
  6342. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  6343. * @param mesh The mesh to remove
  6344. */
  6345. removeIncludedOnlyMesh(mesh: Mesh): void;
  6346. /**
  6347. * Determine if a given mesh will be used in the glow layer
  6348. * @param mesh The mesh to test
  6349. * @returns true if the mesh will be highlighted by the current glow layer
  6350. */
  6351. hasMesh(mesh: AbstractMesh): boolean;
  6352. /**
  6353. * Free any resources and references associated to a mesh.
  6354. * Internal use
  6355. * @param mesh The mesh to free.
  6356. */
  6357. _disposeMesh(mesh: Mesh): void;
  6358. }
  6359. }
  6360. declare module BABYLON {
  6361. /**
  6362. * Highlight layer options. This helps customizing the behaviour
  6363. * of the highlight layer.
  6364. */
  6365. interface IHighlightLayerOptions {
  6366. /**
  6367. * Multiplication factor apply to the canvas size to compute the render target size
  6368. * used to generated the glowing objects (the smaller the faster).
  6369. */
  6370. mainTextureRatio: number;
  6371. /**
  6372. * Enforces a fixed size texture to ensure resize independant blur.
  6373. */
  6374. mainTextureFixedSize?: number;
  6375. /**
  6376. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  6377. * of the picture to blur (the smaller the faster).
  6378. */
  6379. blurTextureSizeRatio: number;
  6380. /**
  6381. * How big in texel of the blur texture is the vertical blur.
  6382. */
  6383. blurVerticalSize: number;
  6384. /**
  6385. * How big in texel of the blur texture is the horizontal blur.
  6386. */
  6387. blurHorizontalSize: number;
  6388. /**
  6389. * Alpha blending mode used to apply the blur. Default is combine.
  6390. */
  6391. alphaBlendingMode: number;
  6392. /**
  6393. * The camera attached to the layer.
  6394. */
  6395. camera: Nullable<Camera>;
  6396. /**
  6397. * Should we display highlight as a solid stroke?
  6398. */
  6399. isStroke?: boolean;
  6400. }
  6401. /**
  6402. * The highlight layer Helps adding a glow effect around a mesh.
  6403. *
  6404. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  6405. * glowy meshes to your scene.
  6406. *
  6407. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  6408. */
  6409. class HighlightLayer extends EffectLayer {
  6410. name: string;
  6411. /**
  6412. * Effect Name of the highlight layer.
  6413. */
  6414. static readonly EffectName: string;
  6415. /**
  6416. * The neutral color used during the preparation of the glow effect.
  6417. * This is black by default as the blend operation is a blend operation.
  6418. */
  6419. static NeutralColor: Color4;
  6420. /**
  6421. * Stencil value used for glowing meshes.
  6422. */
  6423. static GlowingMeshStencilReference: number;
  6424. /**
  6425. * Stencil value used for the other meshes in the scene.
  6426. */
  6427. static NormalMeshStencilReference: number;
  6428. /**
  6429. * Specifies whether or not the inner glow is ACTIVE in the layer.
  6430. */
  6431. innerGlow: boolean;
  6432. /**
  6433. * Specifies whether or not the outer glow is ACTIVE in the layer.
  6434. */
  6435. outerGlow: boolean;
  6436. /**
  6437. * Gets the horizontal size of the blur.
  6438. */
  6439. /**
  6440. * Specifies the horizontal size of the blur.
  6441. */
  6442. blurHorizontalSize: number;
  6443. /**
  6444. * Gets the vertical size of the blur.
  6445. */
  6446. /**
  6447. * Specifies the vertical size of the blur.
  6448. */
  6449. blurVerticalSize: number;
  6450. /**
  6451. * An event triggered when the highlight layer is being blurred.
  6452. */
  6453. onBeforeBlurObservable: Observable<HighlightLayer>;
  6454. /**
  6455. * An event triggered when the highlight layer has been blurred.
  6456. */
  6457. onAfterBlurObservable: Observable<HighlightLayer>;
  6458. private _instanceGlowingMeshStencilReference;
  6459. private _options;
  6460. private _downSamplePostprocess;
  6461. private _horizontalBlurPostprocess;
  6462. private _verticalBlurPostprocess;
  6463. private _blurTexture;
  6464. private _meshes;
  6465. private _excludedMeshes;
  6466. /**
  6467. * Instantiates a new highlight Layer and references it to the scene..
  6468. * @param name The name of the layer
  6469. * @param scene The scene to use the layer in
  6470. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  6471. */
  6472. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  6473. /**
  6474. * Get the effect name of the layer.
  6475. * @return The effect name
  6476. */
  6477. getEffectName(): string;
  6478. /**
  6479. * Create the merge effect. This is the shader use to blit the information back
  6480. * to the main canvas at the end of the scene rendering.
  6481. */
  6482. protected _createMergeEffect(): Effect;
  6483. /**
  6484. * Creates the render target textures and post processes used in the highlight layer.
  6485. */
  6486. protected _createTextureAndPostProcesses(): void;
  6487. /**
  6488. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  6489. */
  6490. needStencil(): boolean;
  6491. /**
  6492. * Checks for the readiness of the element composing the layer.
  6493. * @param subMesh the mesh to check for
  6494. * @param useInstances specify wether or not to use instances to render the mesh
  6495. * @param emissiveTexture the associated emissive texture used to generate the glow
  6496. * @return true if ready otherwise, false
  6497. */
  6498. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  6499. /**
  6500. * Implementation specific of rendering the generating effect on the main canvas.
  6501. * @param effect The effect used to render through
  6502. */
  6503. protected _internalRender(effect: Effect): void;
  6504. /**
  6505. * Returns true if the layer contains information to display, otherwise false.
  6506. */
  6507. shouldRender(): boolean;
  6508. /**
  6509. * Returns true if the mesh should render, otherwise false.
  6510. * @param mesh The mesh to render
  6511. * @returns true if it should render otherwise false
  6512. */
  6513. protected _shouldRenderMesh(mesh: Mesh): boolean;
  6514. /**
  6515. * Sets the required values for both the emissive texture and and the main color.
  6516. */
  6517. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  6518. /**
  6519. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  6520. * @param mesh The mesh to exclude from the highlight layer
  6521. */
  6522. addExcludedMesh(mesh: Mesh): void;
  6523. /**
  6524. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  6525. * @param mesh The mesh to highlight
  6526. */
  6527. removeExcludedMesh(mesh: Mesh): void;
  6528. /**
  6529. * Determine if a given mesh will be highlighted by the current HighlightLayer
  6530. * @param mesh mesh to test
  6531. * @returns true if the mesh will be highlighted by the current HighlightLayer
  6532. */
  6533. hasMesh(mesh: AbstractMesh): boolean;
  6534. /**
  6535. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  6536. * @param mesh The mesh to highlight
  6537. * @param color The color of the highlight
  6538. * @param glowEmissiveOnly Extract the glow from the emissive texture
  6539. */
  6540. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  6541. /**
  6542. * Remove a mesh from the highlight layer in order to make it stop glowing.
  6543. * @param mesh The mesh to highlight
  6544. */
  6545. removeMesh(mesh: Mesh): void;
  6546. /**
  6547. * Force the stencil to the normal expected value for none glowing parts
  6548. */
  6549. private _defaultStencilReference(mesh);
  6550. /**
  6551. * Free any resources and references associated to a mesh.
  6552. * Internal use
  6553. * @param mesh The mesh to free.
  6554. */
  6555. _disposeMesh(mesh: Mesh): void;
  6556. /**
  6557. * Dispose the highlight layer and free resources.
  6558. */
  6559. dispose(): void;
  6560. }
  6561. }
  6562. declare module BABYLON {
  6563. class Layer {
  6564. name: string;
  6565. texture: Nullable<Texture>;
  6566. isBackground: boolean;
  6567. color: Color4;
  6568. scale: Vector2;
  6569. offset: Vector2;
  6570. alphaBlendingMode: number;
  6571. alphaTest: boolean;
  6572. layerMask: number;
  6573. private _scene;
  6574. private _vertexBuffers;
  6575. private _indexBuffer;
  6576. private _effect;
  6577. private _alphaTestEffect;
  6578. /**
  6579. * An event triggered when the layer is disposed.
  6580. * @type {BABYLON.Observable}
  6581. */
  6582. onDisposeObservable: Observable<Layer>;
  6583. private _onDisposeObserver;
  6584. onDispose: () => void;
  6585. /**
  6586. * An event triggered before rendering the scene
  6587. * @type {BABYLON.Observable}
  6588. */
  6589. onBeforeRenderObservable: Observable<Layer>;
  6590. private _onBeforeRenderObserver;
  6591. onBeforeRender: () => void;
  6592. /**
  6593. * An event triggered after rendering the scene
  6594. * @type {BABYLON.Observable}
  6595. */
  6596. onAfterRenderObservable: Observable<Layer>;
  6597. private _onAfterRenderObserver;
  6598. onAfterRender: () => void;
  6599. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  6600. private _createIndexBuffer();
  6601. _rebuild(): void;
  6602. render(): void;
  6603. dispose(): void;
  6604. }
  6605. }
  6606. declare module BABYLON {
  6607. /**
  6608. * This class can be used to get instrumentation data from a Babylon engine
  6609. */
  6610. class EngineInstrumentation implements IDisposable {
  6611. engine: Engine;
  6612. private _captureGPUFrameTime;
  6613. private _gpuFrameTimeToken;
  6614. private _gpuFrameTime;
  6615. private _captureShaderCompilationTime;
  6616. private _shaderCompilationTime;
  6617. private _onBeginFrameObserver;
  6618. private _onEndFrameObserver;
  6619. private _onBeforeShaderCompilationObserver;
  6620. private _onAfterShaderCompilationObserver;
  6621. /**
  6622. * Gets the perf counter used for GPU frame time
  6623. */
  6624. readonly gpuFrameTimeCounter: PerfCounter;
  6625. /**
  6626. * Gets the GPU frame time capture status
  6627. */
  6628. /**
  6629. * Enable or disable the GPU frame time capture
  6630. */
  6631. captureGPUFrameTime: boolean;
  6632. /**
  6633. * Gets the perf counter used for shader compilation time
  6634. */
  6635. readonly shaderCompilationTimeCounter: PerfCounter;
  6636. /**
  6637. * Gets the shader compilation time capture status
  6638. */
  6639. /**
  6640. * Enable or disable the shader compilation time capture
  6641. */
  6642. captureShaderCompilationTime: boolean;
  6643. constructor(engine: Engine);
  6644. dispose(): void;
  6645. }
  6646. }
  6647. declare module BABYLON {
  6648. /**
  6649. * This class can be used to get instrumentation data from a Babylon engine
  6650. */
  6651. class SceneInstrumentation implements IDisposable {
  6652. scene: Scene;
  6653. private _captureActiveMeshesEvaluationTime;
  6654. private _activeMeshesEvaluationTime;
  6655. private _captureRenderTargetsRenderTime;
  6656. private _renderTargetsRenderTime;
  6657. private _captureFrameTime;
  6658. private _frameTime;
  6659. private _captureRenderTime;
  6660. private _renderTime;
  6661. private _captureInterFrameTime;
  6662. private _interFrameTime;
  6663. private _captureParticlesRenderTime;
  6664. private _particlesRenderTime;
  6665. private _captureSpritesRenderTime;
  6666. private _spritesRenderTime;
  6667. private _capturePhysicsTime;
  6668. private _physicsTime;
  6669. private _captureAnimationsTime;
  6670. private _animationsTime;
  6671. private _onBeforeActiveMeshesEvaluationObserver;
  6672. private _onAfterActiveMeshesEvaluationObserver;
  6673. private _onBeforeRenderTargetsRenderObserver;
  6674. private _onAfterRenderTargetsRenderObserver;
  6675. private _onAfterRenderObserver;
  6676. private _onBeforeDrawPhaseObserver;
  6677. private _onAfterDrawPhaseObserver;
  6678. private _onBeforeAnimationsObserver;
  6679. private _onBeforeParticlesRenderingObserver;
  6680. private _onAfterParticlesRenderingObserver;
  6681. private _onBeforeSpritesRenderingObserver;
  6682. private _onAfterSpritesRenderingObserver;
  6683. private _onBeforePhysicsObserver;
  6684. private _onAfterPhysicsObserver;
  6685. private _onAfterAnimationsObserver;
  6686. /**
  6687. * Gets the perf counter used for active meshes evaluation time
  6688. */
  6689. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  6690. /**
  6691. * Gets the active meshes evaluation time capture status
  6692. */
  6693. /**
  6694. * Enable or disable the active meshes evaluation time capture
  6695. */
  6696. captureActiveMeshesEvaluationTime: boolean;
  6697. /**
  6698. * Gets the perf counter used for render targets render time
  6699. */
  6700. readonly renderTargetsRenderTimeCounter: PerfCounter;
  6701. /**
  6702. * Gets the render targets render time capture status
  6703. */
  6704. /**
  6705. * Enable or disable the render targets render time capture
  6706. */
  6707. captureRenderTargetsRenderTime: boolean;
  6708. /**
  6709. * Gets the perf counter used for particles render time
  6710. */
  6711. readonly particlesRenderTimeCounter: PerfCounter;
  6712. /**
  6713. * Gets the particles render time capture status
  6714. */
  6715. /**
  6716. * Enable or disable the particles render time capture
  6717. */
  6718. captureParticlesRenderTime: boolean;
  6719. /**
  6720. * Gets the perf counter used for sprites render time
  6721. */
  6722. readonly spritesRenderTimeCounter: PerfCounter;
  6723. /**
  6724. * Gets the sprites render time capture status
  6725. */
  6726. /**
  6727. * Enable or disable the sprites render time capture
  6728. */
  6729. captureSpritesRenderTime: boolean;
  6730. /**
  6731. * Gets the perf counter used for physics time
  6732. */
  6733. readonly physicsTimeCounter: PerfCounter;
  6734. /**
  6735. * Gets the physics time capture status
  6736. */
  6737. /**
  6738. * Enable or disable the physics time capture
  6739. */
  6740. capturePhysicsTime: boolean;
  6741. /**
  6742. * Gets the perf counter used for animations time
  6743. */
  6744. readonly animationsTimeCounter: PerfCounter;
  6745. /**
  6746. * Gets the animations time capture status
  6747. */
  6748. /**
  6749. * Enable or disable the animations time capture
  6750. */
  6751. captureAnimationsTime: boolean;
  6752. /**
  6753. * Gets the perf counter used for frame time capture
  6754. */
  6755. readonly frameTimeCounter: PerfCounter;
  6756. /**
  6757. * Gets the frame time capture status
  6758. */
  6759. /**
  6760. * Enable or disable the frame time capture
  6761. */
  6762. captureFrameTime: boolean;
  6763. /**
  6764. * Gets the perf counter used for inter-frames time capture
  6765. */
  6766. readonly interFrameTimeCounter: PerfCounter;
  6767. /**
  6768. * Gets the inter-frames time capture status
  6769. */
  6770. /**
  6771. * Enable or disable the inter-frames time capture
  6772. */
  6773. captureInterFrameTime: boolean;
  6774. /**
  6775. * Gets the perf counter used for render time capture
  6776. */
  6777. readonly renderTimeCounter: PerfCounter;
  6778. /**
  6779. * Gets the render time capture status
  6780. */
  6781. /**
  6782. * Enable or disable the render time capture
  6783. */
  6784. captureRenderTime: boolean;
  6785. /**
  6786. * Gets the perf counter used for draw calls
  6787. */
  6788. readonly drawCallsCounter: PerfCounter;
  6789. /**
  6790. * Gets the perf counter used for texture collisions
  6791. */
  6792. readonly textureCollisionsCounter: PerfCounter;
  6793. constructor(scene: Scene);
  6794. dispose(): void;
  6795. }
  6796. }
  6797. declare module BABYLON {
  6798. class _TimeToken {
  6799. _startTimeQuery: Nullable<WebGLQuery>;
  6800. _endTimeQuery: Nullable<WebGLQuery>;
  6801. _timeElapsedQuery: Nullable<WebGLQuery>;
  6802. _timeElapsedQueryEnded: boolean;
  6803. }
  6804. }
  6805. declare module BABYLON {
  6806. class LensFlare {
  6807. size: number;
  6808. position: number;
  6809. color: Color3;
  6810. texture: Nullable<Texture>;
  6811. alphaMode: number;
  6812. private _system;
  6813. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  6814. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  6815. dispose(): void;
  6816. }
  6817. }
  6818. declare module BABYLON {
  6819. class LensFlareSystem {
  6820. name: string;
  6821. lensFlares: LensFlare[];
  6822. borderLimit: number;
  6823. viewportBorder: number;
  6824. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  6825. layerMask: number;
  6826. id: string;
  6827. private _scene;
  6828. private _emitter;
  6829. private _vertexBuffers;
  6830. private _indexBuffer;
  6831. private _effect;
  6832. private _positionX;
  6833. private _positionY;
  6834. private _isEnabled;
  6835. constructor(name: string, emitter: any, scene: Scene);
  6836. isEnabled: boolean;
  6837. getScene(): Scene;
  6838. getEmitter(): any;
  6839. setEmitter(newEmitter: any): void;
  6840. getEmitterPosition(): Vector3;
  6841. computeEffectivePosition(globalViewport: Viewport): boolean;
  6842. _isVisible(): boolean;
  6843. render(): boolean;
  6844. dispose(): void;
  6845. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  6846. serialize(): any;
  6847. }
  6848. }
  6849. declare module BABYLON {
  6850. interface ILoadingScreen {
  6851. displayLoadingUI: () => void;
  6852. hideLoadingUI: () => void;
  6853. loadingUIBackgroundColor: string;
  6854. loadingUIText: string;
  6855. }
  6856. class DefaultLoadingScreen implements ILoadingScreen {
  6857. private _renderingCanvas;
  6858. private _loadingText;
  6859. private _loadingDivBackgroundColor;
  6860. private _loadingDiv;
  6861. private _loadingTextDiv;
  6862. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  6863. displayLoadingUI(): void;
  6864. hideLoadingUI(): void;
  6865. loadingUIText: string;
  6866. loadingUIBackgroundColor: string;
  6867. private _resizeLoadingUI;
  6868. }
  6869. }
  6870. declare module BABYLON {
  6871. class SceneLoaderProgressEvent {
  6872. readonly lengthComputable: boolean;
  6873. readonly loaded: number;
  6874. readonly total: number;
  6875. constructor(lengthComputable: boolean, loaded: number, total: number);
  6876. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  6877. }
  6878. interface ISceneLoaderPluginExtensions {
  6879. [extension: string]: {
  6880. isBinary: boolean;
  6881. };
  6882. }
  6883. interface ISceneLoaderPluginFactory {
  6884. name: string;
  6885. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  6886. canDirectLoad?: (data: string) => boolean;
  6887. }
  6888. interface ISceneLoaderPlugin {
  6889. /**
  6890. * The friendly name of this plugin.
  6891. */
  6892. name: string;
  6893. /**
  6894. * The file extensions supported by this plugin.
  6895. */
  6896. extensions: string | ISceneLoaderPluginExtensions;
  6897. /**
  6898. * Import meshes into a scene.
  6899. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  6900. * @param scene The scene to import into
  6901. * @param data The data to import
  6902. * @param rootUrl The root url for scene and resources
  6903. * @param meshes The meshes array to import into
  6904. * @param particleSystems The particle systems array to import into
  6905. * @param skeletons The skeletons array to import into
  6906. * @param onError The callback when import fails
  6907. * @returns True if successful or false otherwise
  6908. */
  6909. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  6910. /**
  6911. * Load into a scene.
  6912. * @param scene The scene to load into
  6913. * @param data The data to import
  6914. * @param rootUrl The root url for scene and resources
  6915. * @param onError The callback when import fails
  6916. * @returns true if successful or false otherwise
  6917. */
  6918. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  6919. /**
  6920. * The callback that returns true if the data can be directly loaded.
  6921. */
  6922. canDirectLoad?: (data: string) => boolean;
  6923. /**
  6924. * The callback that allows custom handling of the root url based on the response url.
  6925. */
  6926. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  6927. /**
  6928. * Load into an asset container.
  6929. * @param scene The scene to load into
  6930. * @param data The data to import
  6931. * @param rootUrl The root url for scene and resources
  6932. * @param onError The callback when import fails
  6933. * @returns The loaded asset container
  6934. */
  6935. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  6936. }
  6937. interface ISceneLoaderPluginAsync {
  6938. /**
  6939. * The friendly name of this plugin.
  6940. */
  6941. name: string;
  6942. /**
  6943. * The file extensions supported by this plugin.
  6944. */
  6945. extensions: string | ISceneLoaderPluginExtensions;
  6946. /**
  6947. * Import meshes into a scene.
  6948. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  6949. * @param scene The scene to import into
  6950. * @param data The data to import
  6951. * @param rootUrl The root url for scene and resources
  6952. * @param onProgress The callback when the load progresses
  6953. * @returns The loaded meshes, particle systems, and skeletons
  6954. */
  6955. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  6956. meshes: AbstractMesh[];
  6957. particleSystems: ParticleSystem[];
  6958. skeletons: Skeleton[];
  6959. }>;
  6960. /**
  6961. * Load into a scene.
  6962. * @param scene The scene to load into
  6963. * @param data The data to import
  6964. * @param rootUrl The root url for scene and resources
  6965. * @param onProgress The callback when the load progresses
  6966. * @returns Nothing
  6967. */
  6968. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  6969. /**
  6970. * The callback that returns true if the data can be directly loaded.
  6971. */
  6972. canDirectLoad?: (data: string) => boolean;
  6973. /**
  6974. * The callback that allows custom handling of the root url based on the response url.
  6975. */
  6976. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  6977. /**
  6978. * Load into an asset container.
  6979. * @param scene The scene to load into
  6980. * @param data The data to import
  6981. * @param rootUrl The root url for scene and resources
  6982. * @param onProgress The callback when the load progresses
  6983. * @returns The loaded asset container
  6984. */
  6985. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  6986. }
  6987. class SceneLoader {
  6988. private static _ForceFullSceneLoadingForIncremental;
  6989. private static _ShowLoadingScreen;
  6990. private static _CleanBoneMatrixWeights;
  6991. static readonly NO_LOGGING: number;
  6992. static readonly MINIMAL_LOGGING: number;
  6993. static readonly SUMMARY_LOGGING: number;
  6994. static readonly DETAILED_LOGGING: number;
  6995. private static _loggingLevel;
  6996. static ForceFullSceneLoadingForIncremental: boolean;
  6997. static ShowLoadingScreen: boolean;
  6998. static loggingLevel: number;
  6999. static CleanBoneMatrixWeights: boolean;
  7000. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  7001. private static _registeredPlugins;
  7002. private static _getDefaultPlugin();
  7003. private static _getPluginForExtension(extension);
  7004. private static _getPluginForDirectLoad(data);
  7005. private static _getPluginForFilename(sceneFilename);
  7006. private static _getDirectLoad(sceneFilename);
  7007. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  7008. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  7009. static IsPluginForExtensionAvailable(extension: string): boolean;
  7010. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  7011. /**
  7012. * Import meshes into a scene
  7013. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  7014. * @param rootUrl a string that defines the root url for scene and resources
  7015. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7016. * @param scene the instance of BABYLON.Scene to append to
  7017. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  7018. * @param onProgress a callback with a progress event for each file being loaded
  7019. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  7020. * @param pluginExtension the extension used to determine the plugin
  7021. * @returns The loaded plugin
  7022. */
  7023. 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>;
  7024. /**
  7025. * Import meshes into a scene
  7026. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  7027. * @param rootUrl a string that defines the root url for scene and resources
  7028. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7029. * @param scene the instance of BABYLON.Scene to append to
  7030. * @param onProgress a callback with a progress event for each file being loaded
  7031. * @param pluginExtension the extension used to determine the plugin
  7032. * @returns The loaded list of imported meshes, particleSystems, and skeletons
  7033. */
  7034. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  7035. meshes: AbstractMesh[];
  7036. particleSystems: ParticleSystem[];
  7037. skeletons: Skeleton[];
  7038. }>;
  7039. /**
  7040. * Load a scene
  7041. * @param rootUrl a string that defines the root url for scene and resources
  7042. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7043. * @param engine is the instance of BABYLON.Engine to use to create the scene
  7044. * @param onSuccess a callback with the scene when import succeeds
  7045. * @param onProgress a callback with a progress event for each file being loaded
  7046. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  7047. * @param pluginExtension the extension used to determine the plugin
  7048. * @returns The loaded plugin
  7049. */
  7050. 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>;
  7051. /**
  7052. * Load a scene
  7053. * @param rootUrl a string that defines the root url for scene and resources
  7054. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7055. * @param engine is the instance of BABYLON.Engine to use to create the scene
  7056. * @param onProgress a callback with a progress event for each file being loaded
  7057. * @param pluginExtension the extension used to determine the plugin
  7058. * @returns The loaded scene
  7059. */
  7060. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  7061. /**
  7062. * Append a scene
  7063. * @param rootUrl a string that defines the root url for scene and resources
  7064. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7065. * @param scene is the instance of BABYLON.Scene to append to
  7066. * @param onSuccess a callback with the scene when import succeeds
  7067. * @param onProgress a callback with a progress event for each file being loaded
  7068. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  7069. * @param pluginExtension the extension used to determine the plugin
  7070. * @returns The loaded plugin
  7071. */
  7072. 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>;
  7073. /**
  7074. * Append a scene
  7075. * @param rootUrl a string that defines the root url for scene and resources
  7076. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7077. * @param scene is the instance of BABYLON.Scene to append to
  7078. * @param onProgress a callback with a progress event for each file being loaded
  7079. * @param pluginExtension the extension used to determine the plugin
  7080. * @returns The given scene
  7081. */
  7082. static AppendAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  7083. /**
  7084. * Load a scene into an asset container
  7085. * @param rootUrl a string that defines the root url for scene and resources
  7086. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7087. * @param scene is the instance of BABYLON.Scene to append to
  7088. * @param onSuccess a callback with the scene when import succeeds
  7089. * @param onProgress a callback with a progress event for each file being loaded
  7090. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  7091. * @param pluginExtension the extension used to determine the plugin
  7092. * @returns The loaded plugin
  7093. */
  7094. 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>;
  7095. /**
  7096. * Load a scene into an asset container
  7097. * @param rootUrl a string that defines the root url for scene and resources
  7098. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7099. * @param scene is the instance of BABYLON.Scene to append to
  7100. * @param onProgress a callback with a progress event for each file being loaded
  7101. * @param pluginExtension the extension used to determine the plugin
  7102. * @returns The loaded asset container
  7103. */
  7104. static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  7105. }
  7106. }
  7107. declare module BABYLON {
  7108. /**
  7109. * A directional light is defined by a direction (what a surprise!).
  7110. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  7111. * 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.
  7112. * Documentation: https://doc.babylonjs.com/babylon101/lights
  7113. */
  7114. class DirectionalLight extends ShadowLight {
  7115. private _shadowFrustumSize;
  7116. /**
  7117. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  7118. */
  7119. /**
  7120. * Specifies a fix frustum size for the shadow generation.
  7121. */
  7122. shadowFrustumSize: number;
  7123. private _shadowOrthoScale;
  7124. /**
  7125. * Gets the shadow projection scale against the optimal computed one.
  7126. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  7127. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  7128. */
  7129. /**
  7130. * Sets the shadow projection scale against the optimal computed one.
  7131. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  7132. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  7133. */
  7134. shadowOrthoScale: number;
  7135. /**
  7136. * Automatically compute the projection matrix to best fit (including all the casters)
  7137. * on each frame.
  7138. */
  7139. autoUpdateExtends: boolean;
  7140. private _orthoLeft;
  7141. private _orthoRight;
  7142. private _orthoTop;
  7143. private _orthoBottom;
  7144. /**
  7145. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  7146. * The directional light is emitted from everywhere in the given direction.
  7147. * It can cast shawdows.
  7148. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7149. * @param name The friendly name of the light
  7150. * @param direction The direction of the light
  7151. * @param scene The scene the light belongs to
  7152. */
  7153. constructor(name: string, direction: Vector3, scene: Scene);
  7154. /**
  7155. * Returns the string "DirectionalLight".
  7156. * @return The class name
  7157. */
  7158. getClassName(): string;
  7159. /**
  7160. * Returns the integer 1.
  7161. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7162. */
  7163. getTypeID(): number;
  7164. /**
  7165. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  7166. * Returns the DirectionalLight Shadow projection matrix.
  7167. */
  7168. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7169. /**
  7170. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  7171. * Returns the DirectionalLight Shadow projection matrix.
  7172. */
  7173. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  7174. /**
  7175. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  7176. * Returns the DirectionalLight Shadow projection matrix.
  7177. */
  7178. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7179. protected _buildUniformLayout(): void;
  7180. /**
  7181. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  7182. * @param effect The effect to update
  7183. * @param lightIndex The index of the light in the effect to update
  7184. * @returns The directional light
  7185. */
  7186. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  7187. /**
  7188. * Gets the minZ used for shadow according to both the scene and the light.
  7189. *
  7190. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  7191. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  7192. * @param activeCamera The camera we are returning the min for
  7193. * @returns the depth min z
  7194. */
  7195. getDepthMinZ(activeCamera: Camera): number;
  7196. /**
  7197. * Gets the maxZ used for shadow according to both the scene and the light.
  7198. *
  7199. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  7200. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  7201. * @param activeCamera The camera we are returning the max for
  7202. * @returns the depth max z
  7203. */
  7204. getDepthMaxZ(activeCamera: Camera): number;
  7205. }
  7206. }
  7207. declare module BABYLON {
  7208. /**
  7209. * The HemisphericLight simulates the ambient environment light,
  7210. * so the passed direction is the light reflection direction, not the incoming direction.
  7211. */
  7212. class HemisphericLight extends Light {
  7213. /**
  7214. * The groundColor is the light in the opposite direction to the one specified during creation.
  7215. * 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.
  7216. */
  7217. groundColor: Color3;
  7218. /**
  7219. * The light reflection direction, not the incoming direction.
  7220. */
  7221. direction: Vector3;
  7222. private _worldMatrix;
  7223. /**
  7224. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  7225. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  7226. * The HemisphericLight can't cast shadows.
  7227. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7228. * @param name The friendly name of the light
  7229. * @param direction The direction of the light reflection
  7230. * @param scene The scene the light belongs to
  7231. */
  7232. constructor(name: string, direction: Vector3, scene: Scene);
  7233. protected _buildUniformLayout(): void;
  7234. /**
  7235. * Returns the string "HemisphericLight".
  7236. * @return The class name
  7237. */
  7238. getClassName(): string;
  7239. /**
  7240. * Sets the HemisphericLight direction towards the passed target (Vector3).
  7241. * Returns the updated direction.
  7242. * @param target The target the direction should point to
  7243. * @return The computed direction
  7244. */
  7245. setDirectionToTarget(target: Vector3): Vector3;
  7246. /**
  7247. * Returns the shadow generator associated to the light.
  7248. * @returns Always null for hemispheric lights because it does not support shadows.
  7249. */
  7250. getShadowGenerator(): Nullable<ShadowGenerator>;
  7251. /**
  7252. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  7253. * @param effect The effect to update
  7254. * @param lightIndex The index of the light in the effect to update
  7255. * @returns The hemispheric light
  7256. */
  7257. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  7258. /**
  7259. * @ignore internal use only.
  7260. */
  7261. _getWorldMatrix(): Matrix;
  7262. /**
  7263. * Returns the integer 3.
  7264. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7265. */
  7266. getTypeID(): number;
  7267. }
  7268. }
  7269. declare module BABYLON {
  7270. /**
  7271. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  7272. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  7273. * 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.
  7274. */
  7275. abstract class Light extends Node {
  7276. private static _LIGHTMAP_DEFAULT;
  7277. private static _LIGHTMAP_SPECULAR;
  7278. private static _LIGHTMAP_SHADOWSONLY;
  7279. /**
  7280. * If every light affecting the material is in this lightmapMode,
  7281. * material.lightmapTexture adds or multiplies
  7282. * (depends on material.useLightmapAsShadowmap)
  7283. * after every other light calculations.
  7284. */
  7285. static readonly LIGHTMAP_DEFAULT: number;
  7286. /**
  7287. * material.lightmapTexture as only diffuse lighting from this light
  7288. * adds only specular lighting from this light
  7289. * adds dynamic shadows
  7290. */
  7291. static readonly LIGHTMAP_SPECULAR: number;
  7292. /**
  7293. * material.lightmapTexture as only lighting
  7294. * no light calculation from this light
  7295. * only adds dynamic shadows from this light
  7296. */
  7297. static readonly LIGHTMAP_SHADOWSONLY: number;
  7298. private static _INTENSITYMODE_AUTOMATIC;
  7299. private static _INTENSITYMODE_LUMINOUSPOWER;
  7300. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  7301. private static _INTENSITYMODE_ILLUMINANCE;
  7302. private static _INTENSITYMODE_LUMINANCE;
  7303. /**
  7304. * Each light type uses the default quantity according to its type:
  7305. * point/spot lights use luminous intensity
  7306. * directional lights use illuminance
  7307. */
  7308. static readonly INTENSITYMODE_AUTOMATIC: number;
  7309. /**
  7310. * lumen (lm)
  7311. */
  7312. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  7313. /**
  7314. * candela (lm/sr)
  7315. */
  7316. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  7317. /**
  7318. * lux (lm/m^2)
  7319. */
  7320. static readonly INTENSITYMODE_ILLUMINANCE: number;
  7321. /**
  7322. * nit (cd/m^2)
  7323. */
  7324. static readonly INTENSITYMODE_LUMINANCE: number;
  7325. private static _LIGHTTYPEID_POINTLIGHT;
  7326. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  7327. private static _LIGHTTYPEID_SPOTLIGHT;
  7328. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  7329. /**
  7330. * Light type const id of the point light.
  7331. */
  7332. static readonly LIGHTTYPEID_POINTLIGHT: number;
  7333. /**
  7334. * Light type const id of the directional light.
  7335. */
  7336. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  7337. /**
  7338. * Light type const id of the spot light.
  7339. */
  7340. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  7341. /**
  7342. * Light type const id of the hemispheric light.
  7343. */
  7344. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  7345. /**
  7346. * Diffuse gives the basic color to an object.
  7347. */
  7348. diffuse: Color3;
  7349. /**
  7350. * Specular produces a highlight color on an object.
  7351. * Note: This is note affecting PBR materials.
  7352. */
  7353. specular: Color3;
  7354. /**
  7355. * Strength of the light.
  7356. * Note: By default it is define in the framework own unit.
  7357. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  7358. */
  7359. intensity: number;
  7360. /**
  7361. * Defines how far from the source the light is impacting in scene units.
  7362. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  7363. */
  7364. range: number;
  7365. /**
  7366. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  7367. * of light.
  7368. */
  7369. private _photometricScale;
  7370. private _intensityMode;
  7371. /**
  7372. * Gets the photometric scale used to interpret the intensity.
  7373. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  7374. */
  7375. /**
  7376. * Sets the photometric scale used to interpret the intensity.
  7377. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  7378. */
  7379. intensityMode: number;
  7380. private _radius;
  7381. /**
  7382. * Gets the light radius used by PBR Materials to simulate soft area lights.
  7383. */
  7384. /**
  7385. * sets the light radius used by PBR Materials to simulate soft area lights.
  7386. */
  7387. radius: number;
  7388. private _renderPriority;
  7389. /**
  7390. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  7391. * exceeding the number allowed of the materials.
  7392. */
  7393. renderPriority: number;
  7394. /**
  7395. * Defines wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  7396. * the current shadow generator.
  7397. */
  7398. shadowEnabled: boolean;
  7399. private _includedOnlyMeshes;
  7400. /**
  7401. * Gets the only meshes impacted by this light.
  7402. */
  7403. /**
  7404. * Sets the only meshes impacted by this light.
  7405. */
  7406. includedOnlyMeshes: AbstractMesh[];
  7407. private _excludedMeshes;
  7408. /**
  7409. * Gets the meshes not impacted by this light.
  7410. */
  7411. /**
  7412. * Sets the meshes not impacted by this light.
  7413. */
  7414. excludedMeshes: AbstractMesh[];
  7415. private _excludeWithLayerMask;
  7416. /**
  7417. * Gets the layer id use to find what meshes are not impacted by the light.
  7418. * Inactive if 0
  7419. */
  7420. /**
  7421. * Sets the layer id use to find what meshes are not impacted by the light.
  7422. * Inactive if 0
  7423. */
  7424. excludeWithLayerMask: number;
  7425. private _includeOnlyWithLayerMask;
  7426. /**
  7427. * Gets the layer id use to find what meshes are impacted by the light.
  7428. * Inactive if 0
  7429. */
  7430. /**
  7431. * Sets the layer id use to find what meshes are impacted by the light.
  7432. * Inactive if 0
  7433. */
  7434. includeOnlyWithLayerMask: number;
  7435. private _lightmapMode;
  7436. /**
  7437. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  7438. */
  7439. /**
  7440. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  7441. */
  7442. lightmapMode: number;
  7443. private _parentedWorldMatrix;
  7444. /**
  7445. * Shadow generator associted to the light.
  7446. * Internal use only.
  7447. */
  7448. _shadowGenerator: Nullable<IShadowGenerator>;
  7449. /**
  7450. * @ignore Internal use only.
  7451. */
  7452. _excludedMeshesIds: string[];
  7453. /**
  7454. * @ignore Internal use only.
  7455. */
  7456. _includedOnlyMeshesIds: string[];
  7457. /**
  7458. * The current light unifom buffer.
  7459. * @ignore Internal use only.
  7460. */
  7461. _uniformBuffer: UniformBuffer;
  7462. /**
  7463. * Creates a Light object in the scene.
  7464. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7465. * @param name The firendly name of the light
  7466. * @param scene The scene the light belongs too
  7467. */
  7468. constructor(name: string, scene: Scene);
  7469. protected abstract _buildUniformLayout(): void;
  7470. /**
  7471. * Sets the passed Effect "effect" with the Light information.
  7472. * @param effect The effect to update
  7473. * @param lightIndex The index of the light in the effect to update
  7474. * @returns The light
  7475. */
  7476. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  7477. /**
  7478. * @ignore internal use only.
  7479. */
  7480. abstract _getWorldMatrix(): Matrix;
  7481. /**
  7482. * Returns the string "Light".
  7483. * @returns the class name
  7484. */
  7485. getClassName(): string;
  7486. /**
  7487. * Converts the light information to a readable string for debug purpose.
  7488. * @param fullDetails Supports for multiple levels of logging within scene loading
  7489. * @returns the human readable light info
  7490. */
  7491. toString(fullDetails?: boolean): string;
  7492. /**
  7493. * Set the enabled state of this node.
  7494. * @param value - the new enabled state
  7495. * @see isEnabled
  7496. */
  7497. setEnabled(value: boolean): void;
  7498. /**
  7499. * Returns the Light associated shadow generator if any.
  7500. * @return the associated shadow generator.
  7501. */
  7502. getShadowGenerator(): Nullable<IShadowGenerator>;
  7503. /**
  7504. * Returns a Vector3, the absolute light position in the World.
  7505. * @returns the world space position of the light
  7506. */
  7507. getAbsolutePosition(): Vector3;
  7508. /**
  7509. * Specifies if the light will affect the passed mesh.
  7510. * @param mesh The mesh to test against the light
  7511. * @return true the mesh is affected otherwise, false.
  7512. */
  7513. canAffectMesh(mesh: AbstractMesh): boolean;
  7514. /**
  7515. * Computes and Returns the light World matrix.
  7516. * @returns the world matrix
  7517. */
  7518. getWorldMatrix(): Matrix;
  7519. /**
  7520. * Sort function to order lights for rendering.
  7521. * @param a First Light object to compare to second.
  7522. * @param b Second Light object to compare first.
  7523. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  7524. */
  7525. static CompareLightsPriority(a: Light, b: Light): number;
  7526. /**
  7527. * Releases resources associated with this node.
  7528. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7529. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7530. */
  7531. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7532. /**
  7533. * Returns the light type ID (integer).
  7534. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7535. */
  7536. getTypeID(): number;
  7537. /**
  7538. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  7539. * @returns the scaled intensity in intensity mode unit
  7540. */
  7541. getScaledIntensity(): number;
  7542. /**
  7543. * Returns a new Light object, named "name", from the current one.
  7544. * @param name The name of the cloned light
  7545. * @returns the new created light
  7546. */
  7547. clone(name: string): Nullable<Light>;
  7548. /**
  7549. * Serializes the current light into a Serialization object.
  7550. * @returns the serialized object.
  7551. */
  7552. serialize(): any;
  7553. /**
  7554. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  7555. * This new light is named "name" and added to the passed scene.
  7556. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  7557. * @param name The friendly name of the light
  7558. * @param scene The scene the new light will belong to
  7559. * @returns the constructor function
  7560. */
  7561. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  7562. /**
  7563. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  7564. * @param parsedLight The JSON representation of the light
  7565. * @param scene The scene to create the parsed light in
  7566. * @returns the created light after parsing
  7567. */
  7568. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  7569. private _hookArrayForExcluded(array);
  7570. private _hookArrayForIncludedOnly(array);
  7571. private _resyncMeshes();
  7572. /**
  7573. * Forces the meshes to update their light related information in their rendering used effects
  7574. * @ignore Internal Use Only
  7575. */
  7576. _markMeshesAsLightDirty(): void;
  7577. /**
  7578. * Recomputes the cached photometric scale if needed.
  7579. */
  7580. private _computePhotometricScale();
  7581. /**
  7582. * Returns the Photometric Scale according to the light type and intensity mode.
  7583. */
  7584. private _getPhotometricScale();
  7585. /**
  7586. * Reorder the light in the scene according to their defined priority.
  7587. * @ignore Internal Use Only
  7588. */
  7589. _reorderLightsInScene(): void;
  7590. }
  7591. }
  7592. declare module BABYLON {
  7593. /**
  7594. * A point light is a light defined by an unique point in world space.
  7595. * The light is emitted in every direction from this point.
  7596. * A good example of a point light is a standard light bulb.
  7597. * Documentation: https://doc.babylonjs.com/babylon101/lights
  7598. */
  7599. class PointLight extends ShadowLight {
  7600. private _shadowAngle;
  7601. /**
  7602. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7603. * This specifies what angle the shadow will use to be created.
  7604. *
  7605. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  7606. */
  7607. /**
  7608. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7609. * This specifies what angle the shadow will use to be created.
  7610. *
  7611. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  7612. */
  7613. shadowAngle: number;
  7614. /**
  7615. * Gets the direction if it has been set.
  7616. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7617. */
  7618. /**
  7619. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7620. */
  7621. direction: Vector3;
  7622. /**
  7623. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  7624. * A PointLight emits the light in every direction.
  7625. * It can cast shadows.
  7626. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  7627. * ```javascript
  7628. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  7629. * ```
  7630. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7631. * @param name The light friendly name
  7632. * @param position The position of the point light in the scene
  7633. * @param scene The scene the lights belongs to
  7634. */
  7635. constructor(name: string, position: Vector3, scene: Scene);
  7636. /**
  7637. * Returns the string "PointLight"
  7638. * @returns the class name
  7639. */
  7640. getClassName(): string;
  7641. /**
  7642. * Returns the integer 0.
  7643. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7644. */
  7645. getTypeID(): number;
  7646. /**
  7647. * Specifies wether or not the shadowmap should be a cube texture.
  7648. * @returns true if the shadowmap needs to be a cube texture.
  7649. */
  7650. needCube(): boolean;
  7651. /**
  7652. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  7653. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7654. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7655. */
  7656. getShadowDirection(faceIndex?: number): Vector3;
  7657. /**
  7658. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  7659. * - fov = PI / 2
  7660. * - aspect ratio : 1.0
  7661. * - z-near and far equal to the active camera minZ and maxZ.
  7662. * Returns the PointLight.
  7663. */
  7664. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7665. protected _buildUniformLayout(): void;
  7666. /**
  7667. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  7668. * @param effect The effect to update
  7669. * @param lightIndex The index of the light in the effect to update
  7670. * @returns The point light
  7671. */
  7672. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  7673. }
  7674. }
  7675. declare module BABYLON {
  7676. /**
  7677. * Interface describing all the common properties and methods a shadow light needs to implement.
  7678. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  7679. * as well as binding the different shadow properties to the effects.
  7680. */
  7681. interface IShadowLight extends Light {
  7682. /**
  7683. * The light id in the scene (used in scene.findLighById for instance)
  7684. */
  7685. id: string;
  7686. /**
  7687. * The position the shdow will be casted from.
  7688. */
  7689. position: Vector3;
  7690. /**
  7691. * In 2d mode (needCube being false), the direction used to cast the shadow.
  7692. */
  7693. direction: Vector3;
  7694. /**
  7695. * The transformed position. Position of the light in world space taking parenting in account.
  7696. */
  7697. transformedPosition: Vector3;
  7698. /**
  7699. * The transformed direction. Direction of the light in world space taking parenting in account.
  7700. */
  7701. transformedDirection: Vector3;
  7702. /**
  7703. * The friendly name of the light in the scene.
  7704. */
  7705. name: string;
  7706. /**
  7707. * Defines the shadow projection clipping minimum z value.
  7708. */
  7709. shadowMinZ: number;
  7710. /**
  7711. * Defines the shadow projection clipping maximum z value.
  7712. */
  7713. shadowMaxZ: number;
  7714. /**
  7715. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  7716. * @returns true if the information has been computed, false if it does not need to (no parenting)
  7717. */
  7718. computeTransformedInformation(): boolean;
  7719. /**
  7720. * Gets the scene the light belongs to.
  7721. * @returns The scene
  7722. */
  7723. getScene(): Scene;
  7724. /**
  7725. * Callback defining a custom Projection Matrix Builder.
  7726. * This can be used to override the default projection matrix computation.
  7727. */
  7728. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  7729. /**
  7730. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  7731. * @param matrix The materix to updated with the projection information
  7732. * @param viewMatrix The transform matrix of the light
  7733. * @param renderList The list of mesh to render in the map
  7734. * @returns The current light
  7735. */
  7736. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  7737. /**
  7738. * Gets the current depth scale used in ESM.
  7739. * @returns The scale
  7740. */
  7741. getDepthScale(): number;
  7742. /**
  7743. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  7744. * @returns true if a cube texture needs to be use
  7745. */
  7746. needCube(): boolean;
  7747. /**
  7748. * Detects if the projection matrix requires to be recomputed this frame.
  7749. * @returns true if it requires to be recomputed otherwise, false.
  7750. */
  7751. needProjectionMatrixCompute(): boolean;
  7752. /**
  7753. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  7754. */
  7755. forceProjectionMatrixCompute(): void;
  7756. /**
  7757. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  7758. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7759. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7760. */
  7761. getShadowDirection(faceIndex?: number): Vector3;
  7762. /**
  7763. * Gets the minZ used for shadow according to both the scene and the light.
  7764. * @param activeCamera The camera we are returning the min for
  7765. * @returns the depth min z
  7766. */
  7767. getDepthMinZ(activeCamera: Camera): number;
  7768. /**
  7769. * Gets the maxZ used for shadow according to both the scene and the light.
  7770. * @param activeCamera The camera we are returning the max for
  7771. * @returns the depth max z
  7772. */
  7773. getDepthMaxZ(activeCamera: Camera): number;
  7774. }
  7775. /**
  7776. * Base implementation of @see IShadowLight
  7777. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  7778. */
  7779. abstract class ShadowLight extends Light implements IShadowLight {
  7780. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7781. protected _position: Vector3;
  7782. protected _setPosition(value: Vector3): void;
  7783. /**
  7784. * Sets the position the shadow will be casted from. Also use as the light position for both
  7785. * point and spot lights.
  7786. */
  7787. /**
  7788. * Sets the position the shadow will be casted from. Also use as the light position for both
  7789. * point and spot lights.
  7790. */
  7791. position: Vector3;
  7792. protected _direction: Vector3;
  7793. protected _setDirection(value: Vector3): void;
  7794. /**
  7795. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  7796. * Also use as the light direction on spot and directional lights.
  7797. */
  7798. /**
  7799. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  7800. * Also use as the light direction on spot and directional lights.
  7801. */
  7802. direction: Vector3;
  7803. private _shadowMinZ;
  7804. /**
  7805. * Gets the shadow projection clipping minimum z value.
  7806. */
  7807. /**
  7808. * Sets the shadow projection clipping minimum z value.
  7809. */
  7810. shadowMinZ: number;
  7811. private _shadowMaxZ;
  7812. /**
  7813. * Sets the shadow projection clipping maximum z value.
  7814. */
  7815. /**
  7816. * Gets the shadow projection clipping maximum z value.
  7817. */
  7818. shadowMaxZ: number;
  7819. /**
  7820. * Callback defining a custom Projection Matrix Builder.
  7821. * This can be used to override the default projection matrix computation.
  7822. */
  7823. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  7824. /**
  7825. * The transformed position. Position of the light in world space taking parenting in account.
  7826. */
  7827. transformedPosition: Vector3;
  7828. /**
  7829. * The transformed direction. Direction of the light in world space taking parenting in account.
  7830. */
  7831. transformedDirection: Vector3;
  7832. private _worldMatrix;
  7833. private _needProjectionMatrixCompute;
  7834. /**
  7835. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  7836. * @returns true if the information has been computed, false if it does not need to (no parenting)
  7837. */
  7838. computeTransformedInformation(): boolean;
  7839. /**
  7840. * Return the depth scale used for the shadow map.
  7841. * @returns the depth scale.
  7842. */
  7843. getDepthScale(): number;
  7844. /**
  7845. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  7846. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7847. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7848. */
  7849. getShadowDirection(faceIndex?: number): Vector3;
  7850. /**
  7851. * Returns the ShadowLight absolute position in the World.
  7852. * @returns the position vector in world space
  7853. */
  7854. getAbsolutePosition(): Vector3;
  7855. /**
  7856. * Sets the ShadowLight direction toward the passed target.
  7857. * @param target The point tot target in local space
  7858. * @returns the updated ShadowLight direction
  7859. */
  7860. setDirectionToTarget(target: Vector3): Vector3;
  7861. /**
  7862. * Returns the light rotation in euler definition.
  7863. * @returns the x y z rotation in local space.
  7864. */
  7865. getRotation(): Vector3;
  7866. /**
  7867. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  7868. * @returns true if a cube texture needs to be use
  7869. */
  7870. needCube(): boolean;
  7871. /**
  7872. * Detects if the projection matrix requires to be recomputed this frame.
  7873. * @returns true if it requires to be recomputed otherwise, false.
  7874. */
  7875. needProjectionMatrixCompute(): boolean;
  7876. /**
  7877. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  7878. */
  7879. forceProjectionMatrixCompute(): void;
  7880. /**
  7881. * Get the world matrix of the sahdow lights.
  7882. * @ignore Internal Use Only
  7883. */
  7884. _getWorldMatrix(): Matrix;
  7885. /**
  7886. * Gets the minZ used for shadow according to both the scene and the light.
  7887. * @param activeCamera The camera we are returning the min for
  7888. * @returns the depth min z
  7889. */
  7890. getDepthMinZ(activeCamera: Camera): number;
  7891. /**
  7892. * Gets the maxZ used for shadow according to both the scene and the light.
  7893. * @param activeCamera The camera we are returning the max for
  7894. * @returns the depth max z
  7895. */
  7896. getDepthMaxZ(activeCamera: Camera): number;
  7897. /**
  7898. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  7899. * @param matrix The materix to updated with the projection information
  7900. * @param viewMatrix The transform matrix of the light
  7901. * @param renderList The list of mesh to render in the map
  7902. * @returns The current light
  7903. */
  7904. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  7905. }
  7906. }
  7907. declare module BABYLON {
  7908. /**
  7909. * A spot light is defined by a position, a direction, an angle, and an exponent.
  7910. * These values define a cone of light starting from the position, emitting toward the direction.
  7911. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  7912. * and the exponent defines the speed of the decay of the light with distance (reach).
  7913. * Documentation: https://doc.babylonjs.com/babylon101/lights
  7914. */
  7915. class SpotLight extends ShadowLight {
  7916. private _angle;
  7917. /**
  7918. * Gets the cone angle of the spot light in Radians.
  7919. */
  7920. /**
  7921. * Sets the cone angle of the spot light in Radians.
  7922. */
  7923. angle: number;
  7924. private _shadowAngleScale;
  7925. /**
  7926. * Allows scaling the angle of the light for shadow generation only.
  7927. */
  7928. /**
  7929. * Allows scaling the angle of the light for shadow generation only.
  7930. */
  7931. shadowAngleScale: number;
  7932. /**
  7933. * The light decay speed with the distance from the emission spot.
  7934. */
  7935. exponent: number;
  7936. private _projectionTextureMatrix;
  7937. /**
  7938. * Allows reading the projecton texture
  7939. */
  7940. readonly projectionTextureMatrix: Matrix;
  7941. protected _projectionTextureLightNear: number;
  7942. /**
  7943. * Gets the near clip of the Spotlight for texture projection.
  7944. */
  7945. /**
  7946. * Sets the near clip of the Spotlight for texture projection.
  7947. */
  7948. projectionTextureLightNear: number;
  7949. protected _projectionTextureLightFar: number;
  7950. /**
  7951. * Gets the far clip of the Spotlight for texture projection.
  7952. */
  7953. /**
  7954. * Sets the far clip of the Spotlight for texture projection.
  7955. */
  7956. projectionTextureLightFar: number;
  7957. protected _projectionTextureUpDirection: Vector3;
  7958. /**
  7959. * Gets the Up vector of the Spotlight for texture projection.
  7960. */
  7961. /**
  7962. * Sets the Up vector of the Spotlight for texture projection.
  7963. */
  7964. projectionTextureUpDirection: Vector3;
  7965. private _projectionTexture;
  7966. /**
  7967. * Gets the projection texture of the light.
  7968. */
  7969. /**
  7970. * Sets the projection texture of the light.
  7971. */
  7972. projectionTexture: Nullable<BaseTexture>;
  7973. private _projectionTextureViewLightDirty;
  7974. private _projectionTextureProjectionLightDirty;
  7975. private _projectionTextureDirty;
  7976. private _projectionTextureViewTargetVector;
  7977. private _projectionTextureViewLightMatrix;
  7978. private _projectionTextureProjectionLightMatrix;
  7979. private _projectionTextureScalingMatrix;
  7980. /**
  7981. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  7982. * It can cast shadows.
  7983. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7984. * @param name The light friendly name
  7985. * @param position The position of the spot light in the scene
  7986. * @param direction The direction of the light in the scene
  7987. * @param angle The cone angle of the light in Radians
  7988. * @param exponent The light decay speed with the distance from the emission spot
  7989. * @param scene The scene the lights belongs to
  7990. */
  7991. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  7992. /**
  7993. * Returns the string "SpotLight".
  7994. * @returns the class name
  7995. */
  7996. getClassName(): string;
  7997. /**
  7998. * Returns the integer 2.
  7999. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8000. */
  8001. getTypeID(): number;
  8002. /**
  8003. * Overrides the direction setter to recompute the projection texture view light Matrix.
  8004. */
  8005. protected _setDirection(value: Vector3): void;
  8006. /**
  8007. * Overrides the position setter to recompute the projection texture view light Matrix.
  8008. */
  8009. protected _setPosition(value: Vector3): void;
  8010. /**
  8011. * 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.
  8012. * Returns the SpotLight.
  8013. */
  8014. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8015. protected _computeProjectionTextureViewLightMatrix(): void;
  8016. protected _computeProjectionTextureProjectionLightMatrix(): void;
  8017. /**
  8018. * Main function for light texture projection matrix computing.
  8019. */
  8020. protected _computeProjectionTextureMatrix(): void;
  8021. protected _buildUniformLayout(): void;
  8022. /**
  8023. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  8024. * @param effect The effect to update
  8025. * @param lightIndex The index of the light in the effect to update
  8026. * @returns The spot light
  8027. */
  8028. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  8029. /**
  8030. * Disposes the light and the associated resources.
  8031. */
  8032. dispose(): void;
  8033. }
  8034. }
  8035. declare module BABYLON {
  8036. /**
  8037. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8038. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8039. * 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;
  8040. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8041. */
  8042. class ColorCurves {
  8043. private _dirty;
  8044. private _tempColor;
  8045. private _globalCurve;
  8046. private _highlightsCurve;
  8047. private _midtonesCurve;
  8048. private _shadowsCurve;
  8049. private _positiveCurve;
  8050. private _negativeCurve;
  8051. private _globalHue;
  8052. private _globalDensity;
  8053. private _globalSaturation;
  8054. private _globalExposure;
  8055. /**
  8056. * Gets the global Hue value.
  8057. * 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).
  8058. */
  8059. /**
  8060. * Sets the global Hue value.
  8061. * 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).
  8062. */
  8063. globalHue: number;
  8064. /**
  8065. * Gets the global Density value.
  8066. * 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.
  8067. * Values less than zero provide a filter of opposite hue.
  8068. */
  8069. /**
  8070. * Sets the global Density value.
  8071. * 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.
  8072. * Values less than zero provide a filter of opposite hue.
  8073. */
  8074. globalDensity: number;
  8075. /**
  8076. * Gets the global Saturation value.
  8077. * 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.
  8078. */
  8079. /**
  8080. * Sets the global Saturation value.
  8081. * 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.
  8082. */
  8083. globalSaturation: number;
  8084. private _highlightsHue;
  8085. private _highlightsDensity;
  8086. private _highlightsSaturation;
  8087. private _highlightsExposure;
  8088. /**
  8089. * Gets the highlights Hue value.
  8090. * 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).
  8091. */
  8092. /**
  8093. * Sets the highlights Hue value.
  8094. * 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).
  8095. */
  8096. highlightsHue: number;
  8097. /**
  8098. * Gets the highlights Density value.
  8099. * 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.
  8100. * Values less than zero provide a filter of opposite hue.
  8101. */
  8102. /**
  8103. * Sets the highlights Density value.
  8104. * 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.
  8105. * Values less than zero provide a filter of opposite hue.
  8106. */
  8107. highlightsDensity: number;
  8108. /**
  8109. * Gets the highlights Saturation value.
  8110. * 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.
  8111. */
  8112. /**
  8113. * Sets the highlights Saturation value.
  8114. * 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.
  8115. */
  8116. highlightsSaturation: number;
  8117. /**
  8118. * Gets the highlights Exposure value.
  8119. * 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.
  8120. */
  8121. /**
  8122. * Sets the highlights Exposure value.
  8123. * 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.
  8124. */
  8125. highlightsExposure: number;
  8126. private _midtonesHue;
  8127. private _midtonesDensity;
  8128. private _midtonesSaturation;
  8129. private _midtonesExposure;
  8130. /**
  8131. * Gets the midtones Hue value.
  8132. * 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).
  8133. */
  8134. /**
  8135. * Sets the midtones Hue value.
  8136. * 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).
  8137. */
  8138. midtonesHue: number;
  8139. /**
  8140. * Gets the midtones Density value.
  8141. * 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.
  8142. * Values less than zero provide a filter of opposite hue.
  8143. */
  8144. /**
  8145. * Sets the midtones Density value.
  8146. * 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.
  8147. * Values less than zero provide a filter of opposite hue.
  8148. */
  8149. midtonesDensity: number;
  8150. /**
  8151. * Gets the midtones Saturation value.
  8152. * 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.
  8153. */
  8154. /**
  8155. * Sets the midtones Saturation value.
  8156. * 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.
  8157. */
  8158. midtonesSaturation: number;
  8159. /**
  8160. * Gets the midtones Exposure value.
  8161. * 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.
  8162. */
  8163. /**
  8164. * Sets the midtones Exposure value.
  8165. * 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.
  8166. */
  8167. midtonesExposure: number;
  8168. private _shadowsHue;
  8169. private _shadowsDensity;
  8170. private _shadowsSaturation;
  8171. private _shadowsExposure;
  8172. /**
  8173. * Gets the shadows Hue value.
  8174. * 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).
  8175. */
  8176. /**
  8177. * Sets the shadows Hue value.
  8178. * 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).
  8179. */
  8180. shadowsHue: number;
  8181. /**
  8182. * Gets the shadows Density value.
  8183. * 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.
  8184. * Values less than zero provide a filter of opposite hue.
  8185. */
  8186. /**
  8187. * Sets the shadows Density value.
  8188. * 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.
  8189. * Values less than zero provide a filter of opposite hue.
  8190. */
  8191. shadowsDensity: number;
  8192. /**
  8193. * Gets the shadows Saturation value.
  8194. * 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.
  8195. */
  8196. /**
  8197. * Sets the shadows Saturation value.
  8198. * 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.
  8199. */
  8200. shadowsSaturation: number;
  8201. /**
  8202. * Gets the shadows Exposure value.
  8203. * 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.
  8204. */
  8205. /**
  8206. * Sets the shadows Exposure value.
  8207. * 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.
  8208. */
  8209. shadowsExposure: number;
  8210. getClassName(): string;
  8211. /**
  8212. * Binds the color curves to the shader.
  8213. * @param colorCurves The color curve to bind
  8214. * @param effect The effect to bind to
  8215. */
  8216. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8217. /**
  8218. * Prepare the list of uniforms associated with the ColorCurves effects.
  8219. * @param uniformsList The list of uniforms used in the effect
  8220. */
  8221. static PrepareUniforms(uniformsList: string[]): void;
  8222. /**
  8223. * Returns color grading data based on a hue, density, saturation and exposure value.
  8224. * @param filterHue The hue of the color filter.
  8225. * @param filterDensity The density of the color filter.
  8226. * @param saturation The saturation.
  8227. * @param exposure The exposure.
  8228. * @param result The result data container.
  8229. */
  8230. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  8231. /**
  8232. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8233. * @param value The input slider value in range [-100,100].
  8234. * @returns Adjusted value.
  8235. */
  8236. private static applyColorGradingSliderNonlinear(value);
  8237. /**
  8238. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8239. * @param hue The hue (H) input.
  8240. * @param saturation The saturation (S) input.
  8241. * @param brightness The brightness (B) input.
  8242. * @result An RGBA color represented as Vector4.
  8243. */
  8244. private static fromHSBToRef(hue, saturation, brightness, result);
  8245. /**
  8246. * Returns a value clamped between min and max
  8247. * @param value The value to clamp
  8248. * @param min The minimum of value
  8249. * @param max The maximum of value
  8250. * @returns The clamped value.
  8251. */
  8252. private static clamp(value, min, max);
  8253. /**
  8254. * Clones the current color curve instance.
  8255. * @return The cloned curves
  8256. */
  8257. clone(): ColorCurves;
  8258. /**
  8259. * Serializes the current color curve instance to a json representation.
  8260. * @return a JSON representation
  8261. */
  8262. serialize(): any;
  8263. /**
  8264. * Parses the color curve from a json representation.
  8265. * @param source the JSON source to parse
  8266. * @return The parsed curves
  8267. */
  8268. static Parse(source: any): ColorCurves;
  8269. }
  8270. }
  8271. declare module BABYLON {
  8272. /**
  8273. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8274. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8275. */
  8276. class EffectFallbacks {
  8277. private _defines;
  8278. private _currentRank;
  8279. private _maxRank;
  8280. private _mesh;
  8281. /**
  8282. * Removes the fallback from the bound mesh.
  8283. */
  8284. unBindMesh(): void;
  8285. /**
  8286. * Adds a fallback on the specified property.
  8287. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8288. * @param define The name of the define in the shader
  8289. */
  8290. addFallback(rank: number, define: string): void;
  8291. /**
  8292. * Sets the mesh to use CPU skinning when needing to fallback.
  8293. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8294. * @param mesh The mesh to use the fallbacks.
  8295. */
  8296. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8297. /**
  8298. * Checks to see if more fallbacks are still availible.
  8299. */
  8300. readonly isMoreFallbacks: boolean;
  8301. /**
  8302. * Removes the defines that shoould be removed when falling back.
  8303. * @param currentDefines defines the current define statements for the shader.
  8304. * @param effect defines the current effect we try to compile
  8305. * @returns The resulting defines with defines of the current rank removed.
  8306. */
  8307. reduce(currentDefines: string, effect: Effect): string;
  8308. }
  8309. /**
  8310. * Options to be used when creating an effect.
  8311. */
  8312. class EffectCreationOptions {
  8313. /**
  8314. * Atrributes that will be used in the shader.
  8315. */
  8316. attributes: string[];
  8317. /**
  8318. * Uniform varible names that will be set in the shader.
  8319. */
  8320. uniformsNames: string[];
  8321. /**
  8322. * Uniform buffer varible names that will be set in the shader.
  8323. */
  8324. uniformBuffersNames: string[];
  8325. /**
  8326. * Sampler texture variable names that will be set in the shader.
  8327. */
  8328. samplers: string[];
  8329. /**
  8330. * Define statements that will be set in the shader.
  8331. */
  8332. defines: any;
  8333. /**
  8334. * Possible fallbacks for this effect to improve performance when needed.
  8335. */
  8336. fallbacks: Nullable<EffectFallbacks>;
  8337. /**
  8338. * Callback that will be called when the shader is compiled.
  8339. */
  8340. onCompiled: Nullable<(effect: Effect) => void>;
  8341. /**
  8342. * Callback that will be called if an error occurs during shader compilation.
  8343. */
  8344. onError: Nullable<(effect: Effect, errors: string) => void>;
  8345. /**
  8346. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  8347. */
  8348. indexParameters: any;
  8349. /**
  8350. * Max number of lights that can be used in the shader.
  8351. */
  8352. maxSimultaneousLights: number;
  8353. /**
  8354. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  8355. */
  8356. transformFeedbackVaryings: Nullable<string[]>;
  8357. }
  8358. /**
  8359. * Effect containing vertex and fragment shader that can be executed on an object.
  8360. */
  8361. class Effect {
  8362. /**
  8363. * Name of the effect.
  8364. */
  8365. name: any;
  8366. /**
  8367. * String container all the define statements that should be set on the shader.
  8368. */
  8369. defines: string;
  8370. /**
  8371. * Callback that will be called when the shader is compiled.
  8372. */
  8373. onCompiled: Nullable<(effect: Effect) => void>;
  8374. /**
  8375. * Callback that will be called if an error occurs during shader compilation.
  8376. */
  8377. onError: Nullable<(effect: Effect, errors: string) => void>;
  8378. /**
  8379. * Callback that will be called when effect is bound.
  8380. */
  8381. onBind: Nullable<(effect: Effect) => void>;
  8382. /**
  8383. * Unique ID of the effect.
  8384. */
  8385. uniqueId: number;
  8386. /**
  8387. * Observable that will be called when the shader is compiled.
  8388. */
  8389. onCompileObservable: Observable<Effect>;
  8390. /**
  8391. * Observable that will be called if an error occurs during shader compilation.
  8392. */
  8393. onErrorObservable: Observable<Effect>;
  8394. /**
  8395. * Observable that will be called when effect is bound.
  8396. */
  8397. onBindObservable: Observable<Effect>;
  8398. private static _uniqueIdSeed;
  8399. private _engine;
  8400. private _uniformBuffersNames;
  8401. private _uniformsNames;
  8402. private _samplers;
  8403. private _isReady;
  8404. private _compilationError;
  8405. private _attributesNames;
  8406. private _attributes;
  8407. private _uniforms;
  8408. /**
  8409. * Key for the effect.
  8410. */
  8411. _key: string;
  8412. private _indexParameters;
  8413. private _fallbacks;
  8414. private _vertexSourceCode;
  8415. private _fragmentSourceCode;
  8416. private _vertexSourceCodeOverride;
  8417. private _fragmentSourceCodeOverride;
  8418. private _transformFeedbackVaryings;
  8419. /**
  8420. * Compiled shader to webGL program.
  8421. */
  8422. _program: WebGLProgram;
  8423. private _valueCache;
  8424. private static _baseCache;
  8425. /**
  8426. * Instantiates an effect.
  8427. * An effect can be used to create/manage/execute vertex and fragment shaders.
  8428. * @param baseName Name of the effect.
  8429. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  8430. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  8431. * @param samplers List of sampler variables that will be passed to the shader.
  8432. * @param engine Engine to be used to render the effect
  8433. * @param defines Define statements to be added to the shader.
  8434. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  8435. * @param onCompiled Callback that will be called when the shader is compiled.
  8436. * @param onError Callback that will be called if an error occurs during shader compilation.
  8437. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  8438. */
  8439. 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);
  8440. /**
  8441. * Unique key for this effect
  8442. */
  8443. readonly key: string;
  8444. /**
  8445. * If the effect has been compiled and prepared.
  8446. * @returns if the effect is compiled and prepared.
  8447. */
  8448. isReady(): boolean;
  8449. /**
  8450. * The engine the effect was initialized with.
  8451. * @returns the engine.
  8452. */
  8453. getEngine(): Engine;
  8454. /**
  8455. * The compiled webGL program for the effect
  8456. * @returns the webGL program.
  8457. */
  8458. getProgram(): WebGLProgram;
  8459. /**
  8460. * The set of names of attribute variables for the shader.
  8461. * @returns An array of attribute names.
  8462. */
  8463. getAttributesNames(): string[];
  8464. /**
  8465. * Returns the attribute at the given index.
  8466. * @param index The index of the attribute.
  8467. * @returns The location of the attribute.
  8468. */
  8469. getAttributeLocation(index: number): number;
  8470. /**
  8471. * Returns the attribute based on the name of the variable.
  8472. * @param name of the attribute to look up.
  8473. * @returns the attribute location.
  8474. */
  8475. getAttributeLocationByName(name: string): number;
  8476. /**
  8477. * The number of attributes.
  8478. * @returns the numnber of attributes.
  8479. */
  8480. getAttributesCount(): number;
  8481. /**
  8482. * Gets the index of a uniform variable.
  8483. * @param uniformName of the uniform to look up.
  8484. * @returns the index.
  8485. */
  8486. getUniformIndex(uniformName: string): number;
  8487. /**
  8488. * Returns the attribute based on the name of the variable.
  8489. * @param uniformName of the uniform to look up.
  8490. * @returns the location of the uniform.
  8491. */
  8492. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  8493. /**
  8494. * Returns an array of sampler variable names
  8495. * @returns The array of sampler variable neames.
  8496. */
  8497. getSamplers(): string[];
  8498. /**
  8499. * The error from the last compilation.
  8500. * @returns the error string.
  8501. */
  8502. getCompilationError(): string;
  8503. /**
  8504. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  8505. * @param func The callback to be used.
  8506. */
  8507. executeWhenCompiled(func: (effect: Effect) => void): void;
  8508. /** @ignore */
  8509. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  8510. /** @ignore */
  8511. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  8512. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  8513. private _processShaderConversion(sourceCode, isFragment, callback);
  8514. private _processIncludes(sourceCode, callback);
  8515. private _processPrecision(source);
  8516. /**
  8517. * Recompiles the webGL program
  8518. * @param vertexSourceCode The source code for the vertex shader.
  8519. * @param fragmentSourceCode The source code for the fragment shader.
  8520. * @param onCompiled Callback called when completed.
  8521. * @param onError Callback called on error.
  8522. */
  8523. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  8524. /**
  8525. * Gets the uniform locations of the the specified variable names
  8526. * @param names THe names of the variables to lookup.
  8527. * @returns Array of locations in the same order as variable names.
  8528. */
  8529. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  8530. /**
  8531. * Prepares the effect
  8532. */
  8533. _prepareEffect(): void;
  8534. /**
  8535. * Checks if the effect is supported. (Must be called after compilation)
  8536. */
  8537. readonly isSupported: boolean;
  8538. /**
  8539. * Binds a texture to the engine to be used as output of the shader.
  8540. * @param channel Name of the output variable.
  8541. * @param texture Texture to bind.
  8542. */
  8543. _bindTexture(channel: string, texture: InternalTexture): void;
  8544. /**
  8545. * Sets a texture on the engine to be used in the shader.
  8546. * @param channel Name of the sampler variable.
  8547. * @param texture Texture to set.
  8548. */
  8549. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  8550. /**
  8551. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  8552. * @param channel Name of the sampler variable.
  8553. * @param texture Texture to set.
  8554. */
  8555. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  8556. /**
  8557. * Sets an array of textures on the engine to be used in the shader.
  8558. * @param channel Name of the variable.
  8559. * @param textures Textures to set.
  8560. */
  8561. setTextureArray(channel: string, textures: BaseTexture[]): void;
  8562. /**
  8563. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  8564. * @param channel Name of the sampler variable.
  8565. * @param postProcess Post process to get the input texture from.
  8566. */
  8567. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  8568. /**
  8569. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  8570. * 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)
  8571. * @param channel Name of the sampler variable.
  8572. * @param postProcess Post process to get the output texture from.
  8573. */
  8574. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  8575. /** @ignore */
  8576. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  8577. /** @ignore */
  8578. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8579. /** @ignore */
  8580. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8581. /** @ignore */
  8582. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8583. /**
  8584. * Binds a buffer to a uniform.
  8585. * @param buffer Buffer to bind.
  8586. * @param name Name of the uniform variable to bind to.
  8587. */
  8588. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  8589. /**
  8590. * Binds block to a uniform.
  8591. * @param blockName Name of the block to bind.
  8592. * @param index Index to bind.
  8593. */
  8594. bindUniformBlock(blockName: string, index: number): void;
  8595. /**
  8596. * Sets an interger value on a uniform variable.
  8597. * @param uniformName Name of the variable.
  8598. * @param value Value to be set.
  8599. * @returns this effect.
  8600. */
  8601. setInt(uniformName: string, value: number): Effect;
  8602. /**
  8603. * Sets an int array on a uniform variable.
  8604. * @param uniformName Name of the variable.
  8605. * @param array array to be set.
  8606. * @returns this effect.
  8607. */
  8608. setIntArray(uniformName: string, array: Int32Array): Effect;
  8609. /**
  8610. * 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)
  8611. * @param uniformName Name of the variable.
  8612. * @param array array to be set.
  8613. * @returns this effect.
  8614. */
  8615. setIntArray2(uniformName: string, array: Int32Array): Effect;
  8616. /**
  8617. * 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)
  8618. * @param uniformName Name of the variable.
  8619. * @param array array to be set.
  8620. * @returns this effect.
  8621. */
  8622. setIntArray3(uniformName: string, array: Int32Array): Effect;
  8623. /**
  8624. * 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)
  8625. * @param uniformName Name of the variable.
  8626. * @param array array to be set.
  8627. * @returns this effect.
  8628. */
  8629. setIntArray4(uniformName: string, array: Int32Array): Effect;
  8630. /**
  8631. * Sets an float array on a uniform variable.
  8632. * @param uniformName Name of the variable.
  8633. * @param array array to be set.
  8634. * @returns this effect.
  8635. */
  8636. setFloatArray(uniformName: string, array: Float32Array): Effect;
  8637. /**
  8638. * 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)
  8639. * @param uniformName Name of the variable.
  8640. * @param array array to be set.
  8641. * @returns this effect.
  8642. */
  8643. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  8644. /**
  8645. * 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)
  8646. * @param uniformName Name of the variable.
  8647. * @param array array to be set.
  8648. * @returns this effect.
  8649. */
  8650. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  8651. /**
  8652. * 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)
  8653. * @param uniformName Name of the variable.
  8654. * @param array array to be set.
  8655. * @returns this effect.
  8656. */
  8657. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  8658. /**
  8659. * Sets an array on a uniform variable.
  8660. * @param uniformName Name of the variable.
  8661. * @param array array to be set.
  8662. * @returns this effect.
  8663. */
  8664. setArray(uniformName: string, array: number[]): Effect;
  8665. /**
  8666. * 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)
  8667. * @param uniformName Name of the variable.
  8668. * @param array array to be set.
  8669. * @returns this effect.
  8670. */
  8671. setArray2(uniformName: string, array: number[]): Effect;
  8672. /**
  8673. * 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)
  8674. * @param uniformName Name of the variable.
  8675. * @param array array to be set.
  8676. * @returns this effect.
  8677. */
  8678. setArray3(uniformName: string, array: number[]): Effect;
  8679. /**
  8680. * 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)
  8681. * @param uniformName Name of the variable.
  8682. * @param array array to be set.
  8683. * @returns this effect.
  8684. */
  8685. setArray4(uniformName: string, array: number[]): Effect;
  8686. /**
  8687. * Sets matrices on a uniform variable.
  8688. * @param uniformName Name of the variable.
  8689. * @param matrices matrices to be set.
  8690. * @returns this effect.
  8691. */
  8692. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  8693. /**
  8694. * Sets matrix on a uniform variable.
  8695. * @param uniformName Name of the variable.
  8696. * @param matrix matrix to be set.
  8697. * @returns this effect.
  8698. */
  8699. setMatrix(uniformName: string, matrix: Matrix): Effect;
  8700. /**
  8701. * 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)
  8702. * @param uniformName Name of the variable.
  8703. * @param matrix matrix to be set.
  8704. * @returns this effect.
  8705. */
  8706. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  8707. /**
  8708. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8709. * @param uniformName Name of the variable.
  8710. * @param matrix matrix to be set.
  8711. * @returns this effect.
  8712. */
  8713. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  8714. /**
  8715. * Sets a float on a uniform variable.
  8716. * @param uniformName Name of the variable.
  8717. * @param value value to be set.
  8718. * @returns this effect.
  8719. */
  8720. setFloat(uniformName: string, value: number): Effect;
  8721. /**
  8722. * Sets a boolean on a uniform variable.
  8723. * @param uniformName Name of the variable.
  8724. * @param bool value to be set.
  8725. * @returns this effect.
  8726. */
  8727. setBool(uniformName: string, bool: boolean): Effect;
  8728. /**
  8729. * Sets a Vector2 on a uniform variable.
  8730. * @param uniformName Name of the variable.
  8731. * @param vector2 vector2 to be set.
  8732. * @returns this effect.
  8733. */
  8734. setVector2(uniformName: string, vector2: Vector2): Effect;
  8735. /**
  8736. * Sets a float2 on a uniform variable.
  8737. * @param uniformName Name of the variable.
  8738. * @param x First float in float2.
  8739. * @param y Second float in float2.
  8740. * @returns this effect.
  8741. */
  8742. setFloat2(uniformName: string, x: number, y: number): Effect;
  8743. /**
  8744. * Sets a Vector3 on a uniform variable.
  8745. * @param uniformName Name of the variable.
  8746. * @param vector3 Value to be set.
  8747. * @returns this effect.
  8748. */
  8749. setVector3(uniformName: string, vector3: Vector3): Effect;
  8750. /**
  8751. * Sets a float3 on a uniform variable.
  8752. * @param uniformName Name of the variable.
  8753. * @param x First float in float3.
  8754. * @param y Second float in float3.
  8755. * @param z Third float in float3.
  8756. * @returns this effect.
  8757. */
  8758. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  8759. /**
  8760. * Sets a Vector4 on a uniform variable.
  8761. * @param uniformName Name of the variable.
  8762. * @param vector4 Value to be set.
  8763. * @returns this effect.
  8764. */
  8765. setVector4(uniformName: string, vector4: Vector4): Effect;
  8766. /**
  8767. * Sets a float4 on a uniform variable.
  8768. * @param uniformName Name of the variable.
  8769. * @param x First float in float4.
  8770. * @param y Second float in float4.
  8771. * @param z Third float in float4.
  8772. * @param w Fourth float in float4.
  8773. * @returns this effect.
  8774. */
  8775. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  8776. /**
  8777. * Sets a Color3 on a uniform variable.
  8778. * @param uniformName Name of the variable.
  8779. * @param color3 Value to be set.
  8780. * @returns this effect.
  8781. */
  8782. setColor3(uniformName: string, color3: Color3): Effect;
  8783. /**
  8784. * Sets a Color4 on a uniform variable.
  8785. * @param uniformName Name of the variable.
  8786. * @param color3 Value to be set.
  8787. * @param alpha Alpha value to be set.
  8788. * @returns this effect.
  8789. */
  8790. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  8791. /**
  8792. * Sets a Color4 on a uniform variable
  8793. * @param uniformName defines the name of the variable
  8794. * @param color4 defines the value to be set
  8795. * @returns this effect.
  8796. */
  8797. setDirectColor4(uniformName: string, color4: Color4): Effect;
  8798. /**
  8799. * Store of each shader (The can be looked up using effect.key)
  8800. */
  8801. static ShadersStore: {
  8802. [key: string]: string;
  8803. };
  8804. /**
  8805. * Store of each included file for a shader (The can be looked up using effect.key)
  8806. */
  8807. static IncludesShadersStore: {
  8808. [key: string]: string;
  8809. };
  8810. /**
  8811. * Resets the cache of effects.
  8812. */
  8813. static ResetCache(): void;
  8814. }
  8815. }
  8816. declare module BABYLON {
  8817. class FresnelParameters {
  8818. private _isEnabled;
  8819. isEnabled: boolean;
  8820. leftColor: Color3;
  8821. rightColor: Color3;
  8822. bias: number;
  8823. power: number;
  8824. clone(): FresnelParameters;
  8825. serialize(): any;
  8826. static Parse(parsedFresnelParameters: any): FresnelParameters;
  8827. }
  8828. }
  8829. declare module BABYLON {
  8830. /**
  8831. * Interface to follow in your material defines to integrate easily the
  8832. * Image proccessing functions.
  8833. * @ignore
  8834. */
  8835. interface IImageProcessingConfigurationDefines {
  8836. IMAGEPROCESSING: boolean;
  8837. VIGNETTE: boolean;
  8838. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8839. VIGNETTEBLENDMODEOPAQUE: boolean;
  8840. TONEMAPPING: boolean;
  8841. CONTRAST: boolean;
  8842. EXPOSURE: boolean;
  8843. COLORCURVES: boolean;
  8844. COLORGRADING: boolean;
  8845. COLORGRADING3D: boolean;
  8846. SAMPLER3DGREENDEPTH: boolean;
  8847. SAMPLER3DBGRMAP: boolean;
  8848. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8849. /**
  8850. * If the grain should be performed in the image processing shader.
  8851. */
  8852. GRAIN: boolean;
  8853. }
  8854. /**
  8855. * This groups together the common properties used for image processing either in direct forward pass
  8856. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8857. * or not.
  8858. */
  8859. class ImageProcessingConfiguration {
  8860. /**
  8861. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8862. */
  8863. colorCurves: Nullable<ColorCurves>;
  8864. private _colorCurvesEnabled;
  8865. /**
  8866. * Gets wether the color curves effect is enabled.
  8867. */
  8868. /**
  8869. * Sets wether the color curves effect is enabled.
  8870. */
  8871. colorCurvesEnabled: boolean;
  8872. /**
  8873. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8874. */
  8875. colorGradingTexture: Nullable<BaseTexture>;
  8876. private _colorGradingEnabled;
  8877. /**
  8878. * Gets wether the color grading effect is enabled.
  8879. */
  8880. /**
  8881. * Sets wether the color grading effect is enabled.
  8882. */
  8883. colorGradingEnabled: boolean;
  8884. private _colorGradingWithGreenDepth;
  8885. /**
  8886. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8887. */
  8888. /**
  8889. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8890. */
  8891. colorGradingWithGreenDepth: boolean;
  8892. private _colorGradingBGR;
  8893. /**
  8894. * Gets wether the color grading texture contains BGR values.
  8895. */
  8896. /**
  8897. * Sets wether the color grading texture contains BGR values.
  8898. */
  8899. colorGradingBGR: boolean;
  8900. _exposure: number;
  8901. /**
  8902. * Gets the Exposure used in the effect.
  8903. */
  8904. /**
  8905. * Sets the Exposure used in the effect.
  8906. */
  8907. exposure: number;
  8908. private _toneMappingEnabled;
  8909. /**
  8910. * Gets wether the tone mapping effect is enabled.
  8911. */
  8912. /**
  8913. * Sets wether the tone mapping effect is enabled.
  8914. */
  8915. toneMappingEnabled: boolean;
  8916. protected _contrast: number;
  8917. /**
  8918. * Gets the contrast used in the effect.
  8919. */
  8920. /**
  8921. * Sets the contrast used in the effect.
  8922. */
  8923. contrast: number;
  8924. /**
  8925. * Vignette stretch size.
  8926. */
  8927. vignetteStretch: number;
  8928. /**
  8929. * Vignette centre X Offset.
  8930. */
  8931. vignetteCentreX: number;
  8932. /**
  8933. * Vignette centre Y Offset.
  8934. */
  8935. vignetteCentreY: number;
  8936. /**
  8937. * Vignette weight or intensity of the vignette effect.
  8938. */
  8939. vignetteWeight: number;
  8940. /**
  8941. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8942. * if vignetteEnabled is set to true.
  8943. */
  8944. vignetteColor: Color4;
  8945. /**
  8946. * Camera field of view used by the Vignette effect.
  8947. */
  8948. vignetteCameraFov: number;
  8949. private _grainEnabled;
  8950. /**
  8951. * If the grain effect should be enabled.
  8952. */
  8953. grainEnabled: boolean;
  8954. private _grainIntensity;
  8955. /**
  8956. * Amount of grain to be applied by the grain effect.
  8957. */
  8958. grainIntensity: number;
  8959. private _grainAnimated;
  8960. /**
  8961. * If the grain effect should be animated.
  8962. */
  8963. grainAnimated: boolean;
  8964. private _vignetteBlendMode;
  8965. /**
  8966. * Gets the vignette blend mode allowing different kind of effect.
  8967. */
  8968. /**
  8969. * Sets the vignette blend mode allowing different kind of effect.
  8970. */
  8971. vignetteBlendMode: number;
  8972. private _vignetteEnabled;
  8973. /**
  8974. * Gets wether the vignette effect is enabled.
  8975. */
  8976. /**
  8977. * Sets wether the vignette effect is enabled.
  8978. */
  8979. vignetteEnabled: boolean;
  8980. private _applyByPostProcess;
  8981. /**
  8982. * Gets wether the image processing is applied through a post process or not.
  8983. */
  8984. /**
  8985. * Sets wether the image processing is applied through a post process or not.
  8986. */
  8987. applyByPostProcess: boolean;
  8988. private _isEnabled;
  8989. /**
  8990. * Gets wether the image processing is enabled or not.
  8991. */
  8992. /**
  8993. * Sets wether the image processing is enabled or not.
  8994. */
  8995. isEnabled: boolean;
  8996. /**
  8997. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8998. * @type {BABYLON.Observable}
  8999. */
  9000. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  9001. /**
  9002. * Method called each time the image processing information changes requires to recompile the effect.
  9003. */
  9004. protected _updateParameters(): void;
  9005. getClassName(): string;
  9006. /**
  9007. * Prepare the list of uniforms associated with the Image Processing effects.
  9008. * @param uniformsList The list of uniforms used in the effect
  9009. * @param defines the list of defines currently in use
  9010. */
  9011. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  9012. /**
  9013. * Prepare the list of samplers associated with the Image Processing effects.
  9014. * @param uniformsList The list of uniforms used in the effect
  9015. * @param defines the list of defines currently in use
  9016. */
  9017. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  9018. /**
  9019. * Prepare the list of defines associated to the shader.
  9020. * @param defines the list of defines to complete
  9021. */
  9022. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  9023. /**
  9024. * Returns true if all the image processing information are ready.
  9025. */
  9026. isReady(): boolean;
  9027. /**
  9028. * Binds the image processing to the shader.
  9029. * @param effect The effect to bind to
  9030. */
  9031. bind(effect: Effect, aspectRatio?: number): void;
  9032. /**
  9033. * Clones the current image processing instance.
  9034. * @return The cloned image processing
  9035. */
  9036. clone(): ImageProcessingConfiguration;
  9037. /**
  9038. * Serializes the current image processing instance to a json representation.
  9039. * @return a JSON representation
  9040. */
  9041. serialize(): any;
  9042. /**
  9043. * Parses the image processing from a json representation.
  9044. * @param source the JSON source to parse
  9045. * @return The parsed image processing
  9046. */
  9047. static Parse(source: any): ImageProcessingConfiguration;
  9048. private static _VIGNETTEMODE_MULTIPLY;
  9049. private static _VIGNETTEMODE_OPAQUE;
  9050. /**
  9051. * Used to apply the vignette as a mix with the pixel color.
  9052. */
  9053. static readonly VIGNETTEMODE_MULTIPLY: number;
  9054. /**
  9055. * Used to apply the vignette as a replacement of the pixel color.
  9056. */
  9057. static readonly VIGNETTEMODE_OPAQUE: number;
  9058. }
  9059. }
  9060. declare module BABYLON {
  9061. /**
  9062. * Manages the defines for the Material.
  9063. */
  9064. class MaterialDefines {
  9065. private _keys;
  9066. private _isDirty;
  9067. _renderId: number;
  9068. _areLightsDirty: boolean;
  9069. _areAttributesDirty: boolean;
  9070. _areTexturesDirty: boolean;
  9071. _areFresnelDirty: boolean;
  9072. _areMiscDirty: boolean;
  9073. _areImageProcessingDirty: boolean;
  9074. _normals: boolean;
  9075. _uvs: boolean;
  9076. _needNormals: boolean;
  9077. _needUVs: boolean;
  9078. /**
  9079. * Specifies if the material needs to be re-calculated.
  9080. */
  9081. readonly isDirty: boolean;
  9082. /**
  9083. * Marks the material to indicate that it has been re-calculated.
  9084. */
  9085. markAsProcessed(): void;
  9086. /**
  9087. * Marks the material to indicate that it needs to be re-calculated.
  9088. */
  9089. markAsUnprocessed(): void;
  9090. /**
  9091. * Marks the material to indicate all of its defines need to be re-calculated.
  9092. */
  9093. markAllAsDirty(): void;
  9094. /**
  9095. * Marks the material to indicate that image processing needs to be re-calculated.
  9096. */
  9097. markAsImageProcessingDirty(): void;
  9098. /**
  9099. * Marks the material to indicate the lights need to be re-calculated.
  9100. */
  9101. markAsLightDirty(): void;
  9102. /**
  9103. * Marks the attribute state as changed.
  9104. */
  9105. markAsAttributesDirty(): void;
  9106. /**
  9107. * Marks the texture state as changed.
  9108. */
  9109. markAsTexturesDirty(): void;
  9110. /**
  9111. * Marks the fresnel state as changed.
  9112. */
  9113. markAsFresnelDirty(): void;
  9114. /**
  9115. * Marks the misc state as changed.
  9116. */
  9117. markAsMiscDirty(): void;
  9118. /**
  9119. * Rebuilds the material defines.
  9120. */
  9121. rebuild(): void;
  9122. /**
  9123. * Specifies if two material defines are equal.
  9124. * @param other - A material define instance to compare to.
  9125. * @returns - Boolean indicating if the material defines are equal (true) or not (false).
  9126. */
  9127. isEqual(other: MaterialDefines): boolean;
  9128. /**
  9129. * Clones this instance's defines to another instance.
  9130. * @param other - material defines to clone values to.
  9131. */
  9132. cloneTo(other: MaterialDefines): void;
  9133. /**
  9134. * Resets the material define values.
  9135. */
  9136. reset(): void;
  9137. /**
  9138. * Converts the material define values to a string.
  9139. * @returns - String of material define information.
  9140. */
  9141. toString(): string;
  9142. }
  9143. /**
  9144. * This offers the main features of a material in BJS.
  9145. */
  9146. class Material implements IAnimatable {
  9147. private static _TriangleFillMode;
  9148. private static _WireFrameFillMode;
  9149. private static _PointFillMode;
  9150. private static _PointListDrawMode;
  9151. private static _LineListDrawMode;
  9152. private static _LineLoopDrawMode;
  9153. private static _LineStripDrawMode;
  9154. private static _TriangleStripDrawMode;
  9155. private static _TriangleFanDrawMode;
  9156. /**
  9157. * Returns the triangle fill mode.
  9158. */
  9159. static readonly TriangleFillMode: number;
  9160. /**
  9161. * Returns the wireframe mode.
  9162. */
  9163. static readonly WireFrameFillMode: number;
  9164. /**
  9165. * Returns the point fill mode.
  9166. */
  9167. static readonly PointFillMode: number;
  9168. /**
  9169. * Returns the point list draw mode.
  9170. */
  9171. static readonly PointListDrawMode: number;
  9172. /**
  9173. * Returns the line list draw mode.
  9174. */
  9175. static readonly LineListDrawMode: number;
  9176. /**
  9177. * Returns the line loop draw mode.
  9178. */
  9179. static readonly LineLoopDrawMode: number;
  9180. /**
  9181. * Returns the line strip draw mode.
  9182. */
  9183. static readonly LineStripDrawMode: number;
  9184. /**
  9185. * Returns the triangle strip draw mode.
  9186. */
  9187. static readonly TriangleStripDrawMode: number;
  9188. /**
  9189. * Returns the triangle fan draw mode.
  9190. */
  9191. static readonly TriangleFanDrawMode: number;
  9192. /**
  9193. * Stores the clock-wise side orientation.
  9194. */
  9195. private static _ClockWiseSideOrientation;
  9196. /**
  9197. * Stores the counter clock-wise side orientation.
  9198. */
  9199. private static _CounterClockWiseSideOrientation;
  9200. /**
  9201. * Returns the clock-wise side orientation.
  9202. */
  9203. static readonly ClockWiseSideOrientation: number;
  9204. /**
  9205. * Returns the counter clock-wise side orientation.
  9206. */
  9207. static readonly CounterClockWiseSideOrientation: number;
  9208. /**
  9209. * The dirty texture flag value.
  9210. */
  9211. private static _TextureDirtyFlag;
  9212. /**
  9213. * The dirty light flag value.
  9214. */
  9215. private static _LightDirtyFlag;
  9216. /**
  9217. * The dirty fresnel flag value.
  9218. */
  9219. private static _FresnelDirtyFlag;
  9220. /**
  9221. * The dirty attribute flag value.
  9222. */
  9223. private static _AttributesDirtyFlag;
  9224. /**
  9225. * The dirty misc flag value.
  9226. */
  9227. private static _MiscDirtyFlag;
  9228. /**
  9229. * Returns the dirty texture flag value.
  9230. */
  9231. static readonly TextureDirtyFlag: number;
  9232. /**
  9233. * Returns the dirty light flag value.
  9234. */
  9235. static readonly LightDirtyFlag: number;
  9236. /**
  9237. * Returns the dirty fresnel flag value.
  9238. */
  9239. static readonly FresnelDirtyFlag: number;
  9240. /**
  9241. * Returns the dirty attributes flag value.
  9242. */
  9243. static readonly AttributesDirtyFlag: number;
  9244. /**
  9245. * Returns the dirty misc flag value.
  9246. */
  9247. static readonly MiscDirtyFlag: number;
  9248. /**
  9249. * The ID of the material.
  9250. */
  9251. id: string;
  9252. /**
  9253. * The name of the material.
  9254. */
  9255. name: string;
  9256. /**
  9257. * Specifies if the ready state should be checked on each call.
  9258. */
  9259. checkReadyOnEveryCall: boolean;
  9260. /**
  9261. * Specifies if the ready state should be checked once.
  9262. */
  9263. checkReadyOnlyOnce: boolean;
  9264. /**
  9265. * The state of the material.
  9266. */
  9267. state: string;
  9268. /**
  9269. * The alpha value of the material.
  9270. */
  9271. protected _alpha: number;
  9272. /**
  9273. * Gets the alpha value of the material.
  9274. */
  9275. /**
  9276. * Sets the alpha value of the material.
  9277. */
  9278. alpha: number;
  9279. /**
  9280. * Specifies if back face culling is enabled.
  9281. */
  9282. protected _backFaceCulling: boolean;
  9283. /**
  9284. * Gets the back-face culling state.
  9285. */
  9286. /**
  9287. * Sets the back-face culling state.
  9288. */
  9289. backFaceCulling: boolean;
  9290. /**
  9291. * Stores the value for side orientation.
  9292. */
  9293. sideOrientation: number;
  9294. /**
  9295. * Callback triggered when the material is compiled.
  9296. */
  9297. onCompiled: (effect: Effect) => void;
  9298. /**
  9299. * Callback triggered when an error occurs.
  9300. */
  9301. onError: (effect: Effect, errors: string) => void;
  9302. /**
  9303. * Callback triggered to get the render target textures.
  9304. */
  9305. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  9306. /**
  9307. * Specifies if the material should be serialized.
  9308. */
  9309. doNotSerialize: boolean;
  9310. /**
  9311. * Specifies if the effect should be stored on sub meshes.
  9312. */
  9313. storeEffectOnSubMeshes: boolean;
  9314. /**
  9315. * Stores the animations for the material.
  9316. */
  9317. animations: Array<Animation>;
  9318. /**
  9319. * An event triggered when the material is disposed.
  9320. * @type {BABYLON.Observable}
  9321. */
  9322. onDisposeObservable: Observable<Material>;
  9323. /**
  9324. * An observer which watches for dispose events.
  9325. * @type {BABYLON.Observer}
  9326. */
  9327. private _onDisposeObserver;
  9328. /**
  9329. * Called during a dispose event.
  9330. */
  9331. onDispose: () => void;
  9332. /**
  9333. * An event triggered when the material is bound.
  9334. * @type {BABYLON.Observable}
  9335. */
  9336. onBindObservable: Observable<AbstractMesh>;
  9337. /**
  9338. * An observer which watches for bind events.
  9339. * @type {BABYLON.Observer}
  9340. */
  9341. private _onBindObserver;
  9342. /**
  9343. * Called during a bind event.
  9344. */
  9345. onBind: (Mesh: AbstractMesh) => void;
  9346. /**
  9347. * An event triggered when the material is unbound.
  9348. * @type {BABYLON.Observable}
  9349. */
  9350. onUnBindObservable: Observable<Material>;
  9351. /**
  9352. * Stores the value of the alpha mode.
  9353. */
  9354. private _alphaMode;
  9355. /**
  9356. * Gets the value of the alpha mode.
  9357. */
  9358. /**
  9359. * Sets the value of the alpha mode.
  9360. */
  9361. alphaMode: number;
  9362. /**
  9363. * Stores the state of the need depth pre-pass value.
  9364. */
  9365. private _needDepthPrePass;
  9366. /**
  9367. * Gets the depth pre-pass value.
  9368. */
  9369. /**
  9370. * Sets the need depth pre-pass value.
  9371. */
  9372. needDepthPrePass: boolean;
  9373. /**
  9374. * Specifies if depth writing should be disabled.
  9375. */
  9376. disableDepthWrite: boolean;
  9377. /**
  9378. * Specifies if depth writing should be forced.
  9379. */
  9380. forceDepthWrite: boolean;
  9381. /**
  9382. * Specifies if there should be a separate pass for culling.
  9383. */
  9384. separateCullingPass: boolean;
  9385. /**
  9386. * Stores the state specifing if fog should be enabled.
  9387. */
  9388. private _fogEnabled;
  9389. /**
  9390. * Gets the value of the fog enabled state.
  9391. */
  9392. /**
  9393. * Sets the state for enabling fog.
  9394. */
  9395. fogEnabled: boolean;
  9396. /**
  9397. * Stores the size of points.
  9398. */
  9399. pointSize: number;
  9400. /**
  9401. * Stores the z offset value.
  9402. */
  9403. zOffset: number;
  9404. /**
  9405. * Gets a value specifying if wireframe mode is enabled.
  9406. */
  9407. /**
  9408. * Sets the state of wireframe mode.
  9409. */
  9410. wireframe: boolean;
  9411. /**
  9412. * Gets the value specifying if point clouds are enabled.
  9413. */
  9414. /**
  9415. * Sets the state of point cloud mode.
  9416. */
  9417. pointsCloud: boolean;
  9418. /**
  9419. * Gets the material fill mode.
  9420. */
  9421. /**
  9422. * Sets the material fill mode.
  9423. */
  9424. fillMode: number;
  9425. /**
  9426. * Stores the effects for the material.
  9427. */
  9428. _effect: Nullable<Effect>;
  9429. /**
  9430. * Specifies if the material was previously ready.
  9431. */
  9432. _wasPreviouslyReady: boolean;
  9433. /**
  9434. * Specifies if uniform buffers should be used.
  9435. */
  9436. private _useUBO;
  9437. /**
  9438. * Stores a reference to the scene.
  9439. */
  9440. private _scene;
  9441. /**
  9442. * Stores the fill mode state.
  9443. */
  9444. private _fillMode;
  9445. /**
  9446. * Specifies if the depth write state should be cached.
  9447. */
  9448. private _cachedDepthWriteState;
  9449. /**
  9450. * Stores the uniform buffer.
  9451. */
  9452. protected _uniformBuffer: UniformBuffer;
  9453. /**
  9454. * Creates a material instance.
  9455. * @param name - The name of the material.
  9456. * @param scene - The BJS scene to reference.
  9457. * @param doNotAdd - Specifies if the material should be added to the scene.
  9458. */
  9459. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  9460. /**
  9461. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  9462. * subclasses should override adding information pertainent to themselves.
  9463. * @returns - String with material information.
  9464. */
  9465. toString(fullDetails?: boolean): string;
  9466. /**
  9467. * Gets the class name of the material.
  9468. * @returns - String with the class name of the material.
  9469. */
  9470. getClassName(): string;
  9471. /**
  9472. * Specifies if updates for the material been locked.
  9473. */
  9474. readonly isFrozen: boolean;
  9475. /**
  9476. * Locks updates for the material.
  9477. */
  9478. freeze(): void;
  9479. /**
  9480. * Unlocks updates for the material.
  9481. */
  9482. unfreeze(): void;
  9483. /**
  9484. * Specifies if the material is ready to be used.
  9485. * @param mesh - BJS mesh.
  9486. * @param useInstances - Specifies if instances should be used.
  9487. * @returns - Boolean indicating if the material is ready to be used.
  9488. */
  9489. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  9490. /**
  9491. * Specifies that the submesh is ready to be used.
  9492. * @param mesh - BJS mesh.
  9493. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  9494. * @param useInstances - Specifies that instances should be used.
  9495. * @returns - boolean indicating that the submesh is ready or not.
  9496. */
  9497. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  9498. /**
  9499. * Returns the material effect.
  9500. * @returns - Nullable material effect.
  9501. */
  9502. getEffect(): Nullable<Effect>;
  9503. /**
  9504. * Returns the BJS scene.
  9505. * @returns - BJS Scene.
  9506. */
  9507. getScene(): Scene;
  9508. /**
  9509. * Specifies if the material will require alpha blending
  9510. * @returns - Boolean specifying if alpha blending is needed.
  9511. */
  9512. needAlphaBlending(): boolean;
  9513. /**
  9514. * Specifies if the mesh will require alpha blending.
  9515. * @param mesh - BJS mesh.
  9516. * @returns - Boolean specifying if alpha blending is needed for the mesh.
  9517. */
  9518. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  9519. /**
  9520. * Specifies if this material should be rendered in alpha test mode.
  9521. * @returns - Boolean specifying if an alpha test is needed.
  9522. */
  9523. needAlphaTesting(): boolean;
  9524. /**
  9525. * Gets the texture used for the alpha test.
  9526. * @returns - Nullable alpha test texture.
  9527. */
  9528. getAlphaTestTexture(): Nullable<BaseTexture>;
  9529. /**
  9530. * Marks the material to indicate that it needs to be re-calculated.
  9531. */
  9532. markDirty(): void;
  9533. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  9534. /**
  9535. * Binds the material to the mesh.
  9536. * @param world - World transformation matrix.
  9537. * @param mesh - Mesh to bind the material to.
  9538. */
  9539. bind(world: Matrix, mesh?: Mesh): void;
  9540. /**
  9541. * Binds the submesh to the material.
  9542. * @param world - World transformation matrix.
  9543. * @param mesh - Mesh containing the submesh.
  9544. * @param subMesh - Submesh to bind the material to.
  9545. */
  9546. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  9547. /**
  9548. * Binds the world matrix to the material.
  9549. * @param world - World transformation matrix.
  9550. */
  9551. bindOnlyWorldMatrix(world: Matrix): void;
  9552. /**
  9553. * Binds the scene's uniform buffer to the effect.
  9554. * @param effect - Effect to bind to the scene uniform buffer.
  9555. * @param sceneUbo - Scene uniform buffer.
  9556. */
  9557. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  9558. /**
  9559. * Binds the view matrix to the effect.
  9560. * @param effect - Effect to bind the view matrix to.
  9561. */
  9562. bindView(effect: Effect): void;
  9563. /**
  9564. * Binds the view projection matrix to the effect.
  9565. * @param effect - Effect to bind the view projection matrix to.
  9566. */
  9567. bindViewProjection(effect: Effect): void;
  9568. /**
  9569. * Specifies if material alpha testing should be turned on for the mesh.
  9570. * @param mesh - BJS mesh.
  9571. */
  9572. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  9573. /**
  9574. * Processes to execute after binding the material to a mesh.
  9575. * @param mesh - BJS mesh.
  9576. */
  9577. protected _afterBind(mesh?: Mesh): void;
  9578. /**
  9579. * Unbinds the material from the mesh.
  9580. */
  9581. unbind(): void;
  9582. /**
  9583. * Gets the active textures from the material.
  9584. * @returns - Array of textures.
  9585. */
  9586. getActiveTextures(): BaseTexture[];
  9587. /**
  9588. * Specifies if the material uses a texture.
  9589. * @param texture - Texture to check against the material.
  9590. * @returns - Boolean specifying if the material uses the texture.
  9591. */
  9592. hasTexture(texture: BaseTexture): boolean;
  9593. /**
  9594. * Makes a duplicate of the material, and gives it a new name.
  9595. * @param name - Name to call the duplicated material.
  9596. * @returns - Nullable cloned material
  9597. */
  9598. clone(name: string): Nullable<Material>;
  9599. /**
  9600. * Gets the meshes bound to the material.
  9601. * @returns - Array of meshes bound to the material.
  9602. */
  9603. getBindedMeshes(): AbstractMesh[];
  9604. /**
  9605. * Force shader compilation
  9606. * @param mesh - BJS mesh.
  9607. * @param onCompiled - function to execute once the material is compiled.
  9608. * @param options - options to pass to this function.
  9609. */
  9610. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  9611. clipPlane: boolean;
  9612. }>): void;
  9613. /**
  9614. * Force shader compilation.
  9615. * @param mesh The mesh that will use this material
  9616. * @param options Additional options for compiling the shaders
  9617. * @returns A promise that resolves when the compilation completes
  9618. */
  9619. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  9620. clipPlane: boolean;
  9621. }>): Promise<void>;
  9622. /**
  9623. * Marks a define in the material to indicate that it needs to be re-computed.
  9624. * @param flag - Material define flag.
  9625. */
  9626. markAsDirty(flag: number): void;
  9627. /**
  9628. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated.
  9629. * @param func - function which checks material defines against the submeshes.
  9630. */
  9631. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  9632. /**
  9633. * Indicates that image processing needs to be re-calculated for all submeshes.
  9634. */
  9635. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  9636. /**
  9637. * Indicates that textures need to be re-calculated for all submeshes.
  9638. */
  9639. protected _markAllSubMeshesAsTexturesDirty(): void;
  9640. /**
  9641. * Indicates that fresnel needs to be re-calculated for all submeshes.
  9642. */
  9643. protected _markAllSubMeshesAsFresnelDirty(): void;
  9644. /**
  9645. * Indicates that fresnel and misc need to be re-calculated for all submeshes.
  9646. */
  9647. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  9648. /**
  9649. * Indicates that lights need to be re-calculated for all submeshes.
  9650. */
  9651. protected _markAllSubMeshesAsLightsDirty(): void;
  9652. /**
  9653. * Indicates that attributes need to be re-calculated for all submeshes.
  9654. */
  9655. protected _markAllSubMeshesAsAttributesDirty(): void;
  9656. /**
  9657. * Indicates that misc needs to be re-calculated for all submeshes.
  9658. */
  9659. protected _markAllSubMeshesAsMiscDirty(): void;
  9660. /**
  9661. * Indicates that textures and misc need to be re-calculated for all submeshes.
  9662. */
  9663. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  9664. /**
  9665. * Disposes the material.
  9666. * @param forceDisposeEffect - Specifies if effects should be force disposed.
  9667. * @param forceDisposeTextures - Specifies if textures should be force disposed.
  9668. */
  9669. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  9670. /**
  9671. * Serializes this material.
  9672. * @returns - serialized material object.
  9673. */
  9674. serialize(): any;
  9675. /**
  9676. * Creates a MultiMaterial from parse MultiMaterial data.
  9677. * @param parsedMultiMaterial - Parsed MultiMaterial data.
  9678. * @param scene - BJS scene.
  9679. * @returns - MultiMaterial.
  9680. */
  9681. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  9682. /**
  9683. * Creates a material from parsed material data.
  9684. * @param parsedMaterial - Parsed material data.
  9685. * @param scene - BJS scene.
  9686. * @param rootUrl - Root URL containing the material information.
  9687. * @returns - Parsed material.
  9688. */
  9689. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  9690. }
  9691. }
  9692. declare module BABYLON {
  9693. /**
  9694. * "Static Class" containing the most commonly used helper while dealing with material for
  9695. * rendering purpose.
  9696. *
  9697. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9698. *
  9699. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9700. */
  9701. class MaterialHelper {
  9702. /**
  9703. * Bind the current view position to an effect.
  9704. * @param effect The effect to be bound
  9705. * @param scene The scene the eyes position is used from
  9706. */
  9707. static BindEyePosition(effect: Effect, scene: Scene): void;
  9708. /**
  9709. * Helps preparing the defines values about the UVs in used in the effect.
  9710. * UVs are shared as much as we can accross chanels in the shaders.
  9711. * @param texture The texture we are preparing the UVs for
  9712. * @param defines The defines to update
  9713. * @param key The chanel key "diffuse", "specular"... used in the shader
  9714. */
  9715. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9716. /**
  9717. * Binds a texture matrix value to its corrsponding uniform
  9718. * @param texture The texture to bind the matrix for
  9719. * @param uniformBuffer The uniform buffer receivin the data
  9720. * @param key The chanel key "diffuse", "specular"... used in the shader
  9721. */
  9722. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9723. /**
  9724. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9725. * @param mesh defines the current mesh
  9726. * @param scene defines the current scene
  9727. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9728. * @param pointsCloud defines if point cloud rendering has to be turned on
  9729. * @param fogEnabled defines if fog has to be turned on
  9730. * @param alphaTest defines if alpha testing has to be turned on
  9731. * @param defines defines the current list of defines
  9732. */
  9733. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9734. /**
  9735. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9736. * @param scene defines the current scene
  9737. * @param engine defines the current engine
  9738. * @param defines specifies the list of active defines
  9739. * @param useInstances defines if instances have to be turned on
  9740. * @param useClipPlane defines if clip plane have to be turned on
  9741. */
  9742. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9743. /**
  9744. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9745. * @param mesh The mesh containing the geometry data we will draw
  9746. * @param defines The defines to update
  9747. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9748. * @param useBones Precise whether bones should be used or not (override mesh info)
  9749. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9750. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9751. * @returns false if defines are considered not dirty and have not been checked
  9752. */
  9753. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9754. /**
  9755. * Prepares the defines related to the light information passed in parameter
  9756. * @param scene The scene we are intending to draw
  9757. * @param mesh The mesh the effect is compiling for
  9758. * @param defines The defines to update
  9759. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9760. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9761. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9762. * @returns true if normals will be required for the rest of the effect
  9763. */
  9764. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9765. /**
  9766. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9767. * that won t be acctive due to defines being turned off.
  9768. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9769. * @param samplersList The samplers list
  9770. * @param defines The defines helping in the list generation
  9771. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9772. */
  9773. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9774. /**
  9775. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9776. * @param defines The defines to update while falling back
  9777. * @param fallbacks The authorized effect fallbacks
  9778. * @param maxSimultaneousLights The maximum number of lights allowed
  9779. * @param rank the current rank of the Effect
  9780. * @returns The newly affected rank
  9781. */
  9782. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9783. /**
  9784. * Prepares the list of attributes required for morph targets according to the effect defines.
  9785. * @param attribs The current list of supported attribs
  9786. * @param mesh The mesh to prepare the morph targets attributes for
  9787. * @param defines The current Defines of the effect
  9788. */
  9789. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9790. /**
  9791. * Prepares the list of attributes required for bones according to the effect defines.
  9792. * @param attribs The current list of supported attribs
  9793. * @param mesh The mesh to prepare the bones attributes for
  9794. * @param defines The current Defines of the effect
  9795. * @param fallbacks The current efffect fallback strategy
  9796. */
  9797. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9798. /**
  9799. * Prepares the list of attributes required for instances according to the effect defines.
  9800. * @param attribs The current list of supported attribs
  9801. * @param defines The current Defines of the effect
  9802. */
  9803. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9804. /**
  9805. * Binds the light shadow information to the effect for the given mesh.
  9806. * @param light The light containing the generator
  9807. * @param scene The scene the lights belongs to
  9808. * @param mesh The mesh we are binding the information to render
  9809. * @param lightIndex The light index in the effect used to render the mesh
  9810. * @param effect The effect we are binding the data to
  9811. */
  9812. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9813. /**
  9814. * Binds the light information to the effect.
  9815. * @param light The light containing the generator
  9816. * @param effect The effect we are binding the data to
  9817. * @param lightIndex The light index in the effect used to render
  9818. */
  9819. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9820. /**
  9821. * Binds the lights information from the scene to the effect for the given mesh.
  9822. * @param scene The scene the lights belongs to
  9823. * @param mesh The mesh we are binding the information to render
  9824. * @param effect The effect we are binding the data to
  9825. * @param defines The generated defines for the effect
  9826. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9827. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9828. */
  9829. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9830. /**
  9831. * Binds the fog information from the scene to the effect for the given mesh.
  9832. * @param scene The scene the lights belongs to
  9833. * @param mesh The mesh we are binding the information to render
  9834. * @param effect The effect we are binding the data to
  9835. */
  9836. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  9837. /**
  9838. * Binds the bones information from the mesh to the effect.
  9839. * @param mesh The mesh we are binding the information to render
  9840. * @param effect The effect we are binding the data to
  9841. */
  9842. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9843. /**
  9844. * Binds the morph targets information from the mesh to the effect.
  9845. * @param abstractMesh The mesh we are binding the information to render
  9846. * @param effect The effect we are binding the data to
  9847. */
  9848. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9849. /**
  9850. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9851. * @param defines The generated defines used in the effect
  9852. * @param effect The effect we are binding the data to
  9853. * @param scene The scene we are willing to render with logarithmic scale for
  9854. */
  9855. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9856. /**
  9857. * Binds the clip plane information from the scene to the effect.
  9858. * @param scene The scene the clip plane information are extracted from
  9859. * @param effect The effect we are binding the data to
  9860. */
  9861. static BindClipPlane(effect: Effect, scene: Scene): void;
  9862. }
  9863. }
  9864. declare module BABYLON {
  9865. class MultiMaterial extends Material {
  9866. private _subMaterials;
  9867. subMaterials: Nullable<Material>[];
  9868. constructor(name: string, scene: Scene);
  9869. private _hookArray(array);
  9870. getSubMaterial(index: number): Nullable<Material>;
  9871. getActiveTextures(): BaseTexture[];
  9872. getClassName(): string;
  9873. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  9874. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  9875. serialize(): any;
  9876. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  9877. }
  9878. }
  9879. declare module BABYLON {
  9880. class PushMaterial extends Material {
  9881. protected _activeEffect: Effect;
  9882. protected _normalMatrix: Matrix;
  9883. constructor(name: string, scene: Scene);
  9884. getEffect(): Effect;
  9885. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  9886. /**
  9887. * Binds the given world matrix to the active effect
  9888. *
  9889. * @param world the matrix to bind
  9890. */
  9891. bindOnlyWorldMatrix(world: Matrix): void;
  9892. /**
  9893. * Binds the given normal matrix to the active effect
  9894. *
  9895. * @param normalMatrix the matrix to bind
  9896. */
  9897. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  9898. bind(world: Matrix, mesh?: Mesh): void;
  9899. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  9900. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  9901. }
  9902. }
  9903. declare module BABYLON {
  9904. class ShaderMaterial extends Material {
  9905. private _shaderPath;
  9906. private _options;
  9907. private _textures;
  9908. private _textureArrays;
  9909. private _floats;
  9910. private _ints;
  9911. private _floatsArrays;
  9912. private _colors3;
  9913. private _colors3Arrays;
  9914. private _colors4;
  9915. private _vectors2;
  9916. private _vectors3;
  9917. private _vectors4;
  9918. private _matrices;
  9919. private _matrices3x3;
  9920. private _matrices2x2;
  9921. private _vectors2Arrays;
  9922. private _vectors3Arrays;
  9923. private _cachedWorldViewMatrix;
  9924. private _renderId;
  9925. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  9926. getClassName(): string;
  9927. needAlphaBlending(): boolean;
  9928. needAlphaTesting(): boolean;
  9929. private _checkUniform(uniformName);
  9930. setTexture(name: string, texture: Texture): ShaderMaterial;
  9931. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  9932. setFloat(name: string, value: number): ShaderMaterial;
  9933. setInt(name: string, value: number): ShaderMaterial;
  9934. setFloats(name: string, value: number[]): ShaderMaterial;
  9935. setColor3(name: string, value: Color3): ShaderMaterial;
  9936. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  9937. setColor4(name: string, value: Color4): ShaderMaterial;
  9938. setVector2(name: string, value: Vector2): ShaderMaterial;
  9939. setVector3(name: string, value: Vector3): ShaderMaterial;
  9940. setVector4(name: string, value: Vector4): ShaderMaterial;
  9941. setMatrix(name: string, value: Matrix): ShaderMaterial;
  9942. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  9943. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  9944. setArray2(name: string, value: number[]): ShaderMaterial;
  9945. setArray3(name: string, value: number[]): ShaderMaterial;
  9946. private _checkCache(scene, mesh?, useInstances?);
  9947. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  9948. bindOnlyWorldMatrix(world: Matrix): void;
  9949. bind(world: Matrix, mesh?: Mesh): void;
  9950. getActiveTextures(): BaseTexture[];
  9951. hasTexture(texture: BaseTexture): boolean;
  9952. clone(name: string): ShaderMaterial;
  9953. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  9954. serialize(): any;
  9955. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  9956. }
  9957. }
  9958. declare module BABYLON {
  9959. /** @ignore */
  9960. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  9961. MAINUV1: boolean;
  9962. MAINUV2: boolean;
  9963. DIFFUSE: boolean;
  9964. DIFFUSEDIRECTUV: number;
  9965. AMBIENT: boolean;
  9966. AMBIENTDIRECTUV: number;
  9967. OPACITY: boolean;
  9968. OPACITYDIRECTUV: number;
  9969. OPACITYRGB: boolean;
  9970. REFLECTION: boolean;
  9971. EMISSIVE: boolean;
  9972. EMISSIVEDIRECTUV: number;
  9973. SPECULAR: boolean;
  9974. SPECULARDIRECTUV: number;
  9975. BUMP: boolean;
  9976. BUMPDIRECTUV: number;
  9977. PARALLAX: boolean;
  9978. PARALLAXOCCLUSION: boolean;
  9979. SPECULAROVERALPHA: boolean;
  9980. CLIPPLANE: boolean;
  9981. ALPHATEST: boolean;
  9982. DEPTHPREPASS: boolean;
  9983. ALPHAFROMDIFFUSE: boolean;
  9984. POINTSIZE: boolean;
  9985. FOG: boolean;
  9986. SPECULARTERM: boolean;
  9987. DIFFUSEFRESNEL: boolean;
  9988. OPACITYFRESNEL: boolean;
  9989. REFLECTIONFRESNEL: boolean;
  9990. REFRACTIONFRESNEL: boolean;
  9991. EMISSIVEFRESNEL: boolean;
  9992. FRESNEL: boolean;
  9993. NORMAL: boolean;
  9994. UV1: boolean;
  9995. UV2: boolean;
  9996. VERTEXCOLOR: boolean;
  9997. VERTEXALPHA: boolean;
  9998. NUM_BONE_INFLUENCERS: number;
  9999. BonesPerMesh: number;
  10000. INSTANCES: boolean;
  10001. GLOSSINESS: boolean;
  10002. ROUGHNESS: boolean;
  10003. EMISSIVEASILLUMINATION: boolean;
  10004. LINKEMISSIVEWITHDIFFUSE: boolean;
  10005. REFLECTIONFRESNELFROMSPECULAR: boolean;
  10006. LIGHTMAP: boolean;
  10007. LIGHTMAPDIRECTUV: number;
  10008. OBJECTSPACE_NORMALMAP: boolean;
  10009. USELIGHTMAPASSHADOWMAP: boolean;
  10010. REFLECTIONMAP_3D: boolean;
  10011. REFLECTIONMAP_SPHERICAL: boolean;
  10012. REFLECTIONMAP_PLANAR: boolean;
  10013. REFLECTIONMAP_CUBIC: boolean;
  10014. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  10015. REFLECTIONMAP_PROJECTION: boolean;
  10016. REFLECTIONMAP_SKYBOX: boolean;
  10017. REFLECTIONMAP_EXPLICIT: boolean;
  10018. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  10019. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  10020. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  10021. INVERTCUBICMAP: boolean;
  10022. LOGARITHMICDEPTH: boolean;
  10023. REFRACTION: boolean;
  10024. REFRACTIONMAP_3D: boolean;
  10025. REFLECTIONOVERALPHA: boolean;
  10026. TWOSIDEDLIGHTING: boolean;
  10027. SHADOWFLOAT: boolean;
  10028. MORPHTARGETS: boolean;
  10029. MORPHTARGETS_NORMAL: boolean;
  10030. MORPHTARGETS_TANGENT: boolean;
  10031. NUM_MORPH_INFLUENCERS: number;
  10032. NONUNIFORMSCALING: boolean;
  10033. PREMULTIPLYALPHA: boolean;
  10034. IMAGEPROCESSING: boolean;
  10035. VIGNETTE: boolean;
  10036. VIGNETTEBLENDMODEMULTIPLY: boolean;
  10037. VIGNETTEBLENDMODEOPAQUE: boolean;
  10038. TONEMAPPING: boolean;
  10039. CONTRAST: boolean;
  10040. COLORCURVES: boolean;
  10041. COLORGRADING: boolean;
  10042. COLORGRADING3D: boolean;
  10043. SAMPLER3DGREENDEPTH: boolean;
  10044. SAMPLER3DBGRMAP: boolean;
  10045. IMAGEPROCESSINGPOSTPROCESS: boolean;
  10046. EXPOSURE: boolean;
  10047. GRAIN: boolean;
  10048. constructor();
  10049. setReflectionMode(modeToEnable: string): void;
  10050. }
  10051. class StandardMaterial extends PushMaterial {
  10052. private _diffuseTexture;
  10053. diffuseTexture: Nullable<BaseTexture>;
  10054. private _ambientTexture;
  10055. ambientTexture: Nullable<BaseTexture>;
  10056. private _opacityTexture;
  10057. opacityTexture: Nullable<BaseTexture>;
  10058. private _reflectionTexture;
  10059. reflectionTexture: Nullable<BaseTexture>;
  10060. private _emissiveTexture;
  10061. emissiveTexture: Nullable<BaseTexture>;
  10062. private _specularTexture;
  10063. specularTexture: Nullable<BaseTexture>;
  10064. private _bumpTexture;
  10065. bumpTexture: Nullable<BaseTexture>;
  10066. private _lightmapTexture;
  10067. lightmapTexture: Nullable<BaseTexture>;
  10068. private _refractionTexture;
  10069. refractionTexture: Nullable<BaseTexture>;
  10070. ambientColor: Color3;
  10071. diffuseColor: Color3;
  10072. specularColor: Color3;
  10073. emissiveColor: Color3;
  10074. specularPower: number;
  10075. private _useAlphaFromDiffuseTexture;
  10076. useAlphaFromDiffuseTexture: boolean;
  10077. private _useEmissiveAsIllumination;
  10078. useEmissiveAsIllumination: boolean;
  10079. private _linkEmissiveWithDiffuse;
  10080. linkEmissiveWithDiffuse: boolean;
  10081. private _useSpecularOverAlpha;
  10082. useSpecularOverAlpha: boolean;
  10083. private _useReflectionOverAlpha;
  10084. useReflectionOverAlpha: boolean;
  10085. private _disableLighting;
  10086. disableLighting: boolean;
  10087. private _useObjectSpaceNormalMap;
  10088. /**
  10089. * Allows using an object space normal map (instead of tangent space).
  10090. */
  10091. useObjectSpaceNormalMap: boolean;
  10092. private _useParallax;
  10093. useParallax: boolean;
  10094. private _useParallaxOcclusion;
  10095. useParallaxOcclusion: boolean;
  10096. parallaxScaleBias: number;
  10097. private _roughness;
  10098. roughness: number;
  10099. indexOfRefraction: number;
  10100. invertRefractionY: boolean;
  10101. private _useLightmapAsShadowmap;
  10102. useLightmapAsShadowmap: boolean;
  10103. private _diffuseFresnelParameters;
  10104. diffuseFresnelParameters: FresnelParameters;
  10105. private _opacityFresnelParameters;
  10106. opacityFresnelParameters: FresnelParameters;
  10107. private _reflectionFresnelParameters;
  10108. reflectionFresnelParameters: FresnelParameters;
  10109. private _refractionFresnelParameters;
  10110. refractionFresnelParameters: FresnelParameters;
  10111. private _emissiveFresnelParameters;
  10112. emissiveFresnelParameters: FresnelParameters;
  10113. private _useReflectionFresnelFromSpecular;
  10114. useReflectionFresnelFromSpecular: boolean;
  10115. private _useGlossinessFromSpecularMapAlpha;
  10116. useGlossinessFromSpecularMapAlpha: boolean;
  10117. private _maxSimultaneousLights;
  10118. maxSimultaneousLights: number;
  10119. /**
  10120. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  10121. */
  10122. private _invertNormalMapX;
  10123. invertNormalMapX: boolean;
  10124. /**
  10125. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  10126. */
  10127. private _invertNormalMapY;
  10128. invertNormalMapY: boolean;
  10129. /**
  10130. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  10131. */
  10132. private _twoSidedLighting;
  10133. twoSidedLighting: boolean;
  10134. /**
  10135. * Default configuration related to image processing available in the standard Material.
  10136. */
  10137. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  10138. /**
  10139. * Gets the image processing configuration used either in this material.
  10140. */
  10141. /**
  10142. * Sets the Default image processing configuration used either in the this material.
  10143. *
  10144. * If sets to null, the scene one is in use.
  10145. */
  10146. imageProcessingConfiguration: ImageProcessingConfiguration;
  10147. /**
  10148. * Keep track of the image processing observer to allow dispose and replace.
  10149. */
  10150. private _imageProcessingObserver;
  10151. /**
  10152. * Attaches a new image processing configuration to the Standard Material.
  10153. * @param configuration
  10154. */
  10155. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  10156. /**
  10157. * Gets wether the color curves effect is enabled.
  10158. */
  10159. /**
  10160. * Sets wether the color curves effect is enabled.
  10161. */
  10162. cameraColorCurvesEnabled: boolean;
  10163. /**
  10164. * Gets wether the color grading effect is enabled.
  10165. */
  10166. /**
  10167. * Gets wether the color grading effect is enabled.
  10168. */
  10169. cameraColorGradingEnabled: boolean;
  10170. /**
  10171. * Gets wether tonemapping is enabled or not.
  10172. */
  10173. /**
  10174. * Sets wether tonemapping is enabled or not
  10175. */
  10176. cameraToneMappingEnabled: boolean;
  10177. /**
  10178. * The camera exposure used on this material.
  10179. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  10180. * This corresponds to a photographic exposure.
  10181. */
  10182. /**
  10183. * The camera exposure used on this material.
  10184. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  10185. * This corresponds to a photographic exposure.
  10186. */
  10187. cameraExposure: number;
  10188. /**
  10189. * Gets The camera contrast used on this material.
  10190. */
  10191. /**
  10192. * Sets The camera contrast used on this material.
  10193. */
  10194. cameraContrast: number;
  10195. /**
  10196. * Gets the Color Grading 2D Lookup Texture.
  10197. */
  10198. /**
  10199. * Sets the Color Grading 2D Lookup Texture.
  10200. */
  10201. cameraColorGradingTexture: Nullable<BaseTexture>;
  10202. /**
  10203. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  10204. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  10205. * 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;
  10206. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  10207. */
  10208. /**
  10209. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  10210. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  10211. * 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;
  10212. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  10213. */
  10214. cameraColorCurves: Nullable<ColorCurves>;
  10215. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  10216. protected _renderTargets: SmartArray<RenderTargetTexture>;
  10217. protected _worldViewProjectionMatrix: Matrix;
  10218. protected _globalAmbientColor: Color3;
  10219. protected _useLogarithmicDepth: boolean;
  10220. constructor(name: string, scene: Scene);
  10221. getClassName(): string;
  10222. useLogarithmicDepth: boolean;
  10223. needAlphaBlending(): boolean;
  10224. needAlphaTesting(): boolean;
  10225. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  10226. getAlphaTestTexture(): Nullable<BaseTexture>;
  10227. /**
  10228. * Child classes can use it to update shaders
  10229. */
  10230. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  10231. buildUniformLayout(): void;
  10232. unbind(): void;
  10233. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  10234. getAnimatables(): IAnimatable[];
  10235. getActiveTextures(): BaseTexture[];
  10236. hasTexture(texture: BaseTexture): boolean;
  10237. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  10238. clone(name: string): StandardMaterial;
  10239. serialize(): any;
  10240. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  10241. static _DiffuseTextureEnabled: boolean;
  10242. static DiffuseTextureEnabled: boolean;
  10243. static _AmbientTextureEnabled: boolean;
  10244. static AmbientTextureEnabled: boolean;
  10245. static _OpacityTextureEnabled: boolean;
  10246. static OpacityTextureEnabled: boolean;
  10247. static _ReflectionTextureEnabled: boolean;
  10248. static ReflectionTextureEnabled: boolean;
  10249. static _EmissiveTextureEnabled: boolean;
  10250. static EmissiveTextureEnabled: boolean;
  10251. static _SpecularTextureEnabled: boolean;
  10252. static SpecularTextureEnabled: boolean;
  10253. static _BumpTextureEnabled: boolean;
  10254. static BumpTextureEnabled: boolean;
  10255. static _LightmapTextureEnabled: boolean;
  10256. static LightmapTextureEnabled: boolean;
  10257. static _RefractionTextureEnabled: boolean;
  10258. static RefractionTextureEnabled: boolean;
  10259. static _ColorGradingTextureEnabled: boolean;
  10260. static ColorGradingTextureEnabled: boolean;
  10261. static _FresnelEnabled: boolean;
  10262. static FresnelEnabled: boolean;
  10263. }
  10264. }
  10265. declare module BABYLON {
  10266. class UniformBuffer {
  10267. private _engine;
  10268. private _buffer;
  10269. private _data;
  10270. private _bufferData;
  10271. private _dynamic?;
  10272. private _uniformLocations;
  10273. private _uniformSizes;
  10274. private _uniformLocationPointer;
  10275. private _needSync;
  10276. private _noUBO;
  10277. private _currentEffect;
  10278. private static _MAX_UNIFORM_SIZE;
  10279. private static _tempBuffer;
  10280. /**
  10281. * Wrapper for updateUniform.
  10282. * @method updateMatrix3x3
  10283. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10284. * @param {Float32Array} matrix
  10285. */
  10286. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  10287. /**
  10288. * Wrapper for updateUniform.
  10289. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10290. * @param {Float32Array} matrix
  10291. */
  10292. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  10293. /**
  10294. * Wrapper for updateUniform.
  10295. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10296. * @param {number} x
  10297. */
  10298. updateFloat: (name: string, x: number) => void;
  10299. /**
  10300. * Wrapper for updateUniform.
  10301. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10302. * @param {number} x
  10303. * @param {number} y
  10304. * @param {string} [suffix] Suffix to add to the uniform name.
  10305. */
  10306. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  10307. /**
  10308. * Wrapper for updateUniform.
  10309. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10310. * @param {number} x
  10311. * @param {number} y
  10312. * @param {number} z
  10313. * @param {string} [suffix] Suffix to add to the uniform name.
  10314. */
  10315. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  10316. /**
  10317. * Wrapper for updateUniform.
  10318. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10319. * @param {number} x
  10320. * @param {number} y
  10321. * @param {number} z
  10322. * @param {number} w
  10323. * @param {string} [suffix] Suffix to add to the uniform name.
  10324. */
  10325. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  10326. /**
  10327. * Wrapper for updateUniform.
  10328. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10329. * @param {Matrix} A 4x4 matrix.
  10330. */
  10331. updateMatrix: (name: string, mat: Matrix) => void;
  10332. /**
  10333. * Wrapper for updateUniform.
  10334. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10335. * @param {Vector3} vector
  10336. */
  10337. updateVector3: (name: string, vector: Vector3) => void;
  10338. /**
  10339. * Wrapper for updateUniform.
  10340. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10341. * @param {Vector4} vector
  10342. */
  10343. updateVector4: (name: string, vector: Vector4) => void;
  10344. /**
  10345. * Wrapper for updateUniform.
  10346. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10347. * @param {Color3} color
  10348. * @param {string} [suffix] Suffix to add to the uniform name.
  10349. */
  10350. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  10351. /**
  10352. * Wrapper for updateUniform.
  10353. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10354. * @param {Color3} color
  10355. * @param {number} alpha
  10356. * @param {string} [suffix] Suffix to add to the uniform name.
  10357. */
  10358. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  10359. /**
  10360. * Uniform buffer objects.
  10361. *
  10362. * Handles blocks of uniform on the GPU.
  10363. *
  10364. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  10365. *
  10366. * For more information, please refer to :
  10367. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  10368. */
  10369. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  10370. /**
  10371. * Indicates if the buffer is using the WebGL2 UBO implementation,
  10372. * or just falling back on setUniformXXX calls.
  10373. */
  10374. readonly useUbo: boolean;
  10375. /**
  10376. * Indicates if the WebGL underlying uniform buffer is in sync
  10377. * with the javascript cache data.
  10378. */
  10379. readonly isSync: boolean;
  10380. /**
  10381. * Indicates if the WebGL underlying uniform buffer is dynamic.
  10382. * Also, a dynamic UniformBuffer will disable cache verification and always
  10383. * update the underlying WebGL uniform buffer to the GPU.
  10384. */
  10385. isDynamic(): boolean;
  10386. /**
  10387. * The data cache on JS side.
  10388. */
  10389. getData(): Float32Array;
  10390. /**
  10391. * The underlying WebGL Uniform buffer.
  10392. */
  10393. getBuffer(): Nullable<WebGLBuffer>;
  10394. /**
  10395. * std140 layout specifies how to align data within an UBO structure.
  10396. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  10397. * for specs.
  10398. */
  10399. private _fillAlignment(size);
  10400. /**
  10401. * Adds an uniform in the buffer.
  10402. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  10403. * for the layout to be correct !
  10404. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10405. * @param {number|number[]} size Data size, or data directly.
  10406. */
  10407. addUniform(name: string, size: number | number[]): void;
  10408. /**
  10409. * Wrapper for addUniform.
  10410. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10411. * @param {Matrix} mat A 4x4 matrix.
  10412. */
  10413. addMatrix(name: string, mat: Matrix): void;
  10414. /**
  10415. * Wrapper for addUniform.
  10416. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10417. * @param {number} x
  10418. * @param {number} y
  10419. */
  10420. addFloat2(name: string, x: number, y: number): void;
  10421. /**
  10422. * Wrapper for addUniform.
  10423. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10424. * @param {number} x
  10425. * @param {number} y
  10426. * @param {number} z
  10427. */
  10428. addFloat3(name: string, x: number, y: number, z: number): void;
  10429. /**
  10430. * Wrapper for addUniform.
  10431. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10432. * @param {Color3} color
  10433. */
  10434. addColor3(name: string, color: Color3): void;
  10435. /**
  10436. * Wrapper for addUniform.
  10437. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10438. * @param {Color3} color
  10439. * @param {number} alpha
  10440. */
  10441. addColor4(name: string, color: Color3, alpha: number): void;
  10442. /**
  10443. * Wrapper for addUniform.
  10444. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10445. * @param {Vector3} vector
  10446. */
  10447. addVector3(name: string, vector: Vector3): void;
  10448. /**
  10449. * Wrapper for addUniform.
  10450. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10451. */
  10452. addMatrix3x3(name: string): void;
  10453. /**
  10454. * Wrapper for addUniform.
  10455. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10456. */
  10457. addMatrix2x2(name: string): void;
  10458. /**
  10459. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  10460. */
  10461. create(): void;
  10462. _rebuild(): void;
  10463. /**
  10464. * Updates the WebGL Uniform Buffer on the GPU.
  10465. * If the `dynamic` flag is set to true, no cache comparison is done.
  10466. * Otherwise, the buffer will be updated only if the cache differs.
  10467. */
  10468. update(): void;
  10469. /**
  10470. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  10471. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  10472. * @param {number[]|Float32Array} data Flattened data
  10473. * @param {number} size Size of the data.
  10474. */
  10475. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  10476. private _updateMatrix3x3ForUniform(name, matrix);
  10477. private _updateMatrix3x3ForEffect(name, matrix);
  10478. private _updateMatrix2x2ForEffect(name, matrix);
  10479. private _updateMatrix2x2ForUniform(name, matrix);
  10480. private _updateFloatForEffect(name, x);
  10481. private _updateFloatForUniform(name, x);
  10482. private _updateFloat2ForEffect(name, x, y, suffix?);
  10483. private _updateFloat2ForUniform(name, x, y, suffix?);
  10484. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  10485. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  10486. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  10487. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  10488. private _updateMatrixForEffect(name, mat);
  10489. private _updateMatrixForUniform(name, mat);
  10490. private _updateVector3ForEffect(name, vector);
  10491. private _updateVector3ForUniform(name, vector);
  10492. private _updateVector4ForEffect(name, vector);
  10493. private _updateVector4ForUniform(name, vector);
  10494. private _updateColor3ForEffect(name, color, suffix?);
  10495. private _updateColor3ForUniform(name, color, suffix?);
  10496. private _updateColor4ForEffect(name, color, alpha, suffix?);
  10497. private _updateColor4ForUniform(name, color, alpha, suffix?);
  10498. /**
  10499. * Sets a sampler uniform on the effect.
  10500. * @param {string} name Name of the sampler.
  10501. * @param {Texture} texture
  10502. */
  10503. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  10504. /**
  10505. * Directly updates the value of the uniform in the cache AND on the GPU.
  10506. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  10507. * @param {number[]|Float32Array} data Flattened data
  10508. */
  10509. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  10510. /**
  10511. * Binds this uniform buffer to an effect.
  10512. * @param {Effect} effect
  10513. * @param {string} name Name of the uniform block in the shader.
  10514. */
  10515. bindToEffect(effect: Effect, name: string): void;
  10516. /**
  10517. * Disposes the uniform buffer.
  10518. */
  10519. dispose(): void;
  10520. }
  10521. }
  10522. declare module BABYLON {
  10523. class Scalar {
  10524. /**
  10525. * Two pi constants convenient for computation.
  10526. */
  10527. static TwoPi: number;
  10528. /**
  10529. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  10530. */
  10531. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  10532. /**
  10533. * Returns a string : the upper case translation of the number i to hexadecimal.
  10534. */
  10535. static ToHex(i: number): string;
  10536. /**
  10537. * Returns -1 if value is negative and +1 is value is positive.
  10538. * Returns the value itself if it's equal to zero.
  10539. */
  10540. static Sign(value: number): number;
  10541. /**
  10542. * Returns the value itself if it's between min and max.
  10543. * Returns min if the value is lower than min.
  10544. * Returns max if the value is greater than max.
  10545. */
  10546. static Clamp(value: number, min?: number, max?: number): number;
  10547. /**
  10548. * Returns the log2 of value.
  10549. */
  10550. static Log2(value: number): number;
  10551. /**
  10552. * Loops the value, so that it is never larger than length and never smaller than 0.
  10553. *
  10554. * This is similar to the modulo operator but it works with floating point numbers.
  10555. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  10556. * With t = 5 and length = 2.5, the result would be 0.0.
  10557. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  10558. */
  10559. static Repeat(value: number, length: number): number;
  10560. /**
  10561. * Normalize the value between 0.0 and 1.0 using min and max values
  10562. */
  10563. static Normalize(value: number, min: number, max: number): number;
  10564. /**
  10565. * Denormalize the value from 0.0 and 1.0 using min and max values
  10566. */
  10567. static Denormalize(normalized: number, min: number, max: number): number;
  10568. /**
  10569. * Calculates the shortest difference between two given angles given in degrees.
  10570. */
  10571. static DeltaAngle(current: number, target: number): number;
  10572. /**
  10573. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  10574. *
  10575. * The returned value will move back and forth between 0 and length
  10576. */
  10577. static PingPong(tx: number, length: number): number;
  10578. /**
  10579. * Interpolates between min and max with smoothing at the limits.
  10580. *
  10581. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  10582. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  10583. */
  10584. static SmoothStep(from: number, to: number, tx: number): number;
  10585. /**
  10586. * Moves a value current towards target.
  10587. *
  10588. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  10589. * Negative values of maxDelta pushes the value away from target.
  10590. */
  10591. static MoveTowards(current: number, target: number, maxDelta: number): number;
  10592. /**
  10593. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  10594. *
  10595. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  10596. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  10597. */
  10598. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  10599. /**
  10600. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  10601. */
  10602. static Lerp(start: number, end: number, amount: number): number;
  10603. /**
  10604. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  10605. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  10606. */
  10607. static LerpAngle(start: number, end: number, amount: number): number;
  10608. /**
  10609. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  10610. */
  10611. static InverseLerp(a: number, b: number, value: number): number;
  10612. /**
  10613. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  10614. */
  10615. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  10616. /**
  10617. * Returns a random float number between and min and max values
  10618. */
  10619. static RandomRange(min: number, max: number): number;
  10620. /**
  10621. * This function returns percentage of a number in a given range.
  10622. *
  10623. * RangeToPercent(40,20,60) will return 0.5 (50%)
  10624. * RangeToPercent(34,0,100) will return 0.34 (34%)
  10625. */
  10626. static RangeToPercent(number: number, min: number, max: number): number;
  10627. /**
  10628. * This function returns number that corresponds to the percentage in a given range.
  10629. *
  10630. * PercentToRange(0.34,0,100) will return 34.
  10631. */
  10632. static PercentToRange(percent: number, min: number, max: number): number;
  10633. /**
  10634. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  10635. * @param angle The angle to normalize in radian.
  10636. * @return The converted angle.
  10637. */
  10638. static NormalizeRadians(angle: number): number;
  10639. }
  10640. }
  10641. declare module BABYLON {
  10642. const ToGammaSpace: number;
  10643. const ToLinearSpace = 2.2;
  10644. const Epsilon = 0.001;
  10645. /**
  10646. * Class used to hold a RBG color
  10647. */
  10648. class Color3 {
  10649. /**
  10650. * Defines the red component (between 0 and 1, default is 0)
  10651. */
  10652. r: number;
  10653. /**
  10654. * Defines the green component (between 0 and 1, default is 0)
  10655. */
  10656. g: number;
  10657. /**
  10658. * Defines the blue component (between 0 and 1, default is 0)
  10659. */
  10660. b: number;
  10661. /**
  10662. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  10663. * @param r defines the red component (between 0 and 1, default is 0)
  10664. * @param g defines the green component (between 0 and 1, default is 0)
  10665. * @param b defines the blue component (between 0 and 1, default is 0)
  10666. */
  10667. constructor(
  10668. /**
  10669. * Defines the red component (between 0 and 1, default is 0)
  10670. */
  10671. r?: number,
  10672. /**
  10673. * Defines the green component (between 0 and 1, default is 0)
  10674. */
  10675. g?: number,
  10676. /**
  10677. * Defines the blue component (between 0 and 1, default is 0)
  10678. */
  10679. b?: number);
  10680. /**
  10681. * Creates a string with the Color3 current values
  10682. * @returns the string representation of the Color3 object
  10683. */
  10684. toString(): string;
  10685. /**
  10686. * Returns the string "Color3"
  10687. * @returns "Color3"
  10688. */
  10689. getClassName(): string;
  10690. /**
  10691. * Compute the Color3 hash code
  10692. * @returns an unique number that can be used to hash Color3 objects
  10693. */
  10694. getHashCode(): number;
  10695. /**
  10696. * Stores in the passed array from the passed starting index the red, green, blue values as successive elements
  10697. * @param array defines the array where to store the r,g,b components
  10698. * @param index defines an optional index in the target array to define where to start storing values
  10699. * @returns the current Color3 object
  10700. */
  10701. toArray(array: FloatArray, index?: number): Color3;
  10702. /**
  10703. * Returns a new {BABYLON.Color4} object from the current Color3 and the passed alpha
  10704. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  10705. * @returns a new {BABYLON.Color4} object
  10706. */
  10707. toColor4(alpha?: number): Color4;
  10708. /**
  10709. * Returns a new array populated with 3 numeric elements : red, green and blue values
  10710. * @returns the new array
  10711. */
  10712. asArray(): number[];
  10713. /**
  10714. * Returns the luminance value
  10715. * @returns a float value
  10716. */
  10717. toLuminance(): number;
  10718. /**
  10719. * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object
  10720. * @param otherColor defines the second operand
  10721. * @returns the new Color3 object
  10722. */
  10723. multiply(otherColor: Color3): Color3;
  10724. /**
  10725. * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result"
  10726. * @param otherColor defines the second operand
  10727. * @param result defines the Color3 object where to store the result
  10728. * @returns the current Color3
  10729. */
  10730. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  10731. /**
  10732. * Determines equality between Color3 objects
  10733. * @param otherColor defines the second operand
  10734. * @returns true if the rgb values are equal to the passed ones
  10735. */
  10736. equals(otherColor: Color3): boolean;
  10737. /**
  10738. * Determines equality between the current Color3 object and a set of r,b,g values
  10739. * @param r defines the red component to check
  10740. * @param g defines the green component to check
  10741. * @param b defines the blue component to check
  10742. * @returns true if the rgb values are equal to the passed ones
  10743. */
  10744. equalsFloats(r: number, g: number, b: number): boolean;
  10745. /**
  10746. * Multiplies in place each rgb value by scale
  10747. * @param scale defines the scaling factor
  10748. * @returns the updated Color3
  10749. */
  10750. scale(scale: number): Color3;
  10751. /**
  10752. * Multiplies the rgb values by scale and stores the result into "result"
  10753. * @param scale defines the scaling factor
  10754. * @param result defines the Color3 object where to store the result
  10755. * @returns the unmodified current Color3
  10756. */
  10757. scaleToRef(scale: number, result: Color3): Color3;
  10758. /**
  10759. * Scale the current Color3 values by a factor and add the result to a given Color3
  10760. * @param scale defines the scale factor
  10761. * @param result defines color to store the result into
  10762. * @returns the unmodified current Color3
  10763. */
  10764. scaleAndAddToRef(scale: number, result: Color3): Color3;
  10765. /**
  10766. * Clamps the rgb values by the min and max values and stores the result into "result"
  10767. * @param min defines minimum clamping value (default is 0)
  10768. * @param max defines maximum clamping value (default is 1)
  10769. * @param result defines color to store the result into
  10770. * @returns the original Color3
  10771. */
  10772. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  10773. /**
  10774. * Creates a new Color3 set with the added values of the current Color3 and of the passed one
  10775. * @param otherColor defines the second operand
  10776. * @returns the new Color3
  10777. */
  10778. add(otherColor: Color3): Color3;
  10779. /**
  10780. * Stores the result of the addition of the current Color3 and passed one rgb values into "result"
  10781. * @param otherColor defines the second operand
  10782. * @param result defines Color3 object to store the result into
  10783. * @returns the unmodified current Color3
  10784. */
  10785. addToRef(otherColor: Color3, result: Color3): Color3;
  10786. /**
  10787. * Returns a new Color3 set with the subtracted values of the passed one from the current Color3
  10788. * @param otherColor defines the second operand
  10789. * @returns the new Color3
  10790. */
  10791. subtract(otherColor: Color3): Color3;
  10792. /**
  10793. * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result"
  10794. * @param otherColor defines the second operand
  10795. * @param result defines Color3 object to store the result into
  10796. * @returns the unmodified current Color3
  10797. */
  10798. subtractToRef(otherColor: Color3, result: Color3): Color3;
  10799. /**
  10800. * Copy the current object
  10801. * @returns a new Color3 copied the current one
  10802. */
  10803. clone(): Color3;
  10804. /**
  10805. * Copies the rgb values from the source in the current Color3
  10806. * @param source defines the source Color3 object
  10807. * @returns the updated Color3 object
  10808. */
  10809. copyFrom(source: Color3): Color3;
  10810. /**
  10811. * Updates the Color3 rgb values from the passed floats
  10812. * @param r defines the red component to read from
  10813. * @param g defines the green component to read from
  10814. * @param b defines the blue component to read from
  10815. * @returns the current Color3 object
  10816. */
  10817. copyFromFloats(r: number, g: number, b: number): Color3;
  10818. /**
  10819. * Updates the Color3 rgb values from the passed floats
  10820. * @param r defines the red component to read from
  10821. * @param g defines the green component to read from
  10822. * @param b defines the blue component to read from
  10823. * @returns the current Color3 object
  10824. */
  10825. set(r: number, g: number, b: number): Color3;
  10826. /**
  10827. * Compute the Color3 hexadecimal code as a string
  10828. * @returns a string containing the hexadecimal representation of the Color3 object
  10829. */
  10830. toHexString(): string;
  10831. /**
  10832. * Computes a new Color3 converted from the current one to linear space
  10833. * @returns a new Color3 object
  10834. */
  10835. toLinearSpace(): Color3;
  10836. /**
  10837. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  10838. * @param convertedColor defines the Color3 object where to store the linear space version
  10839. * @returns the unmodified Color3
  10840. */
  10841. toLinearSpaceToRef(convertedColor: Color3): Color3;
  10842. /**
  10843. * Computes a new Color3 converted from the current one to gamma space
  10844. * @returns a new Color3 object
  10845. */
  10846. toGammaSpace(): Color3;
  10847. /**
  10848. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  10849. * @param convertedColor defines the Color3 object where to store the gamma space version
  10850. * @returns the unmodified Color3
  10851. */
  10852. toGammaSpaceToRef(convertedColor: Color3): Color3;
  10853. /**
  10854. * Creates a new Color3 from the string containing valid hexadecimal values
  10855. * @param hex defines a string containing valid hexadecimal values
  10856. * @returns a new Color3 object
  10857. */
  10858. static FromHexString(hex: string): Color3;
  10859. /**
  10860. * Creates a new Vector3 from the starting index of the passed array
  10861. * @param array defines the source array
  10862. * @param offset defines an offset in the source array
  10863. * @returns a new Color3 object
  10864. */
  10865. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  10866. /**
  10867. * Creates a new Color3 from integer values (< 256)
  10868. * @param r defines the red component to read from (value between 0 and 255)
  10869. * @param g defines the green component to read from (value between 0 and 255)
  10870. * @param b defines the blue component to read from (value between 0 and 255)
  10871. * @returns a new Color3 object
  10872. */
  10873. static FromInts(r: number, g: number, b: number): Color3;
  10874. /**
  10875. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  10876. * @param start defines the start Color3 value
  10877. * @param end defines the end Color3 value
  10878. * @param amount defines the gradient value between start and end
  10879. * @returns a new Color3 object
  10880. */
  10881. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  10882. /**
  10883. * Returns a Color3 value containing a red color
  10884. * @returns a new Color3 object
  10885. */
  10886. static Red(): Color3;
  10887. /**
  10888. * Returns a Color3 value containing a green color
  10889. * @returns a new Color3 object
  10890. */
  10891. static Green(): Color3;
  10892. /**
  10893. * Returns a Color3 value containing a blue color
  10894. * @returns a new Color3 object
  10895. */
  10896. static Blue(): Color3;
  10897. /**
  10898. * Returns a Color3 value containing a black color
  10899. * @returns a new Color3 object
  10900. */
  10901. static Black(): Color3;
  10902. /**
  10903. * Returns a Color3 value containing a white color
  10904. * @returns a new Color3 object
  10905. */
  10906. static White(): Color3;
  10907. /**
  10908. * Returns a Color3 value containing a purple color
  10909. * @returns a new Color3 object
  10910. */
  10911. static Purple(): Color3;
  10912. /**
  10913. * Returns a Color3 value containing a magenta color
  10914. * @returns a new Color3 object
  10915. */
  10916. static Magenta(): Color3;
  10917. /**
  10918. * Returns a Color3 value containing a yellow color
  10919. * @returns a new Color3 object
  10920. */
  10921. static Yellow(): Color3;
  10922. /**
  10923. * Returns a Color3 value containing a gray color
  10924. * @returns a new Color3 object
  10925. */
  10926. static Gray(): Color3;
  10927. /**
  10928. * Returns a Color3 value containing a teal color
  10929. * @returns a new Color3 object
  10930. */
  10931. static Teal(): Color3;
  10932. /**
  10933. * Returns a Color3 value containing a random color
  10934. * @returns a new Color3 object
  10935. */
  10936. static Random(): Color3;
  10937. }
  10938. /**
  10939. * Class used to hold a RBGA color
  10940. */
  10941. class Color4 {
  10942. /**
  10943. * Defines the red component (between 0 and 1, default is 0)
  10944. */
  10945. r: number;
  10946. /**
  10947. * Defines the green component (between 0 and 1, default is 0)
  10948. */
  10949. g: number;
  10950. /**
  10951. * Defines the blue component (between 0 and 1, default is 0)
  10952. */
  10953. b: number;
  10954. /**
  10955. * Defines the alpha component (between 0 and 1, default is 1)
  10956. */
  10957. a: number;
  10958. /**
  10959. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  10960. * @param r defines the red component (between 0 and 1, default is 0)
  10961. * @param g defines the green component (between 0 and 1, default is 0)
  10962. * @param b defines the blue component (between 0 and 1, default is 0)
  10963. * @param a defines the alpha component (between 0 and 1, default is 1)
  10964. */
  10965. constructor(
  10966. /**
  10967. * Defines the red component (between 0 and 1, default is 0)
  10968. */
  10969. r?: number,
  10970. /**
  10971. * Defines the green component (between 0 and 1, default is 0)
  10972. */
  10973. g?: number,
  10974. /**
  10975. * Defines the blue component (between 0 and 1, default is 0)
  10976. */
  10977. b?: number,
  10978. /**
  10979. * Defines the alpha component (between 0 and 1, default is 1)
  10980. */
  10981. a?: number);
  10982. /**
  10983. * Adds in place the passed Color4 values to the current Color4 object
  10984. * @param right defines the second operand
  10985. * @returns the current updated Color4 object
  10986. */
  10987. addInPlace(right: Color4): Color4;
  10988. /**
  10989. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  10990. * @returns the new array
  10991. */
  10992. asArray(): number[];
  10993. /**
  10994. * Stores from the starting index in the passed array the Color4 successive values
  10995. * @param array defines the array where to store the r,g,b components
  10996. * @param index defines an optional index in the target array to define where to start storing values
  10997. * @returns the current Color4 object
  10998. */
  10999. toArray(array: number[], index?: number): Color4;
  11000. /**
  11001. * Creates a new Color4 set with the added values of the current Color4 and of the passed one
  11002. * @param right defines the second operand
  11003. * @returns a new Color4 object
  11004. */
  11005. add(right: Color4): Color4;
  11006. /**
  11007. * Creates a new Color4 set with the subtracted values of the passed one from the current Color4
  11008. * @param right defines the second operand
  11009. * @returns a new Color4 object
  11010. */
  11011. subtract(right: Color4): Color4;
  11012. /**
  11013. * Subtracts the passed ones from the current Color4 values and stores the results in "result"
  11014. * @param right defines the second operand
  11015. * @param result defines the Color4 object where to store the result
  11016. * @returns the current Color4 object
  11017. */
  11018. subtractToRef(right: Color4, result: Color4): Color4;
  11019. /**
  11020. * Creates a new Color4 with the current Color4 values multiplied by scale
  11021. * @param scale defines the scaling factor to apply
  11022. * @returns a new Color4 object
  11023. */
  11024. scale(scale: number): Color4;
  11025. /**
  11026. * Multiplies the current Color4 values by scale and stores the result in "result"
  11027. * @param scale defines the scaling factor to apply
  11028. * @param result defines the Color4 object where to store the result
  11029. * @returns the current unmodified Color4
  11030. */
  11031. scaleToRef(scale: number, result: Color4): Color4;
  11032. /**
  11033. * Scale the current Color4 values by a factor and add the result to a given Color4
  11034. * @param scale defines the scale factor
  11035. * @param result defines the Color4 object where to store the result
  11036. * @returns the unmodified current Color4
  11037. */
  11038. scaleAndAddToRef(scale: number, result: Color4): Color4;
  11039. /**
  11040. * Clamps the rgb values by the min and max values and stores the result into "result"
  11041. * @param min defines minimum clamping value (default is 0)
  11042. * @param max defines maximum clamping value (default is 1)
  11043. * @param result defines color to store the result into.
  11044. * @returns the cuurent Color4
  11045. */
  11046. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  11047. /**
  11048. * Multipy an Color4 value by another and return a new Color4 object
  11049. * @param color defines the Color4 value to multiply by
  11050. * @returns a new Color4 object
  11051. */
  11052. multiply(color: Color4): Color4;
  11053. /**
  11054. * Multipy a Color4 value by another and push the result in a reference value
  11055. * @param color defines the Color4 value to multiply by
  11056. * @param result defines the Color4 to fill the result in
  11057. * @returns the result Color4
  11058. */
  11059. multiplyToRef(color: Color4, result: Color4): Color4;
  11060. /**
  11061. * Creates a string with the Color4 current values
  11062. * @returns the string representation of the Color4 object
  11063. */
  11064. toString(): string;
  11065. /**
  11066. * Returns the string "Color4"
  11067. * @returns "Color4"
  11068. */
  11069. getClassName(): string;
  11070. /**
  11071. * Compute the Color4 hash code
  11072. * @returns an unique number that can be used to hash Color4 objects
  11073. */
  11074. getHashCode(): number;
  11075. /**
  11076. * Creates a new Color4 copied from the current one
  11077. * @returns a new Color4 object
  11078. */
  11079. clone(): Color4;
  11080. /**
  11081. * Copies the passed Color4 values into the current one
  11082. * @param source defines the source Color4 object
  11083. * @returns the current updated Color4 object
  11084. */
  11085. copyFrom(source: Color4): Color4;
  11086. /**
  11087. * Copies the passed float values into the current one
  11088. * @param r defines the red component to read from
  11089. * @param g defines the green component to read from
  11090. * @param b defines the blue component to read from
  11091. * @param a defines the alpha component to read from
  11092. * @returns the current updated Color4 object
  11093. */
  11094. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  11095. /**
  11096. * Copies the passed float values into the current one
  11097. * @param r defines the red component to read from
  11098. * @param g defines the green component to read from
  11099. * @param b defines the blue component to read from
  11100. * @param a defines the alpha component to read from
  11101. * @returns the current updated Color4 object
  11102. */
  11103. set(r: number, g: number, b: number, a: number): Color4;
  11104. /**
  11105. * Compute the Color4 hexadecimal code as a string
  11106. * @returns a string containing the hexadecimal representation of the Color4 object
  11107. */
  11108. toHexString(): string;
  11109. /**
  11110. * Computes a new Color4 converted from the current one to linear space
  11111. * @returns a new Color4 object
  11112. */
  11113. toLinearSpace(): Color4;
  11114. /**
  11115. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  11116. * @param convertedColor defines the Color4 object where to store the linear space version
  11117. * @returns the unmodified Color4
  11118. */
  11119. toLinearSpaceToRef(convertedColor: Color4): Color4;
  11120. /**
  11121. * Computes a new Color4 converted from the current one to gamma space
  11122. * @returns a new Color4 object
  11123. */
  11124. toGammaSpace(): Color4;
  11125. /**
  11126. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  11127. * @param convertedColor defines the Color4 object where to store the gamma space version
  11128. * @returns the unmodified Color4
  11129. */
  11130. toGammaSpaceToRef(convertedColor: Color4): Color4;
  11131. /**
  11132. * Creates a new Color4 from the string containing valid hexadecimal values
  11133. * @param hex defines a string containing valid hexadecimal values
  11134. * @returns a new Color4 object
  11135. */
  11136. static FromHexString(hex: string): Color4;
  11137. /**
  11138. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  11139. * @param left defines the start value
  11140. * @param right defines the end value
  11141. * @param amount defines the gradient factor
  11142. * @returns a new Color4 object
  11143. */
  11144. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  11145. /**
  11146. * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  11147. * @param left defines the start value
  11148. * @param right defines the end value
  11149. * @param amount defines the gradient factor
  11150. * @param result defines the Color4 object where to store data
  11151. */
  11152. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  11153. /**
  11154. * Creates a new Color4 from the starting index element of the passed array
  11155. * @param array defines the source array to read from
  11156. * @param offset defines the offset in the source array
  11157. * @returns a new Color4 object
  11158. */
  11159. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  11160. /**
  11161. * Creates a new Color3 from integer values (< 256)
  11162. * @param r defines the red component to read from (value between 0 and 255)
  11163. * @param g defines the green component to read from (value between 0 and 255)
  11164. * @param b defines the blue component to read from (value between 0 and 255)
  11165. * @param a defines the alpha component to read from (value between 0 and 255)
  11166. * @returns a new Color3 object
  11167. */
  11168. static FromInts(r: number, g: number, b: number, a: number): Color4;
  11169. /**
  11170. * Check the content of a given array and convert it to an array containing RGBA data
  11171. * If the original array was already containing count * 4 values then it is returned directly
  11172. * @param colors defines the array to check
  11173. * @param count defines the number of RGBA data to expect
  11174. * @returns an array containing count * 4 values (RGBA)
  11175. */
  11176. static CheckColors4(colors: number[], count: number): number[];
  11177. }
  11178. class Vector2 {
  11179. x: number;
  11180. y: number;
  11181. /**
  11182. * Creates a new Vector2 from the passed x and y coordinates.
  11183. */
  11184. constructor(x: number, y: number);
  11185. /**
  11186. * Returns a string with the Vector2 coordinates.
  11187. */
  11188. toString(): string;
  11189. /**
  11190. * Returns the string "Vector2"
  11191. */
  11192. getClassName(): string;
  11193. /**
  11194. * Returns the Vector2 hash code as a number.
  11195. */
  11196. getHashCode(): number;
  11197. /**
  11198. * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index.
  11199. * Returns the Vector2.
  11200. */
  11201. toArray(array: FloatArray, index?: number): Vector2;
  11202. /**
  11203. * Returns a new array with 2 elements : the Vector2 coordinates.
  11204. */
  11205. asArray(): number[];
  11206. /**
  11207. * Sets the Vector2 coordinates with the passed Vector2 coordinates.
  11208. * Returns the updated Vector2.
  11209. */
  11210. copyFrom(source: Vector2): Vector2;
  11211. /**
  11212. * Sets the Vector2 coordinates with the passed floats.
  11213. * Returns the updated Vector2.
  11214. */
  11215. copyFromFloats(x: number, y: number): Vector2;
  11216. /**
  11217. * Sets the Vector2 coordinates with the passed floats.
  11218. * Returns the updated Vector2.
  11219. */
  11220. set(x: number, y: number): Vector2;
  11221. /**
  11222. * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates.
  11223. */
  11224. add(otherVector: Vector2): Vector2;
  11225. /**
  11226. * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates.
  11227. * Returns the Vector2.
  11228. */
  11229. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  11230. /**
  11231. * Set the Vector2 coordinates by adding the passed Vector2 coordinates.
  11232. * Returns the updated Vector2.
  11233. */
  11234. addInPlace(otherVector: Vector2): Vector2;
  11235. /**
  11236. * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates.
  11237. */
  11238. addVector3(otherVector: Vector3): Vector2;
  11239. /**
  11240. * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2.
  11241. */
  11242. subtract(otherVector: Vector2): Vector2;
  11243. /**
  11244. * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates.
  11245. * Returns the Vector2.
  11246. */
  11247. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  11248. /**
  11249. * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates.
  11250. * Returns the updated Vector2.
  11251. */
  11252. subtractInPlace(otherVector: Vector2): Vector2;
  11253. /**
  11254. * Multiplies in place the current Vector2 coordinates by the passed ones.
  11255. * Returns the updated Vector2.
  11256. */
  11257. multiplyInPlace(otherVector: Vector2): Vector2;
  11258. /**
  11259. * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates.
  11260. */
  11261. multiply(otherVector: Vector2): Vector2;
  11262. /**
  11263. * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates.
  11264. * Returns the Vector2.
  11265. */
  11266. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  11267. /**
  11268. * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats.
  11269. */
  11270. multiplyByFloats(x: number, y: number): Vector2;
  11271. /**
  11272. * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates.
  11273. */
  11274. divide(otherVector: Vector2): Vector2;
  11275. /**
  11276. * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates.
  11277. * Returns the Vector2.
  11278. */
  11279. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  11280. /**
  11281. * Divides the current Vector3 coordinates by the passed ones.
  11282. * Returns the updated Vector3.
  11283. */
  11284. divideInPlace(otherVector: Vector2): Vector2;
  11285. /**
  11286. * Returns a new Vector2 with current Vector2 negated coordinates.
  11287. */
  11288. negate(): Vector2;
  11289. /**
  11290. * Multiply the Vector2 coordinates by scale.
  11291. * Returns the updated Vector2.
  11292. */
  11293. scaleInPlace(scale: number): Vector2;
  11294. /**
  11295. * Returns a new Vector2 scaled by "scale" from the current Vector2.
  11296. */
  11297. scale(scale: number): Vector2;
  11298. /**
  11299. * Scale the current Vector2 values by a factor to a given Vector2
  11300. * @param scale defines the scale factor
  11301. * @param result defines the Vector2 object where to store the result
  11302. * @returns the unmodified current Vector2
  11303. */
  11304. scaleToRef(scale: number, result: Vector2): Vector2;
  11305. /**
  11306. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  11307. * @param scale defines the scale factor
  11308. * @param result defines the Vector2 object where to store the result
  11309. * @returns the unmodified current Vector2
  11310. */
  11311. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  11312. /**
  11313. * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones.
  11314. */
  11315. equals(otherVector: Vector2): boolean;
  11316. /**
  11317. * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon.
  11318. */
  11319. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  11320. /**
  11321. * Returns the vector length (float).
  11322. */
  11323. length(): number;
  11324. /**
  11325. * Returns the vector squared length (float);
  11326. */
  11327. lengthSquared(): number;
  11328. /**
  11329. * Normalize the vector.
  11330. * Returns the updated Vector2.
  11331. */
  11332. normalize(): Vector2;
  11333. /**
  11334. * Returns a new Vector2 copied from the Vector2.
  11335. */
  11336. clone(): Vector2;
  11337. /**
  11338. * Returns a new Vector2(0, 0)
  11339. */
  11340. static Zero(): Vector2;
  11341. /**
  11342. * Returns a new Vector2(1, 1)
  11343. */
  11344. static One(): Vector2;
  11345. /**
  11346. * Returns a new Vector2 set from the passed index element of the passed array.
  11347. */
  11348. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  11349. /**
  11350. * Sets "result" from the passed index element of the passed array.
  11351. */
  11352. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  11353. /**
  11354. * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2.
  11355. */
  11356. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  11357. /**
  11358. * 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".
  11359. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  11360. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate.
  11361. */
  11362. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  11363. /**
  11364. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2".
  11365. */
  11366. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  11367. /**
  11368. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  11369. */
  11370. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  11371. /**
  11372. * Returns the dot product (float) of the vector "left" and the vector "right".
  11373. */
  11374. static Dot(left: Vector2, right: Vector2): number;
  11375. /**
  11376. * Returns a new Vector2 equal to the normalized passed vector.
  11377. */
  11378. static Normalize(vector: Vector2): Vector2;
  11379. /**
  11380. * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors.
  11381. */
  11382. static Minimize(left: Vector2, right: Vector2): Vector2;
  11383. /**
  11384. * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors.
  11385. */
  11386. static Maximize(left: Vector2, right: Vector2): Vector2;
  11387. /**
  11388. * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix.
  11389. */
  11390. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  11391. /**
  11392. * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates.
  11393. */
  11394. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  11395. /**
  11396. * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  11397. */
  11398. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  11399. /**
  11400. * Returns the distance (float) between the vectors "value1" and "value2".
  11401. */
  11402. static Distance(value1: Vector2, value2: Vector2): number;
  11403. /**
  11404. * Returns the squared distance (float) between the vectors "value1" and "value2".
  11405. */
  11406. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  11407. /**
  11408. * Returns a new Vecto2 located at the center of the vectors "value1" and "value2".
  11409. */
  11410. static Center(value1: Vector2, value2: Vector2): Vector2;
  11411. /**
  11412. * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  11413. */
  11414. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  11415. }
  11416. /**
  11417. * Classed used to store (x,y,z) vector representation
  11418. * A Vector3 is the main object used in 3D geometry
  11419. * It can represent etiher the coordinates of a point the space, either a direction
  11420. * Reminder: Babylon.js uses a left handed forward facing system
  11421. */
  11422. class Vector3 {
  11423. /**
  11424. * Defines the first coordinates (on X axis)
  11425. */
  11426. x: number;
  11427. /**
  11428. * Defines the second coordinates (on Y axis)
  11429. */
  11430. y: number;
  11431. /**
  11432. * Defines the third coordinates (on Z axis)
  11433. */
  11434. z: number;
  11435. /**
  11436. * Creates a new Vector3 object from the passed x, y, z (floats) coordinates.
  11437. * @param x defines the first coordinates (on X axis)
  11438. * @param y defines the second coordinates (on Y axis)
  11439. * @param z defines the third coordinates (on Z axis)
  11440. */
  11441. constructor(
  11442. /**
  11443. * Defines the first coordinates (on X axis)
  11444. */
  11445. x: number,
  11446. /**
  11447. * Defines the second coordinates (on Y axis)
  11448. */
  11449. y: number,
  11450. /**
  11451. * Defines the third coordinates (on Z axis)
  11452. */
  11453. z: number);
  11454. /**
  11455. * Creates a string representation of the Vector3
  11456. * @returns a string with the Vector3 coordinates.
  11457. */
  11458. toString(): string;
  11459. /**
  11460. * Gets the class name
  11461. * @returns the string "Vector3"
  11462. */
  11463. getClassName(): string;
  11464. /**
  11465. * Creates the Vector3 hash code
  11466. * @returns a number which tends to be unique between Vector3 instances
  11467. */
  11468. getHashCode(): number;
  11469. /**
  11470. * Creates an array containing three elements : the coordinates of the Vector3
  11471. * @returns a new array of numbers
  11472. */
  11473. asArray(): number[];
  11474. /**
  11475. * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3
  11476. * @param array defines the destination array
  11477. * @param index defines the offset in the destination array
  11478. * @returns the current Vector3
  11479. */
  11480. toArray(array: FloatArray, index?: number): Vector3;
  11481. /**
  11482. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  11483. * @returns a new Quaternion object, computed from the Vector3 coordinates
  11484. */
  11485. toQuaternion(): Quaternion;
  11486. /**
  11487. * Adds the passed vector to the current Vector3
  11488. * @param otherVector defines the second operand
  11489. * @returns the current updated Vector3
  11490. */
  11491. addInPlace(otherVector: Vector3): Vector3;
  11492. /**
  11493. * Gets a new Vector3, result of the addition the current Vector3 and the passed vector
  11494. * @param otherVector defines the second operand
  11495. * @returns the resulting Vector3
  11496. */
  11497. add(otherVector: Vector3): Vector3;
  11498. /**
  11499. * Adds the current Vector3 to the passed one and stores the result in the vector "result"
  11500. * @param otherVector defines the second operand
  11501. * @param result defines the Vector3 object where to store the result
  11502. * @returns the current Vector3
  11503. */
  11504. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  11505. /**
  11506. * Subtract the passed vector from the current Vector3
  11507. * @param otherVector defines the second operand
  11508. * @returns the current updated Vector3
  11509. */
  11510. subtractInPlace(otherVector: Vector3): Vector3;
  11511. /**
  11512. * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3
  11513. * @param otherVector defines the second operand
  11514. * @returns the resulting Vector3
  11515. */
  11516. subtract(otherVector: Vector3): Vector3;
  11517. /**
  11518. * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result".
  11519. * @param otherVector defines the second operand
  11520. * @param result defines the Vector3 object where to store the result
  11521. * @returns the current Vector3
  11522. */
  11523. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  11524. /**
  11525. * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates
  11526. * @param x defines the x coordinate of the operand
  11527. * @param y defines the y coordinate of the operand
  11528. * @param z defines the z coordinate of the operand
  11529. * @returns the resulting Vector3
  11530. */
  11531. subtractFromFloats(x: number, y: number, z: number): Vector3;
  11532. /**
  11533. * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result
  11534. * @param x defines the x coordinate of the operand
  11535. * @param y defines the y coordinate of the operand
  11536. * @param z defines the z coordinate of the operand
  11537. * @param result defines the Vector3 object where to store the result
  11538. * @returns the current Vector3
  11539. */
  11540. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  11541. /**
  11542. * Gets a new Vector3 set with the current Vector3 negated coordinates
  11543. * @returns a new Vector3
  11544. */
  11545. negate(): Vector3;
  11546. /**
  11547. * Multiplies the Vector3 coordinates by the float "scale"
  11548. * @param scale defines the multiplier factor
  11549. * @returns the current updated Vector3
  11550. */
  11551. scaleInPlace(scale: number): Vector3;
  11552. /**
  11553. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  11554. * @param scale defines the multiplier factor
  11555. * @returns a new Vector3
  11556. */
  11557. scale(scale: number): Vector3;
  11558. /**
  11559. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates
  11560. * @param scale defines the multiplier factor
  11561. * @param result defines the Vector3 object where to store the result
  11562. * @returns the current Vector3
  11563. */
  11564. scaleToRef(scale: number, result: Vector3): Vector3;
  11565. /**
  11566. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  11567. * @param scale defines the scale factor
  11568. * @param result defines the Vector3 object where to store the result
  11569. * @returns the unmodified current Vector3
  11570. */
  11571. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  11572. /**
  11573. * Returns true if the current Vector3 and the passed vector coordinates are strictly equal
  11574. * @param otherVector defines the second operand
  11575. * @returns true if both vectors are equals
  11576. */
  11577. equals(otherVector: Vector3): boolean;
  11578. /**
  11579. * Returns true if the current Vector3 and the passed vector coordinates are distant less than epsilon
  11580. * @param otherVector defines the second operand
  11581. * @param epsilon defines the minimal distance to define values as equals
  11582. * @returns true if both vectors are distant less than epsilon
  11583. */
  11584. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  11585. /**
  11586. * Returns true if the current Vector3 coordinates equals the passed floats
  11587. * @param x defines the x coordinate of the operand
  11588. * @param y defines the y coordinate of the operand
  11589. * @param z defines the z coordinate of the operand
  11590. * @returns true if both vectors are equals
  11591. */
  11592. equalsToFloats(x: number, y: number, z: number): boolean;
  11593. /**
  11594. * Multiplies the current Vector3 coordinates by the passed ones
  11595. * @param otherVector defines the second operand
  11596. * @returns the current updated Vector3
  11597. */
  11598. multiplyInPlace(otherVector: Vector3): Vector3;
  11599. /**
  11600. * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector
  11601. * @param otherVector defines the second operand
  11602. * @returns the new Vector3
  11603. */
  11604. multiply(otherVector: Vector3): Vector3;
  11605. /**
  11606. * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result"
  11607. * @param otherVector defines the second operand
  11608. * @param result defines the Vector3 object where to store the result
  11609. * @returns the current Vector3
  11610. */
  11611. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  11612. /**
  11613. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the passed floats
  11614. * @param x defines the x coordinate of the operand
  11615. * @param y defines the y coordinate of the operand
  11616. * @param z defines the z coordinate of the operand
  11617. * @returns the new Vector3
  11618. */
  11619. multiplyByFloats(x: number, y: number, z: number): Vector3;
  11620. /**
  11621. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the passed ones
  11622. * @param otherVector defines the second operand
  11623. * @returns the new Vector3
  11624. */
  11625. divide(otherVector: Vector3): Vector3;
  11626. /**
  11627. * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result"
  11628. * @param otherVector defines the second operand
  11629. * @param result defines the Vector3 object where to store the result
  11630. * @returns the current Vector3
  11631. */
  11632. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  11633. /**
  11634. * Divides the current Vector3 coordinates by the passed ones.
  11635. * @param otherVector defines the second operand
  11636. * @returns the current updated Vector3
  11637. */
  11638. divideInPlace(otherVector: Vector3): Vector3;
  11639. /**
  11640. * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones
  11641. * @param other defines the second operand
  11642. * @returns the current updated Vector3
  11643. */
  11644. minimizeInPlace(other: Vector3): Vector3;
  11645. /**
  11646. * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones.
  11647. * @param other defines the second operand
  11648. * @returns the current updated Vector3
  11649. */
  11650. maximizeInPlace(other: Vector3): Vector3;
  11651. /**
  11652. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  11653. */
  11654. readonly isNonUniform: boolean;
  11655. /**
  11656. * Gets the length of the Vector3
  11657. * @returns the length of the Vecto3
  11658. */
  11659. length(): number;
  11660. /**
  11661. * Gets the squared length of the Vector3
  11662. * @returns squared length of the Vector3
  11663. */
  11664. lengthSquared(): number;
  11665. /**
  11666. * Normalize the current Vector3.
  11667. * Please note that this is an in place operation.
  11668. * @returns the current updated Vector3
  11669. */
  11670. normalize(): Vector3;
  11671. /**
  11672. * Normalize the current Vector3 to a new vector
  11673. * @returns the new Vector3
  11674. */
  11675. normalizeToNew(): Vector3;
  11676. /**
  11677. * Normalize the current Vector3 to the reference
  11678. * @param reference define the Vector3 to update
  11679. * @returns the updated Vector3
  11680. */
  11681. normalizeToRef(reference: Vector3): Vector3;
  11682. /**
  11683. * Creates a new Vector3 copied from the current Vector3
  11684. * @returns the new Vector3
  11685. */
  11686. clone(): Vector3;
  11687. /**
  11688. * Copies the passed vector coordinates to the current Vector3 ones
  11689. * @param source defines the source Vector3
  11690. * @returns the current updated Vector3
  11691. */
  11692. copyFrom(source: Vector3): Vector3;
  11693. /**
  11694. * Copies the passed floats to the current Vector3 coordinates
  11695. * @param x defines the x coordinate of the operand
  11696. * @param y defines the y coordinate of the operand
  11697. * @param z defines the z coordinate of the operand
  11698. * @returns the current updated Vector3
  11699. */
  11700. copyFromFloats(x: number, y: number, z: number): Vector3;
  11701. /**
  11702. * Copies the passed floats to the current Vector3 coordinates
  11703. * @param x defines the x coordinate of the operand
  11704. * @param y defines the y coordinate of the operand
  11705. * @param z defines the z coordinate of the operand
  11706. * @returns the current updated Vector3
  11707. */
  11708. set(x: number, y: number, z: number): Vector3;
  11709. /**
  11710. * Get the clip factor between two vectors
  11711. * @param vector0 defines the first operand
  11712. * @param vector1 defines the second operand
  11713. * @param axis defines the axis to use
  11714. * @param size defines the size along the axis
  11715. * @returns the clip factor
  11716. */
  11717. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  11718. /**
  11719. * Get angle between two vectors
  11720. * @param vector0 angle between vector0 and vector1
  11721. * @param vector1 angle between vector0 and vector1
  11722. * @param normal direction of the normal
  11723. * @return the angle between vector0 and vector1
  11724. */
  11725. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  11726. /**
  11727. * Returns a new Vector3 set from the index "offset" of the passed array
  11728. * @param array defines the source array
  11729. * @param offset defines the offset in the source array
  11730. * @returns the new Vector3
  11731. */
  11732. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  11733. /**
  11734. * Returns a new Vector3 set from the index "offset" of the passed Float32Array
  11735. * This function is deprecated. Use FromArray instead
  11736. * @param array defines the source array
  11737. * @param offset defines the offset in the source array
  11738. * @returns the new Vector3
  11739. */
  11740. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  11741. /**
  11742. * Sets the passed vector "result" with the element values from the index "offset" of the passed array
  11743. * @param array defines the source array
  11744. * @param offset defines the offset in the source array
  11745. * @param result defines the Vector3 where to store the result
  11746. */
  11747. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  11748. /**
  11749. * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array
  11750. * This function is deprecated. Use FromArrayToRef instead.
  11751. * @param array defines the source array
  11752. * @param offset defines the offset in the source array
  11753. * @param result defines the Vector3 where to store the result
  11754. */
  11755. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  11756. /**
  11757. * Sets the passed vector "result" with the passed floats.
  11758. * @param x defines the x coordinate of the source
  11759. * @param y defines the y coordinate of the source
  11760. * @param z defines the z coordinate of the source
  11761. * @param result defines the Vector3 where to store the result
  11762. */
  11763. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  11764. /**
  11765. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  11766. * @returns a new empty Vector3
  11767. */
  11768. static Zero(): Vector3;
  11769. /**
  11770. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  11771. * @returns a new unit Vector3
  11772. */
  11773. static One(): Vector3;
  11774. /**
  11775. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  11776. * @returns a new up Vector3
  11777. */
  11778. static Up(): Vector3;
  11779. /**
  11780. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  11781. * @returns a new forward Vector3
  11782. */
  11783. static Forward(): Vector3;
  11784. /**
  11785. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  11786. * @returns a new right Vector3
  11787. */
  11788. static Right(): Vector3;
  11789. /**
  11790. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  11791. * @returns a new left Vector3
  11792. */
  11793. static Left(): Vector3;
  11794. /**
  11795. * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector.
  11796. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  11797. * @param vector defines the Vector3 to transform
  11798. * @param transformation defines the transformation matrix
  11799. * @returns the transformed Vector3
  11800. */
  11801. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  11802. /**
  11803. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector
  11804. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  11805. * @param vector defines the Vector3 to transform
  11806. * @param transformation defines the transformation matrix
  11807. * @param result defines the Vector3 where to store the result
  11808. */
  11809. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  11810. /**
  11811. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z)
  11812. * This method computes tranformed coordinates only, not transformed direction vectors
  11813. * @param x define the x coordinate of the source vector
  11814. * @param y define the y coordinate of the source vector
  11815. * @param z define the z coordinate of the source vector
  11816. * @param transformation defines the transformation matrix
  11817. * @param result defines the Vector3 where to store the result
  11818. */
  11819. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  11820. /**
  11821. * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector
  11822. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  11823. * @param vector defines the Vector3 to transform
  11824. * @param transformation defines the transformation matrix
  11825. * @returns the new Vector3
  11826. */
  11827. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  11828. /**
  11829. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector
  11830. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  11831. * @param vector defines the Vector3 to transform
  11832. * @param transformation defines the transformation matrix
  11833. * @param result defines the Vector3 where to store the result
  11834. */
  11835. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  11836. /**
  11837. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z)
  11838. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  11839. * @param x define the x coordinate of the source vector
  11840. * @param y define the y coordinate of the source vector
  11841. * @param z define the z coordinate of the source vector
  11842. * @param transformation defines the transformation matrix
  11843. * @param result defines the Vector3 where to store the result
  11844. */
  11845. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  11846. /**
  11847. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  11848. * @param value1 defines the first control point
  11849. * @param value2 defines the second control point
  11850. * @param value3 defines the third control point
  11851. * @param value4 defines the fourth control point
  11852. * @param amount defines the amount on the spline to use
  11853. * @returns the new Vector3
  11854. */
  11855. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  11856. /**
  11857. * 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"
  11858. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  11859. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  11860. * @param value defines the current value
  11861. * @param min defines the lower range value
  11862. * @param max defines the upper range value
  11863. * @returns the new Vector3
  11864. */
  11865. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  11866. /**
  11867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  11868. * @param value1 defines the first control point
  11869. * @param tangent1 defines the first tangent vector
  11870. * @param value2 defines the second control point
  11871. * @param tangent2 defines the second tangent vector
  11872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  11873. * @returns the new Vector3
  11874. */
  11875. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  11876. /**
  11877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  11878. * @param start defines the start value
  11879. * @param end defines the end value
  11880. * @param amount max defines amount between both (between 0 and 1)
  11881. * @returns the new Vector3
  11882. */
  11883. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  11884. /**
  11885. * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  11886. * @param start defines the start value
  11887. * @param end defines the end value
  11888. * @param amount max defines amount between both (between 0 and 1)
  11889. * @param result defines the Vector3 where to store the result
  11890. */
  11891. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  11892. /**
  11893. * Returns the dot product (float) between the vectors "left" and "right"
  11894. * @param left defines the left operand
  11895. * @param right defines the right operand
  11896. * @returns the dot product
  11897. */
  11898. static Dot(left: Vector3, right: Vector3): number;
  11899. /**
  11900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  11901. * The cross product is then orthogonal to both "left" and "right"
  11902. * @param left defines the left operand
  11903. * @param right defines the right operand
  11904. * @returns the cross product
  11905. */
  11906. static Cross(left: Vector3, right: Vector3): Vector3;
  11907. /**
  11908. * Sets the passed vector "result" with the cross product of "left" and "right"
  11909. * The cross product is then orthogonal to both "left" and "right"
  11910. * @param left defines the left operand
  11911. * @param right defines the right operand
  11912. * @param result defines the Vector3 where to store the result
  11913. */
  11914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  11915. /**
  11916. * Returns a new Vector3 as the normalization of the passed vector
  11917. * @param vector defines the Vector3 to normalize
  11918. * @returns the new Vector3
  11919. */
  11920. static Normalize(vector: Vector3): Vector3;
  11921. /**
  11922. * Sets the passed vector "result" with the normalization of the passed first vector
  11923. * @param vector defines the Vector3 to normalize
  11924. * @param result defines the Vector3 where to store the result
  11925. */
  11926. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  11927. private static _viewportMatrixCache;
  11928. /**
  11929. * Project a Vector3 onto screen space
  11930. * @param vector defines the Vector3 to project
  11931. * @param world defines the world matrix to use
  11932. * @param transform defines the transform (view x projection) matrix to use
  11933. * @param viewport defines the screen viewport to use
  11934. * @returns the new Vector3
  11935. */
  11936. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  11937. /**
  11938. * Unproject from screen space to object space
  11939. * @param source defines the screen space Vector3 to use
  11940. * @param viewportWidth defines the current width of the viewport
  11941. * @param viewportHeight defines the current height of the viewport
  11942. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11943. * @param transform defines the transform (view x projection) matrix to use
  11944. * @returns the new Vector3
  11945. */
  11946. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  11947. /**
  11948. * Unproject from screen space to object space
  11949. * @param source defines the screen space Vector3 to use
  11950. * @param viewportWidth defines the current width of the viewport
  11951. * @param viewportHeight defines the current height of the viewport
  11952. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11953. * @param view defines the view matrix to use
  11954. * @param projection defines the projection matrix to use
  11955. * @returns the new Vector3
  11956. */
  11957. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  11958. /**
  11959. * Unproject from screen space to object space
  11960. * @param source defines the screen space Vector3 to use
  11961. * @param viewportWidth defines the current width of the viewport
  11962. * @param viewportHeight defines the current height of the viewport
  11963. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11964. * @param view defines the view matrix to use
  11965. * @param projection defines the projection matrix to use
  11966. * @param result defines the Vector3 where to store the result
  11967. */
  11968. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  11969. /**
  11970. * Unproject from screen space to object space
  11971. * @param sourceX defines the screen space x coordinate to use
  11972. * @param sourceY defines the screen space y coordinate to use
  11973. * @param sourceZ defines the screen space z coordinate to use
  11974. * @param viewportWidth defines the current width of the viewport
  11975. * @param viewportHeight defines the current height of the viewport
  11976. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11977. * @param view defines the view matrix to use
  11978. * @param projection defines the projection matrix to use
  11979. * @param result defines the Vector3 where to store the result
  11980. */
  11981. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  11982. /**
  11983. * Gets the minimal coordinate values between two Vector3
  11984. * @param left defines the first operand
  11985. * @param right defines the second operand
  11986. * @returns the new Vector3
  11987. */
  11988. static Minimize(left: Vector3, right: Vector3): Vector3;
  11989. /**
  11990. * Gets the maximal coordinate values between two Vector3
  11991. * @param left defines the first operand
  11992. * @param right defines the second operand
  11993. * @returns the new Vector3
  11994. */
  11995. static Maximize(left: Vector3, right: Vector3): Vector3;
  11996. /**
  11997. * Returns the distance between the vectors "value1" and "value2"
  11998. * @param value1 defines the first operand
  11999. * @param value2 defines the second operand
  12000. * @returns the distance
  12001. */
  12002. static Distance(value1: Vector3, value2: Vector3): number;
  12003. /**
  12004. * Returns the squared distance between the vectors "value1" and "value2"
  12005. * @param value1 defines the first operand
  12006. * @param value2 defines the second operand
  12007. * @returns the squared distance
  12008. */
  12009. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  12010. /**
  12011. * Returns a new Vector3 located at the center between "value1" and "value2"
  12012. * @param value1 defines the first operand
  12013. * @param value2 defines the second operand
  12014. * @returns the new Vector3
  12015. */
  12016. static Center(value1: Vector3, value2: Vector3): Vector3;
  12017. /**
  12018. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  12019. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  12020. * to something in order to rotate it from its local system to the given target system
  12021. * Note: axis1, axis2 and axis3 are normalized during this operation
  12022. * @param axis1 defines the first axis
  12023. * @param axis2 defines the second axis
  12024. * @param axis3 defines the third axis
  12025. * @returns a new Vector3
  12026. */
  12027. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  12028. /**
  12029. * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3
  12030. * @param axis1 defines the first axis
  12031. * @param axis2 defines the second axis
  12032. * @param axis3 defines the third axis
  12033. * @param ref defines the Vector3 where to store the result
  12034. */
  12035. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  12036. }
  12037. class Vector4 {
  12038. x: number;
  12039. y: number;
  12040. z: number;
  12041. w: number;
  12042. /**
  12043. * Creates a Vector4 object from the passed floats.
  12044. */
  12045. constructor(x: number, y: number, z: number, w: number);
  12046. /**
  12047. * Returns the string with the Vector4 coordinates.
  12048. */
  12049. toString(): string;
  12050. /**
  12051. * Returns the string "Vector4".
  12052. */
  12053. getClassName(): string;
  12054. /**
  12055. * Returns the Vector4 hash code.
  12056. */
  12057. getHashCode(): number;
  12058. /**
  12059. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  12060. */
  12061. asArray(): number[];
  12062. /**
  12063. * Populates the passed array from the passed index with the Vector4 coordinates.
  12064. * Returns the Vector4.
  12065. */
  12066. toArray(array: FloatArray, index?: number): Vector4;
  12067. /**
  12068. * Adds the passed vector to the current Vector4.
  12069. * Returns the updated Vector4.
  12070. */
  12071. addInPlace(otherVector: Vector4): Vector4;
  12072. /**
  12073. * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one.
  12074. */
  12075. add(otherVector: Vector4): Vector4;
  12076. /**
  12077. * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one.
  12078. * Returns the current Vector4.
  12079. */
  12080. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  12081. /**
  12082. * Subtract in place the passed vector from the current Vector4.
  12083. * Returns the updated Vector4.
  12084. */
  12085. subtractInPlace(otherVector: Vector4): Vector4;
  12086. /**
  12087. * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4.
  12088. */
  12089. subtract(otherVector: Vector4): Vector4;
  12090. /**
  12091. * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4.
  12092. * Returns the current Vector4.
  12093. */
  12094. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  12095. /**
  12096. * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  12097. */
  12098. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  12099. /**
  12100. * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  12101. * Returns the current Vector4.
  12102. */
  12103. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  12104. /**
  12105. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  12106. */
  12107. negate(): Vector4;
  12108. /**
  12109. * Multiplies the current Vector4 coordinates by scale (float).
  12110. * Returns the updated Vector4.
  12111. */
  12112. scaleInPlace(scale: number): Vector4;
  12113. /**
  12114. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  12115. */
  12116. scale(scale: number): Vector4;
  12117. /**
  12118. * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float).
  12119. * Returns the current Vector4.
  12120. */
  12121. scaleToRef(scale: number, result: Vector4): Vector4;
  12122. /**
  12123. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  12124. * @param scale defines the scale factor
  12125. * @param result defines the Vector4 object where to store the result
  12126. * @returns the unmodified current Vector4
  12127. */
  12128. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  12129. /**
  12130. * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones.
  12131. */
  12132. equals(otherVector: Vector4): boolean;
  12133. /**
  12134. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones.
  12135. */
  12136. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  12137. /**
  12138. * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates.
  12139. */
  12140. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  12141. /**
  12142. * Multiplies in place the current Vector4 by the passed one.
  12143. * Returns the updated Vector4.
  12144. */
  12145. multiplyInPlace(otherVector: Vector4): Vector4;
  12146. /**
  12147. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one.
  12148. */
  12149. multiply(otherVector: Vector4): Vector4;
  12150. /**
  12151. * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one.
  12152. * Returns the current Vector4.
  12153. */
  12154. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  12155. /**
  12156. * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates.
  12157. */
  12158. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  12159. /**
  12160. * Returns a new Vector4 set with the division result of the current Vector4 by the passed one.
  12161. */
  12162. divide(otherVector: Vector4): Vector4;
  12163. /**
  12164. * Updates the passed vector "result" with the division result of the current Vector4 by the passed one.
  12165. * Returns the current Vector4.
  12166. */
  12167. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  12168. /**
  12169. * Divides the current Vector3 coordinates by the passed ones.
  12170. * @returns the updated Vector3.
  12171. */
  12172. divideInPlace(otherVector: Vector4): Vector4;
  12173. /**
  12174. * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones
  12175. * @param other defines the second operand
  12176. * @returns the current updated Vector4
  12177. */
  12178. minimizeInPlace(other: Vector4): Vector4;
  12179. /**
  12180. * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones
  12181. * @param other defines the second operand
  12182. * @returns the current updated Vector4
  12183. */
  12184. maximizeInPlace(other: Vector4): Vector4;
  12185. /**
  12186. * Returns the Vector4 length (float).
  12187. */
  12188. length(): number;
  12189. /**
  12190. * Returns the Vector4 squared length (float).
  12191. */
  12192. lengthSquared(): number;
  12193. /**
  12194. * Normalizes in place the Vector4.
  12195. * Returns the updated Vector4.
  12196. */
  12197. normalize(): Vector4;
  12198. /**
  12199. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  12200. */
  12201. toVector3(): Vector3;
  12202. /**
  12203. * Returns a new Vector4 copied from the current one.
  12204. */
  12205. clone(): Vector4;
  12206. /**
  12207. * Updates the current Vector4 with the passed one coordinates.
  12208. * Returns the updated Vector4.
  12209. */
  12210. copyFrom(source: Vector4): Vector4;
  12211. /**
  12212. * Updates the current Vector4 coordinates with the passed floats.
  12213. * Returns the updated Vector4.
  12214. */
  12215. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  12216. /**
  12217. * Updates the current Vector4 coordinates with the passed floats.
  12218. * Returns the updated Vector4.
  12219. */
  12220. set(x: number, y: number, z: number, w: number): Vector4;
  12221. /**
  12222. * Returns a new Vector4 set from the starting index of the passed array.
  12223. */
  12224. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  12225. /**
  12226. * Updates the passed vector "result" from the starting index of the passed array.
  12227. */
  12228. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  12229. /**
  12230. * Updates the passed vector "result" from the starting index of the passed Float32Array.
  12231. */
  12232. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  12233. /**
  12234. * Updates the passed vector "result" coordinates from the passed floats.
  12235. */
  12236. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  12237. /**
  12238. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  12239. */
  12240. static Zero(): Vector4;
  12241. /**
  12242. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  12243. */
  12244. static One(): Vector4;
  12245. /**
  12246. * Returns a new normalized Vector4 from the passed one.
  12247. */
  12248. static Normalize(vector: Vector4): Vector4;
  12249. /**
  12250. * Updates the passed vector "result" from the normalization of the passed one.
  12251. */
  12252. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  12253. static Minimize(left: Vector4, right: Vector4): Vector4;
  12254. static Maximize(left: Vector4, right: Vector4): Vector4;
  12255. /**
  12256. * Returns the distance (float) between the vectors "value1" and "value2".
  12257. */
  12258. static Distance(value1: Vector4, value2: Vector4): number;
  12259. /**
  12260. * Returns the squared distance (float) between the vectors "value1" and "value2".
  12261. */
  12262. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  12263. /**
  12264. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  12265. */
  12266. static Center(value1: Vector4, value2: Vector4): Vector4;
  12267. /**
  12268. * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector.
  12269. * This methods computes transformed normalized direction vectors only.
  12270. */
  12271. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  12272. /**
  12273. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector.
  12274. * This methods computes transformed normalized direction vectors only.
  12275. */
  12276. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  12277. /**
  12278. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w).
  12279. * This methods computes transformed normalized direction vectors only.
  12280. */
  12281. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  12282. }
  12283. interface ISize {
  12284. width: number;
  12285. height: number;
  12286. }
  12287. class Size implements ISize {
  12288. width: number;
  12289. height: number;
  12290. /**
  12291. * Creates a Size object from the passed width and height (floats).
  12292. */
  12293. constructor(width: number, height: number);
  12294. toString(): string;
  12295. /**
  12296. * Returns the string "Size"
  12297. */
  12298. getClassName(): string;
  12299. /**
  12300. * Returns the Size hash code.
  12301. */
  12302. getHashCode(): number;
  12303. /**
  12304. * Updates the current size from the passed one.
  12305. * Returns the updated Size.
  12306. */
  12307. copyFrom(src: Size): void;
  12308. /**
  12309. * Updates in place the current Size from the passed floats.
  12310. * Returns the updated Size.
  12311. */
  12312. copyFromFloats(width: number, height: number): Size;
  12313. /**
  12314. * Updates in place the current Size from the passed floats.
  12315. * Returns the updated Size.
  12316. */
  12317. set(width: number, height: number): Size;
  12318. /**
  12319. * Returns a new Size set with the multiplication result of the current Size and the passed floats.
  12320. */
  12321. multiplyByFloats(w: number, h: number): Size;
  12322. /**
  12323. * Returns a new Size copied from the passed one.
  12324. */
  12325. clone(): Size;
  12326. /**
  12327. * Boolean : True if the current Size and the passed one width and height are strictly equal.
  12328. */
  12329. equals(other: Size): boolean;
  12330. /**
  12331. * Returns the surface of the Size : width * height (float).
  12332. */
  12333. readonly surface: number;
  12334. /**
  12335. * Returns a new Size set to (0.0, 0.0)
  12336. */
  12337. static Zero(): Size;
  12338. /**
  12339. * Returns a new Size set as the addition result of the current Size and the passed one.
  12340. */
  12341. add(otherSize: Size): Size;
  12342. /**
  12343. * Returns a new Size set as the subtraction result of the passed one from the current Size.
  12344. */
  12345. subtract(otherSize: Size): Size;
  12346. /**
  12347. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  12348. */
  12349. static Lerp(start: Size, end: Size, amount: number): Size;
  12350. }
  12351. class Quaternion {
  12352. x: number;
  12353. y: number;
  12354. z: number;
  12355. w: number;
  12356. /**
  12357. * Creates a new Quaternion from the passed floats.
  12358. */
  12359. constructor(x?: number, y?: number, z?: number, w?: number);
  12360. /**
  12361. * Returns a string with the Quaternion coordinates.
  12362. */
  12363. toString(): string;
  12364. /**
  12365. * Returns the string "Quaternion".
  12366. */
  12367. getClassName(): string;
  12368. /**
  12369. * Returns the Quaternion hash code.
  12370. */
  12371. getHashCode(): number;
  12372. /**
  12373. * Returns a new array populated with 4 elements : the Quaternion coordinates.
  12374. */
  12375. asArray(): number[];
  12376. /**
  12377. * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal.
  12378. */
  12379. equals(otherQuaternion: Quaternion): boolean;
  12380. /**
  12381. * Returns a new Quaternion copied from the current one.
  12382. */
  12383. clone(): Quaternion;
  12384. /**
  12385. * Updates the current Quaternion from the passed one coordinates.
  12386. * Returns the updated Quaterion.
  12387. */
  12388. copyFrom(other: Quaternion): Quaternion;
  12389. /**
  12390. * Updates the current Quaternion from the passed float coordinates.
  12391. * Returns the updated Quaterion.
  12392. */
  12393. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  12394. /**
  12395. * Updates the current Quaternion from the passed float coordinates.
  12396. * Returns the updated Quaterion.
  12397. */
  12398. set(x: number, y: number, z: number, w: number): Quaternion;
  12399. /**
  12400. * Returns a new Quaternion as the addition result of the passed one and the current Quaternion.
  12401. */
  12402. add(other: Quaternion): Quaternion;
  12403. /**
  12404. * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion.
  12405. */
  12406. subtract(other: Quaternion): Quaternion;
  12407. /**
  12408. * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale".
  12409. */
  12410. scale(value: number): Quaternion;
  12411. /**
  12412. * Scale the current Quaternion values by a factor to a given Quaternion
  12413. * @param scale defines the scale factor
  12414. * @param result defines the Quaternion object where to store the result
  12415. * @returns the unmodified current Quaternion
  12416. */
  12417. scaleToRef(scale: number, result: Quaternion): Quaternion;
  12418. /**
  12419. * Scale the current Quaternion values by a factor and add the result to a given Quaternion
  12420. * @param scale defines the scale factor
  12421. * @param result defines the Quaternion object where to store the result
  12422. * @returns the unmodified current Quaternion
  12423. */
  12424. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  12425. /**
  12426. * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1".
  12427. */
  12428. multiply(q1: Quaternion): Quaternion;
  12429. /**
  12430. * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1".
  12431. * Returns the current Quaternion.
  12432. */
  12433. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  12434. /**
  12435. * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1".
  12436. * Returns the updated Quaternion.
  12437. */
  12438. multiplyInPlace(q1: Quaternion): Quaternion;
  12439. /**
  12440. * Sets the passed "ref" with the conjugation of the current Quaternion.
  12441. * Returns the current Quaternion.
  12442. */
  12443. conjugateToRef(ref: Quaternion): Quaternion;
  12444. /**
  12445. * Conjugates in place the current Quaternion.
  12446. * Returns the updated Quaternion.
  12447. */
  12448. conjugateInPlace(): Quaternion;
  12449. /**
  12450. * Returns a new Quaternion as the conjugate of the current Quaternion.
  12451. */
  12452. conjugate(): Quaternion;
  12453. /**
  12454. * Returns the Quaternion length (float).
  12455. */
  12456. length(): number;
  12457. /**
  12458. * Normalize in place the current Quaternion.
  12459. * Returns the updated Quaternion.
  12460. */
  12461. normalize(): Quaternion;
  12462. /**
  12463. * Returns a new Vector3 set with the Euler angles translated from the current Quaternion
  12464. * @param order is a reserved parameter and is ignore for now
  12465. * @returns the new Vector3
  12466. */
  12467. toEulerAngles(order?: string): Vector3;
  12468. /**
  12469. * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion
  12470. * @param result defines the vector which will be filled with the Euler angles
  12471. * @param order is a reserved parameter and is ignore for now
  12472. * @returns the current Quaternion
  12473. */
  12474. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  12475. /**
  12476. * Updates the passed rotation matrix with the current Quaternion values.
  12477. * Returns the current Quaternion.
  12478. */
  12479. toRotationMatrix(result: Matrix): Quaternion;
  12480. /**
  12481. * Updates the current Quaternion from the passed rotation matrix values.
  12482. * Returns the updated Quaternion.
  12483. */
  12484. fromRotationMatrix(matrix: Matrix): Quaternion;
  12485. /**
  12486. * Returns a new Quaternion set from the passed rotation matrix values.
  12487. */
  12488. static FromRotationMatrix(matrix: Matrix): Quaternion;
  12489. /**
  12490. * Updates the passed quaternion "result" with the passed rotation matrix values.
  12491. */
  12492. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  12493. /**
  12494. * Returns a new Quaternion set to (0.0, 0.0, 0.0).
  12495. */
  12496. static Zero(): Quaternion;
  12497. /**
  12498. * Returns a new Quaternion as the inverted current Quaternion.
  12499. */
  12500. static Inverse(q: Quaternion): Quaternion;
  12501. /**
  12502. * Returns the identity Quaternion.
  12503. */
  12504. static Identity(): Quaternion;
  12505. static IsIdentity(quaternion: Quaternion): boolean;
  12506. /**
  12507. * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float).
  12508. */
  12509. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  12510. /**
  12511. * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float).
  12512. */
  12513. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  12514. /**
  12515. * Retuns a new Quaternion set from the starting index of the passed array.
  12516. */
  12517. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  12518. /**
  12519. * Returns a new Quaternion set from the passed Euler float angles (y, x, z).
  12520. */
  12521. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  12522. /**
  12523. * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z).
  12524. */
  12525. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  12526. /**
  12527. * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation
  12528. */
  12529. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  12530. /**
  12531. * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation
  12532. */
  12533. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  12534. /**
  12535. * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  12536. * cf to Vector3.RotationFromAxis() documentation.
  12537. * Note : axis1, axis2 and axis3 are normalized during this operation.
  12538. */
  12539. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion;
  12540. /**
  12541. * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  12542. * cf to Vector3.RotationFromAxis() documentation.
  12543. * Note : axis1, axis2 and axis3 are normalized during this operation.
  12544. */
  12545. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  12546. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  12547. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  12548. /**
  12549. * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2".
  12550. */
  12551. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  12552. }
  12553. class Matrix {
  12554. private static _tempQuaternion;
  12555. private static _xAxis;
  12556. private static _yAxis;
  12557. private static _zAxis;
  12558. private static _updateFlagSeed;
  12559. private static _identityReadOnly;
  12560. private _isIdentity;
  12561. private _isIdentityDirty;
  12562. updateFlag: number;
  12563. m: Float32Array;
  12564. _markAsUpdated(): void;
  12565. constructor();
  12566. /**
  12567. * Boolean : True is the matrix is the identity matrix
  12568. */
  12569. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  12570. /**
  12571. * Returns the matrix determinant (float).
  12572. */
  12573. determinant(): number;
  12574. /**
  12575. * Returns the matrix underlying array.
  12576. */
  12577. toArray(): Float32Array;
  12578. /**
  12579. * Returns the matrix underlying array.
  12580. */
  12581. asArray(): Float32Array;
  12582. /**
  12583. * Inverts in place the Matrix.
  12584. * Returns the Matrix inverted.
  12585. */
  12586. invert(): Matrix;
  12587. /**
  12588. * Sets all the matrix elements to zero.
  12589. * Returns the Matrix.
  12590. */
  12591. reset(): Matrix;
  12592. /**
  12593. * Returns a new Matrix as the addition result of the current Matrix and the passed one.
  12594. */
  12595. add(other: Matrix): Matrix;
  12596. /**
  12597. * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one.
  12598. * Returns the Matrix.
  12599. */
  12600. addToRef(other: Matrix, result: Matrix): Matrix;
  12601. /**
  12602. * Adds in place the passed matrix to the current Matrix.
  12603. * Returns the updated Matrix.
  12604. */
  12605. addToSelf(other: Matrix): Matrix;
  12606. /**
  12607. * Sets the passed matrix with the current inverted Matrix.
  12608. * Returns the unmodified current Matrix.
  12609. */
  12610. invertToRef(other: Matrix): Matrix;
  12611. /**
  12612. * Inserts the translation vector (using 3 x floats) in the current Matrix.
  12613. * Returns the updated Matrix.
  12614. */
  12615. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  12616. /**
  12617. * Inserts the translation vector in the current Matrix.
  12618. * Returns the updated Matrix.
  12619. */
  12620. setTranslation(vector3: Vector3): Matrix;
  12621. /**
  12622. * Returns a new Vector3 as the extracted translation from the Matrix.
  12623. */
  12624. getTranslation(): Vector3;
  12625. /**
  12626. * Fill a Vector3 with the extracted translation from the Matrix.
  12627. */
  12628. getTranslationToRef(result: Vector3): Matrix;
  12629. /**
  12630. * Remove rotation and scaling part from the Matrix.
  12631. * Returns the updated Matrix.
  12632. */
  12633. removeRotationAndScaling(): Matrix;
  12634. /**
  12635. * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one.
  12636. */
  12637. multiply(other: Matrix): Matrix;
  12638. /**
  12639. * Updates the current Matrix from the passed one values.
  12640. * Returns the updated Matrix.
  12641. */
  12642. copyFrom(other: Matrix): Matrix;
  12643. /**
  12644. * Populates the passed array from the starting index with the Matrix values.
  12645. * Returns the Matrix.
  12646. */
  12647. copyToArray(array: Float32Array, offset?: number): Matrix;
  12648. /**
  12649. * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one.
  12650. */
  12651. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  12652. /**
  12653. * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one.
  12654. */
  12655. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  12656. /**
  12657. * Boolean : True is the current Matrix and the passed one values are strictly equal.
  12658. */
  12659. equals(value: Matrix): boolean;
  12660. /**
  12661. * Returns a new Matrix from the current Matrix.
  12662. */
  12663. clone(): Matrix;
  12664. /**
  12665. * Returns the string "Matrix"
  12666. */
  12667. getClassName(): string;
  12668. /**
  12669. * Returns the Matrix hash code.
  12670. */
  12671. getHashCode(): number;
  12672. /**
  12673. * Decomposes the current Matrix into :
  12674. * - a scale vector3 passed as a reference to update,
  12675. * - a rotation quaternion passed as a reference to update,
  12676. * - a translation vector3 passed as a reference to update.
  12677. * Returns the true if operation was successful.
  12678. */
  12679. decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean;
  12680. /**
  12681. * Returns the index-th row of the current matrix as a new Vector4.
  12682. */
  12683. getRow(index: number): Nullable<Vector4>;
  12684. /**
  12685. * Sets the index-th row of the current matrix with the passed Vector4 values.
  12686. * Returns the updated Matrix.
  12687. */
  12688. setRow(index: number, row: Vector4): Matrix;
  12689. /**
  12690. * Compute the transpose of the matrix.
  12691. * Returns a new Matrix.
  12692. */
  12693. transpose(): Matrix;
  12694. /**
  12695. * Compute the transpose of the matrix.
  12696. * Returns the current matrix.
  12697. */
  12698. transposeToRef(result: Matrix): Matrix;
  12699. /**
  12700. * Sets the index-th row of the current matrix with the passed 4 x float values.
  12701. * Returns the updated Matrix.
  12702. */
  12703. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  12704. /**
  12705. * Compute a new Matrix set with the current Matrix values multiplied by scale (float)
  12706. * @param scale defines the scale factor
  12707. * @returns a new Matrix
  12708. */
  12709. scale(scale: number): Matrix;
  12710. /**
  12711. * Scale the current Matrix values by a factor to a given result Matrix
  12712. * @param scale defines the scale factor
  12713. * @param result defines the Matrix to store the result
  12714. * @returns the current Matrix
  12715. */
  12716. scaleToRef(scale: number, result: Matrix): Matrix;
  12717. /**
  12718. * Scale the current Matrix values by a factor and add the result to a given Matrix
  12719. * @param scale defines the scale factor
  12720. * @param result defines the Matrix to store the result
  12721. * @returns the current Matrix
  12722. */
  12723. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  12724. /**
  12725. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  12726. * @param ref matrix to store the result
  12727. */
  12728. toNormalMatrix(ref: Matrix): void;
  12729. /**
  12730. * Returns a new Matrix as the extracted rotation matrix from the current one.
  12731. */
  12732. getRotationMatrix(): Matrix;
  12733. /**
  12734. * Extracts the rotation matrix from the current one and sets it as the passed "result".
  12735. * Returns the current Matrix.
  12736. */
  12737. getRotationMatrixToRef(result: Matrix): Matrix;
  12738. /**
  12739. * Returns a new Matrix set from the starting index of the passed array.
  12740. */
  12741. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  12742. /**
  12743. * Sets the passed "result" matrix from the starting index of the passed array.
  12744. */
  12745. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  12746. /**
  12747. * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale".
  12748. */
  12749. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  12750. /**
  12751. * Sets the passed matrix "result" with the 16 passed floats.
  12752. */
  12753. 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;
  12754. /**
  12755. * Static identity matrix to be used as readonly matrix
  12756. * Must not be updated.
  12757. */
  12758. static readonly IdentityReadOnly: Matrix;
  12759. /**
  12760. * Returns a new Matrix set from the 16 passed floats.
  12761. */
  12762. 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;
  12763. /**
  12764. * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  12765. */
  12766. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  12767. /**
  12768. * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  12769. */
  12770. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  12771. /**
  12772. * Returns a new indentity Matrix.
  12773. */
  12774. static Identity(): Matrix;
  12775. /**
  12776. * Sets the passed "result" as an identity matrix.
  12777. */
  12778. static IdentityToRef(result: Matrix): void;
  12779. /**
  12780. * Returns a new zero Matrix.
  12781. */
  12782. static Zero(): Matrix;
  12783. /**
  12784. * Returns a new rotation matrix for "angle" radians around the X axis.
  12785. */
  12786. static RotationX(angle: number): Matrix;
  12787. /**
  12788. * Returns a new Matrix as the passed inverted one.
  12789. */
  12790. static Invert(source: Matrix): Matrix;
  12791. /**
  12792. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis.
  12793. */
  12794. static RotationXToRef(angle: number, result: Matrix): void;
  12795. /**
  12796. * Returns a new rotation matrix for "angle" radians around the Y axis.
  12797. */
  12798. static RotationY(angle: number): Matrix;
  12799. /**
  12800. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis.
  12801. */
  12802. static RotationYToRef(angle: number, result: Matrix): void;
  12803. /**
  12804. * Returns a new rotation matrix for "angle" radians around the Z axis.
  12805. */
  12806. static RotationZ(angle: number): Matrix;
  12807. /**
  12808. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis.
  12809. */
  12810. static RotationZToRef(angle: number, result: Matrix): void;
  12811. /**
  12812. * Returns a new rotation matrix for "angle" radians around the passed axis.
  12813. */
  12814. static RotationAxis(axis: Vector3, angle: number): Matrix;
  12815. /**
  12816. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis.
  12817. */
  12818. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  12819. /**
  12820. * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z).
  12821. */
  12822. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  12823. /**
  12824. * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z).
  12825. */
  12826. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  12827. /**
  12828. * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z).
  12829. */
  12830. static Scaling(x: number, y: number, z: number): Matrix;
  12831. /**
  12832. * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z).
  12833. */
  12834. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  12835. /**
  12836. * Returns a new Matrix as a translation matrix from the passed floats (x, y, z).
  12837. */
  12838. static Translation(x: number, y: number, z: number): Matrix;
  12839. /**
  12840. * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z).
  12841. */
  12842. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  12843. /**
  12844. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  12845. * @param startValue defines the start value
  12846. * @param endValue defines the end value
  12847. * @param gradient defines the gradient factor
  12848. * @returns the new matrix
  12849. */
  12850. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  12851. /**
  12852. * Set the passed matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  12853. * @param startValue defines the start value
  12854. * @param endValue defines the end value
  12855. * @param gradient defines the gradient factor
  12856. * @param result defines the Matrix object where to store data
  12857. */
  12858. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  12859. /**
  12860. * Returns a new Matrix whose values are computed by :
  12861. * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices,
  12862. * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end,
  12863. * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices.
  12864. */
  12865. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  12866. /**
  12867. * 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".
  12868. * This methods works for a Left-Handed system.
  12869. */
  12870. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  12871. /**
  12872. * 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".
  12873. * This methods works for a Left-Handed system.
  12874. */
  12875. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  12876. /**
  12877. * 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".
  12878. * This methods works for a Right-Handed system.
  12879. */
  12880. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  12881. /**
  12882. * 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".
  12883. * This methods works for a Left-Handed system.
  12884. */
  12885. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  12886. /**
  12887. * 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.
  12888. */
  12889. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  12890. /**
  12891. * 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.
  12892. */
  12893. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  12894. /**
  12895. * 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.
  12896. */
  12897. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  12898. /**
  12899. * 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.
  12900. */
  12901. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  12902. /**
  12903. * 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.
  12904. */
  12905. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  12906. /**
  12907. * 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.
  12908. */
  12909. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  12910. /**
  12911. * 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.
  12912. */
  12913. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  12914. /**
  12915. * 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.
  12916. */
  12917. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  12918. /**
  12919. * 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.
  12920. */
  12921. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  12922. /**
  12923. * 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.
  12924. */
  12925. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  12926. /**
  12927. * 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.
  12928. */
  12929. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  12930. /**
  12931. * 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.
  12932. */
  12933. static PerspectiveFovWebVRToRef(fov: {
  12934. upDegrees: number;
  12935. downDegrees: number;
  12936. leftDegrees: number;
  12937. rightDegrees: number;
  12938. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  12939. /**
  12940. * Returns the final transformation matrix : world * view * projection * viewport
  12941. */
  12942. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  12943. /**
  12944. * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix.
  12945. */
  12946. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  12947. /**
  12948. * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix.
  12949. */
  12950. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  12951. /**
  12952. * Compute the transpose of the passed Matrix.
  12953. * Returns a new Matrix.
  12954. */
  12955. static Transpose(matrix: Matrix): Matrix;
  12956. /**
  12957. * Compute the transpose of the passed Matrix and store it in the result matrix.
  12958. */
  12959. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  12960. /**
  12961. * Returns a new Matrix as the reflection matrix across the passed plane.
  12962. */
  12963. static Reflection(plane: Plane): Matrix;
  12964. /**
  12965. * Sets the passed matrix "result" as the reflection matrix across the passed plane.
  12966. */
  12967. static ReflectionToRef(plane: Plane, result: Matrix): void;
  12968. /**
  12969. * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis.
  12970. */
  12971. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  12972. /**
  12973. * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion.
  12974. */
  12975. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  12976. }
  12977. class Plane {
  12978. normal: Vector3;
  12979. d: number;
  12980. /**
  12981. * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  12982. */
  12983. constructor(a: number, b: number, c: number, d: number);
  12984. /**
  12985. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  12986. */
  12987. asArray(): number[];
  12988. /**
  12989. * Returns a new plane copied from the current Plane.
  12990. */
  12991. clone(): Plane;
  12992. /**
  12993. * Returns the string "Plane".
  12994. */
  12995. getClassName(): string;
  12996. /**
  12997. * Returns the Plane hash code.
  12998. */
  12999. getHashCode(): number;
  13000. /**
  13001. * Normalize the current Plane in place.
  13002. * Returns the updated Plane.
  13003. */
  13004. normalize(): Plane;
  13005. /**
  13006. * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix.
  13007. */
  13008. transform(transformation: Matrix): Plane;
  13009. /**
  13010. * Returns the dot product (float) of the point coordinates and the plane normal.
  13011. */
  13012. dotCoordinate(point: Vector3): number;
  13013. /**
  13014. * Updates the current Plane from the plane defined by the three passed points.
  13015. * Returns the updated Plane.
  13016. */
  13017. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  13018. /**
  13019. * Boolean : True is the vector "direction" is the same side than the plane normal.
  13020. */
  13021. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  13022. /**
  13023. * Returns the signed distance (float) from the passed point to the Plane.
  13024. */
  13025. signedDistanceTo(point: Vector3): number;
  13026. /**
  13027. * Returns a new Plane from the passed array.
  13028. */
  13029. static FromArray(array: ArrayLike<number>): Plane;
  13030. /**
  13031. * Returns a new Plane defined by the three passed points.
  13032. */
  13033. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  13034. /**
  13035. * Returns a new Plane the normal vector to this plane at the passed origin point.
  13036. * Note : the vector "normal" is updated because normalized.
  13037. */
  13038. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  13039. /**
  13040. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point.
  13041. */
  13042. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  13043. }
  13044. class Viewport {
  13045. x: number;
  13046. y: number;
  13047. width: number;
  13048. height: number;
  13049. /**
  13050. * Creates a Viewport object located at (x, y) and sized (width, height).
  13051. */
  13052. constructor(x: number, y: number, width: number, height: number);
  13053. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  13054. /**
  13055. * Returns a new Viewport copied from the current one.
  13056. */
  13057. clone(): Viewport;
  13058. }
  13059. class Frustum {
  13060. /**
  13061. * Returns a new array of 6 Frustum planes computed by the passed transformation matrix.
  13062. */
  13063. static GetPlanes(transform: Matrix): Plane[];
  13064. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  13065. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  13066. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  13067. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  13068. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  13069. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  13070. /**
  13071. * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix.
  13072. */
  13073. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  13074. }
  13075. enum Space {
  13076. LOCAL = 0,
  13077. WORLD = 1,
  13078. BONE = 2,
  13079. }
  13080. class Axis {
  13081. static X: Vector3;
  13082. static Y: Vector3;
  13083. static Z: Vector3;
  13084. }
  13085. class BezierCurve {
  13086. /**
  13087. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats.
  13088. */
  13089. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  13090. }
  13091. enum Orientation {
  13092. CW = 0,
  13093. CCW = 1,
  13094. }
  13095. class Angle {
  13096. private _radians;
  13097. /**
  13098. * Creates an Angle object of "radians" radians (float).
  13099. */
  13100. constructor(radians: number);
  13101. /**
  13102. * Returns the Angle value in degrees (float).
  13103. */
  13104. degrees: () => number;
  13105. /**
  13106. * Returns the Angle value in radians (float).
  13107. */
  13108. radians: () => number;
  13109. /**
  13110. * Returns a new Angle object valued with the angle value in radians between the two passed vectors.
  13111. */
  13112. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  13113. /**
  13114. * Returns a new Angle object from the passed float in radians.
  13115. */
  13116. static FromRadians(radians: number): Angle;
  13117. /**
  13118. * Returns a new Angle object from the passed float in degrees.
  13119. */
  13120. static FromDegrees(degrees: number): Angle;
  13121. }
  13122. class Arc2 {
  13123. startPoint: Vector2;
  13124. midPoint: Vector2;
  13125. endPoint: Vector2;
  13126. centerPoint: Vector2;
  13127. radius: number;
  13128. angle: Angle;
  13129. startAngle: Angle;
  13130. orientation: Orientation;
  13131. /**
  13132. * Creates an Arc object from the three passed points : start, middle and end.
  13133. */
  13134. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  13135. }
  13136. class Path2 {
  13137. private _points;
  13138. private _length;
  13139. closed: boolean;
  13140. /**
  13141. * Creates a Path2 object from the starting 2D coordinates x and y.
  13142. */
  13143. constructor(x: number, y: number);
  13144. /**
  13145. * Adds a new segment until the passed coordinates (x, y) to the current Path2.
  13146. * Returns the updated Path2.
  13147. */
  13148. addLineTo(x: number, y: number): Path2;
  13149. /**
  13150. * 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.
  13151. * Returns the updated Path2.
  13152. */
  13153. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  13154. /**
  13155. * Closes the Path2.
  13156. * Returns the Path2.
  13157. */
  13158. close(): Path2;
  13159. /**
  13160. * Returns the Path2 total length (float).
  13161. */
  13162. length(): number;
  13163. /**
  13164. * Returns the Path2 internal array of points.
  13165. */
  13166. getPoints(): Vector2[];
  13167. /**
  13168. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  13169. */
  13170. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  13171. /**
  13172. * Returns a new Path2 starting at the coordinates (x, y).
  13173. */
  13174. static StartingAt(x: number, y: number): Path2;
  13175. }
  13176. class Path3D {
  13177. path: Vector3[];
  13178. private _curve;
  13179. private _distances;
  13180. private _tangents;
  13181. private _normals;
  13182. private _binormals;
  13183. private _raw;
  13184. /**
  13185. * new Path3D(path, normal, raw)
  13186. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  13187. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  13188. * path : an array of Vector3, the curve axis of the Path3D
  13189. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  13190. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  13191. */
  13192. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  13193. /**
  13194. * Returns the Path3D array of successive Vector3 designing its curve.
  13195. */
  13196. getCurve(): Vector3[];
  13197. /**
  13198. * Returns an array populated with tangent vectors on each Path3D curve point.
  13199. */
  13200. getTangents(): Vector3[];
  13201. /**
  13202. * Returns an array populated with normal vectors on each Path3D curve point.
  13203. */
  13204. getNormals(): Vector3[];
  13205. /**
  13206. * Returns an array populated with binormal vectors on each Path3D curve point.
  13207. */
  13208. getBinormals(): Vector3[];
  13209. /**
  13210. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  13211. */
  13212. getDistances(): number[];
  13213. /**
  13214. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  13215. * Returns the same object updated.
  13216. */
  13217. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  13218. private _compute(firstNormal);
  13219. private _getFirstNonNullVector(index);
  13220. private _getLastNonNullVector(index);
  13221. private _normalVector(v0, vt, va);
  13222. }
  13223. class Curve3 {
  13224. private _points;
  13225. private _length;
  13226. /**
  13227. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  13228. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  13229. * @param v1 (Vector3) the control point
  13230. * @param v2 (Vector3) the end point of the Quadratic Bezier
  13231. * @param nbPoints (integer) the wanted number of points in the curve
  13232. */
  13233. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  13234. /**
  13235. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  13236. * @param v0 (Vector3) the origin point of the Cubic Bezier
  13237. * @param v1 (Vector3) the first control point
  13238. * @param v2 (Vector3) the second control point
  13239. * @param v3 (Vector3) the end point of the Cubic Bezier
  13240. * @param nbPoints (integer) the wanted number of points in the curve
  13241. */
  13242. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  13243. /**
  13244. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  13245. * @param p1 (Vector3) the origin point of the Hermite Spline
  13246. * @param t1 (Vector3) the tangent vector at the origin point
  13247. * @param p2 (Vector3) the end point of the Hermite Spline
  13248. * @param t2 (Vector3) the tangent vector at the end point
  13249. * @param nbPoints (integer) the wanted number of points in the curve
  13250. */
  13251. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  13252. /**
  13253. * Returns a Curve3 object along a CatmullRom Spline curve :
  13254. * @param points (array of Vector3) the points the spline must pass through. At least, four points required.
  13255. * @param nbPoints (integer) the wanted number of points between each curve control points.
  13256. */
  13257. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3;
  13258. /**
  13259. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  13260. * A Curve3 is designed from a series of successive Vector3.
  13261. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  13262. */
  13263. constructor(points: Vector3[]);
  13264. /**
  13265. * Returns the Curve3 stored array of successive Vector3
  13266. */
  13267. getPoints(): Vector3[];
  13268. /**
  13269. * Returns the computed length (float) of the curve.
  13270. */
  13271. length(): number;
  13272. /**
  13273. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  13274. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  13275. * curveA and curveB keep unchanged.
  13276. */
  13277. continue(curve: Curve3): Curve3;
  13278. private _computeLength(path);
  13279. }
  13280. class PositionNormalVertex {
  13281. position: Vector3;
  13282. normal: Vector3;
  13283. constructor(position?: Vector3, normal?: Vector3);
  13284. clone(): PositionNormalVertex;
  13285. }
  13286. class PositionNormalTextureVertex {
  13287. position: Vector3;
  13288. normal: Vector3;
  13289. uv: Vector2;
  13290. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  13291. clone(): PositionNormalTextureVertex;
  13292. }
  13293. class Tmp {
  13294. static Color3: Color3[];
  13295. static Vector2: Vector2[];
  13296. static Vector3: Vector3[];
  13297. static Vector4: Vector4[];
  13298. static Quaternion: Quaternion[];
  13299. static Matrix: Matrix[];
  13300. }
  13301. }
  13302. declare module BABYLON {
  13303. class SphericalPolynomial {
  13304. x: Vector3;
  13305. y: Vector3;
  13306. z: Vector3;
  13307. xx: Vector3;
  13308. yy: Vector3;
  13309. zz: Vector3;
  13310. xy: Vector3;
  13311. yz: Vector3;
  13312. zx: Vector3;
  13313. addAmbient(color: Color3): void;
  13314. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  13315. scale(scale: number): void;
  13316. }
  13317. class SphericalHarmonics {
  13318. L00: Vector3;
  13319. L1_1: Vector3;
  13320. L10: Vector3;
  13321. L11: Vector3;
  13322. L2_2: Vector3;
  13323. L2_1: Vector3;
  13324. L20: Vector3;
  13325. L21: Vector3;
  13326. L22: Vector3;
  13327. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  13328. scale(scale: number): void;
  13329. convertIncidentRadianceToIrradiance(): void;
  13330. convertIrradianceToLambertianRadiance(): void;
  13331. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  13332. }
  13333. }
  13334. declare module BABYLON {
  13335. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  13336. static OCCLUSION_TYPE_NONE: number;
  13337. static OCCLUSION_TYPE_OPTIMISTIC: number;
  13338. static OCCLUSION_TYPE_STRICT: number;
  13339. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  13340. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  13341. static readonly BILLBOARDMODE_NONE: number;
  13342. static readonly BILLBOARDMODE_X: number;
  13343. static readonly BILLBOARDMODE_Y: number;
  13344. static readonly BILLBOARDMODE_Z: number;
  13345. static readonly BILLBOARDMODE_ALL: number;
  13346. private _facetPositions;
  13347. private _facetNormals;
  13348. private _facetPartitioning;
  13349. private _facetNb;
  13350. private _partitioningSubdivisions;
  13351. private _partitioningBBoxRatio;
  13352. private _facetDataEnabled;
  13353. private _facetParameters;
  13354. private _bbSize;
  13355. private _subDiv;
  13356. private _facetDepthSort;
  13357. private _facetDepthSortEnabled;
  13358. private _depthSortedIndices;
  13359. private _depthSortedFacets;
  13360. private _facetDepthSortFunction;
  13361. private _facetDepthSortFrom;
  13362. private _facetDepthSortOrigin;
  13363. private _invertedMatrix;
  13364. /**
  13365. * Read-only : the number of facets in the mesh
  13366. */
  13367. readonly facetNb: number;
  13368. /**
  13369. * The number (integer) of subdivisions per axis in the partioning space
  13370. */
  13371. partitioningSubdivisions: number;
  13372. /**
  13373. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  13374. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box.
  13375. */
  13376. partitioningBBoxRatio: number;
  13377. /**
  13378. * Boolean : must the facet be depth sorted on next call to `updateFacetData()` ?
  13379. * Works only for updatable meshes.
  13380. * Doesn't work with multi-materials.
  13381. */
  13382. mustDepthSortFacets: boolean;
  13383. /**
  13384. * The location (Vector3) where the facet depth sort must be computed from.
  13385. * By default, the active camera position.
  13386. * Used only when facet depth sort is enabled.
  13387. */
  13388. facetDepthSortFrom: Vector3;
  13389. /**
  13390. * Read-only boolean : is the feature facetData enabled ?
  13391. */
  13392. readonly isFacetDataEnabled: boolean;
  13393. _updateNonUniformScalingState(value: boolean): boolean;
  13394. /**
  13395. * An event triggered when this mesh collides with another one
  13396. * @type {BABYLON.Observable}
  13397. */
  13398. onCollideObservable: Observable<AbstractMesh>;
  13399. private _onCollideObserver;
  13400. onCollide: () => void;
  13401. /**
  13402. * An event triggered when the collision's position changes
  13403. * @type {BABYLON.Observable}
  13404. */
  13405. onCollisionPositionChangeObservable: Observable<Vector3>;
  13406. private _onCollisionPositionChangeObserver;
  13407. onCollisionPositionChange: () => void;
  13408. /**
  13409. * An event triggered when material is changed
  13410. * @type {BABYLON.Observable}
  13411. */
  13412. onMaterialChangedObservable: Observable<AbstractMesh>;
  13413. definedFacingForward: boolean;
  13414. /**
  13415. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  13416. * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  13417. * or
  13418. * 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.
  13419. * for more info check WebGl documentations
  13420. */
  13421. occlusionQueryAlgorithmType: number;
  13422. /**
  13423. * 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:
  13424. * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  13425. * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  13426. * 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.
  13427. */
  13428. occlusionType: number;
  13429. /**
  13430. * 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.
  13431. * The default value is -1 which means don't break the query and wait till the result.
  13432. */
  13433. occlusionRetryCount: number;
  13434. private _occlusionInternalRetryCounter;
  13435. protected _isOccluded: boolean;
  13436. /**
  13437. * 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.
  13438. */
  13439. isOccluded: boolean;
  13440. private _isOcclusionQueryInProgress;
  13441. /**
  13442. * Flag to check the progress status of the query
  13443. */
  13444. readonly isOcclusionQueryInProgress: boolean;
  13445. private _occlusionQuery;
  13446. private _visibility;
  13447. /**
  13448. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  13449. */
  13450. /**
  13451. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  13452. */
  13453. visibility: number;
  13454. alphaIndex: number;
  13455. isVisible: boolean;
  13456. isPickable: boolean;
  13457. showBoundingBox: boolean;
  13458. showSubMeshesBoundingBox: boolean;
  13459. isBlocker: boolean;
  13460. enablePointerMoveEvents: boolean;
  13461. renderingGroupId: number;
  13462. private _material;
  13463. material: Nullable<Material>;
  13464. private _receiveShadows;
  13465. receiveShadows: boolean;
  13466. renderOutline: boolean;
  13467. outlineColor: Color3;
  13468. outlineWidth: number;
  13469. renderOverlay: boolean;
  13470. overlayColor: Color3;
  13471. overlayAlpha: number;
  13472. private _hasVertexAlpha;
  13473. hasVertexAlpha: boolean;
  13474. private _useVertexColors;
  13475. useVertexColors: boolean;
  13476. private _computeBonesUsingShaders;
  13477. computeBonesUsingShaders: boolean;
  13478. private _numBoneInfluencers;
  13479. numBoneInfluencers: number;
  13480. private _applyFog;
  13481. applyFog: boolean;
  13482. useOctreeForRenderingSelection: boolean;
  13483. useOctreeForPicking: boolean;
  13484. useOctreeForCollisions: boolean;
  13485. private _layerMask;
  13486. layerMask: number;
  13487. /**
  13488. * True if the mesh must be rendered in any case.
  13489. */
  13490. alwaysSelectAsActiveMesh: boolean;
  13491. /**
  13492. * This scene's action manager
  13493. * @type {BABYLON.ActionManager}
  13494. */
  13495. actionManager: Nullable<ActionManager>;
  13496. physicsImpostor: Nullable<PhysicsImpostor>;
  13497. private _checkCollisions;
  13498. private _collisionMask;
  13499. private _collisionGroup;
  13500. ellipsoid: Vector3;
  13501. ellipsoidOffset: Vector3;
  13502. private _collider;
  13503. private _oldPositionForCollisions;
  13504. private _diffPositionForCollisions;
  13505. collisionMask: number;
  13506. collisionGroup: number;
  13507. edgesWidth: number;
  13508. edgesColor: Color4;
  13509. _edgesRenderer: Nullable<EdgesRenderer>;
  13510. private _collisionsTransformMatrix;
  13511. private _collisionsScalingMatrix;
  13512. _masterMesh: Nullable<AbstractMesh>;
  13513. _boundingInfo: Nullable<BoundingInfo>;
  13514. _renderId: number;
  13515. subMeshes: SubMesh[];
  13516. _submeshesOctree: Octree<SubMesh>;
  13517. _intersectionsInProgress: AbstractMesh[];
  13518. _unIndexed: boolean;
  13519. _lightSources: Light[];
  13520. readonly _positions: Nullable<Vector3[]>;
  13521. _waitingActions: any;
  13522. _waitingFreezeWorldMatrix: Nullable<boolean>;
  13523. private _skeleton;
  13524. _bonesTransformMatrices: Nullable<Float32Array>;
  13525. skeleton: Nullable<Skeleton>;
  13526. constructor(name: string, scene?: Nullable<Scene>);
  13527. /**
  13528. * Returns the string "AbstractMesh"
  13529. */
  13530. getClassName(): string;
  13531. /**
  13532. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  13533. */
  13534. toString(fullDetails?: boolean): string;
  13535. _rebuild(): void;
  13536. _resyncLightSources(): void;
  13537. _resyncLighSource(light: Light): void;
  13538. _removeLightSource(light: Light): void;
  13539. private _markSubMeshesAsDirty(func);
  13540. _markSubMeshesAsLightDirty(): void;
  13541. _markSubMeshesAsAttributesDirty(): void;
  13542. _markSubMeshesAsMiscDirty(): void;
  13543. /**
  13544. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  13545. * Default : (1.0, 1.0, 1.0)
  13546. */
  13547. /**
  13548. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  13549. * Default : (1.0, 1.0, 1.0)
  13550. */
  13551. scaling: Vector3;
  13552. /**
  13553. * Disables the mesh edger rendering mode.
  13554. * Returns the AbstractMesh.
  13555. */
  13556. disableEdgesRendering(): AbstractMesh;
  13557. /**
  13558. * Enables the edge rendering mode on the mesh.
  13559. * This mode makes the mesh edges visible.
  13560. * Returns the AbstractMesh.
  13561. */
  13562. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  13563. /**
  13564. * Returns true if the mesh is blocked. Used by the class Mesh.
  13565. * Returns the boolean `false` by default.
  13566. */
  13567. readonly isBlocked: boolean;
  13568. /**
  13569. * Returns the mesh itself by default, used by the class Mesh.
  13570. * Returned type : AbstractMesh
  13571. */
  13572. getLOD(camera: Camera): AbstractMesh;
  13573. /**
  13574. * Returns 0 by default, used by the class Mesh.
  13575. * Returns an integer.
  13576. */
  13577. getTotalVertices(): number;
  13578. /**
  13579. * Returns null by default, used by the class Mesh.
  13580. * Returned type : integer array
  13581. */
  13582. getIndices(): Nullable<IndicesArray>;
  13583. /**
  13584. * Returns the array of the requested vertex data kind. Used by the class Mesh. Returns null here.
  13585. * Returned type : float array or Float32Array
  13586. */
  13587. getVerticesData(kind: string): Nullable<FloatArray>;
  13588. /**
  13589. * Sets the vertex data of the mesh geometry for the requested `kind`.
  13590. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  13591. * The `data` are either a numeric array either a Float32Array.
  13592. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  13593. * 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).
  13594. * Note that a new underlying VertexBuffer object is created each call.
  13595. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  13596. *
  13597. * Possible `kind` values :
  13598. * - BABYLON.VertexBuffer.PositionKind
  13599. * - BABYLON.VertexBuffer.UVKind
  13600. * - BABYLON.VertexBuffer.UV2Kind
  13601. * - BABYLON.VertexBuffer.UV3Kind
  13602. * - BABYLON.VertexBuffer.UV4Kind
  13603. * - BABYLON.VertexBuffer.UV5Kind
  13604. * - BABYLON.VertexBuffer.UV6Kind
  13605. * - BABYLON.VertexBuffer.ColorKind
  13606. * - BABYLON.VertexBuffer.MatricesIndicesKind
  13607. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  13608. * - BABYLON.VertexBuffer.MatricesWeightsKind
  13609. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  13610. *
  13611. * Returns the Mesh.
  13612. */
  13613. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  13614. /**
  13615. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  13616. * If the mesh has no geometry, it is simply returned as it is.
  13617. * The `data` are either a numeric array either a Float32Array.
  13618. * No new underlying VertexBuffer object is created.
  13619. * 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.
  13620. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  13621. *
  13622. * Possible `kind` values :
  13623. * - BABYLON.VertexBuffer.PositionKind
  13624. * - BABYLON.VertexBuffer.UVKind
  13625. * - BABYLON.VertexBuffer.UV2Kind
  13626. * - BABYLON.VertexBuffer.UV3Kind
  13627. * - BABYLON.VertexBuffer.UV4Kind
  13628. * - BABYLON.VertexBuffer.UV5Kind
  13629. * - BABYLON.VertexBuffer.UV6Kind
  13630. * - BABYLON.VertexBuffer.ColorKind
  13631. * - BABYLON.VertexBuffer.MatricesIndicesKind
  13632. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  13633. * - BABYLON.VertexBuffer.MatricesWeightsKind
  13634. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  13635. *
  13636. * Returns the Mesh.
  13637. */
  13638. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  13639. /**
  13640. * Sets the mesh indices.
  13641. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  13642. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  13643. * This method creates a new index buffer each call.
  13644. * Returns the Mesh.
  13645. */
  13646. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  13647. /** Returns false by default, used by the class Mesh.
  13648. * Returns a boolean
  13649. */
  13650. isVerticesDataPresent(kind: string): boolean;
  13651. /**
  13652. * Returns the mesh BoundingInfo object or creates a new one and returns it if undefined.
  13653. * Returns a BoundingInfo
  13654. */
  13655. getBoundingInfo(): BoundingInfo;
  13656. /**
  13657. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units).
  13658. * @param includeDescendants Take the hierarchy's bounding box instead of the mesh's bounding box.
  13659. */
  13660. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  13661. /**
  13662. * Sets a mesh new object BoundingInfo.
  13663. * Returns the AbstractMesh.
  13664. */
  13665. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  13666. readonly useBones: boolean;
  13667. _preActivate(): void;
  13668. _preActivateForIntermediateRendering(renderId: number): void;
  13669. _activate(renderId: number): void;
  13670. /**
  13671. * Returns the latest update of the World matrix
  13672. * Returns a Matrix.
  13673. */
  13674. getWorldMatrix(): Matrix;
  13675. /**
  13676. * Returns the latest update of the World matrix determinant.
  13677. */
  13678. protected _getWorldMatrixDeterminant(): number;
  13679. /**
  13680. * Perform relative position change from the point of view of behind the front of the mesh.
  13681. * This is performed taking into account the meshes current rotation, so you do not have to care.
  13682. * Supports definition of mesh facing forward or backward.
  13683. * @param {number} amountRight
  13684. * @param {number} amountUp
  13685. * @param {number} amountForward
  13686. *
  13687. * Returns the AbstractMesh.
  13688. */
  13689. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  13690. /**
  13691. * Calculate relative position change from the point of view of behind the front of the mesh.
  13692. * This is performed taking into account the meshes current rotation, so you do not have to care.
  13693. * Supports definition of mesh facing forward or backward.
  13694. * @param {number} amountRight
  13695. * @param {number} amountUp
  13696. * @param {number} amountForward
  13697. *
  13698. * Returns a new Vector3.
  13699. */
  13700. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  13701. /**
  13702. * Perform relative rotation change from the point of view of behind the front of the mesh.
  13703. * Supports definition of mesh facing forward or backward.
  13704. * @param {number} flipBack
  13705. * @param {number} twirlClockwise
  13706. * @param {number} tiltRight
  13707. *
  13708. * Returns the AbstractMesh.
  13709. */
  13710. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  13711. /**
  13712. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  13713. * Supports definition of mesh facing forward or backward.
  13714. * @param {number} flipBack
  13715. * @param {number} twirlClockwise
  13716. * @param {number} tiltRight
  13717. *
  13718. * Returns a new Vector3.
  13719. */
  13720. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  13721. /**
  13722. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  13723. * @param includeDescendants Include bounding info from descendants as well (true by default).
  13724. */
  13725. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  13726. min: Vector3;
  13727. max: Vector3;
  13728. };
  13729. /**
  13730. * Updates the mesh BoundingInfo object and all its children BoundingInfo objects also.
  13731. * Returns the AbstractMesh.
  13732. */
  13733. _updateBoundingInfo(): AbstractMesh;
  13734. /**
  13735. * Update a mesh's children BoundingInfo objects only.
  13736. * Returns the AbstractMesh.
  13737. */
  13738. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  13739. protected _afterComputeWorldMatrix(): void;
  13740. /**
  13741. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  13742. * A mesh is in the frustum if its bounding box intersects the frustum.
  13743. * Boolean returned.
  13744. */
  13745. isInFrustum(frustumPlanes: Plane[]): boolean;
  13746. /**
  13747. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  13748. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  13749. * Boolean returned.
  13750. */
  13751. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  13752. /**
  13753. * True if the mesh intersects another mesh or a SolidParticle object.
  13754. * 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)
  13755. * includeDescendants can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  13756. * Returns a boolean.
  13757. */
  13758. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  13759. /**
  13760. * Returns true if the passed point (Vector3) is inside the mesh bounding box.
  13761. * Returns a boolean.
  13762. */
  13763. intersectsPoint(point: Vector3): boolean;
  13764. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  13765. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13766. /**
  13767. * Returns the distance from the mesh to the active camera.
  13768. * Returns a float.
  13769. */
  13770. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13771. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  13772. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  13773. /**
  13774. * Property checkCollisions : Boolean, whether the camera should check the collisions against the mesh.
  13775. * Default `false`.
  13776. */
  13777. checkCollisions: boolean;
  13778. /**
  13779. * Gets Collider object used to compute collisions (not physics)
  13780. */
  13781. readonly collider: Collider;
  13782. moveWithCollisions(displacement: Vector3): AbstractMesh;
  13783. private _onCollisionPositionChange;
  13784. /**
  13785. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  13786. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree.
  13787. * Returns an Octree of submeshes.
  13788. */
  13789. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  13790. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  13791. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  13792. _checkCollision(collider: Collider): AbstractMesh;
  13793. _generatePointsArray(): boolean;
  13794. /**
  13795. * Checks if the passed Ray intersects with the mesh.
  13796. * Returns an object PickingInfo.
  13797. */
  13798. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  13799. /**
  13800. * Clones the mesh, used by the class Mesh.
  13801. * Just returns `null` for an AbstractMesh.
  13802. */
  13803. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  13804. /**
  13805. * Disposes all the mesh submeshes.
  13806. * Returns the AbstractMesh.
  13807. */
  13808. releaseSubMeshes(): AbstractMesh;
  13809. /**
  13810. * Releases resources associated with this abstract mesh.
  13811. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13812. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13813. */
  13814. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13815. /**
  13816. * Adds the passed mesh as a child to the current mesh.
  13817. * Returns the AbstractMesh.
  13818. */
  13819. addChild(mesh: AbstractMesh): AbstractMesh;
  13820. /**
  13821. * Removes the passed mesh from the current mesh children list.
  13822. * Returns the AbstractMesh.
  13823. */
  13824. removeChild(mesh: AbstractMesh): AbstractMesh;
  13825. /**
  13826. * Initialize the facet data arrays : facetNormals, facetPositions and facetPartitioning.
  13827. * Returns the AbstractMesh.
  13828. */
  13829. private _initFacetData();
  13830. /**
  13831. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  13832. * This method can be called within the render loop.
  13833. * 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.
  13834. * Returns the AbstractMesh.
  13835. */
  13836. updateFacetData(): AbstractMesh;
  13837. /**
  13838. * Returns the facetLocalNormals array.
  13839. * The normals are expressed in the mesh local space.
  13840. */
  13841. getFacetLocalNormals(): Vector3[];
  13842. /**
  13843. * Returns the facetLocalPositions array.
  13844. * The facet positions are expressed in the mesh local space.
  13845. */
  13846. getFacetLocalPositions(): Vector3[];
  13847. /**
  13848. * Returns the facetLocalPartioning array.
  13849. */
  13850. getFacetLocalPartitioning(): number[][];
  13851. /**
  13852. * Returns the i-th facet position in the world system.
  13853. * This method allocates a new Vector3 per call.
  13854. */
  13855. getFacetPosition(i: number): Vector3;
  13856. /**
  13857. * Sets the reference Vector3 with the i-th facet position in the world system.
  13858. * Returns the AbstractMesh.
  13859. */
  13860. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  13861. /**
  13862. * Returns the i-th facet normal in the world system.
  13863. * This method allocates a new Vector3 per call.
  13864. */
  13865. getFacetNormal(i: number): Vector3;
  13866. /**
  13867. * Sets the reference Vector3 with the i-th facet normal in the world system.
  13868. * Returns the AbstractMesh.
  13869. */
  13870. getFacetNormalToRef(i: number, ref: Vector3): this;
  13871. /**
  13872. * 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).
  13873. */
  13874. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  13875. /**
  13876. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found.
  13877. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) World projection on the facet.
  13878. * 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.
  13879. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  13880. * 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.
  13881. */
  13882. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  13883. /**
  13884. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found.
  13885. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) local projection on the facet.
  13886. * 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.
  13887. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  13888. * 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.
  13889. */
  13890. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  13891. /**
  13892. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  13893. */
  13894. getFacetDataParameters(): any;
  13895. /**
  13896. * Disables the feature FacetData and frees the related memory.
  13897. * Returns the AbstractMesh.
  13898. */
  13899. disableFacetData(): AbstractMesh;
  13900. /**
  13901. * Updates the AbstractMesh indices array. Actually, used by the Mesh object.
  13902. * Returns the mesh.
  13903. */
  13904. updateIndices(indices: IndicesArray): AbstractMesh;
  13905. /**
  13906. * The mesh Geometry. Actually used by the Mesh object.
  13907. * Returns a blank geometry object.
  13908. */
  13909. /**
  13910. * Creates new normals data for the mesh.
  13911. * @param updatable.
  13912. */
  13913. createNormals(updatable: boolean): void;
  13914. /**
  13915. * Align the mesh with a normal.
  13916. * Returns the mesh.
  13917. */
  13918. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  13919. protected checkOcclusionQuery(): void;
  13920. }
  13921. }
  13922. declare module BABYLON {
  13923. class Buffer {
  13924. private _engine;
  13925. private _buffer;
  13926. private _data;
  13927. private _updatable;
  13928. private _strideSize;
  13929. private _instanced;
  13930. constructor(engine: any, data: FloatArray, updatable: boolean, stride: number, postponeInternalCreation?: boolean, instanced?: boolean);
  13931. /**
  13932. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  13933. * @param kind defines the vertex buffer kind (position, normal, etc.)
  13934. * @param offset defines offset in the buffer (0 by default)
  13935. * @param size defines the size in floats of attributes (position is 3 for instance)
  13936. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  13937. * @param instanced defines if the vertex buffer contains indexed data
  13938. * @returns the new vertex buffer
  13939. */
  13940. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean): VertexBuffer;
  13941. isUpdatable(): boolean;
  13942. getData(): Nullable<FloatArray>;
  13943. getBuffer(): Nullable<WebGLBuffer>;
  13944. getStrideSize(): number;
  13945. create(data?: Nullable<FloatArray>): void;
  13946. _rebuild(): void;
  13947. update(data: FloatArray): void;
  13948. updateDirectly(data: Float32Array, offset: number, vertexCount?: number): void;
  13949. dispose(): void;
  13950. }
  13951. }
  13952. declare module BABYLON {
  13953. class CSG {
  13954. private polygons;
  13955. matrix: Matrix;
  13956. position: Vector3;
  13957. rotation: Vector3;
  13958. rotationQuaternion: Nullable<Quaternion>;
  13959. scaling: Vector3;
  13960. static FromMesh(mesh: Mesh): CSG;
  13961. private static FromPolygons(polygons);
  13962. clone(): CSG;
  13963. union(csg: CSG): CSG;
  13964. unionInPlace(csg: CSG): void;
  13965. subtract(csg: CSG): CSG;
  13966. subtractInPlace(csg: CSG): void;
  13967. intersect(csg: CSG): CSG;
  13968. intersectInPlace(csg: CSG): void;
  13969. inverse(): CSG;
  13970. inverseInPlace(): void;
  13971. copyTransformAttributes(csg: CSG): CSG;
  13972. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  13973. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  13974. }
  13975. }
  13976. declare module BABYLON {
  13977. /**
  13978. * Class used to store geometry data (vertex buffers + index buffer)
  13979. */
  13980. class Geometry implements IGetSetVerticesData {
  13981. /**
  13982. * Gets or sets the unique ID of the geometry
  13983. */
  13984. id: string;
  13985. /**
  13986. * Gets the delay loading state of the geometry (none by default which means not delayed)
  13987. */
  13988. delayLoadState: number;
  13989. /**
  13990. * Gets the file containing the data to load when running in delay load state
  13991. */
  13992. delayLoadingFile: Nullable<string>;
  13993. /**
  13994. * Callback called when the geometry is updated
  13995. */
  13996. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  13997. private _scene;
  13998. private _engine;
  13999. private _meshes;
  14000. private _totalVertices;
  14001. private _indices;
  14002. private _vertexBuffers;
  14003. private _isDisposed;
  14004. private _extend;
  14005. private _boundingBias;
  14006. /** @ignore */
  14007. _delayInfo: Array<string>;
  14008. private _indexBuffer;
  14009. private _indexBufferIsUpdatable;
  14010. /** @ignore */
  14011. _boundingInfo: Nullable<BoundingInfo>;
  14012. /** @ignore */
  14013. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  14014. /** @ignore */
  14015. _softwareSkinningRenderId: number;
  14016. private _vertexArrayObjects;
  14017. private _updatable;
  14018. /** @ignore */
  14019. _positions: Nullable<Vector3[]>;
  14020. /**
  14021. * 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
  14022. */
  14023. /**
  14024. * 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
  14025. */
  14026. boundingBias: Vector2;
  14027. /**
  14028. * Static function used to attach a new empty geometry to a mesh
  14029. * @param mesh defines the mesh to attach the geometry to
  14030. * @returns the new {BABYLON.Geometry}
  14031. */
  14032. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  14033. /**
  14034. * Creates a new geometry
  14035. * @param id defines the unique ID
  14036. * @param scene defines the hosting scene
  14037. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  14038. * @param updatable defines if geometry must be updatable (false by default)
  14039. * @param mesh defines the mesh that will be associated with the geometry
  14040. */
  14041. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  14042. /**
  14043. * Gets the current extend of the geometry
  14044. */
  14045. readonly extend: {
  14046. minimum: Vector3;
  14047. maximum: Vector3;
  14048. };
  14049. /**
  14050. * Gets the hosting scene
  14051. * @returns the hosting {BABYLON.Scene}
  14052. */
  14053. getScene(): Scene;
  14054. /**
  14055. * Gets the hosting engine
  14056. * @returns the hosting {BABYLON.Engine}
  14057. */
  14058. getEngine(): Engine;
  14059. /**
  14060. * Defines if the geometry is ready to use
  14061. * @returns true if the geometry is ready to be used
  14062. */
  14063. isReady(): boolean;
  14064. /**
  14065. * Gets a value indicating that the geometry should not be serialized
  14066. */
  14067. readonly doNotSerialize: boolean;
  14068. /** @ignore */
  14069. _rebuild(): void;
  14070. /**
  14071. * Affects all gemetry data in one call
  14072. * @param vertexData defines the geometry data
  14073. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  14074. */
  14075. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  14076. /**
  14077. * Set specific vertex data
  14078. * @param kind defines the data kind (Position, normal, etc...)
  14079. * @param data defines the vertex data to use
  14080. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  14081. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  14082. */
  14083. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  14084. /**
  14085. * Removes a specific vertex data
  14086. * @param kind defines the data kind (Position, normal, etc...)
  14087. */
  14088. removeVerticesData(kind: string): void;
  14089. /**
  14090. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  14091. * @param buffer defines the vertex buffer to use
  14092. */
  14093. setVerticesBuffer(buffer: VertexBuffer): void;
  14094. /**
  14095. * Update a specific vertex buffer
  14096. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  14097. * It will do nothing if the buffer is not updatable
  14098. * @param kind defines the data kind (Position, normal, etc...)
  14099. * @param data defines the data to use
  14100. * @param offset defines the offset in the target buffer where to store the data
  14101. */
  14102. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  14103. /**
  14104. * Update a specific vertex buffer
  14105. * This function will create a new buffer if the current one is not updatable
  14106. * @param kind defines the data kind (Position, normal, etc...)
  14107. * @param data defines the data to use
  14108. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  14109. */
  14110. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  14111. private updateBoundingInfo(updateExtends, data);
  14112. /** @ignore */
  14113. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  14114. /**
  14115. * Gets total number of vertices
  14116. * @returns the total number of vertices
  14117. */
  14118. getTotalVertices(): number;
  14119. /**
  14120. * Gets a specific vertex data attached to this geometry
  14121. * @param kind defines the data kind (Position, normal, etc...)
  14122. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  14123. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14124. * @returns a float array containing vertex data
  14125. */
  14126. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14127. /**
  14128. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  14129. * @param kind defines the data kind (Position, normal, etc...)
  14130. * @returns true if the vertex buffer with the specified kind is updatable
  14131. */
  14132. isVertexBufferUpdatable(kind: string): boolean;
  14133. /**
  14134. * Gets a specific vertex buffer
  14135. * @param kind defines the data kind (Position, normal, etc...)
  14136. * @returns a {BABYLON.VertexBuffer}
  14137. */
  14138. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14139. /**
  14140. * Returns all vertex buffers
  14141. * @return an object holding all vertex buffers indexed by kind
  14142. */
  14143. getVertexBuffers(): Nullable<{
  14144. [key: string]: VertexBuffer;
  14145. }>;
  14146. /**
  14147. * Gets a boolean indicating if specific vertex buffer is present
  14148. * @param kind defines the data kind (Position, normal, etc...)
  14149. * @returns true if data is present
  14150. */
  14151. isVerticesDataPresent(kind: string): boolean;
  14152. /**
  14153. * Gets a list of all attached data kinds (Position, normal, etc...)
  14154. * @returns a list of string containing all kinds
  14155. */
  14156. getVerticesDataKinds(): string[];
  14157. /**
  14158. * Update index buffer
  14159. * @param indices defines the indices to store in the index buffer
  14160. * @param offset defines the offset in the target buffer where to store the data
  14161. */
  14162. updateIndices(indices: IndicesArray, offset?: number): void;
  14163. /**
  14164. * Creates a new index buffer
  14165. * @param indices defines the indices to store in the index buffer
  14166. * @param totalVertices defines the total number of vertices (could be null)
  14167. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  14168. */
  14169. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  14170. /**
  14171. * Return the total number of indices
  14172. * @returns the total number of indices
  14173. */
  14174. getTotalIndices(): number;
  14175. /**
  14176. * Gets the index buffer array
  14177. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  14178. * @returns the index buffer array
  14179. */
  14180. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  14181. /**
  14182. * Gets the index buffer
  14183. * @return the index buffer
  14184. */
  14185. getIndexBuffer(): Nullable<WebGLBuffer>;
  14186. /** @ignore */
  14187. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  14188. /**
  14189. * Release the associated resources for a specific mesh
  14190. * @param mesh defines the source mesh
  14191. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  14192. */
  14193. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  14194. /**
  14195. * Apply current geometry to a given mesh
  14196. * @param mesh defines the mesh to apply geometry to
  14197. */
  14198. applyToMesh(mesh: Mesh): void;
  14199. private updateExtend(data?, stride?);
  14200. private _applyToMesh(mesh);
  14201. private notifyUpdate(kind?);
  14202. /**
  14203. * Load the geometry if it was flagged as delay loaded
  14204. * @param scene defines the hosting scene
  14205. * @param onLoaded defines a callback called when the geometry is loaded
  14206. */
  14207. load(scene: Scene, onLoaded?: () => void): void;
  14208. private _queueLoad(scene, onLoaded?);
  14209. /**
  14210. * Invert the geometry to move from a right handed system to a left handed one.
  14211. */
  14212. toLeftHanded(): void;
  14213. /** @ignore */
  14214. _resetPointsArrayCache(): void;
  14215. /** @ignore */
  14216. _generatePointsArray(): boolean;
  14217. /**
  14218. * Gets a value indicating if the geometry is disposed
  14219. * @returns true if the geometry was disposed
  14220. */
  14221. isDisposed(): boolean;
  14222. private _disposeVertexArrayObjects();
  14223. /**
  14224. * Free all associated resources
  14225. */
  14226. dispose(): void;
  14227. /**
  14228. * Clone the current geometry into a new geometry
  14229. * @param id defines the unique ID of the new geometry
  14230. * @returns a new geometry object
  14231. */
  14232. copy(id: string): Geometry;
  14233. /**
  14234. * Serialize the current geometry info (and not the vertices data) into a JSON object
  14235. * @return a JSON representation of the current geometry data (without the vertices data)
  14236. */
  14237. serialize(): any;
  14238. private toNumberArray(origin);
  14239. /**
  14240. * Serialize all vertices data into a JSON oject
  14241. * @returns a JSON representation of the current geometry data
  14242. */
  14243. serializeVerticeData(): any;
  14244. /**
  14245. * Extracts a clone of a mesh geometry
  14246. * @param mesh defines the source mesh
  14247. * @param id defines the unique ID of the new geometry object
  14248. * @returns the new geometry object
  14249. */
  14250. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  14251. /**
  14252. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  14253. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  14254. * Be aware Math.random() could cause collisions, but:
  14255. * "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"
  14256. * @returns a string containing a new GUID
  14257. */
  14258. static RandomId(): string;
  14259. /** @ignore */
  14260. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  14261. private static _CleanMatricesWeights(parsedGeometry, mesh);
  14262. /**
  14263. * Create a new geometry from persisted data (Using .babylon file format)
  14264. * @param parsedVertexData defines the persisted data
  14265. * @param scene defines the hosting scene
  14266. * @param rootUrl defines the root url to use to load assets (like delayed data)
  14267. * @returns the new geometry object
  14268. */
  14269. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  14270. }
  14271. /**
  14272. * Abstract class used to provide common services for all typed geometries
  14273. */
  14274. class _PrimitiveGeometry extends Geometry {
  14275. private _canBeRegenerated;
  14276. private _beingRegenerated;
  14277. /**
  14278. * Creates a new typed geometry
  14279. * @param id defines the unique ID of the geometry
  14280. * @param scene defines the hosting scene
  14281. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14282. * @param mesh defines the hosting mesh (can be null)
  14283. */
  14284. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  14285. /**
  14286. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  14287. * @returns true if the geometry can be regenerated
  14288. */
  14289. canBeRegenerated(): boolean;
  14290. /**
  14291. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  14292. */
  14293. regenerate(): void;
  14294. /**
  14295. * Clone the geometry
  14296. * @param id defines the unique ID of the new geometry
  14297. * @returns the new geometry
  14298. */
  14299. asNewGeometry(id: string): Geometry;
  14300. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  14301. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  14302. /** @ignore */
  14303. _regenerateVertexData(): VertexData;
  14304. copy(id: string): Geometry;
  14305. serialize(): any;
  14306. }
  14307. /**
  14308. * Creates a ribbon geometry
  14309. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  14310. */
  14311. class RibbonGeometry extends _PrimitiveGeometry {
  14312. /**
  14313. * Defines the array of paths to use
  14314. */
  14315. pathArray: Vector3[][];
  14316. /**
  14317. * Defines if the last and first points of each path in your pathArray must be joined
  14318. */
  14319. closeArray: boolean;
  14320. /**
  14321. * Defines if the last and first points of each path in your pathArray must be joined
  14322. */
  14323. closePath: boolean;
  14324. /**
  14325. * Defines the offset between points
  14326. */
  14327. offset: number;
  14328. /**
  14329. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14330. */
  14331. side: number;
  14332. /**
  14333. * Creates a ribbon geometry
  14334. * @param id defines the unique ID of the geometry
  14335. * @param scene defines the hosting scene
  14336. * @param pathArray defines the array of paths to use
  14337. * @param closeArray defines if the last path and the first path must be joined
  14338. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  14339. * @param offset defines the offset between points
  14340. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14341. * @param mesh defines the hosting mesh (can be null)
  14342. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14343. */
  14344. constructor(id: string, scene: Scene,
  14345. /**
  14346. * Defines the array of paths to use
  14347. */
  14348. pathArray: Vector3[][],
  14349. /**
  14350. * Defines if the last and first points of each path in your pathArray must be joined
  14351. */
  14352. closeArray: boolean,
  14353. /**
  14354. * Defines if the last and first points of each path in your pathArray must be joined
  14355. */
  14356. closePath: boolean,
  14357. /**
  14358. * Defines the offset between points
  14359. */
  14360. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  14361. /**
  14362. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14363. */
  14364. side?: number);
  14365. /** @ignore */
  14366. _regenerateVertexData(): VertexData;
  14367. copy(id: string): Geometry;
  14368. }
  14369. /**
  14370. * Creates a box geometry
  14371. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  14372. */
  14373. class BoxGeometry extends _PrimitiveGeometry {
  14374. /**
  14375. * Defines the zise of the box (width, height and depth are the same)
  14376. */
  14377. size: number;
  14378. /**
  14379. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14380. */
  14381. side: number;
  14382. /**
  14383. * Creates a box geometry
  14384. * @param id defines the unique ID of the geometry
  14385. * @param scene defines the hosting scene
  14386. * @param size defines the zise of the box (width, height and depth are the same)
  14387. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14388. * @param mesh defines the hosting mesh (can be null)
  14389. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14390. */
  14391. constructor(id: string, scene: Scene,
  14392. /**
  14393. * Defines the zise of the box (width, height and depth are the same)
  14394. */
  14395. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14396. /**
  14397. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14398. */
  14399. side?: number);
  14400. _regenerateVertexData(): VertexData;
  14401. copy(id: string): Geometry;
  14402. serialize(): any;
  14403. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  14404. }
  14405. /**
  14406. * Creates a sphere geometry
  14407. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  14408. */
  14409. class SphereGeometry extends _PrimitiveGeometry {
  14410. /**
  14411. * Defines the number of segments to use to create the sphere
  14412. */
  14413. segments: number;
  14414. /**
  14415. * Defines the diameter of the sphere
  14416. */
  14417. diameter: number;
  14418. /**
  14419. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14420. */
  14421. side: number;
  14422. /**
  14423. * Create a new sphere geometry
  14424. * @param id defines the unique ID of the geometry
  14425. * @param scene defines the hosting scene
  14426. * @param segments defines the number of segments to use to create the sphere
  14427. * @param diameter defines the diameter of the sphere
  14428. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14429. * @param mesh defines the hosting mesh (can be null)
  14430. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14431. */
  14432. constructor(id: string, scene: Scene,
  14433. /**
  14434. * Defines the number of segments to use to create the sphere
  14435. */
  14436. segments: number,
  14437. /**
  14438. * Defines the diameter of the sphere
  14439. */
  14440. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14441. /**
  14442. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14443. */
  14444. side?: number);
  14445. _regenerateVertexData(): VertexData;
  14446. copy(id: string): Geometry;
  14447. serialize(): any;
  14448. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  14449. }
  14450. /**
  14451. * Creates a disc geometry
  14452. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  14453. */
  14454. class DiscGeometry extends _PrimitiveGeometry {
  14455. /**
  14456. * Defines the radius of the disc
  14457. */
  14458. radius: number;
  14459. /**
  14460. * Defines the tesselation factor to apply to the disc
  14461. */
  14462. tessellation: number;
  14463. /**
  14464. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14465. */
  14466. side: number;
  14467. /**
  14468. * Creates a new disc geometry
  14469. * @param id defines the unique ID of the geometry
  14470. * @param scene defines the hosting scene
  14471. * @param radius defines the radius of the disc
  14472. * @param tessellation defines the tesselation factor to apply to the disc
  14473. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14474. * @param mesh defines the hosting mesh (can be null)
  14475. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14476. */
  14477. constructor(id: string, scene: Scene,
  14478. /**
  14479. * Defines the radius of the disc
  14480. */
  14481. radius: number,
  14482. /**
  14483. * Defines the tesselation factor to apply to the disc
  14484. */
  14485. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14486. /**
  14487. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14488. */
  14489. side?: number);
  14490. _regenerateVertexData(): VertexData;
  14491. copy(id: string): Geometry;
  14492. }
  14493. /**
  14494. * Creates a new cylinder geometry
  14495. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  14496. */
  14497. class CylinderGeometry extends _PrimitiveGeometry {
  14498. /**
  14499. * Defines the height of the cylinder
  14500. */
  14501. height: number;
  14502. /**
  14503. * Defines the diameter of the cylinder's top cap
  14504. */
  14505. diameterTop: number;
  14506. /**
  14507. * Defines the diameter of the cylinder's bottom cap
  14508. */
  14509. diameterBottom: number;
  14510. /**
  14511. * Defines the tessellation factor to apply to the cylinder
  14512. */
  14513. tessellation: number;
  14514. /**
  14515. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  14516. */
  14517. subdivisions: number;
  14518. /**
  14519. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14520. */
  14521. side: number;
  14522. /**
  14523. * Creates a new cylinder geometry
  14524. * @param id defines the unique ID of the geometry
  14525. * @param scene defines the hosting scene
  14526. * @param height defines the height of the cylinder
  14527. * @param diameterTop defines the diameter of the cylinder's top cap
  14528. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  14529. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  14530. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  14531. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14532. * @param mesh defines the hosting mesh (can be null)
  14533. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14534. */
  14535. constructor(id: string, scene: Scene,
  14536. /**
  14537. * Defines the height of the cylinder
  14538. */
  14539. height: number,
  14540. /**
  14541. * Defines the diameter of the cylinder's top cap
  14542. */
  14543. diameterTop: number,
  14544. /**
  14545. * Defines the diameter of the cylinder's bottom cap
  14546. */
  14547. diameterBottom: number,
  14548. /**
  14549. * Defines the tessellation factor to apply to the cylinder
  14550. */
  14551. tessellation: number,
  14552. /**
  14553. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  14554. */
  14555. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14556. /**
  14557. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14558. */
  14559. side?: number);
  14560. _regenerateVertexData(): VertexData;
  14561. copy(id: string): Geometry;
  14562. serialize(): any;
  14563. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  14564. }
  14565. /**
  14566. * Creates a new torus geometry
  14567. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  14568. */
  14569. class TorusGeometry extends _PrimitiveGeometry {
  14570. /**
  14571. * Defines the diameter of the torus
  14572. */
  14573. diameter: number;
  14574. /**
  14575. * Defines the thickness of the torus (ie. internal diameter)
  14576. */
  14577. thickness: number;
  14578. /**
  14579. * Defines the tesselation factor to apply to the torus
  14580. */
  14581. tessellation: number;
  14582. /**
  14583. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14584. */
  14585. side: number;
  14586. /**
  14587. * Creates a new torus geometry
  14588. * @param id defines the unique ID of the geometry
  14589. * @param scene defines the hosting scene
  14590. * @param diameter defines the diameter of the torus
  14591. * @param thickness defines the thickness of the torus (ie. internal diameter)
  14592. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  14593. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14594. * @param mesh defines the hosting mesh (can be null)
  14595. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14596. */
  14597. constructor(id: string, scene: Scene,
  14598. /**
  14599. * Defines the diameter of the torus
  14600. */
  14601. diameter: number,
  14602. /**
  14603. * Defines the thickness of the torus (ie. internal diameter)
  14604. */
  14605. thickness: number,
  14606. /**
  14607. * Defines the tesselation factor to apply to the torus
  14608. */
  14609. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14610. /**
  14611. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14612. */
  14613. side?: number);
  14614. _regenerateVertexData(): VertexData;
  14615. copy(id: string): Geometry;
  14616. serialize(): any;
  14617. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  14618. }
  14619. /**
  14620. * Creates a new ground geometry
  14621. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  14622. */
  14623. class GroundGeometry extends _PrimitiveGeometry {
  14624. /**
  14625. * Defines the width of the ground
  14626. */
  14627. width: number;
  14628. /**
  14629. * Defines the height of the ground
  14630. */
  14631. height: number;
  14632. /**
  14633. * Defines the subdivisions to apply to the ground
  14634. */
  14635. subdivisions: number;
  14636. /**
  14637. * Creates a new ground geometry
  14638. * @param id defines the unique ID of the geometry
  14639. * @param scene defines the hosting scene
  14640. * @param width defines the width of the ground
  14641. * @param height defines the height of the ground
  14642. * @param subdivisions defines the subdivisions to apply to the ground
  14643. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14644. * @param mesh defines the hosting mesh (can be null)
  14645. */
  14646. constructor(id: string, scene: Scene,
  14647. /**
  14648. * Defines the width of the ground
  14649. */
  14650. width: number,
  14651. /**
  14652. * Defines the height of the ground
  14653. */
  14654. height: number,
  14655. /**
  14656. * Defines the subdivisions to apply to the ground
  14657. */
  14658. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  14659. _regenerateVertexData(): VertexData;
  14660. copy(id: string): Geometry;
  14661. serialize(): any;
  14662. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  14663. }
  14664. /**
  14665. * Creates a tiled ground geometry
  14666. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  14667. */
  14668. class TiledGroundGeometry extends _PrimitiveGeometry {
  14669. /**
  14670. * Defines the minimum value on X axis
  14671. */
  14672. xmin: number;
  14673. /**
  14674. * Defines the minimum value on Z axis
  14675. */
  14676. zmin: number;
  14677. /**
  14678. * Defines the maximum value on X axis
  14679. */
  14680. xmax: number;
  14681. /**
  14682. * Defines the maximum value on Z axis
  14683. */
  14684. zmax: number;
  14685. /**
  14686. * Defines the subdivisions to apply to the ground
  14687. */
  14688. subdivisions: {
  14689. w: number;
  14690. h: number;
  14691. };
  14692. /**
  14693. * Defines the precision to use when computing the tiles
  14694. */
  14695. precision: {
  14696. w: number;
  14697. h: number;
  14698. };
  14699. /**
  14700. * Creates a tiled ground geometry
  14701. * @param id defines the unique ID of the geometry
  14702. * @param scene defines the hosting scene
  14703. * @param xmin defines the minimum value on X axis
  14704. * @param zmin defines the minimum value on Z axis
  14705. * @param xmax defines the maximum value on X axis
  14706. * @param zmax defines the maximum value on Z axis
  14707. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  14708. * @param precision defines the precision to use when computing the tiles
  14709. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14710. * @param mesh defines the hosting mesh (can be null)
  14711. */
  14712. constructor(id: string, scene: Scene,
  14713. /**
  14714. * Defines the minimum value on X axis
  14715. */
  14716. xmin: number,
  14717. /**
  14718. * Defines the minimum value on Z axis
  14719. */
  14720. zmin: number,
  14721. /**
  14722. * Defines the maximum value on X axis
  14723. */
  14724. xmax: number,
  14725. /**
  14726. * Defines the maximum value on Z axis
  14727. */
  14728. zmax: number,
  14729. /**
  14730. * Defines the subdivisions to apply to the ground
  14731. */
  14732. subdivisions: {
  14733. w: number;
  14734. h: number;
  14735. },
  14736. /**
  14737. * Defines the precision to use when computing the tiles
  14738. */
  14739. precision: {
  14740. w: number;
  14741. h: number;
  14742. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  14743. _regenerateVertexData(): VertexData;
  14744. copy(id: string): Geometry;
  14745. }
  14746. /**
  14747. * Creates a plane geometry
  14748. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  14749. */
  14750. class PlaneGeometry extends _PrimitiveGeometry {
  14751. /**
  14752. * Defines the size of the plane (width === height)
  14753. */
  14754. size: number;
  14755. /**
  14756. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14757. */
  14758. side: number;
  14759. /**
  14760. * Creates a plane geometry
  14761. * @param id defines the unique ID of the geometry
  14762. * @param scene defines the hosting scene
  14763. * @param size defines the size of the plane (width === height)
  14764. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14765. * @param mesh defines the hosting mesh (can be null)
  14766. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14767. */
  14768. constructor(id: string, scene: Scene,
  14769. /**
  14770. * Defines the size of the plane (width === height)
  14771. */
  14772. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14773. /**
  14774. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14775. */
  14776. side?: number);
  14777. _regenerateVertexData(): VertexData;
  14778. copy(id: string): Geometry;
  14779. serialize(): any;
  14780. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  14781. }
  14782. /**
  14783. * Creates a torus knot geometry
  14784. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  14785. */
  14786. class TorusKnotGeometry extends _PrimitiveGeometry {
  14787. /**
  14788. * Defines the radius of the torus knot
  14789. */
  14790. radius: number;
  14791. /**
  14792. * Defines the thickness of the torus knot tube
  14793. */
  14794. tube: number;
  14795. /**
  14796. * Defines the number of radial segments
  14797. */
  14798. radialSegments: number;
  14799. /**
  14800. * Defines the number of tubular segments
  14801. */
  14802. tubularSegments: number;
  14803. /**
  14804. * Defines the first number of windings
  14805. */
  14806. p: number;
  14807. /**
  14808. * Defines the second number of windings
  14809. */
  14810. q: number;
  14811. /**
  14812. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14813. */
  14814. side: number;
  14815. /**
  14816. * Creates a torus knot geometry
  14817. * @param id defines the unique ID of the geometry
  14818. * @param scene defines the hosting scene
  14819. * @param radius defines the radius of the torus knot
  14820. * @param tube defines the thickness of the torus knot tube
  14821. * @param radialSegments defines the number of radial segments
  14822. * @param tubularSegments defines the number of tubular segments
  14823. * @param p defines the first number of windings
  14824. * @param q defines the second number of windings
  14825. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14826. * @param mesh defines the hosting mesh (can be null)
  14827. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14828. */
  14829. constructor(id: string, scene: Scene,
  14830. /**
  14831. * Defines the radius of the torus knot
  14832. */
  14833. radius: number,
  14834. /**
  14835. * Defines the thickness of the torus knot tube
  14836. */
  14837. tube: number,
  14838. /**
  14839. * Defines the number of radial segments
  14840. */
  14841. radialSegments: number,
  14842. /**
  14843. * Defines the number of tubular segments
  14844. */
  14845. tubularSegments: number,
  14846. /**
  14847. * Defines the first number of windings
  14848. */
  14849. p: number,
  14850. /**
  14851. * Defines the second number of windings
  14852. */
  14853. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14854. /**
  14855. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14856. */
  14857. side?: number);
  14858. _regenerateVertexData(): VertexData;
  14859. copy(id: string): Geometry;
  14860. serialize(): any;
  14861. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  14862. }
  14863. }
  14864. declare module BABYLON {
  14865. class GroundMesh extends Mesh {
  14866. generateOctree: boolean;
  14867. private _heightQuads;
  14868. _subdivisionsX: number;
  14869. _subdivisionsY: number;
  14870. _width: number;
  14871. _height: number;
  14872. _minX: number;
  14873. _maxX: number;
  14874. _minZ: number;
  14875. _maxZ: number;
  14876. constructor(name: string, scene: Scene);
  14877. getClassName(): string;
  14878. readonly subdivisions: number;
  14879. readonly subdivisionsX: number;
  14880. readonly subdivisionsY: number;
  14881. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  14882. /**
  14883. * Returns a height (y) value in the Worl system :
  14884. * the ground altitude at the coordinates (x, z) expressed in the World system.
  14885. * Returns the ground y position if (x, z) are outside the ground surface.
  14886. */
  14887. getHeightAtCoordinates(x: number, z: number): number;
  14888. /**
  14889. * Returns a normalized vector (Vector3) orthogonal to the ground
  14890. * at the ground coordinates (x, z) expressed in the World system.
  14891. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  14892. */
  14893. getNormalAtCoordinates(x: number, z: number): Vector3;
  14894. /**
  14895. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  14896. * at the ground coordinates (x, z) expressed in the World system.
  14897. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  14898. * Returns the GroundMesh.
  14899. */
  14900. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  14901. /**
  14902. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  14903. * if the ground has been updated.
  14904. * This can be used in the render loop.
  14905. * Returns the GroundMesh.
  14906. */
  14907. updateCoordinateHeights(): GroundMesh;
  14908. private _getFacetAt(x, z);
  14909. private _initHeightQuads();
  14910. private _computeHeightQuads();
  14911. serialize(serializationObject: any): void;
  14912. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  14913. }
  14914. }
  14915. declare module BABYLON {
  14916. /**
  14917. * Creates an instance based on a source mesh.
  14918. */
  14919. class InstancedMesh extends AbstractMesh {
  14920. private _sourceMesh;
  14921. private _currentLOD;
  14922. constructor(name: string, source: Mesh);
  14923. /**
  14924. * Returns the string "InstancedMesh".
  14925. */
  14926. getClassName(): string;
  14927. readonly receiveShadows: boolean;
  14928. readonly material: Nullable<Material>;
  14929. readonly visibility: number;
  14930. readonly skeleton: Nullable<Skeleton>;
  14931. renderingGroupId: number;
  14932. /**
  14933. * Returns the total number of vertices (integer).
  14934. */
  14935. getTotalVertices(): number;
  14936. readonly sourceMesh: Mesh;
  14937. /**
  14938. * Is this node ready to be used/rendered
  14939. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14940. * @return {boolean} is it ready
  14941. */
  14942. isReady(completeCheck?: boolean): boolean;
  14943. /**
  14944. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  14945. */
  14946. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  14947. /**
  14948. * Sets the vertex data of the mesh geometry for the requested `kind`.
  14949. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  14950. * The `data` are either a numeric array either a Float32Array.
  14951. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  14952. * 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).
  14953. * Note that a new underlying VertexBuffer object is created each call.
  14954. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  14955. *
  14956. * Possible `kind` values :
  14957. * - BABYLON.VertexBuffer.PositionKind
  14958. * - BABYLON.VertexBuffer.UVKind
  14959. * - BABYLON.VertexBuffer.UV2Kind
  14960. * - BABYLON.VertexBuffer.UV3Kind
  14961. * - BABYLON.VertexBuffer.UV4Kind
  14962. * - BABYLON.VertexBuffer.UV5Kind
  14963. * - BABYLON.VertexBuffer.UV6Kind
  14964. * - BABYLON.VertexBuffer.ColorKind
  14965. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14966. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14967. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14968. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14969. *
  14970. * Returns the Mesh.
  14971. */
  14972. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14973. /**
  14974. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  14975. * If the mesh has no geometry, it is simply returned as it is.
  14976. * The `data` are either a numeric array either a Float32Array.
  14977. * No new underlying VertexBuffer object is created.
  14978. * 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.
  14979. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  14980. *
  14981. * Possible `kind` values :
  14982. * - BABYLON.VertexBuffer.PositionKind
  14983. * - BABYLON.VertexBuffer.UVKind
  14984. * - BABYLON.VertexBuffer.UV2Kind
  14985. * - BABYLON.VertexBuffer.UV3Kind
  14986. * - BABYLON.VertexBuffer.UV4Kind
  14987. * - BABYLON.VertexBuffer.UV5Kind
  14988. * - BABYLON.VertexBuffer.UV6Kind
  14989. * - BABYLON.VertexBuffer.ColorKind
  14990. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14991. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14992. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14993. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14994. *
  14995. * Returns the Mesh.
  14996. */
  14997. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14998. /**
  14999. * Sets the mesh indices.
  15000. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15001. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15002. * This method creates a new index buffer each call.
  15003. * Returns the Mesh.
  15004. */
  15005. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15006. /**
  15007. * Boolean : True if the mesh owns the requested kind of data.
  15008. */
  15009. isVerticesDataPresent(kind: string): boolean;
  15010. /**
  15011. * Returns an array of indices (IndicesArray).
  15012. */
  15013. getIndices(): Nullable<IndicesArray>;
  15014. readonly _positions: Nullable<Vector3[]>;
  15015. /**
  15016. * Sets a new updated BoundingInfo to the mesh.
  15017. * Returns the mesh.
  15018. */
  15019. refreshBoundingInfo(): InstancedMesh;
  15020. _preActivate(): InstancedMesh;
  15021. _activate(renderId: number): InstancedMesh;
  15022. /**
  15023. * Returns the current associated LOD AbstractMesh.
  15024. */
  15025. getLOD(camera: Camera): AbstractMesh;
  15026. _syncSubMeshes(): InstancedMesh;
  15027. _generatePointsArray(): boolean;
  15028. /**
  15029. * Creates a new InstancedMesh from the current mesh.
  15030. * - name (string) : the cloned mesh name
  15031. * - newParent (optional Node) : the optional Node to parent the clone to.
  15032. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15033. *
  15034. * Returns the clone.
  15035. */
  15036. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  15037. /**
  15038. * Disposes the InstancedMesh.
  15039. * Returns nothing.
  15040. */
  15041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15042. }
  15043. }
  15044. declare module BABYLON {
  15045. class LinesMesh extends Mesh {
  15046. useVertexColor: boolean | undefined;
  15047. useVertexAlpha: boolean | undefined;
  15048. color: Color3;
  15049. alpha: number;
  15050. /**
  15051. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15052. * This margin is expressed in world space coordinates, so its value may vary.
  15053. * Default value is 0.1
  15054. * @returns the intersection Threshold value.
  15055. */
  15056. /**
  15057. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15058. * This margin is expressed in world space coordinates, so its value may vary.
  15059. * @param value the new threshold to apply
  15060. */
  15061. intersectionThreshold: number;
  15062. private _intersectionThreshold;
  15063. private _colorShader;
  15064. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  15065. /**
  15066. * Returns the string "LineMesh"
  15067. */
  15068. getClassName(): string;
  15069. material: Material;
  15070. readonly checkCollisions: boolean;
  15071. createInstance(name: string): InstancedMesh;
  15072. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  15073. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  15074. dispose(doNotRecurse?: boolean): void;
  15075. /**
  15076. * Returns a new LineMesh object cloned from the current one.
  15077. */
  15078. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  15079. }
  15080. }
  15081. declare module BABYLON {
  15082. class _InstancesBatch {
  15083. mustReturn: boolean;
  15084. visibleInstances: Nullable<InstancedMesh[]>[];
  15085. renderSelf: boolean[];
  15086. }
  15087. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  15088. static _FRONTSIDE: number;
  15089. static _BACKSIDE: number;
  15090. static _DOUBLESIDE: number;
  15091. static _DEFAULTSIDE: number;
  15092. static _NO_CAP: number;
  15093. static _CAP_START: number;
  15094. static _CAP_END: number;
  15095. static _CAP_ALL: number;
  15096. /**
  15097. * Mesh side orientation : usually the external or front surface
  15098. */
  15099. static readonly FRONTSIDE: number;
  15100. /**
  15101. * Mesh side orientation : usually the internal or back surface
  15102. */
  15103. static readonly BACKSIDE: number;
  15104. /**
  15105. * Mesh side orientation : both internal and external or front and back surfaces
  15106. */
  15107. static readonly DOUBLESIDE: number;
  15108. /**
  15109. * Mesh side orientation : by default, `FRONTSIDE`
  15110. */
  15111. static readonly DEFAULTSIDE: number;
  15112. /**
  15113. * Mesh cap setting : no cap
  15114. */
  15115. static readonly NO_CAP: number;
  15116. /**
  15117. * Mesh cap setting : one cap at the beginning of the mesh
  15118. */
  15119. static readonly CAP_START: number;
  15120. /**
  15121. * Mesh cap setting : one cap at the end of the mesh
  15122. */
  15123. static readonly CAP_END: number;
  15124. /**
  15125. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  15126. */
  15127. static readonly CAP_ALL: number;
  15128. /**
  15129. * An event triggered before rendering the mesh
  15130. * @type {BABYLON.Observable}
  15131. */
  15132. onBeforeRenderObservable: Observable<Mesh>;
  15133. /**
  15134. * An event triggered after rendering the mesh
  15135. * @type {BABYLON.Observable}
  15136. */
  15137. onAfterRenderObservable: Observable<Mesh>;
  15138. /**
  15139. * An event triggered before drawing the mesh
  15140. * @type {BABYLON.Observable}
  15141. */
  15142. onBeforeDrawObservable: Observable<Mesh>;
  15143. private _onBeforeDrawObserver;
  15144. onBeforeDraw: () => void;
  15145. delayLoadState: number;
  15146. instances: InstancedMesh[];
  15147. delayLoadingFile: string;
  15148. _binaryInfo: any;
  15149. private _LODLevels;
  15150. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  15151. private _morphTargetManager;
  15152. morphTargetManager: Nullable<MorphTargetManager>;
  15153. _geometry: Nullable<Geometry>;
  15154. _delayInfo: Array<string>;
  15155. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  15156. _visibleInstances: any;
  15157. private _renderIdForInstances;
  15158. private _batchCache;
  15159. private _instancesBufferSize;
  15160. private _instancesBuffer;
  15161. private _instancesData;
  15162. private _overridenInstanceCount;
  15163. private _effectiveMaterial;
  15164. _shouldGenerateFlatShading: boolean;
  15165. private _preActivateId;
  15166. _originalBuilderSideOrientation: number;
  15167. overrideMaterialSideOrientation: Nullable<number>;
  15168. private _areNormalsFrozen;
  15169. private _sourcePositions;
  15170. private _sourceNormals;
  15171. private _source;
  15172. readonly source: Nullable<Mesh>;
  15173. isUnIndexed: boolean;
  15174. /**
  15175. * @constructor
  15176. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  15177. * @param {Scene} scene The scene to add this mesh to.
  15178. * @param {Node} parent The parent of this mesh, if it has one
  15179. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  15180. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15181. * When false, achieved by calling a clone(), also passing False.
  15182. * This will make creation of children, recursive.
  15183. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  15184. */
  15185. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  15186. /**
  15187. * Returns the string "Mesh".
  15188. */
  15189. getClassName(): string;
  15190. /**
  15191. * Returns a string.
  15192. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  15193. */
  15194. toString(fullDetails?: boolean): string;
  15195. /**
  15196. * True if the mesh has some Levels Of Details (LOD).
  15197. * Returns a boolean.
  15198. */
  15199. readonly hasLODLevels: boolean;
  15200. /**
  15201. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  15202. * @returns an array of {BABYLON.MeshLODLevel}
  15203. */
  15204. getLODLevels(): MeshLODLevel[];
  15205. private _sortLODLevels();
  15206. /**
  15207. * Add a mesh as LOD level triggered at the given distance.
  15208. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  15209. * @param {number} distance The distance from the center of the object to show this level
  15210. * @param {Mesh} mesh The mesh to be added as LOD level
  15211. * @return {Mesh} This mesh (for chaining)
  15212. */
  15213. addLODLevel(distance: number, mesh: Mesh): Mesh;
  15214. /**
  15215. * Returns the LOD level mesh at the passed distance or null if not found.
  15216. * It is related to the method `addLODLevel(distance, mesh)`.
  15217. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  15218. * Returns an object Mesh or `null`.
  15219. */
  15220. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  15221. /**
  15222. * Remove a mesh from the LOD array
  15223. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  15224. * @param {Mesh} mesh The mesh to be removed.
  15225. * @return {Mesh} This mesh (for chaining)
  15226. */
  15227. removeLODLevel(mesh: Mesh): Mesh;
  15228. /**
  15229. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  15230. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  15231. */
  15232. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  15233. /**
  15234. * Returns the mesh internal Geometry object.
  15235. */
  15236. readonly geometry: Nullable<Geometry>;
  15237. /**
  15238. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  15239. */
  15240. getTotalVertices(): number;
  15241. /**
  15242. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  15243. * 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.
  15244. * You can force the copy with forceCopy === true
  15245. * Returns null if the mesh has no geometry or no vertex buffer.
  15246. * Possible `kind` values :
  15247. * - BABYLON.VertexBuffer.PositionKind
  15248. * - BABYLON.VertexBuffer.UVKind
  15249. * - BABYLON.VertexBuffer.UV2Kind
  15250. * - BABYLON.VertexBuffer.UV3Kind
  15251. * - BABYLON.VertexBuffer.UV4Kind
  15252. * - BABYLON.VertexBuffer.UV5Kind
  15253. * - BABYLON.VertexBuffer.UV6Kind
  15254. * - BABYLON.VertexBuffer.ColorKind
  15255. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15256. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15257. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15258. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15259. */
  15260. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  15261. /**
  15262. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  15263. * Returns `null` if the mesh has no geometry.
  15264. * Possible `kind` values :
  15265. * - BABYLON.VertexBuffer.PositionKind
  15266. * - BABYLON.VertexBuffer.UVKind
  15267. * - BABYLON.VertexBuffer.UV2Kind
  15268. * - BABYLON.VertexBuffer.UV3Kind
  15269. * - BABYLON.VertexBuffer.UV4Kind
  15270. * - BABYLON.VertexBuffer.UV5Kind
  15271. * - BABYLON.VertexBuffer.UV6Kind
  15272. * - BABYLON.VertexBuffer.ColorKind
  15273. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15274. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15275. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15276. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15277. */
  15278. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  15279. /**
  15280. * Returns a boolean depending on the existence of the Vertex Data for the requested `kind`.
  15281. * Possible `kind` values :
  15282. * - BABYLON.VertexBuffer.PositionKind
  15283. * - BABYLON.VertexBuffer.UVKind
  15284. * - BABYLON.VertexBuffer.UV2Kind
  15285. * - BABYLON.VertexBuffer.UV3Kind
  15286. * - BABYLON.VertexBuffer.UV4Kind
  15287. * - BABYLON.VertexBuffer.UV5Kind
  15288. * - BABYLON.VertexBuffer.UV6Kind
  15289. * - BABYLON.VertexBuffer.ColorKind
  15290. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15291. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15292. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15293. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15294. */
  15295. isVerticesDataPresent(kind: string): boolean;
  15296. /**
  15297. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  15298. * Possible `kind` values :
  15299. * - BABYLON.VertexBuffer.PositionKind
  15300. * - BABYLON.VertexBuffer.UVKind
  15301. * - BABYLON.VertexBuffer.UV2Kind
  15302. * - BABYLON.VertexBuffer.UV3Kind
  15303. * - BABYLON.VertexBuffer.UV4Kind
  15304. * - BABYLON.VertexBuffer.UV5Kind
  15305. * - BABYLON.VertexBuffer.UV6Kind
  15306. * - BABYLON.VertexBuffer.ColorKind
  15307. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15308. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15309. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15310. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15311. */
  15312. isVertexBufferUpdatable(kind: string): boolean;
  15313. /**
  15314. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  15315. * Possible `kind` values :
  15316. * - BABYLON.VertexBuffer.PositionKind
  15317. * - BABYLON.VertexBuffer.UVKind
  15318. * - BABYLON.VertexBuffer.UV2Kind
  15319. * - BABYLON.VertexBuffer.UV3Kind
  15320. * - BABYLON.VertexBuffer.UV4Kind
  15321. * - BABYLON.VertexBuffer.UV5Kind
  15322. * - BABYLON.VertexBuffer.UV6Kind
  15323. * - BABYLON.VertexBuffer.ColorKind
  15324. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15325. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15326. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15327. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15328. */
  15329. getVerticesDataKinds(): string[];
  15330. /**
  15331. * Returns a positive integer : the total number of indices in this mesh geometry.
  15332. * Returns zero if the mesh has no geometry.
  15333. */
  15334. getTotalIndices(): number;
  15335. /**
  15336. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15337. * 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.
  15338. * Returns an empty array if the mesh has no geometry.
  15339. */
  15340. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  15341. readonly isBlocked: boolean;
  15342. /**
  15343. * Determine if the current mesh is ready to be rendered
  15344. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15345. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  15346. * @returns true if all associated assets are ready (material, textures, shaders)
  15347. */
  15348. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  15349. /**
  15350. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  15351. * This property is pertinent only for updatable parametric shapes.
  15352. */
  15353. readonly areNormalsFrozen: boolean;
  15354. /**
  15355. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  15356. * It has no effect at all on other shapes.
  15357. * It prevents the mesh normals from being recomputed on next `positions` array update.
  15358. * Returns the Mesh.
  15359. */
  15360. freezeNormals(): Mesh;
  15361. /**
  15362. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  15363. * It has no effect at all on other shapes.
  15364. * It reactivates the mesh normals computation if it was previously frozen.
  15365. * Returns the Mesh.
  15366. */
  15367. unfreezeNormals(): Mesh;
  15368. /**
  15369. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  15370. */
  15371. overridenInstanceCount: number;
  15372. _preActivate(): Mesh;
  15373. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15374. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  15375. /**
  15376. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15377. * This means the mesh underlying bounding box and sphere are recomputed.
  15378. * Returns the Mesh.
  15379. */
  15380. refreshBoundingInfo(): Mesh;
  15381. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  15382. private _getPositionData(applySkeleton);
  15383. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  15384. subdivide(count: number): void;
  15385. /**
  15386. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15387. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15388. * The `data` are either a numeric array either a Float32Array.
  15389. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15390. * 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).
  15391. * Note that a new underlying VertexBuffer object is created each call.
  15392. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15393. *
  15394. * Possible `kind` values :
  15395. * - BABYLON.VertexBuffer.PositionKind
  15396. * - BABYLON.VertexBuffer.UVKind
  15397. * - BABYLON.VertexBuffer.UV2Kind
  15398. * - BABYLON.VertexBuffer.UV3Kind
  15399. * - BABYLON.VertexBuffer.UV4Kind
  15400. * - BABYLON.VertexBuffer.UV5Kind
  15401. * - BABYLON.VertexBuffer.UV6Kind
  15402. * - BABYLON.VertexBuffer.ColorKind
  15403. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15404. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15405. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15406. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15407. *
  15408. * Returns the Mesh.
  15409. */
  15410. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  15411. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  15412. /**
  15413. * Sets the mesh VertexBuffer.
  15414. * Returns the Mesh.
  15415. */
  15416. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  15417. /**
  15418. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15419. * If the mesh has no geometry, it is simply returned as it is.
  15420. * The `data` are either a numeric array either a Float32Array.
  15421. * No new underlying VertexBuffer object is created.
  15422. * 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.
  15423. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15424. *
  15425. * Possible `kind` values :
  15426. * - BABYLON.VertexBuffer.PositionKind
  15427. * - BABYLON.VertexBuffer.UVKind
  15428. * - BABYLON.VertexBuffer.UV2Kind
  15429. * - BABYLON.VertexBuffer.UV3Kind
  15430. * - BABYLON.VertexBuffer.UV4Kind
  15431. * - BABYLON.VertexBuffer.UV5Kind
  15432. * - BABYLON.VertexBuffer.UV6Kind
  15433. * - BABYLON.VertexBuffer.ColorKind
  15434. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15435. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15436. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15437. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15438. *
  15439. * Returns the Mesh.
  15440. */
  15441. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15442. /**
  15443. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  15444. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  15445. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  15446. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  15447. * Returns the Mesh.
  15448. */
  15449. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  15450. /**
  15451. * Creates a un-shared specific occurence of the geometry for the mesh.
  15452. * Returns the Mesh.
  15453. */
  15454. makeGeometryUnique(): Mesh;
  15455. /**
  15456. * Sets the mesh indices.
  15457. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15458. * Type is Uint16Array by default unless the mesh has more than 65536 vertices.
  15459. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15460. * This method creates a new index buffer each call.
  15461. * Returns the Mesh.
  15462. */
  15463. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  15464. /**
  15465. * Update the current index buffer
  15466. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  15467. * Returns the Mesh.
  15468. */
  15469. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  15470. /**
  15471. * Invert the geometry to move from a right handed system to a left handed one.
  15472. * Returns the Mesh.
  15473. */
  15474. toLeftHanded(): Mesh;
  15475. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15476. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  15477. /**
  15478. * Registers for this mesh a javascript function called just before the rendering process.
  15479. * This function is passed the current mesh.
  15480. * Return the Mesh.
  15481. */
  15482. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  15483. /**
  15484. * Disposes a previously registered javascript function called before the rendering.
  15485. * This function is passed the current mesh.
  15486. * Returns the Mesh.
  15487. */
  15488. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  15489. /**
  15490. * Registers for this mesh a javascript function called just after the rendering is complete.
  15491. * This function is passed the current mesh.
  15492. * Returns the Mesh.
  15493. */
  15494. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  15495. /**
  15496. * Disposes a previously registered javascript function called after the rendering.
  15497. * This function is passed the current mesh.
  15498. * Return the Mesh.
  15499. */
  15500. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  15501. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  15502. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  15503. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  15504. /**
  15505. * Triggers the draw call for the mesh.
  15506. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  15507. * Returns the Mesh.
  15508. */
  15509. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  15510. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  15511. /**
  15512. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  15513. */
  15514. getEmittedParticleSystems(): IParticleSystem[];
  15515. /**
  15516. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  15517. */
  15518. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  15519. _checkDelayState(): Mesh;
  15520. private _queueLoad(scene);
  15521. /**
  15522. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  15523. */
  15524. isInFrustum(frustumPlanes: Plane[]): boolean;
  15525. /**
  15526. * Sets the mesh material by the material or multiMaterial `id` property.
  15527. * The material `id` is a string identifying the material or the multiMaterial.
  15528. * This method returns the Mesh.
  15529. */
  15530. setMaterialByID(id: string): Mesh;
  15531. /**
  15532. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  15533. */
  15534. getAnimatables(): IAnimatable[];
  15535. /**
  15536. * Modifies the mesh geometry according to the passed transformation matrix.
  15537. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  15538. * The mesh normals are modified accordingly the same transformation.
  15539. * tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  15540. * Note that, under the hood, this method sets a new VertexBuffer each call.
  15541. * Returns the Mesh.
  15542. */
  15543. bakeTransformIntoVertices(transform: Matrix): Mesh;
  15544. /**
  15545. * Modifies the mesh geometry according to its own current World Matrix.
  15546. * The mesh World Matrix is then reset.
  15547. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  15548. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  15549. * Note that, under the hood, this method sets a new VertexBuffer each call.
  15550. * Returns the Mesh.
  15551. */
  15552. bakeCurrentTransformIntoVertices(): Mesh;
  15553. readonly _positions: Nullable<Vector3[]>;
  15554. _resetPointsArrayCache(): Mesh;
  15555. _generatePointsArray(): boolean;
  15556. /**
  15557. * Returns a new Mesh object generated from the current mesh properties.
  15558. * This method must not get confused with createInstance().
  15559. * The parameter `name` is a string, the name given to the new mesh.
  15560. * The optional parameter `newParent` can be any Node object (default `null`).
  15561. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  15562. * 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.
  15563. */
  15564. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  15565. /**
  15566. * Releases resources associated with this mesh.
  15567. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15568. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15569. */
  15570. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15571. /**
  15572. * Modifies the mesh geometry according to a displacement map.
  15573. * 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.
  15574. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  15575. * This method returns nothing.
  15576. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  15577. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  15578. * 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.
  15579. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  15580. * The parameter `uvScale` is an optional vector2 used to scale UV.
  15581. *
  15582. * Returns the Mesh.
  15583. */
  15584. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  15585. /**
  15586. * Modifies the mesh geometry according to a displacementMap buffer.
  15587. * 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.
  15588. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  15589. * This method returns nothing.
  15590. * 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.
  15591. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  15592. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  15593. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  15594. * The parameter `uvScale` is an optional vector2 used to scale UV.
  15595. *
  15596. * Returns the Mesh.
  15597. */
  15598. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  15599. /**
  15600. * Modify the mesh to get a flat shading rendering.
  15601. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  15602. * This method returns the Mesh.
  15603. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  15604. */
  15605. convertToFlatShadedMesh(): Mesh;
  15606. /**
  15607. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  15608. * In other words, more vertices, no more indices and a single bigger VBO.
  15609. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  15610. * Returns the Mesh.
  15611. */
  15612. convertToUnIndexedMesh(): Mesh;
  15613. /**
  15614. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  15615. * This method returns the Mesh.
  15616. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  15617. */
  15618. flipFaces(flipNormals?: boolean): Mesh;
  15619. /**
  15620. * Creates a new InstancedMesh object from the mesh model.
  15621. * An instance shares the same properties and the same material than its model.
  15622. * Only these properties of each instance can then be set individually :
  15623. * - position
  15624. * - rotation
  15625. * - rotationQuaternion
  15626. * - setPivotMatrix
  15627. * - scaling
  15628. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  15629. * Warning : this method is not supported for Line mesh and LineSystem
  15630. */
  15631. createInstance(name: string): InstancedMesh;
  15632. /**
  15633. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  15634. * After this call, all the mesh instances have the same submeshes than the current mesh.
  15635. * This method returns the Mesh.
  15636. */
  15637. synchronizeInstances(): Mesh;
  15638. /**
  15639. * Simplify the mesh according to the given array of settings.
  15640. * Function will return immediately and will simplify async. It returns the Mesh.
  15641. * @param settings a collection of simplification settings.
  15642. * @param parallelProcessing should all levels calculate parallel or one after the other.
  15643. * @param type the type of simplification to run.
  15644. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  15645. */
  15646. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  15647. /**
  15648. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  15649. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  15650. * This should be used together with the simplification to avoid disappearing triangles.
  15651. * Returns the Mesh.
  15652. * @param successCallback an optional success callback to be called after the optimization finished.
  15653. */
  15654. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  15655. serialize(serializationObject: any): void;
  15656. _syncGeometryWithMorphTargetManager(): void;
  15657. /**
  15658. * Returns a new Mesh object parsed from the source provided.
  15659. * The parameter `parsedMesh` is the source.
  15660. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15661. */
  15662. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  15663. /**
  15664. * Creates a ribbon mesh.
  15665. * Please consider using the same method from the MeshBuilder class instead.
  15666. * 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.
  15667. *
  15668. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  15669. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  15670. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  15671. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  15672. * 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.
  15673. * 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.
  15674. * 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
  15675. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15676. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15677. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15678. */
  15679. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15680. /**
  15681. * Creates a plane polygonal mesh. By default, this is a disc.
  15682. * Please consider using the same method from the MeshBuilder class instead.
  15683. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  15684. * 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.
  15685. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15686. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15687. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15688. */
  15689. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  15690. /**
  15691. * Creates a box mesh.
  15692. * Please consider using the same method from the MeshBuilder class instead.
  15693. * The parameter `size` sets the size (float) of each box side (default 1).
  15694. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15695. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15696. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15697. */
  15698. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  15699. /**
  15700. * Creates a sphere mesh.
  15701. * Please consider using the same method from the MeshBuilder class instead.
  15702. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  15703. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  15704. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15705. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15706. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15707. */
  15708. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15709. /**
  15710. * Creates a cylinder or a cone mesh.
  15711. * Please consider using the same method from the MeshBuilder class instead.
  15712. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  15713. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  15714. * 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.
  15715. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  15716. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  15717. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15718. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15719. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15720. */
  15721. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  15722. /**
  15723. * Creates a torus mesh.
  15724. * Please consider using the same method from the MeshBuilder class instead.
  15725. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  15726. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  15727. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  15728. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15729. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15730. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15731. */
  15732. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15733. /**
  15734. * Creates a torus knot mesh.
  15735. * Please consider using the same method from the MeshBuilder class instead.
  15736. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  15737. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  15738. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  15739. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  15740. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15741. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15742. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15743. */
  15744. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15745. /**
  15746. * Creates a line mesh.
  15747. * Please consider using the same method from the MeshBuilder class instead.
  15748. * 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.
  15749. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  15750. * The parameter `points` is an array successive Vector3.
  15751. * 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
  15752. * When updating an instance, remember that only point positions can change, not the number of points.
  15753. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15754. */
  15755. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  15756. /**
  15757. * Creates a dashed line mesh.
  15758. * Please consider using the same method from the MeshBuilder class instead.
  15759. * 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.
  15760. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  15761. * The parameter `points` is an array successive Vector3.
  15762. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  15763. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  15764. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  15765. * 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
  15766. * When updating an instance, remember that only point positions can change, not the number of points.
  15767. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15768. */
  15769. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  15770. /**
  15771. * Creates a polygon mesh.
  15772. * Please consider using the same method from the MeshBuilder class instead.
  15773. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  15774. * 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.
  15775. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15776. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15777. * Remember you can only change the shape positions, not their number when updating a polygon.
  15778. */
  15779. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  15780. /**
  15781. * Creates an extruded polygon mesh, with depth in the Y direction.
  15782. * Please consider using the same method from the MeshBuilder class instead.
  15783. */
  15784. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  15785. /**
  15786. * Creates an extruded shape mesh.
  15787. * 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.
  15788. * Please consider using the same method from the MeshBuilder class instead.
  15789. *
  15790. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  15791. * 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
  15792. * extruded along the Z axis.
  15793. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  15794. * 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.
  15795. * The parameter `scale` (float, default 1) is the value to scale the shape.
  15796. * 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
  15797. * 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
  15798. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  15799. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15800. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15801. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15802. */
  15803. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15804. /**
  15805. * Creates an custom extruded shape mesh.
  15806. * 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.
  15807. * Please consider using the same method from the MeshBuilder class instead.
  15808. *
  15809. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  15810. * 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
  15811. * extruded along the Z axis.
  15812. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  15813. * 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
  15814. * and the distance of this point from the begining of the path :
  15815. * ```javascript
  15816. * var rotationFunction = function(i, distance) {
  15817. * // do things
  15818. * return rotationValue; }
  15819. * ```
  15820. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  15821. * 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
  15822. * and the distance of this point from the begining of the path :
  15823. * ```javascript
  15824. * var scaleFunction = function(i, distance) {
  15825. * // do things
  15826. * return scaleValue;}
  15827. * ```
  15828. * It must returns a float value that will be the scale value applied to the shape on each path point.
  15829. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  15830. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  15831. * 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
  15832. * 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
  15833. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  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 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;
  15839. /**
  15840. * Creates lathe mesh.
  15841. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15842. * Please consider using the same method from the MeshBuilder class instead.
  15843. * 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
  15844. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  15845. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  15846. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  15847. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15848. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15849. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15850. */
  15851. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15852. /**
  15853. * Creates a plane mesh.
  15854. * Please consider using the same method from the MeshBuilder class instead.
  15855. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  15856. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15857. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15858. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15859. */
  15860. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15861. /**
  15862. * Creates a ground mesh.
  15863. * Please consider using the same method from the MeshBuilder class instead.
  15864. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  15865. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  15866. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15867. */
  15868. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15869. /**
  15870. * Creates a tiled ground mesh.
  15871. * Please consider using the same method from the MeshBuilder class instead.
  15872. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  15873. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  15874. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  15875. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  15876. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  15877. * numbers of subdivisions on the ground width and height of each tile.
  15878. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15879. */
  15880. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15881. w: number;
  15882. h: number;
  15883. }, precision: {
  15884. w: number;
  15885. h: number;
  15886. }, scene: Scene, updatable?: boolean): Mesh;
  15887. /**
  15888. * Creates a ground mesh from a height map.
  15889. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  15890. * Please consider using the same method from the MeshBuilder class instead.
  15891. * The parameter `url` sets the URL of the height map image resource.
  15892. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  15893. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  15894. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  15895. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  15896. * 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).
  15897. * This function is passed the newly built mesh :
  15898. * ```javascript
  15899. * function(mesh) { // do things
  15900. * return; }
  15901. * ```
  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 CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void): GroundMesh;
  15905. /**
  15906. * Creates a tube mesh.
  15907. * 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.
  15908. * Please consider using the same method from the MeshBuilder class instead.
  15909. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  15910. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  15911. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  15912. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  15913. * 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.
  15914. * It must return a radius value (positive float) :
  15915. * ```javascript
  15916. * var radiusFunction = function(i, distance) {
  15917. * // do things
  15918. * return radius; }
  15919. * ```
  15920. * 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
  15921. * 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
  15922. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15923. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15924. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15925. */
  15926. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15927. (i: number, distance: number): number;
  15928. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15929. /**
  15930. * Creates a polyhedron mesh.
  15931. * Please consider using the same method from the MeshBuilder class instead.
  15932. * 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
  15933. * to choose the wanted type.
  15934. * The parameter `size` (positive float, default 1) sets the polygon size.
  15935. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  15936. * 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`.
  15937. * 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
  15938. * 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)`).
  15939. * 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
  15940. * 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.
  15941. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15942. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15943. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15944. */
  15945. static CreatePolyhedron(name: string, options: {
  15946. type?: number;
  15947. size?: number;
  15948. sizeX?: number;
  15949. sizeY?: number;
  15950. sizeZ?: number;
  15951. custom?: any;
  15952. faceUV?: Vector4[];
  15953. faceColors?: Color4[];
  15954. updatable?: boolean;
  15955. sideOrientation?: number;
  15956. }, scene: Scene): Mesh;
  15957. /**
  15958. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  15959. * Please consider using the same method from the MeshBuilder class instead.
  15960. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  15961. * 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`).
  15962. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  15963. * 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.
  15964. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15965. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15966. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15967. */
  15968. static CreateIcoSphere(name: string, options: {
  15969. radius?: number;
  15970. flat?: boolean;
  15971. subdivisions?: number;
  15972. sideOrientation?: number;
  15973. updatable?: boolean;
  15974. }, scene: Scene): Mesh;
  15975. /**
  15976. * Creates a decal mesh.
  15977. * Please consider using the same method from the MeshBuilder class instead.
  15978. * 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.
  15979. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  15980. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  15981. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  15982. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  15983. */
  15984. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15985. /**
  15986. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15987. */
  15988. setPositionsForCPUSkinning(): Float32Array;
  15989. /**
  15990. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15991. */
  15992. setNormalsForCPUSkinning(): Float32Array;
  15993. /**
  15994. * Updates the vertex buffer by applying transformation from the bones.
  15995. * Returns the Mesh.
  15996. *
  15997. * @param {skeleton} skeleton to apply
  15998. */
  15999. applySkeleton(skeleton: Skeleton): Mesh;
  16000. /**
  16001. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  16002. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  16003. */
  16004. static MinMax(meshes: AbstractMesh[]): {
  16005. min: Vector3;
  16006. max: Vector3;
  16007. };
  16008. /**
  16009. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  16010. */
  16011. static Center(meshesOrMinMaxVector: {
  16012. min: Vector3;
  16013. max: Vector3;
  16014. } | AbstractMesh[]): Vector3;
  16015. /**
  16016. * Merge the array of meshes into a single mesh for performance reasons.
  16017. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  16018. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  16019. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  16020. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  16021. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  16022. */
  16023. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  16024. }
  16025. }
  16026. declare module BABYLON {
  16027. interface IGetSetVerticesData {
  16028. isVerticesDataPresent(kind: string): boolean;
  16029. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  16030. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  16031. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  16032. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  16033. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  16034. }
  16035. class VertexData {
  16036. positions: Nullable<FloatArray>;
  16037. normals: Nullable<FloatArray>;
  16038. tangents: Nullable<FloatArray>;
  16039. uvs: Nullable<FloatArray>;
  16040. uvs2: Nullable<FloatArray>;
  16041. uvs3: Nullable<FloatArray>;
  16042. uvs4: Nullable<FloatArray>;
  16043. uvs5: Nullable<FloatArray>;
  16044. uvs6: Nullable<FloatArray>;
  16045. colors: Nullable<FloatArray>;
  16046. matricesIndices: Nullable<FloatArray>;
  16047. matricesWeights: Nullable<FloatArray>;
  16048. matricesIndicesExtra: Nullable<FloatArray>;
  16049. matricesWeightsExtra: Nullable<FloatArray>;
  16050. indices: Nullable<IndicesArray>;
  16051. set(data: FloatArray, kind: string): void;
  16052. /**
  16053. * Associates the vertexData to the passed Mesh.
  16054. * Sets it as updatable or not (default `false`).
  16055. * Returns the VertexData.
  16056. */
  16057. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  16058. /**
  16059. * Associates the vertexData to the passed Geometry.
  16060. * Sets it as updatable or not (default `false`).
  16061. * Returns the VertexData.
  16062. */
  16063. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  16064. /**
  16065. * Updates the associated mesh.
  16066. * Returns the VertexData.
  16067. */
  16068. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  16069. /**
  16070. * Updates the associated geometry.
  16071. * Returns the VertexData.
  16072. */
  16073. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  16074. private _applyTo(meshOrGeometry, updatable?);
  16075. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  16076. /**
  16077. * Transforms each position and each normal of the vertexData according to the passed Matrix.
  16078. * Returns the VertexData.
  16079. */
  16080. transform(matrix: Matrix): VertexData;
  16081. /**
  16082. * Merges the passed VertexData into the current one.
  16083. * Returns the modified VertexData.
  16084. */
  16085. merge(other: VertexData): VertexData;
  16086. private _mergeElement(source, other);
  16087. private _validate();
  16088. /**
  16089. * Serializes the VertexData.
  16090. * Returns a serialized object.
  16091. */
  16092. serialize(): any;
  16093. /**
  16094. * Returns the object VertexData associated to the passed mesh.
  16095. */
  16096. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  16097. /**
  16098. * Returns the object VertexData associated to the passed geometry.
  16099. */
  16100. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  16101. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  16102. /**
  16103. * Creates the vertexData of the Ribbon.
  16104. */
  16105. static CreateRibbon(options: {
  16106. pathArray: Vector3[][];
  16107. closeArray?: boolean;
  16108. closePath?: boolean;
  16109. offset?: number;
  16110. sideOrientation?: number;
  16111. frontUVs?: Vector4;
  16112. backUVs?: Vector4;
  16113. invertUV?: boolean;
  16114. uvs?: Vector2[];
  16115. colors?: Color4[];
  16116. }): VertexData;
  16117. /**
  16118. * Creates the VertexData of the Box.
  16119. */
  16120. static CreateBox(options: {
  16121. size?: number;
  16122. width?: number;
  16123. height?: number;
  16124. depth?: number;
  16125. faceUV?: Vector4[];
  16126. faceColors?: Color4[];
  16127. sideOrientation?: number;
  16128. frontUVs?: Vector4;
  16129. backUVs?: Vector4;
  16130. }): VertexData;
  16131. /**
  16132. * Creates the VertexData of the Sphere.
  16133. */
  16134. static CreateSphere(options: {
  16135. segments?: number;
  16136. diameter?: number;
  16137. diameterX?: number;
  16138. diameterY?: number;
  16139. diameterZ?: number;
  16140. arc?: number;
  16141. slice?: number;
  16142. sideOrientation?: number;
  16143. frontUVs?: Vector4;
  16144. backUVs?: Vector4;
  16145. }): VertexData;
  16146. /**
  16147. * Creates the VertexData of the Cylinder or Cone.
  16148. */
  16149. static CreateCylinder(options: {
  16150. height?: number;
  16151. diameterTop?: number;
  16152. diameterBottom?: number;
  16153. diameter?: number;
  16154. tessellation?: number;
  16155. subdivisions?: number;
  16156. arc?: number;
  16157. faceColors?: Color4[];
  16158. faceUV?: Vector4[];
  16159. hasRings?: boolean;
  16160. enclose?: boolean;
  16161. sideOrientation?: number;
  16162. frontUVs?: Vector4;
  16163. backUVs?: Vector4;
  16164. }): VertexData;
  16165. /**
  16166. * Creates the VertexData of the Torus.
  16167. */
  16168. static CreateTorus(options: {
  16169. diameter?: number;
  16170. thickness?: number;
  16171. tessellation?: number;
  16172. sideOrientation?: number;
  16173. frontUVs?: Vector4;
  16174. backUVs?: Vector4;
  16175. }): VertexData;
  16176. /**
  16177. * Creates the VertexData of the LineSystem.
  16178. */
  16179. static CreateLineSystem(options: {
  16180. lines: Vector3[][];
  16181. colors?: Nullable<Color4[][]>;
  16182. }): VertexData;
  16183. /**
  16184. * Create the VertexData of the DashedLines.
  16185. */
  16186. static CreateDashedLines(options: {
  16187. points: Vector3[];
  16188. dashSize?: number;
  16189. gapSize?: number;
  16190. dashNb?: number;
  16191. }): VertexData;
  16192. /**
  16193. * Creates the VertexData of the Ground.
  16194. */
  16195. static CreateGround(options: {
  16196. width?: number;
  16197. height?: number;
  16198. subdivisions?: number;
  16199. subdivisionsX?: number;
  16200. subdivisionsY?: number;
  16201. }): VertexData;
  16202. /**
  16203. * Creates the VertexData of the TiledGround.
  16204. */
  16205. static CreateTiledGround(options: {
  16206. xmin: number;
  16207. zmin: number;
  16208. xmax: number;
  16209. zmax: number;
  16210. subdivisions?: {
  16211. w: number;
  16212. h: number;
  16213. };
  16214. precision?: {
  16215. w: number;
  16216. h: number;
  16217. };
  16218. }): VertexData;
  16219. /**
  16220. * Creates the VertexData of the Ground designed from a heightmap.
  16221. */
  16222. static CreateGroundFromHeightMap(options: {
  16223. width: number;
  16224. height: number;
  16225. subdivisions: number;
  16226. minHeight: number;
  16227. maxHeight: number;
  16228. colorFilter: Color3;
  16229. buffer: Uint8Array;
  16230. bufferWidth: number;
  16231. bufferHeight: number;
  16232. }): VertexData;
  16233. /**
  16234. * Creates the VertexData of the Plane.
  16235. */
  16236. static CreatePlane(options: {
  16237. size?: number;
  16238. width?: number;
  16239. height?: number;
  16240. sideOrientation?: number;
  16241. frontUVs?: Vector4;
  16242. backUVs?: Vector4;
  16243. }): VertexData;
  16244. /**
  16245. * Creates the VertexData of the Disc or regular Polygon.
  16246. */
  16247. static CreateDisc(options: {
  16248. radius?: number;
  16249. tessellation?: number;
  16250. arc?: number;
  16251. sideOrientation?: number;
  16252. frontUVs?: Vector4;
  16253. backUVs?: Vector4;
  16254. }): VertexData;
  16255. /**
  16256. * Re-creates the VertexData of the Polygon for sideOrientation.
  16257. */
  16258. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  16259. /**
  16260. * Creates the VertexData of the IcoSphere.
  16261. */
  16262. static CreateIcoSphere(options: {
  16263. radius?: number;
  16264. radiusX?: number;
  16265. radiusY?: number;
  16266. radiusZ?: number;
  16267. flat?: boolean;
  16268. subdivisions?: number;
  16269. sideOrientation?: number;
  16270. frontUVs?: Vector4;
  16271. backUVs?: Vector4;
  16272. }): VertexData;
  16273. /**
  16274. * Creates the VertexData of the Polyhedron.
  16275. */
  16276. static CreatePolyhedron(options: {
  16277. type?: number;
  16278. size?: number;
  16279. sizeX?: number;
  16280. sizeY?: number;
  16281. sizeZ?: number;
  16282. custom?: any;
  16283. faceUV?: Vector4[];
  16284. faceColors?: Color4[];
  16285. flat?: boolean;
  16286. sideOrientation?: number;
  16287. frontUVs?: Vector4;
  16288. backUVs?: Vector4;
  16289. }): VertexData;
  16290. /**
  16291. * Creates the VertexData of the Torus Knot.
  16292. */
  16293. static CreateTorusKnot(options: {
  16294. radius?: number;
  16295. tube?: number;
  16296. radialSegments?: number;
  16297. tubularSegments?: number;
  16298. p?: number;
  16299. q?: number;
  16300. sideOrientation?: number;
  16301. frontUVs?: Vector4;
  16302. backUVs?: Vector4;
  16303. }): VertexData;
  16304. /**
  16305. * @param {any} - positions (number[] or Float32Array)
  16306. * @param {any} - indices (number[] or Uint16Array)
  16307. * @param {any} - normals (number[] or Float32Array)
  16308. * options (optional) :
  16309. * facetPositions : optional array of facet positions (vector3)
  16310. * facetNormals : optional array of facet normals (vector3)
  16311. * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  16312. * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  16313. * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  16314. * bbSize : optional bounding box size data, required for facetPartitioning computation
  16315. * bInfo : optional bounding info, required for facetPartitioning computation
  16316. * useRightHandedSystem: optional boolean to for right handed system computation
  16317. * depthSort : optional boolean to enable the facet depth sort computation
  16318. * distanceTo : optional Vector3 to compute the facet depth from this location
  16319. * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  16320. */
  16321. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  16322. facetNormals?: any;
  16323. facetPositions?: any;
  16324. facetPartitioning?: any;
  16325. ratio?: number;
  16326. bInfo?: any;
  16327. bbSize?: Vector3;
  16328. subDiv?: any;
  16329. useRightHandedSystem?: boolean;
  16330. depthSort?: boolean;
  16331. distanceTo?: Vector3;
  16332. depthSortedFacets?: any;
  16333. }): void;
  16334. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  16335. /**
  16336. * Creates a new VertexData from the imported parameters.
  16337. */
  16338. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  16339. }
  16340. }
  16341. declare module BABYLON {
  16342. class MeshBuilder {
  16343. private static updateSideOrientation(orientation?);
  16344. /**
  16345. * Creates a box mesh.
  16346. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  16347. * The parameter `size` sets the size (float) of each box side (default 1).
  16348. * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`).
  16349. * 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).
  16350. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  16351. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16352. * 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).
  16353. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16354. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16355. */
  16356. static CreateBox(name: string, options: {
  16357. size?: number;
  16358. width?: number;
  16359. height?: number;
  16360. depth?: number;
  16361. faceUV?: Vector4[];
  16362. faceColors?: Color4[];
  16363. sideOrientation?: number;
  16364. frontUVs?: Vector4;
  16365. backUVs?: Vector4;
  16366. updatable?: boolean;
  16367. }, scene?: Nullable<Scene>): Mesh;
  16368. /**
  16369. * Creates a sphere mesh.
  16370. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  16371. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  16372. * 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`).
  16373. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  16374. * 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
  16375. * 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).
  16376. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16377. * 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).
  16378. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16379. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16380. */
  16381. static CreateSphere(name: string, options: {
  16382. segments?: number;
  16383. diameter?: number;
  16384. diameterX?: number;
  16385. diameterY?: number;
  16386. diameterZ?: number;
  16387. arc?: number;
  16388. slice?: number;
  16389. sideOrientation?: number;
  16390. frontUVs?: Vector4;
  16391. backUVs?: Vector4;
  16392. updatable?: boolean;
  16393. }, scene: any): Mesh;
  16394. /**
  16395. * Creates a plane polygonal mesh. By default, this is a disc.
  16396. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
  16397. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  16398. * 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.
  16399. * 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
  16400. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16401. * 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).
  16402. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16403. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16404. */
  16405. static CreateDisc(name: string, options: {
  16406. radius?: number;
  16407. tessellation?: number;
  16408. arc?: number;
  16409. updatable?: boolean;
  16410. sideOrientation?: number;
  16411. frontUVs?: Vector4;
  16412. backUVs?: Vector4;
  16413. }, scene?: Nullable<Scene>): Mesh;
  16414. /**
  16415. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  16416. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
  16417. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  16418. * 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`).
  16419. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  16420. * 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.
  16421. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16422. * 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).
  16423. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16424. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16425. */
  16426. static CreateIcoSphere(name: string, options: {
  16427. radius?: number;
  16428. radiusX?: number;
  16429. radiusY?: number;
  16430. radiusZ?: number;
  16431. flat?: boolean;
  16432. subdivisions?: number;
  16433. sideOrientation?: number;
  16434. frontUVs?: Vector4;
  16435. backUVs?: Vector4;
  16436. updatable?: boolean;
  16437. }, scene: Scene): Mesh;
  16438. /**
  16439. * Creates a ribbon mesh.
  16440. * 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.
  16441. *
  16442. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  16443. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  16444. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  16445. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  16446. * 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.
  16447. * 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.
  16448. * 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
  16449. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16450. * 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).
  16451. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16452. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16453. * 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.
  16454. * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values.
  16455. * 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
  16456. * if you set `closePath` to `true`, there's one extra vertex per path in the geometry.
  16457. * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time.
  16458. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16459. */
  16460. static CreateRibbon(name: string, options: {
  16461. pathArray: Vector3[][];
  16462. closeArray?: boolean;
  16463. closePath?: boolean;
  16464. offset?: number;
  16465. updatable?: boolean;
  16466. sideOrientation?: number;
  16467. frontUVs?: Vector4;
  16468. backUVs?: Vector4;
  16469. instance?: Mesh;
  16470. invertUV?: boolean;
  16471. uvs?: Vector2[];
  16472. colors?: Color4[];
  16473. }, scene?: Nullable<Scene>): Mesh;
  16474. /**
  16475. * Creates a cylinder or a cone mesh.
  16476. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  16477. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  16478. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  16479. * 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.
  16480. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  16481. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  16482. * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  16483. * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  16484. * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  16485. * 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).
  16486. * 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
  16487. * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  16488. * 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
  16489. * 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.
  16490. * If `enclose` is false, a ring surface is one element.
  16491. * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  16492. * 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
  16493. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16494. * 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).
  16495. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16496. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16497. */
  16498. static CreateCylinder(name: string, options: {
  16499. height?: number;
  16500. diameterTop?: number;
  16501. diameterBottom?: number;
  16502. diameter?: number;
  16503. tessellation?: number;
  16504. subdivisions?: number;
  16505. arc?: number;
  16506. faceColors?: Color4[];
  16507. faceUV?: Vector4[];
  16508. updatable?: boolean;
  16509. hasRings?: boolean;
  16510. enclose?: boolean;
  16511. sideOrientation?: number;
  16512. frontUVs?: Vector4;
  16513. backUVs?: Vector4;
  16514. }, scene: any): Mesh;
  16515. /**
  16516. * Creates a torus mesh.
  16517. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  16518. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  16519. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  16520. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  16521. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16522. * 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).
  16523. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16524. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16525. */
  16526. static CreateTorus(name: string, options: {
  16527. diameter?: number;
  16528. thickness?: number;
  16529. tessellation?: number;
  16530. updatable?: boolean;
  16531. sideOrientation?: number;
  16532. frontUVs?: Vector4;
  16533. backUVs?: Vector4;
  16534. }, scene: any): Mesh;
  16535. /**
  16536. * Creates a torus knot mesh.
  16537. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  16538. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  16539. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  16540. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  16541. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  16542. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16543. * 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).
  16544. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16545. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16546. */
  16547. static CreateTorusKnot(name: string, options: {
  16548. radius?: number;
  16549. tube?: number;
  16550. radialSegments?: number;
  16551. tubularSegments?: number;
  16552. p?: number;
  16553. q?: number;
  16554. updatable?: boolean;
  16555. sideOrientation?: number;
  16556. frontUVs?: Vector4;
  16557. backUVs?: Vector4;
  16558. }, scene: any): Mesh;
  16559. /**
  16560. * Creates a line system mesh.
  16561. * A line system is a pool of many lines gathered in a single mesh.
  16562. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#linesystem
  16563. * 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.
  16564. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function.
  16565. * The parameter `lines` is an array of lines, each line being an array of successive Vector3.
  16566. * 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
  16567. * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point.
  16568. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need the alpha blending (faster).
  16569. * 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
  16570. * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines.
  16571. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16572. */
  16573. static CreateLineSystem(name: string, options: {
  16574. lines: Vector3[][];
  16575. updatable: boolean;
  16576. instance: Nullable<LinesMesh>;
  16577. colors?: Nullable<Color4[][]>;
  16578. useVertexAlpha?: boolean;
  16579. }, scene: Nullable<Scene>): LinesMesh;
  16580. /**
  16581. * Creates a line mesh.
  16582. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lines
  16583. * 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.
  16584. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  16585. * The parameter `points` is an array successive Vector3.
  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. * The optional parameter `colors` is an array of successive Color4, one per line point.
  16588. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need alpha blending (faster).
  16589. * When updating an instance, remember that only point positions can change, not the number of points.
  16590. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16591. */
  16592. static CreateLines(name: string, options: {
  16593. points: Vector3[];
  16594. updatable: boolean;
  16595. instance: Nullable<LinesMesh>;
  16596. colors?: Color4[];
  16597. useVertexAlpha?: boolean;
  16598. }, scene?: Nullable<Scene>): LinesMesh;
  16599. /**
  16600. * Creates a dashed line mesh.
  16601. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#dashed-lines
  16602. * 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.
  16603. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  16604. * The parameter `points` is an array successive Vector3.
  16605. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  16606. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  16607. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  16608. * 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
  16609. * When updating an instance, remember that only point positions can change, not the number of points.
  16610. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16611. */
  16612. static CreateDashedLines(name: string, options: {
  16613. points: Vector3[];
  16614. dashSize?: number;
  16615. gapSize?: number;
  16616. dashNb?: number;
  16617. updatable?: boolean;
  16618. instance?: LinesMesh;
  16619. }, scene?: Nullable<Scene>): LinesMesh;
  16620. /**
  16621. * Creates an extruded shape mesh.
  16622. * 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.
  16623. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes
  16624. *
  16625. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  16626. * 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
  16627. * extruded along the Z axis.
  16628. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  16629. * 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.
  16630. * The parameter `scale` (float, default 1) is the value to scale the shape.
  16631. * 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
  16632. * 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
  16633. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  16634. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16635. * 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).
  16636. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16637. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16638. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16639. */
  16640. static ExtrudeShape(name: string, options: {
  16641. shape: Vector3[];
  16642. path: Vector3[];
  16643. scale?: number;
  16644. rotation?: number;
  16645. cap?: number;
  16646. updatable?: boolean;
  16647. sideOrientation?: number;
  16648. frontUVs?: Vector4;
  16649. backUVs?: Vector4;
  16650. instance?: Mesh;
  16651. invertUV?: boolean;
  16652. }, scene?: Nullable<Scene>): Mesh;
  16653. /**
  16654. * Creates an custom extruded shape mesh.
  16655. * 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.
  16656. * tuto :http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#custom-extruded-shapes
  16657. *
  16658. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  16659. * 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
  16660. * extruded along the Z axis.
  16661. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  16662. * 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
  16663. * and the distance of this point from the begining of the path :
  16664. * ```javascript
  16665. * var rotationFunction = function(i, distance) {
  16666. * // do things
  16667. * return rotationValue; }
  16668. * ```
  16669. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  16670. * 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
  16671. * and the distance of this point from the begining of the path :
  16672. * ```javascript
  16673. * var scaleFunction = function(i, distance) {
  16674. * // do things
  16675. * return scaleValue;}
  16676. * ```
  16677. * It must returns a float value that will be the scale value applied to the shape on each path point.
  16678. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  16679. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  16680. * 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
  16681. * 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
  16682. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  16683. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16684. * 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).
  16685. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16686. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16687. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16688. */
  16689. static ExtrudeShapeCustom(name: string, options: {
  16690. shape: Vector3[];
  16691. path: Vector3[];
  16692. scaleFunction?: any;
  16693. rotationFunction?: any;
  16694. ribbonCloseArray?: boolean;
  16695. ribbonClosePath?: boolean;
  16696. cap?: number;
  16697. updatable?: boolean;
  16698. sideOrientation?: number;
  16699. frontUVs?: Vector4;
  16700. backUVs?: Vector4;
  16701. instance?: Mesh;
  16702. invertUV?: boolean;
  16703. }, scene: Scene): Mesh;
  16704. /**
  16705. * Creates lathe mesh.
  16706. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  16707. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lathe
  16708. *
  16709. * 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
  16710. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  16711. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  16712. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  16713. * 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.
  16714. * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc".
  16715. * 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
  16716. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16717. * 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).
  16718. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16719. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16720. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16721. */
  16722. static CreateLathe(name: string, options: {
  16723. shape: Vector3[];
  16724. radius?: number;
  16725. tessellation?: number;
  16726. arc?: number;
  16727. closed?: boolean;
  16728. updatable?: boolean;
  16729. sideOrientation?: number;
  16730. frontUVs?: Vector4;
  16731. backUVs?: Vector4;
  16732. cap?: number;
  16733. invertUV?: boolean;
  16734. }, scene: Scene): Mesh;
  16735. /**
  16736. * Creates a plane mesh.
  16737. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  16738. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  16739. * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`).
  16740. * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane.
  16741. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16742. * 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).
  16743. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16744. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16745. */
  16746. static CreatePlane(name: string, options: {
  16747. size?: number;
  16748. width?: number;
  16749. height?: number;
  16750. sideOrientation?: number;
  16751. frontUVs?: Vector4;
  16752. backUVs?: Vector4;
  16753. updatable?: boolean;
  16754. sourcePlane?: Plane;
  16755. }, scene: Scene): Mesh;
  16756. /**
  16757. * Creates a ground mesh.
  16758. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  16759. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  16760. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  16761. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16762. */
  16763. static CreateGround(name: string, options: {
  16764. width?: number;
  16765. height?: number;
  16766. subdivisions?: number;
  16767. subdivisionsX?: number;
  16768. subdivisionsY?: number;
  16769. updatable?: boolean;
  16770. }, scene: any): Mesh;
  16771. /**
  16772. * Creates a tiled ground mesh.
  16773. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  16774. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  16775. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  16776. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  16777. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  16778. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  16779. * numbers of subdivisions on the ground width and height of each tile.
  16780. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16781. */
  16782. static CreateTiledGround(name: string, options: {
  16783. xmin: number;
  16784. zmin: number;
  16785. xmax: number;
  16786. zmax: number;
  16787. subdivisions?: {
  16788. w: number;
  16789. h: number;
  16790. };
  16791. precision?: {
  16792. w: number;
  16793. h: number;
  16794. };
  16795. updatable?: boolean;
  16796. }, scene: Scene): Mesh;
  16797. /**
  16798. * Creates a ground mesh from a height map.
  16799. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  16800. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  16801. * The parameter `url` sets the URL of the height map image resource.
  16802. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  16803. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  16804. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  16805. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  16806. * 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.
  16807. * 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).
  16808. * This function is passed the newly built mesh :
  16809. * ```javascript
  16810. * function(mesh) { // do things
  16811. * return; }
  16812. * ```
  16813. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16814. */
  16815. static CreateGroundFromHeightMap(name: string, url: string, options: {
  16816. width?: number;
  16817. height?: number;
  16818. subdivisions?: number;
  16819. minHeight?: number;
  16820. maxHeight?: number;
  16821. colorFilter?: Color3;
  16822. updatable?: boolean;
  16823. onReady?: (mesh: GroundMesh) => void;
  16824. }, scene: Scene): GroundMesh;
  16825. /**
  16826. * Creates a polygon mesh.
  16827. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  16828. * 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.
  16829. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16830. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16831. * 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).
  16832. * Remember you can only change the shape positions, not their number when updating a polygon.
  16833. */
  16834. static CreatePolygon(name: string, options: {
  16835. shape: Vector3[];
  16836. holes?: Vector3[][];
  16837. depth?: number;
  16838. faceUV?: Vector4[];
  16839. faceColors?: Color4[];
  16840. updatable?: boolean;
  16841. sideOrientation?: number;
  16842. frontUVs?: Vector4;
  16843. backUVs?: Vector4;
  16844. }, scene: Scene): Mesh;
  16845. /**
  16846. * Creates an extruded polygon mesh, with depth in the Y direction.
  16847. * 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).
  16848. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  16849. */
  16850. static ExtrudePolygon(name: string, options: {
  16851. shape: Vector3[];
  16852. holes?: Vector3[][];
  16853. depth?: number;
  16854. faceUV?: Vector4[];
  16855. faceColors?: Color4[];
  16856. updatable?: boolean;
  16857. sideOrientation?: number;
  16858. frontUVs?: Vector4;
  16859. backUVs?: Vector4;
  16860. }, scene: Scene): Mesh;
  16861. /**
  16862. * Creates a tube mesh.
  16863. * 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.
  16864. *
  16865. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  16866. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  16867. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  16868. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  16869. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  16870. * 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.
  16871. * It must return a radius value (positive float) :
  16872. * ```javascript
  16873. * var radiusFunction = function(i, distance) {
  16874. * // do things
  16875. * return radius; }
  16876. * ```
  16877. * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc.
  16878. * 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
  16879. * 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
  16880. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16881. * 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).
  16882. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16883. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16884. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16885. */
  16886. static CreateTube(name: string, options: {
  16887. path: Vector3[];
  16888. radius?: number;
  16889. tessellation?: number;
  16890. radiusFunction?: {
  16891. (i: number, distance: number): number;
  16892. };
  16893. cap?: number;
  16894. arc?: number;
  16895. updatable?: boolean;
  16896. sideOrientation?: number;
  16897. frontUVs?: Vector4;
  16898. backUVs?: Vector4;
  16899. instance?: Mesh;
  16900. invertUV?: boolean;
  16901. }, scene: Scene): Mesh;
  16902. /**
  16903. * Creates a polyhedron mesh.
  16904. *
  16905. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#polyhedron
  16906. * 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
  16907. * to choose the wanted type.
  16908. * The parameter `size` (positive float, default 1) sets the polygon size.
  16909. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  16910. * 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`.
  16911. * 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
  16912. * 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)`).
  16913. * 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
  16914. * 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.
  16915. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16916. * 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).
  16917. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16918. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16919. */
  16920. static CreatePolyhedron(name: string, options: {
  16921. type?: number;
  16922. size?: number;
  16923. sizeX?: number;
  16924. sizeY?: number;
  16925. sizeZ?: number;
  16926. custom?: any;
  16927. faceUV?: Vector4[];
  16928. faceColors?: Color4[];
  16929. flat?: boolean;
  16930. updatable?: boolean;
  16931. sideOrientation?: number;
  16932. frontUVs?: Vector4;
  16933. backUVs?: Vector4;
  16934. }, scene: Scene): Mesh;
  16935. /**
  16936. * Creates a decal mesh.
  16937. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#decals
  16938. * 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.
  16939. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  16940. * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates.
  16941. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  16942. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  16943. */
  16944. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  16945. position?: Vector3;
  16946. normal?: Vector3;
  16947. size?: Vector3;
  16948. angle?: number;
  16949. }): Mesh;
  16950. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  16951. }
  16952. }
  16953. declare module BABYLON {
  16954. class MeshLODLevel {
  16955. distance: number;
  16956. mesh: Mesh;
  16957. constructor(distance: number, mesh: Mesh);
  16958. }
  16959. }
  16960. declare module BABYLON {
  16961. /**
  16962. * A simplifier interface for future simplification implementations.
  16963. */
  16964. interface ISimplifier {
  16965. /**
  16966. * Simplification of a given mesh according to the given settings.
  16967. * Since this requires computation, it is assumed that the function runs async.
  16968. * @param settings The settings of the simplification, including quality and distance
  16969. * @param successCallback A callback that will be called after the mesh was simplified.
  16970. * @param errorCallback in case of an error, this callback will be called. optional.
  16971. */
  16972. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  16973. }
  16974. /**
  16975. * Expected simplification settings.
  16976. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  16977. */
  16978. interface ISimplificationSettings {
  16979. quality: number;
  16980. distance: number;
  16981. optimizeMesh?: boolean;
  16982. }
  16983. class SimplificationSettings implements ISimplificationSettings {
  16984. quality: number;
  16985. distance: number;
  16986. optimizeMesh: boolean | undefined;
  16987. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  16988. }
  16989. interface ISimplificationTask {
  16990. settings: Array<ISimplificationSettings>;
  16991. simplificationType: SimplificationType;
  16992. mesh: Mesh;
  16993. successCallback?: () => void;
  16994. parallelProcessing: boolean;
  16995. }
  16996. class SimplificationQueue {
  16997. private _simplificationArray;
  16998. running: boolean;
  16999. constructor();
  17000. addTask(task: ISimplificationTask): void;
  17001. executeNext(): void;
  17002. runSimplification(task: ISimplificationTask): void;
  17003. private getSimplifier(task);
  17004. }
  17005. /**
  17006. * The implemented types of simplification.
  17007. * At the moment only Quadratic Error Decimation is implemented.
  17008. */
  17009. enum SimplificationType {
  17010. QUADRATIC = 0,
  17011. }
  17012. class DecimationTriangle {
  17013. vertices: Array<DecimationVertex>;
  17014. normal: Vector3;
  17015. error: Array<number>;
  17016. deleted: boolean;
  17017. isDirty: boolean;
  17018. borderFactor: number;
  17019. deletePending: boolean;
  17020. originalOffset: number;
  17021. constructor(vertices: Array<DecimationVertex>);
  17022. }
  17023. class DecimationVertex {
  17024. position: Vector3;
  17025. id: number;
  17026. q: QuadraticMatrix;
  17027. isBorder: boolean;
  17028. triangleStart: number;
  17029. triangleCount: number;
  17030. originalOffsets: Array<number>;
  17031. constructor(position: Vector3, id: number);
  17032. updatePosition(newPosition: Vector3): void;
  17033. }
  17034. class QuadraticMatrix {
  17035. data: Array<number>;
  17036. constructor(data?: Array<number>);
  17037. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  17038. addInPlace(matrix: QuadraticMatrix): void;
  17039. addArrayInPlace(data: Array<number>): void;
  17040. add(matrix: QuadraticMatrix): QuadraticMatrix;
  17041. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  17042. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  17043. }
  17044. class Reference {
  17045. vertexId: number;
  17046. triangleId: number;
  17047. constructor(vertexId: number, triangleId: number);
  17048. }
  17049. /**
  17050. * An implementation of the Quadratic Error simplification algorithm.
  17051. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  17052. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  17053. * @author RaananW
  17054. */
  17055. class QuadraticErrorSimplification implements ISimplifier {
  17056. private _mesh;
  17057. private triangles;
  17058. private vertices;
  17059. private references;
  17060. private _reconstructedMesh;
  17061. syncIterations: number;
  17062. aggressiveness: number;
  17063. decimationIterations: number;
  17064. boundingBoxEpsilon: number;
  17065. constructor(_mesh: Mesh);
  17066. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  17067. private runDecimation(settings, submeshIndex, successCallback);
  17068. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  17069. private init(callback);
  17070. private reconstructMesh(submeshIndex);
  17071. private initDecimatedMesh();
  17072. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  17073. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  17074. private identifyBorder();
  17075. private updateMesh(identifyBorders?);
  17076. private vertexError(q, point);
  17077. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  17078. }
  17079. }
  17080. declare module BABYLON {
  17081. class Polygon {
  17082. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  17083. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  17084. static Parse(input: string): Vector2[];
  17085. static StartingAt(x: number, y: number): Path2;
  17086. }
  17087. class PolygonMeshBuilder {
  17088. private _points;
  17089. private _outlinepoints;
  17090. private _holes;
  17091. private _name;
  17092. private _scene;
  17093. private _epoints;
  17094. private _eholes;
  17095. private _addToepoint(points);
  17096. constructor(name: string, contours: Path2, scene: Scene);
  17097. constructor(name: string, contours: Vector2[], scene: Scene);
  17098. addHole(hole: Vector2[]): PolygonMeshBuilder;
  17099. build(updatable?: boolean, depth?: number): Mesh;
  17100. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  17101. }
  17102. }
  17103. declare module BABYLON {
  17104. class BaseSubMesh {
  17105. _materialDefines: Nullable<MaterialDefines>;
  17106. _materialEffect: Nullable<Effect>;
  17107. readonly effect: Nullable<Effect>;
  17108. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  17109. }
  17110. class SubMesh extends BaseSubMesh implements ICullable {
  17111. materialIndex: number;
  17112. verticesStart: number;
  17113. verticesCount: number;
  17114. indexStart: number;
  17115. indexCount: number;
  17116. linesIndexCount: number;
  17117. private _mesh;
  17118. private _renderingMesh;
  17119. private _boundingInfo;
  17120. private _linesIndexBuffer;
  17121. _lastColliderWorldVertices: Nullable<Vector3[]>;
  17122. _trianglePlanes: Plane[];
  17123. _lastColliderTransformMatrix: Matrix;
  17124. _renderId: number;
  17125. _alphaIndex: number;
  17126. _distanceToCamera: number;
  17127. _id: number;
  17128. private _currentMaterial;
  17129. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  17130. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  17131. readonly IsGlobal: boolean;
  17132. /**
  17133. * Returns the submesh BoudingInfo object.
  17134. */
  17135. getBoundingInfo(): BoundingInfo;
  17136. /**
  17137. * Sets the submesh BoundingInfo.
  17138. * Return the SubMesh.
  17139. */
  17140. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  17141. /**
  17142. * Returns the mesh of the current submesh.
  17143. */
  17144. getMesh(): AbstractMesh;
  17145. /**
  17146. * Returns the rendering mesh of the submesh.
  17147. */
  17148. getRenderingMesh(): Mesh;
  17149. /**
  17150. * Returns the submesh material.
  17151. */
  17152. getMaterial(): Nullable<Material>;
  17153. /**
  17154. * Sets a new updated BoundingInfo object to the submesh.
  17155. * Returns the SubMesh.
  17156. */
  17157. refreshBoundingInfo(): SubMesh;
  17158. _checkCollision(collider: Collider): boolean;
  17159. /**
  17160. * Updates the submesh BoundingInfo.
  17161. * Returns the Submesh.
  17162. */
  17163. updateBoundingInfo(world: Matrix): SubMesh;
  17164. /**
  17165. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  17166. * Boolean returned.
  17167. */
  17168. isInFrustum(frustumPlanes: Plane[]): boolean;
  17169. /**
  17170. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  17171. * Boolean returned.
  17172. */
  17173. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  17174. /**
  17175. * Renders the submesh.
  17176. * Returns it.
  17177. */
  17178. render(enableAlphaMode: boolean): SubMesh;
  17179. /**
  17180. * Returns a new Index Buffer.
  17181. * Type returned : WebGLBuffer.
  17182. */
  17183. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  17184. /**
  17185. * True is the passed Ray intersects the submesh bounding box.
  17186. * Boolean returned.
  17187. */
  17188. canIntersects(ray: Ray): boolean;
  17189. /**
  17190. * Returns an object IntersectionInfo.
  17191. */
  17192. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  17193. _rebuild(): void;
  17194. /**
  17195. * Creates a new Submesh from the passed Mesh.
  17196. */
  17197. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  17198. /**
  17199. * Disposes the Submesh.
  17200. * Returns nothing.
  17201. */
  17202. dispose(): void;
  17203. /**
  17204. * Creates a new Submesh from the passed parameters :
  17205. * - materialIndex (integer) : the index of the main mesh material.
  17206. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  17207. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  17208. * - mesh (Mesh) : the main mesh to create the submesh from.
  17209. * - renderingMesh (optional Mesh) : rendering mesh.
  17210. */
  17211. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  17212. }
  17213. }
  17214. declare module BABYLON {
  17215. class TransformNode extends Node {
  17216. static BILLBOARDMODE_NONE: number;
  17217. static BILLBOARDMODE_X: number;
  17218. static BILLBOARDMODE_Y: number;
  17219. static BILLBOARDMODE_Z: number;
  17220. static BILLBOARDMODE_ALL: number;
  17221. private _rotation;
  17222. private _rotationQuaternion;
  17223. protected _scaling: Vector3;
  17224. protected _isDirty: boolean;
  17225. private _transformToBoneReferal;
  17226. billboardMode: number;
  17227. scalingDeterminant: number;
  17228. infiniteDistance: boolean;
  17229. position: Vector3;
  17230. _poseMatrix: Matrix;
  17231. private _localWorld;
  17232. _worldMatrix: Matrix;
  17233. _worldMatrixDeterminant: number;
  17234. private _absolutePosition;
  17235. private _pivotMatrix;
  17236. private _pivotMatrixInverse;
  17237. private _postMultiplyPivotMatrix;
  17238. protected _isWorldMatrixFrozen: boolean;
  17239. /**
  17240. * An event triggered after the world matrix is updated
  17241. * @type {BABYLON.Observable}
  17242. */
  17243. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  17244. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  17245. /**
  17246. * Gets a string idenfifying the name of the class
  17247. * @returns "TransformNode" string
  17248. */
  17249. getClassName(): string;
  17250. /**
  17251. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  17252. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  17253. * Default : (0.0, 0.0, 0.0)
  17254. */
  17255. rotation: Vector3;
  17256. /**
  17257. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  17258. * Default : (1.0, 1.0, 1.0)
  17259. */
  17260. /**
  17261. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  17262. * Default : (1.0, 1.0, 1.0)
  17263. */
  17264. scaling: Vector3;
  17265. /**
  17266. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  17267. * It's null by default.
  17268. * 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)
  17269. */
  17270. rotationQuaternion: Nullable<Quaternion>;
  17271. /**
  17272. * Returns the latest update of the World matrix
  17273. * Returns a Matrix.
  17274. */
  17275. getWorldMatrix(): Matrix;
  17276. /**
  17277. * Returns the latest update of the World matrix determinant.
  17278. */
  17279. protected _getWorldMatrixDeterminant(): number;
  17280. /**
  17281. * Returns directly the latest state of the mesh World matrix.
  17282. * A Matrix is returned.
  17283. */
  17284. readonly worldMatrixFromCache: Matrix;
  17285. /**
  17286. * Copies the paramater passed Matrix into the mesh Pose matrix.
  17287. * Returns the AbstractMesh.
  17288. */
  17289. updatePoseMatrix(matrix: Matrix): TransformNode;
  17290. /**
  17291. * Returns the mesh Pose matrix.
  17292. * Returned object : Matrix
  17293. */
  17294. getPoseMatrix(): Matrix;
  17295. _isSynchronized(): boolean;
  17296. _initCache(): void;
  17297. markAsDirty(property: string): TransformNode;
  17298. /**
  17299. * Returns the current mesh absolute position.
  17300. * Retuns a Vector3.
  17301. */
  17302. readonly absolutePosition: Vector3;
  17303. /**
  17304. * Sets a new matrix to apply before all other transformation
  17305. * @param matrix defines the transform matrix
  17306. * @returns the current TransformNode
  17307. */
  17308. setPreTransformMatrix(matrix: Matrix): TransformNode;
  17309. /**
  17310. * Sets a new pivot matrix to the current node
  17311. * @param matrix defines the new pivot matrix to use
  17312. * @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
  17313. * @returns the current TransformNode
  17314. */
  17315. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  17316. /**
  17317. * Returns the mesh pivot matrix.
  17318. * Default : Identity.
  17319. * A Matrix is returned.
  17320. */
  17321. getPivotMatrix(): Matrix;
  17322. /**
  17323. * Prevents the World matrix to be computed any longer.
  17324. * Returns the AbstractMesh.
  17325. */
  17326. freezeWorldMatrix(): TransformNode;
  17327. /**
  17328. * Allows back the World matrix computation.
  17329. * Returns the AbstractMesh.
  17330. */
  17331. unfreezeWorldMatrix(): this;
  17332. /**
  17333. * True if the World matrix has been frozen.
  17334. * Returns a boolean.
  17335. */
  17336. readonly isWorldMatrixFrozen: boolean;
  17337. /**
  17338. * Retuns the mesh absolute position in the World.
  17339. * Returns a Vector3.
  17340. */
  17341. getAbsolutePosition(): Vector3;
  17342. /**
  17343. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  17344. * Returns the AbstractMesh.
  17345. */
  17346. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  17347. /**
  17348. * Sets the mesh position in its local space.
  17349. * Returns the AbstractMesh.
  17350. */
  17351. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  17352. /**
  17353. * Returns the mesh position in the local space from the current World matrix values.
  17354. * Returns a new Vector3.
  17355. */
  17356. getPositionExpressedInLocalSpace(): Vector3;
  17357. /**
  17358. * Translates the mesh along the passed Vector3 in its local space.
  17359. * Returns the AbstractMesh.
  17360. */
  17361. locallyTranslate(vector3: Vector3): TransformNode;
  17362. private static _lookAtVectorCache;
  17363. /**
  17364. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  17365. * @param targetPoint the position (must be in same space as current mesh) to look at
  17366. * @param yawCor optional yaw (y-axis) correction in radians
  17367. * @param pitchCor optional pitch (x-axis) correction in radians
  17368. * @param rollCor optional roll (z-axis) correction in radians
  17369. * @param space the choosen space of the target
  17370. * @returns the TransformNode.
  17371. */
  17372. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  17373. /**
  17374. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  17375. * This Vector3 is expressed in the World space.
  17376. */
  17377. getDirection(localAxis: Vector3): Vector3;
  17378. /**
  17379. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  17380. * localAxis is expressed in the mesh local space.
  17381. * result is computed in the Wordl space from the mesh World matrix.
  17382. * Returns the AbstractMesh.
  17383. */
  17384. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  17385. /**
  17386. * Sets a new pivot point to the current node
  17387. * @param point defines the new pivot point to use
  17388. * @param space defines if the point is in world or local space (local by default)
  17389. * @returns the current TransformNode
  17390. */
  17391. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  17392. /**
  17393. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  17394. */
  17395. getPivotPoint(): Vector3;
  17396. /**
  17397. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  17398. * Returns the AbstractMesh.
  17399. */
  17400. getPivotPointToRef(result: Vector3): TransformNode;
  17401. /**
  17402. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  17403. */
  17404. getAbsolutePivotPoint(): Vector3;
  17405. /**
  17406. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  17407. * Returns the AbstractMesh.
  17408. */
  17409. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  17410. /**
  17411. * Defines the passed node as the parent of the current node.
  17412. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  17413. * Returns the TransformNode.
  17414. */
  17415. setParent(node: Nullable<Node>): TransformNode;
  17416. private _nonUniformScaling;
  17417. readonly nonUniformScaling: boolean;
  17418. _updateNonUniformScalingState(value: boolean): boolean;
  17419. /**
  17420. * Attach the current TransformNode to another TransformNode associated with a bone
  17421. * @param bone Bone affecting the TransformNode
  17422. * @param affectedTransformNode TransformNode associated with the bone
  17423. */
  17424. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  17425. detachFromBone(): TransformNode;
  17426. private static _rotationAxisCache;
  17427. /**
  17428. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  17429. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  17430. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  17431. * The passed axis is also normalized.
  17432. * Returns the AbstractMesh.
  17433. */
  17434. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  17435. /**
  17436. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  17437. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  17438. * The passed axis is also normalized.
  17439. * Returns the AbstractMesh.
  17440. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  17441. */
  17442. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  17443. /**
  17444. * Translates the mesh along the axis vector for the passed distance in the given space.
  17445. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  17446. * Returns the AbstractMesh.
  17447. */
  17448. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  17449. /**
  17450. * Adds a rotation step to the mesh current rotation.
  17451. * x, y, z are Euler angles expressed in radians.
  17452. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  17453. * This means this rotation is made in the mesh local space only.
  17454. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  17455. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  17456. * ```javascript
  17457. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  17458. * ```
  17459. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  17460. * 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.
  17461. * Returns the AbstractMesh.
  17462. */
  17463. addRotation(x: number, y: number, z: number): TransformNode;
  17464. /**
  17465. * Computes the mesh World matrix and returns it.
  17466. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  17467. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  17468. * If the parameter `force`is set to `true`, the actual computation is done.
  17469. * Returns the mesh World Matrix.
  17470. */
  17471. computeWorldMatrix(force?: boolean): Matrix;
  17472. protected _afterComputeWorldMatrix(): void;
  17473. /**
  17474. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  17475. * @param func: callback function to add
  17476. *
  17477. * Returns the TransformNode.
  17478. */
  17479. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  17480. /**
  17481. * Removes a registered callback function.
  17482. * Returns the TransformNode.
  17483. */
  17484. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  17485. /**
  17486. * Clone the current transform node
  17487. * Returns the new transform node
  17488. * @param name Name of the new clone
  17489. * @param newParent New parent for the clone
  17490. * @param doNotCloneChildren Do not clone children hierarchy
  17491. */
  17492. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  17493. serialize(currentSerializationObject?: any): any;
  17494. /**
  17495. * Returns a new TransformNode object parsed from the source provided.
  17496. * The parameter `parsedMesh` is the source.
  17497. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  17498. */
  17499. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  17500. /**
  17501. * Releases resources associated with this transform node.
  17502. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17503. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17504. */
  17505. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17506. }
  17507. }
  17508. declare module BABYLON {
  17509. class VertexBuffer {
  17510. private _buffer;
  17511. private _kind;
  17512. private _offset;
  17513. private _size;
  17514. private _stride;
  17515. private _ownsBuffer;
  17516. private _instanced;
  17517. private _instanceDivisor;
  17518. /**
  17519. * Gets or sets the instance divisor when in instanced mode
  17520. */
  17521. instanceDivisor: number;
  17522. constructor(engine: any, data: FloatArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number);
  17523. _rebuild(): void;
  17524. /**
  17525. * Returns the kind of the VertexBuffer (string).
  17526. */
  17527. getKind(): string;
  17528. /**
  17529. * Boolean : is the VertexBuffer updatable ?
  17530. */
  17531. isUpdatable(): boolean;
  17532. /**
  17533. * Returns an array of numbers or a Float32Array containing the VertexBuffer data.
  17534. */
  17535. getData(): Nullable<FloatArray>;
  17536. /**
  17537. * Returns the WebGLBuffer associated to the VertexBuffer.
  17538. */
  17539. getBuffer(): Nullable<WebGLBuffer>;
  17540. /**
  17541. * Returns the stride of the VertexBuffer (integer).
  17542. */
  17543. getStrideSize(): number;
  17544. /**
  17545. * Returns the offset (integer).
  17546. */
  17547. getOffset(): number;
  17548. /**
  17549. * Returns the VertexBuffer total size (integer).
  17550. */
  17551. getSize(): number;
  17552. /**
  17553. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  17554. */
  17555. getIsInstanced(): boolean;
  17556. /**
  17557. * Returns the instancing divisor, zero for non-instanced (integer).
  17558. */
  17559. getInstanceDivisor(): number;
  17560. /**
  17561. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  17562. * Returns the created WebGLBuffer.
  17563. */
  17564. create(data?: FloatArray): void;
  17565. /**
  17566. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  17567. * This function will create a new buffer if the current one is not updatable
  17568. * Returns the updated WebGLBuffer.
  17569. */
  17570. update(data: FloatArray): void;
  17571. /**
  17572. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  17573. * Returns the directly updated WebGLBuffer.
  17574. */
  17575. updateDirectly(data: Float32Array, offset: number): void;
  17576. /**
  17577. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  17578. */
  17579. dispose(): void;
  17580. private static _PositionKind;
  17581. private static _NormalKind;
  17582. private static _TangentKind;
  17583. private static _UVKind;
  17584. private static _UV2Kind;
  17585. private static _UV3Kind;
  17586. private static _UV4Kind;
  17587. private static _UV5Kind;
  17588. private static _UV6Kind;
  17589. private static _ColorKind;
  17590. private static _MatricesIndicesKind;
  17591. private static _MatricesWeightsKind;
  17592. private static _MatricesIndicesExtraKind;
  17593. private static _MatricesWeightsExtraKind;
  17594. static readonly PositionKind: string;
  17595. static readonly NormalKind: string;
  17596. static readonly TangentKind: string;
  17597. static readonly UVKind: string;
  17598. static readonly UV2Kind: string;
  17599. static readonly UV3Kind: string;
  17600. static readonly UV4Kind: string;
  17601. static readonly UV5Kind: string;
  17602. static readonly UV6Kind: string;
  17603. static readonly ColorKind: string;
  17604. static readonly MatricesIndicesKind: string;
  17605. static readonly MatricesWeightsKind: string;
  17606. static readonly MatricesIndicesExtraKind: string;
  17607. static readonly MatricesWeightsExtraKind: string;
  17608. /**
  17609. * Deduces the stride given a kind.
  17610. * @param kind The kind string to deduce
  17611. * @returns The deduced stride
  17612. */
  17613. static DeduceStride(kind: string): number;
  17614. }
  17615. }
  17616. declare module BABYLON {
  17617. class MorphTarget {
  17618. name: string;
  17619. animations: Animation[];
  17620. private _positions;
  17621. private _normals;
  17622. private _tangents;
  17623. private _influence;
  17624. onInfluenceChanged: Observable<boolean>;
  17625. influence: number;
  17626. constructor(name: string, influence?: number);
  17627. readonly hasPositions: boolean;
  17628. readonly hasNormals: boolean;
  17629. readonly hasTangents: boolean;
  17630. setPositions(data: Nullable<FloatArray>): void;
  17631. getPositions(): Nullable<FloatArray>;
  17632. setNormals(data: Nullable<FloatArray>): void;
  17633. getNormals(): Nullable<FloatArray>;
  17634. setTangents(data: Nullable<FloatArray>): void;
  17635. getTangents(): Nullable<FloatArray>;
  17636. /**
  17637. * Serializes the current target into a Serialization object.
  17638. * Returns the serialized object.
  17639. */
  17640. serialize(): any;
  17641. static Parse(serializationObject: any): MorphTarget;
  17642. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  17643. }
  17644. }
  17645. declare module BABYLON {
  17646. class MorphTargetManager {
  17647. private _targets;
  17648. private _targetObservable;
  17649. private _activeTargets;
  17650. private _scene;
  17651. private _influences;
  17652. private _supportsNormals;
  17653. private _supportsTangents;
  17654. private _vertexCount;
  17655. private _uniqueId;
  17656. private _tempInfluences;
  17657. constructor(scene?: Nullable<Scene>);
  17658. readonly uniqueId: number;
  17659. readonly vertexCount: number;
  17660. readonly supportsNormals: boolean;
  17661. readonly supportsTangents: boolean;
  17662. readonly numTargets: number;
  17663. readonly numInfluencers: number;
  17664. readonly influences: Float32Array;
  17665. getActiveTarget(index: number): MorphTarget;
  17666. getTarget(index: number): MorphTarget;
  17667. addTarget(target: MorphTarget): void;
  17668. removeTarget(target: MorphTarget): void;
  17669. /**
  17670. * Serializes the current manager into a Serialization object.
  17671. * Returns the serialized object.
  17672. */
  17673. serialize(): any;
  17674. private _syncActiveTargets(needUpdate);
  17675. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  17676. }
  17677. }
  17678. declare module BABYLON {
  17679. /**
  17680. * This represents a GPU particle system in Babylon
  17681. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  17682. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  17683. */
  17684. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  17685. /**
  17686. * The id of the Particle system.
  17687. */
  17688. id: string;
  17689. /**
  17690. * The friendly name of the Particle system.
  17691. */
  17692. name: string;
  17693. /**
  17694. * The emitter represents the Mesh or position we are attaching the particle system to.
  17695. */
  17696. emitter: Nullable<AbstractMesh | Vector3>;
  17697. /**
  17698. * The rendering group used by the Particle system to chose when to render.
  17699. */
  17700. renderingGroupId: number;
  17701. /**
  17702. * The layer mask we are rendering the particles through.
  17703. */
  17704. layerMask: number;
  17705. private _capacity;
  17706. private _activeCount;
  17707. private _currentActiveCount;
  17708. private _renderEffect;
  17709. private _updateEffect;
  17710. private _buffer0;
  17711. private _buffer1;
  17712. private _spriteBuffer;
  17713. private _updateVAO;
  17714. private _renderVAO;
  17715. private _targetIndex;
  17716. private _sourceBuffer;
  17717. private _targetBuffer;
  17718. private _scene;
  17719. private _engine;
  17720. private _currentRenderId;
  17721. private _started;
  17722. private _stopped;
  17723. private _timeDelta;
  17724. private _randomTexture;
  17725. private readonly _attributesStrideSize;
  17726. private _updateEffectOptions;
  17727. private _randomTextureSize;
  17728. private _actualFrame;
  17729. /**
  17730. * List of animations used by the particle system.
  17731. */
  17732. animations: Animation[];
  17733. /**
  17734. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  17735. */
  17736. static readonly IsSupported: boolean;
  17737. /**
  17738. * An event triggered when the system is disposed.
  17739. */
  17740. onDisposeObservable: Observable<GPUParticleSystem>;
  17741. /**
  17742. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17743. */
  17744. updateSpeed: number;
  17745. /**
  17746. * The amount of time the particle system is running (depends of the overall update speed).
  17747. */
  17748. targetStopDuration: number;
  17749. /**
  17750. * The texture used to render each particle. (this can be a spritesheet)
  17751. */
  17752. particleTexture: Nullable<Texture>;
  17753. /**
  17754. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17755. */
  17756. blendMode: number;
  17757. /**
  17758. * Minimum life time of emitting particles.
  17759. */
  17760. minLifeTime: number;
  17761. /**
  17762. * Maximum life time of emitting particles.
  17763. */
  17764. maxLifeTime: number;
  17765. /**
  17766. * Minimum Size of emitting particles.
  17767. */
  17768. minSize: number;
  17769. /**
  17770. * Maximum Size of emitting particles.
  17771. */
  17772. maxSize: number;
  17773. /**
  17774. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17775. */
  17776. color1: Color4;
  17777. /**
  17778. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17779. */
  17780. color2: Color4;
  17781. /**
  17782. * Color the particle will have at the end of its lifetime.
  17783. */
  17784. colorDead: Color4;
  17785. /**
  17786. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17787. */
  17788. emitRate: number;
  17789. /**
  17790. * You can use gravity if you want to give an orientation to your particles.
  17791. */
  17792. gravity: Vector3;
  17793. /**
  17794. * Minimum power of emitting particles.
  17795. */
  17796. minEmitPower: number;
  17797. /**
  17798. * Maximum power of emitting particles.
  17799. */
  17800. maxEmitPower: number;
  17801. /**
  17802. * The particle emitter type defines the emitter used by the particle system.
  17803. * It can be for example box, sphere, or cone...
  17804. */
  17805. particleEmitterType: Nullable<IParticleEmitterType>;
  17806. /**
  17807. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17808. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17809. */
  17810. direction1: Vector3;
  17811. /**
  17812. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17813. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17814. */
  17815. direction2: Vector3;
  17816. /**
  17817. * 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.
  17818. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17819. */
  17820. minEmitBox: Vector3;
  17821. /**
  17822. * 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.
  17823. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17824. */
  17825. maxEmitBox: Vector3;
  17826. /**
  17827. * Gets the maximum number of particles active at the same time.
  17828. * @returns The max number of active particles.
  17829. */
  17830. getCapacity(): number;
  17831. /**
  17832. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17833. * to override the particles.
  17834. */
  17835. forceDepthWrite: boolean;
  17836. /**
  17837. * Gets or set the number of active particles
  17838. */
  17839. activeParticleCount: number;
  17840. /**
  17841. * Is this system ready to be used/rendered
  17842. * @return true if the system is ready
  17843. */
  17844. isReady(): boolean;
  17845. /**
  17846. * Gets Wether the system has been started.
  17847. * @returns True if it has been started, otherwise false.
  17848. */
  17849. isStarted(): boolean;
  17850. /**
  17851. * Starts the particle system and begins to emit.
  17852. */
  17853. start(): void;
  17854. /**
  17855. * Stops the particle system.
  17856. */
  17857. stop(): void;
  17858. /**
  17859. * Remove all active particles
  17860. */
  17861. reset(): void;
  17862. /**
  17863. * Returns the string "GPUParticleSystem"
  17864. * @returns a string containing the class name
  17865. */
  17866. getClassName(): string;
  17867. /**
  17868. * Instantiates a GPU particle system.
  17869. * 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.
  17870. * @param name The name of the particle system
  17871. * @param capacity The max number of particles alive at the same time
  17872. * @param scene The scene the particle system belongs to
  17873. */
  17874. constructor(name: string, options: Partial<{
  17875. capacity: number;
  17876. randomTextureSize: number;
  17877. }>, scene: Scene);
  17878. private _createUpdateVAO(source);
  17879. private _createRenderVAO(source, spriteSource);
  17880. private _initialize(force?);
  17881. /** @ignore */
  17882. _recreateUpdateEffect(): void;
  17883. /** @ignore */
  17884. _recreateRenderEffect(): void;
  17885. /**
  17886. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17887. */
  17888. animate(): void;
  17889. /**
  17890. * Renders the particle system in its current state.
  17891. * @returns the current number of particles
  17892. */
  17893. render(): number;
  17894. /**
  17895. * Rebuilds the particle system
  17896. */
  17897. rebuild(): void;
  17898. private _releaseBuffers();
  17899. private _releaseVAOs();
  17900. /**
  17901. * Disposes the particle system and free the associated resources
  17902. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17903. */
  17904. dispose(disposeTexture?: boolean): void;
  17905. /**
  17906. * Clones the particle system.
  17907. * @param name The name of the cloned object
  17908. * @param newEmitter The new emitter to use
  17909. * @returns the cloned particle system
  17910. */
  17911. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  17912. /**
  17913. * Serializes the particle system to a JSON object.
  17914. * @returns the JSON object
  17915. */
  17916. serialize(): any;
  17917. /**
  17918. * Parses a JSON object to create a GPU particle system.
  17919. * @param parsedParticleSystem The JSON object to parse
  17920. * @param scene The scene to create the particle system in
  17921. * @param rootUrl The root url to use to load external dependencies like texture
  17922. * @returns the parsed GPU particle system
  17923. */
  17924. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  17925. }
  17926. }
  17927. declare module BABYLON {
  17928. /**
  17929. * Interface representing a particle system in Babylon.
  17930. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17931. * A particle system represents a way to manage particles (@see Particle) from their emission to their animation and rendering.
  17932. */
  17933. interface IParticleSystem {
  17934. /**
  17935. * The id of the Particle system.
  17936. */
  17937. id: string;
  17938. /**
  17939. * The name of the Particle system.
  17940. */
  17941. name: string;
  17942. /**
  17943. * The emitter represents the Mesh or position we are attaching the particle system to.
  17944. */
  17945. emitter: Nullable<AbstractMesh | Vector3>;
  17946. /**
  17947. * The rendering group used by the Particle system to chose when to render.
  17948. */
  17949. renderingGroupId: number;
  17950. /**
  17951. * The layer mask we are rendering the particles through.
  17952. */
  17953. layerMask: number;
  17954. /**
  17955. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17956. */
  17957. updateSpeed: number;
  17958. /**
  17959. * The amount of time the particle system is running (depends of the overall update speed).
  17960. */
  17961. targetStopDuration: number;
  17962. /**
  17963. * The texture used to render each particle. (this can be a spritesheet)
  17964. */
  17965. particleTexture: Nullable<Texture>;
  17966. /**
  17967. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17968. */
  17969. blendMode: number;
  17970. /**
  17971. * Minimum life time of emitting particles.
  17972. */
  17973. minLifeTime: number;
  17974. /**
  17975. * Maximum life time of emitting particles.
  17976. */
  17977. maxLifeTime: number;
  17978. /**
  17979. * Minimum Size of emitting particles.
  17980. */
  17981. minSize: number;
  17982. /**
  17983. * Maximum Size of emitting particles.
  17984. */
  17985. maxSize: number;
  17986. /**
  17987. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17988. */
  17989. color1: Color4;
  17990. /**
  17991. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17992. */
  17993. color2: Color4;
  17994. /**
  17995. * Color the particle will have at the end of its lifetime.
  17996. */
  17997. colorDead: Color4;
  17998. /**
  17999. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18000. */
  18001. emitRate: number;
  18002. /**
  18003. * You can use gravity if you want to give an orientation to your particles.
  18004. */
  18005. gravity: Vector3;
  18006. /**
  18007. * Minimum power of emitting particles.
  18008. */
  18009. minEmitPower: number;
  18010. /**
  18011. * Maximum power of emitting particles.
  18012. */
  18013. maxEmitPower: number;
  18014. /**
  18015. * The particle emitter type defines the emitter used by the particle system.
  18016. * It can be for example box, sphere, or cone...
  18017. */
  18018. particleEmitterType: Nullable<IParticleEmitterType>;
  18019. /**
  18020. * Gets the maximum number of particles active at the same time.
  18021. * @returns The max number of active particles.
  18022. */
  18023. getCapacity(): number;
  18024. /**
  18025. * Gets Wether the system has been started.
  18026. * @returns True if it has been started, otherwise false.
  18027. */
  18028. isStarted(): boolean;
  18029. /**
  18030. * Gets if the particle system has been started.
  18031. * @return true if the system has been started, otherwise false.
  18032. */
  18033. isStarted(): boolean;
  18034. /**
  18035. * Animates the particle system for this frame.
  18036. */
  18037. animate(): void;
  18038. /**
  18039. * Renders the particle system in its current state.
  18040. * @returns the current number of particles
  18041. */
  18042. render(): number;
  18043. /**
  18044. * Dispose the particle system and frees its associated resources.
  18045. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18046. */
  18047. dispose(disposeTexture?: boolean): void;
  18048. /**
  18049. * Clones the particle system.
  18050. * @param name The name of the cloned object
  18051. * @param newEmitter The new emitter to use
  18052. * @returns the cloned particle system
  18053. */
  18054. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18055. /**
  18056. * Serializes the particle system to a JSON object.
  18057. * @returns the JSON object
  18058. */
  18059. serialize(): any;
  18060. /**
  18061. * Rebuild the particle system
  18062. */
  18063. rebuild(): void;
  18064. /**
  18065. * Starts the particle system and begins to emit.
  18066. */
  18067. start(): void;
  18068. /**
  18069. * Stops the particle system.
  18070. */
  18071. stop(): void;
  18072. /**
  18073. * Remove all active particles
  18074. */
  18075. reset(): void;
  18076. /**
  18077. * Is this system ready to be used/rendered
  18078. * @return true if the system is ready
  18079. */
  18080. isReady(): boolean;
  18081. }
  18082. }
  18083. declare module BABYLON {
  18084. /**
  18085. * A particle represents one of the element emitted by a particle system.
  18086. * This is mainly define by its coordinates, direction, velocity and age.
  18087. */
  18088. class Particle {
  18089. /**
  18090. * particleSystem the particle system the particle belongs to.
  18091. */
  18092. particleSystem: ParticleSystem;
  18093. /**
  18094. * The world position of the particle in the scene.
  18095. */
  18096. position: Vector3;
  18097. /**
  18098. * The world direction of the particle in the scene.
  18099. */
  18100. direction: Vector3;
  18101. /**
  18102. * The color of the particle.
  18103. */
  18104. color: Color4;
  18105. /**
  18106. * The color change of the particle per step.
  18107. */
  18108. colorStep: Color4;
  18109. /**
  18110. * Defines how long will the life of the particle be.
  18111. */
  18112. lifeTime: number;
  18113. /**
  18114. * The current age of the particle.
  18115. */
  18116. age: number;
  18117. /**
  18118. * The current size of the particle.
  18119. */
  18120. size: number;
  18121. /**
  18122. * The current angle of the particle.
  18123. */
  18124. angle: number;
  18125. /**
  18126. * Defines how fast is the angle changing.
  18127. */
  18128. angularSpeed: number;
  18129. /**
  18130. * Defines the cell index used by the particle to be rendered from a sprite.
  18131. */
  18132. cellIndex: number;
  18133. private _currentFrameCounter;
  18134. /**
  18135. * Creates a new instance of @see Particle
  18136. * @param particleSystem the particle system the particle belongs to
  18137. */
  18138. constructor(
  18139. /**
  18140. * particleSystem the particle system the particle belongs to.
  18141. */
  18142. particleSystem: ParticleSystem);
  18143. private updateCellInfoFromSystem();
  18144. /**
  18145. * Defines how the sprite cell index is updated for the particle. This is
  18146. * defined as a callback.
  18147. */
  18148. updateCellIndex: (scaledUpdateSpeed: number) => void;
  18149. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  18150. private _updateCellIndexWithCustomSpeed();
  18151. /**
  18152. * Copy the properties of particle to another one.
  18153. * @param other the particle to copy the information to.
  18154. */
  18155. copyTo(other: Particle): void;
  18156. }
  18157. }
  18158. declare module BABYLON {
  18159. /**
  18160. * This represents a particle system in Babylon.
  18161. * 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.
  18162. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  18163. * @example https://doc.babylonjs.com/babylon101/particles
  18164. */
  18165. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  18166. /**
  18167. * Source color is added to the destination color without alpha affecting the result.
  18168. */
  18169. static BLENDMODE_ONEONE: number;
  18170. /**
  18171. * Blend current color and particle color using particle’s alpha.
  18172. */
  18173. static BLENDMODE_STANDARD: number;
  18174. /**
  18175. * List of animations used by the particle system.
  18176. */
  18177. animations: Animation[];
  18178. /**
  18179. * The id of the Particle system.
  18180. */
  18181. id: string;
  18182. /**
  18183. * The friendly name of the Particle system.
  18184. */
  18185. name: string;
  18186. /**
  18187. * The rendering group used by the Particle system to chose when to render.
  18188. */
  18189. renderingGroupId: number;
  18190. /**
  18191. * The emitter represents the Mesh or position we are attaching the particle system to.
  18192. */
  18193. emitter: Nullable<AbstractMesh | Vector3>;
  18194. /**
  18195. * The maximum number of particles to emit per frame
  18196. */
  18197. emitRate: number;
  18198. /**
  18199. * If you want to launch only a few particles at once, that can be done, as well.
  18200. */
  18201. manualEmitCount: number;
  18202. /**
  18203. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18204. */
  18205. updateSpeed: number;
  18206. /**
  18207. * The amount of time the particle system is running (depends of the overall update speed).
  18208. */
  18209. targetStopDuration: number;
  18210. /**
  18211. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18212. */
  18213. disposeOnStop: boolean;
  18214. /**
  18215. * Minimum power of emitting particles.
  18216. */
  18217. minEmitPower: number;
  18218. /**
  18219. * Maximum power of emitting particles.
  18220. */
  18221. maxEmitPower: number;
  18222. /**
  18223. * Minimum life time of emitting particles.
  18224. */
  18225. minLifeTime: number;
  18226. /**
  18227. * Maximum life time of emitting particles.
  18228. */
  18229. maxLifeTime: number;
  18230. /**
  18231. * Minimum Size of emitting particles.
  18232. */
  18233. minSize: number;
  18234. /**
  18235. * Maximum Size of emitting particles.
  18236. */
  18237. maxSize: number;
  18238. /**
  18239. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18240. */
  18241. minAngularSpeed: number;
  18242. /**
  18243. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18244. */
  18245. maxAngularSpeed: number;
  18246. /**
  18247. * The texture used to render each particle. (this can be a spritesheet)
  18248. */
  18249. particleTexture: Nullable<Texture>;
  18250. /**
  18251. * The layer mask we are rendering the particles through.
  18252. */
  18253. layerMask: number;
  18254. /**
  18255. * This can help using your own shader to render the particle system.
  18256. * The according effect will be created
  18257. */
  18258. customShader: any;
  18259. /**
  18260. * By default particle system starts as soon as they are created. This prevents the
  18261. * automatic start to happen and let you decide when to start emitting particles.
  18262. */
  18263. preventAutoStart: boolean;
  18264. /**
  18265. * This function can be defined to provide custom update for active particles.
  18266. * This function will be called instead of regular update (age, position, color, etc.).
  18267. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  18268. */
  18269. updateFunction: (particles: Particle[]) => void;
  18270. /**
  18271. * Callback triggered when the particle animation is ending.
  18272. */
  18273. onAnimationEnd: Nullable<() => void>;
  18274. /**
  18275. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18276. */
  18277. blendMode: number;
  18278. /**
  18279. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  18280. * to override the particles.
  18281. */
  18282. forceDepthWrite: boolean;
  18283. /**
  18284. * You can use gravity if you want to give an orientation to your particles.
  18285. */
  18286. gravity: Vector3;
  18287. /**
  18288. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18289. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18290. */
  18291. direction1: Vector3;
  18292. /**
  18293. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18294. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18295. */
  18296. direction2: Vector3;
  18297. /**
  18298. * 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.
  18299. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18300. */
  18301. minEmitBox: Vector3;
  18302. /**
  18303. * 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.
  18304. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18305. */
  18306. maxEmitBox: Vector3;
  18307. /**
  18308. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18309. */
  18310. color1: Color4;
  18311. /**
  18312. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18313. */
  18314. color2: Color4;
  18315. /**
  18316. * Color the particle will have at the end of its lifetime.
  18317. */
  18318. colorDead: Color4;
  18319. /**
  18320. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  18321. */
  18322. textureMask: Color4;
  18323. /**
  18324. * The particle emitter type defines the emitter used by the particle system.
  18325. * It can be for example box, sphere, or cone...
  18326. */
  18327. particleEmitterType: IParticleEmitterType;
  18328. /**
  18329. * This function can be defined to specify initial direction for every new particle.
  18330. * It by default use the emitterType defined function.
  18331. */
  18332. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  18333. /**
  18334. * This function can be defined to specify initial position for every new particle.
  18335. * It by default use the emitterType defined function.
  18336. */
  18337. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  18338. /**
  18339. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  18340. */
  18341. spriteCellLoop: boolean;
  18342. /**
  18343. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  18344. */
  18345. spriteCellChangeSpeed: number;
  18346. /**
  18347. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  18348. */
  18349. startSpriteCellID: number;
  18350. /**
  18351. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  18352. */
  18353. endSpriteCellID: number;
  18354. /**
  18355. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  18356. */
  18357. spriteCellWidth: number;
  18358. /**
  18359. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  18360. */
  18361. spriteCellHeight: number;
  18362. /**
  18363. * An event triggered when the system is disposed.
  18364. */
  18365. onDisposeObservable: Observable<ParticleSystem>;
  18366. private _onDisposeObserver;
  18367. /**
  18368. * Sets a callback that will be triggered when the system is disposed.
  18369. */
  18370. onDispose: () => void;
  18371. /**
  18372. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  18373. */
  18374. readonly isAnimationSheetEnabled: Boolean;
  18375. private _particles;
  18376. private _epsilon;
  18377. private _capacity;
  18378. private _scene;
  18379. private _stockParticles;
  18380. private _newPartsExcess;
  18381. private _vertexData;
  18382. private _vertexBuffer;
  18383. private _vertexBuffers;
  18384. private _indexBuffer;
  18385. private _effect;
  18386. private _customEffect;
  18387. private _cachedDefines;
  18388. private _scaledColorStep;
  18389. private _colorDiff;
  18390. private _scaledDirection;
  18391. private _scaledGravity;
  18392. private _currentRenderId;
  18393. private _alive;
  18394. private _started;
  18395. private _stopped;
  18396. private _actualFrame;
  18397. private _scaledUpdateSpeed;
  18398. private _vertexBufferSize;
  18399. private _isAnimationSheetEnabled;
  18400. /**
  18401. * 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.
  18402. */
  18403. subEmitters: ParticleSystem[];
  18404. /**
  18405. * The current active Sub-systems, this property is used by the root particle system only.
  18406. */
  18407. activeSubSystems: Array<ParticleSystem>;
  18408. private _rootParticleSystem;
  18409. /**
  18410. * Gets the current list of active particles
  18411. */
  18412. readonly particles: Particle[];
  18413. /**
  18414. * Returns the string "ParticleSystem"
  18415. * @returns a string containing the class name
  18416. */
  18417. getClassName(): string;
  18418. /**
  18419. * Instantiates a particle system.
  18420. * 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.
  18421. * @param name The name of the particle system
  18422. * @param capacity The max number of particles alive at the same time
  18423. * @param scene The scene the particle system belongs to
  18424. * @param customEffect a custom effect used to change the way particles are rendered by default
  18425. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  18426. * @param epsilon Offset used to render the particles
  18427. */
  18428. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  18429. private _createIndexBuffer();
  18430. /**
  18431. * Gets the maximum number of particles active at the same time.
  18432. * @returns The max number of active particles.
  18433. */
  18434. getCapacity(): number;
  18435. /**
  18436. * Gets Wether there are still active particles in the system.
  18437. * @returns True if it is alive, otherwise false.
  18438. */
  18439. isAlive(): boolean;
  18440. /**
  18441. * Gets Wether the system has been started.
  18442. * @returns True if it has been started, otherwise false.
  18443. */
  18444. isStarted(): boolean;
  18445. /**
  18446. * Starts the particle system and begins to emit.
  18447. */
  18448. start(): void;
  18449. /**
  18450. * Stops the particle system.
  18451. * @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.
  18452. */
  18453. stop(stopSubEmitters?: boolean): void;
  18454. /**
  18455. * Remove all active particles
  18456. */
  18457. reset(): void;
  18458. /**
  18459. * @ignore (for internal use only)
  18460. */
  18461. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18462. /**
  18463. * @ignore (for internal use only)
  18464. */
  18465. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18466. /**
  18467. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18468. * Its lifetime will start back at 0.
  18469. */
  18470. recycleParticle: (particle: Particle) => void;
  18471. private _stopSubEmitters();
  18472. private _createParticle;
  18473. private _removeFromRoot();
  18474. private _emitFromParticle;
  18475. private _update(newParticles);
  18476. private _getEffect();
  18477. /**
  18478. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18479. */
  18480. animate(): void;
  18481. private _appendParticleVertexes;
  18482. private _appenedParticleVertexesWithSheet(offset, particle);
  18483. private _appenedParticleVertexesNoSheet(offset, particle);
  18484. /**
  18485. * Rebuilds the particle system.
  18486. */
  18487. rebuild(): void;
  18488. /**
  18489. * Is this system ready to be used/rendered
  18490. * @return true if the system is ready
  18491. */
  18492. isReady(): boolean;
  18493. /**
  18494. * Renders the particle system in its current state.
  18495. * @returns the current number of particles
  18496. */
  18497. render(): number;
  18498. /**
  18499. * Disposes the particle system and free the associated resources
  18500. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18501. */
  18502. dispose(disposeTexture?: boolean): void;
  18503. /**
  18504. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  18505. * @param radius The radius of the sphere to emit from
  18506. * @returns the emitter
  18507. */
  18508. createSphereEmitter(radius?: number): SphereParticleEmitter;
  18509. /**
  18510. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  18511. * @param radius The radius of the sphere to emit from
  18512. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18513. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18514. * @returns the emitter
  18515. */
  18516. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  18517. /**
  18518. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  18519. * @param radius The radius of the cone to emit from
  18520. * @param angle The base angle of the cone
  18521. * @returns the emitter
  18522. */
  18523. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  18524. /**
  18525. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18526. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18527. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18528. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18529. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18530. * @returns the emitter
  18531. */
  18532. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18533. /**
  18534. * Clones the particle system.
  18535. * @param name The name of the cloned object
  18536. * @param newEmitter The new emitter to use
  18537. * @returns the cloned particle system
  18538. */
  18539. clone(name: string, newEmitter: any): ParticleSystem;
  18540. /**
  18541. * Serializes the particle system to a JSON object.
  18542. * @returns the JSON object
  18543. */
  18544. serialize(): any;
  18545. /**
  18546. * Parses a JSON object to create a particle system.
  18547. * @param parsedParticleSystem The JSON object to parse
  18548. * @param scene The scene to create the particle system in
  18549. * @param rootUrl The root url to use to load external dependencies like texture
  18550. * @returns the Parsed particle system
  18551. */
  18552. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  18553. }
  18554. }
  18555. declare module BABYLON {
  18556. /**
  18557. * Represents one particle of a solid particle system.
  18558. * @see SolidParticleSystem
  18559. */
  18560. class SolidParticle {
  18561. /**
  18562. * particle global index
  18563. */
  18564. idx: number;
  18565. /**
  18566. * The color of the particle
  18567. */
  18568. color: Nullable<Color4>;
  18569. /**
  18570. * The world space position of the particle.
  18571. */
  18572. position: Vector3;
  18573. /**
  18574. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  18575. */
  18576. rotation: Vector3;
  18577. /**
  18578. * The world space rotation quaternion of the particle.
  18579. */
  18580. rotationQuaternion: Nullable<Quaternion>;
  18581. /**
  18582. * The scaling of the particle.
  18583. */
  18584. scaling: Vector3;
  18585. /**
  18586. * The uvs of the particle.
  18587. */
  18588. uvs: Vector4;
  18589. /**
  18590. * The current speed of the particle.
  18591. */
  18592. velocity: Vector3;
  18593. /**
  18594. * The pivot point in the particle local space.
  18595. */
  18596. pivot: Vector3;
  18597. /**
  18598. * Must the particle be translated from its pivot point in its local space ?
  18599. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  18600. * Default : false
  18601. */
  18602. translateFromPivot: boolean;
  18603. /**
  18604. * Is the particle active or not ?
  18605. */
  18606. alive: boolean;
  18607. /**
  18608. * Is the particle visible or not ?
  18609. */
  18610. isVisible: boolean;
  18611. /**
  18612. * Index of this particle in the global "positions" array (Internal use)
  18613. */
  18614. _pos: number;
  18615. /**
  18616. * Index of this particle in the global "indices" array (Internal use)
  18617. */
  18618. _ind: number;
  18619. /**
  18620. * ModelShape of this particle (Internal use)
  18621. */
  18622. _model: ModelShape;
  18623. /**
  18624. * ModelShape id of this particle
  18625. */
  18626. shapeId: number;
  18627. /**
  18628. * Index of the particle in its shape id (Internal use)
  18629. */
  18630. idxInShape: number;
  18631. /**
  18632. * Reference to the shape model BoundingInfo object (Internal use)
  18633. */
  18634. _modelBoundingInfo: BoundingInfo;
  18635. /**
  18636. * Particle BoundingInfo object (Internal use)
  18637. */
  18638. _boundingInfo: BoundingInfo;
  18639. /**
  18640. * Reference to the SPS what the particle belongs to (Internal use)
  18641. */
  18642. _sps: SolidParticleSystem;
  18643. /**
  18644. * Still set as invisible in order to skip useless computations (Internal use)
  18645. */
  18646. _stillInvisible: boolean;
  18647. /**
  18648. * Last computed particle rotation matrix
  18649. */
  18650. _rotationMatrix: number[];
  18651. /**
  18652. * Parent particle Id, if any.
  18653. * Default null.
  18654. */
  18655. parentId: Nullable<number>;
  18656. /**
  18657. * Internal global position in the SPS.
  18658. */
  18659. _globalPosition: Vector3;
  18660. /**
  18661. * Creates a Solid Particle object.
  18662. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  18663. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  18664. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  18665. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  18666. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  18667. * @param shapeId (integer) is the model shape identifier in the SPS.
  18668. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  18669. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  18670. */
  18671. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  18672. /**
  18673. * Legacy support, changed scale to scaling
  18674. */
  18675. /**
  18676. * Legacy support, changed scale to scaling
  18677. */
  18678. scale: Vector3;
  18679. /**
  18680. * Legacy support, changed quaternion to rotationQuaternion
  18681. */
  18682. /**
  18683. * Legacy support, changed quaternion to rotationQuaternion
  18684. */
  18685. quaternion: Nullable<Quaternion>;
  18686. /**
  18687. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  18688. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  18689. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  18690. * @returns true if it intersects
  18691. */
  18692. intersectsMesh(target: Mesh | SolidParticle): boolean;
  18693. }
  18694. /**
  18695. * Represents the shape of the model used by one particle of a solid particle system.
  18696. * SPS internal tool, don't use it manually.
  18697. * @see SolidParticleSystem
  18698. */
  18699. class ModelShape {
  18700. /**
  18701. * The shape id.
  18702. */
  18703. shapeID: number;
  18704. /**
  18705. * flat array of model positions (internal use)
  18706. */
  18707. _shape: Vector3[];
  18708. /**
  18709. * flat array of model UVs (internal use)
  18710. */
  18711. _shapeUV: number[];
  18712. /**
  18713. * length of the shape in the model indices array (internal use)
  18714. */
  18715. _indicesLength: number;
  18716. /**
  18717. * Custom position function (internal use)
  18718. */
  18719. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  18720. /**
  18721. * Custom vertex function (internal use)
  18722. */
  18723. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  18724. /**
  18725. * 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.
  18726. * SPS internal tool, don't use it manually.
  18727. * @ignore
  18728. */
  18729. 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>);
  18730. }
  18731. /**
  18732. * Represents a Depth Sorted Particle in the solid particle system.
  18733. * @see SolidParticleSystem
  18734. */
  18735. class DepthSortedParticle {
  18736. /**
  18737. * Index of the particle in the "indices" array
  18738. */
  18739. ind: number;
  18740. /**
  18741. * Length of the particle shape in the "indices" array
  18742. */
  18743. indicesLength: number;
  18744. /**
  18745. * Squared distance from the particle to the camera
  18746. */
  18747. sqDistance: number;
  18748. }
  18749. }
  18750. declare module BABYLON {
  18751. /**
  18752. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  18753. *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.
  18754. * The SPS is also a particle system. It provides some methods to manage the particles.
  18755. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  18756. *
  18757. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  18758. */
  18759. class SolidParticleSystem implements IDisposable {
  18760. /**
  18761. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  18762. * Example : var p = SPS.particles[i];
  18763. */
  18764. particles: SolidParticle[];
  18765. /**
  18766. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  18767. */
  18768. nbParticles: number;
  18769. /**
  18770. * If the particles must ever face the camera (default false). Useful for planar particles.
  18771. */
  18772. billboard: boolean;
  18773. /**
  18774. * Recompute normals when adding a shape
  18775. */
  18776. recomputeNormals: boolean;
  18777. /**
  18778. * This a counter ofr your own usage. It's not set by any SPS functions.
  18779. */
  18780. counter: number;
  18781. /**
  18782. * The SPS name. This name is also given to the underlying mesh.
  18783. */
  18784. name: string;
  18785. /**
  18786. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  18787. */
  18788. mesh: Mesh;
  18789. /**
  18790. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  18791. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  18792. */
  18793. vars: any;
  18794. /**
  18795. * This array is populated when the SPS is set as 'pickable'.
  18796. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  18797. * Each element of this array is an object `{idx: int, faceId: int}`.
  18798. * `idx` is the picked particle index in the `SPS.particles` array
  18799. * `faceId` is the picked face index counted within this particle.
  18800. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  18801. */
  18802. pickedParticles: {
  18803. idx: number;
  18804. faceId: number;
  18805. }[];
  18806. /**
  18807. * This array is populated when `enableDepthSort` is set to true.
  18808. * Each element of this array is an instance of the class DepthSortedParticle.
  18809. */
  18810. depthSortedParticles: DepthSortedParticle[];
  18811. /**
  18812. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  18813. */
  18814. _bSphereOnly: boolean;
  18815. /**
  18816. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  18817. */
  18818. _bSphereRadiusFactor: number;
  18819. private _scene;
  18820. private _positions;
  18821. private _indices;
  18822. private _normals;
  18823. private _colors;
  18824. private _uvs;
  18825. private _indices32;
  18826. private _positions32;
  18827. private _normals32;
  18828. private _fixedNormal32;
  18829. private _colors32;
  18830. private _uvs32;
  18831. private _index;
  18832. private _updatable;
  18833. private _pickable;
  18834. private _isVisibilityBoxLocked;
  18835. private _alwaysVisible;
  18836. private _depthSort;
  18837. private _shapeCounter;
  18838. private _copy;
  18839. private _shape;
  18840. private _shapeUV;
  18841. private _color;
  18842. private _computeParticleColor;
  18843. private _computeParticleTexture;
  18844. private _computeParticleRotation;
  18845. private _computeParticleVertex;
  18846. private _computeBoundingBox;
  18847. private _depthSortParticles;
  18848. private _cam_axisZ;
  18849. private _cam_axisY;
  18850. private _cam_axisX;
  18851. private _axisZ;
  18852. private _camera;
  18853. private _particle;
  18854. private _camDir;
  18855. private _camInvertedPosition;
  18856. private _rotMatrix;
  18857. private _invertMatrix;
  18858. private _rotated;
  18859. private _quaternion;
  18860. private _vertex;
  18861. private _normal;
  18862. private _yaw;
  18863. private _pitch;
  18864. private _roll;
  18865. private _halfroll;
  18866. private _halfpitch;
  18867. private _halfyaw;
  18868. private _sinRoll;
  18869. private _cosRoll;
  18870. private _sinPitch;
  18871. private _cosPitch;
  18872. private _sinYaw;
  18873. private _cosYaw;
  18874. private _mustUnrotateFixedNormals;
  18875. private _minimum;
  18876. private _maximum;
  18877. private _minBbox;
  18878. private _maxBbox;
  18879. private _particlesIntersect;
  18880. private _depthSortFunction;
  18881. private _needs32Bits;
  18882. private _pivotBackTranslation;
  18883. private _scaledPivot;
  18884. private _particleHasParent;
  18885. private _parent;
  18886. /**
  18887. * Creates a SPS (Solid Particle System) object.
  18888. * @param name (String) is the SPS name, this will be the underlying mesh name.
  18889. * @param scene (Scene) is the scene in which the SPS is added.
  18890. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  18891. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  18892. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  18893. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  18894. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  18895. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  18896. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  18897. */
  18898. constructor(name: string, scene: Scene, options?: {
  18899. updatable?: boolean;
  18900. isPickable?: boolean;
  18901. enableDepthSort?: boolean;
  18902. particleIntersection?: boolean;
  18903. boundingSphereOnly?: boolean;
  18904. bSphereRadiusFactor?: number;
  18905. });
  18906. /**
  18907. * Builds the SPS underlying mesh. Returns a standard Mesh.
  18908. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  18909. * @returns the created mesh
  18910. */
  18911. buildMesh(): Mesh;
  18912. /**
  18913. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  18914. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  18915. * Thus the particles generated from `digest()` have their property `position` set yet.
  18916. * @param mesh ( Mesh ) is the mesh to be digested
  18917. * @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
  18918. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  18919. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  18920. * @returns the current SPS
  18921. */
  18922. digest(mesh: Mesh, options?: {
  18923. facetNb?: number;
  18924. number?: number;
  18925. delta?: number;
  18926. }): SolidParticleSystem;
  18927. private _unrotateFixedNormals();
  18928. private _resetCopy();
  18929. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  18930. private _posToShape(positions);
  18931. private _uvsToShapeUV(uvs);
  18932. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  18933. /**
  18934. * Adds some particles to the SPS from the model shape. Returns the shape id.
  18935. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  18936. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  18937. * @param nb (positive integer) the number of particles to be created from this model
  18938. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  18939. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  18940. * @returns the number of shapes in the system
  18941. */
  18942. addShape(mesh: Mesh, nb: number, options?: {
  18943. positionFunction?: any;
  18944. vertexFunction?: any;
  18945. }): number;
  18946. private _rebuildParticle(particle);
  18947. /**
  18948. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  18949. * @returns the SPS.
  18950. */
  18951. rebuildMesh(): SolidParticleSystem;
  18952. /**
  18953. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  18954. * This method calls `updateParticle()` for each particle of the SPS.
  18955. * For an animated SPS, it is usually called within the render loop.
  18956. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  18957. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  18958. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  18959. * @returns the SPS.
  18960. */
  18961. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  18962. private _quaternionRotationYPR();
  18963. private _quaternionToRotationMatrix();
  18964. /**
  18965. * Disposes the SPS.
  18966. */
  18967. dispose(): void;
  18968. /**
  18969. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  18970. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18971. * @returns the SPS.
  18972. */
  18973. refreshVisibleSize(): SolidParticleSystem;
  18974. /**
  18975. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  18976. * @param size the size (float) of the visibility box
  18977. * note : this doesn't lock the SPS mesh bounding box.
  18978. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18979. */
  18980. setVisibilityBox(size: number): void;
  18981. /**
  18982. * Gets whether the SPS as always visible or not
  18983. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18984. */
  18985. /**
  18986. * Sets the SPS as always visible or not
  18987. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18988. */
  18989. isAlwaysVisible: boolean;
  18990. /**
  18991. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  18992. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18993. */
  18994. /**
  18995. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  18996. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18997. */
  18998. isVisibilityBoxLocked: boolean;
  18999. /**
  19000. * Gets if `setParticles()` computes the particle rotations or not.
  19001. * Default value : true. The SPS is faster when it's set to false.
  19002. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  19003. */
  19004. /**
  19005. * Tells to `setParticles()` to compute the particle rotations or not.
  19006. * Default value : true. The SPS is faster when it's set to false.
  19007. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  19008. */
  19009. computeParticleRotation: boolean;
  19010. /**
  19011. * Gets if `setParticles()` computes the particle colors or not.
  19012. * Default value : true. The SPS is faster when it's set to false.
  19013. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  19014. */
  19015. /**
  19016. * Tells to `setParticles()` to compute the particle colors or not.
  19017. * Default value : true. The SPS is faster when it's set to false.
  19018. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  19019. */
  19020. computeParticleColor: boolean;
  19021. /**
  19022. * Gets if `setParticles()` computes the particle textures or not.
  19023. * Default value : true. The SPS is faster when it's set to false.
  19024. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  19025. */
  19026. computeParticleTexture: boolean;
  19027. /**
  19028. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  19029. * Default value : false. The SPS is faster when it's set to false.
  19030. * Note : the particle custom vertex positions aren't stored values.
  19031. */
  19032. /**
  19033. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  19034. * Default value : false. The SPS is faster when it's set to false.
  19035. * Note : the particle custom vertex positions aren't stored values.
  19036. */
  19037. computeParticleVertex: boolean;
  19038. /**
  19039. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  19040. */
  19041. /**
  19042. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  19043. */
  19044. computeBoundingBox: boolean;
  19045. /**
  19046. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  19047. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19048. * Default : `true`
  19049. */
  19050. /**
  19051. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  19052. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19053. * Default : `true`
  19054. */
  19055. depthSortParticles: boolean;
  19056. /**
  19057. * This function does nothing. It may be overwritten to set all the particle first values.
  19058. * The SPS doesn't call this function, you may have to call it by your own.
  19059. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19060. */
  19061. initParticles(): void;
  19062. /**
  19063. * This function does nothing. It may be overwritten to recycle a particle.
  19064. * The SPS doesn't call this function, you may have to call it by your own.
  19065. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19066. * @param particle The particle to recycle
  19067. * @returns the recycled particle
  19068. */
  19069. recycleParticle(particle: SolidParticle): SolidParticle;
  19070. /**
  19071. * Updates a particle : this function should be overwritten by the user.
  19072. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  19073. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19074. * @example : just set a particle position or velocity and recycle conditions
  19075. * @param particle The particle to update
  19076. * @returns the updated particle
  19077. */
  19078. updateParticle(particle: SolidParticle): SolidParticle;
  19079. /**
  19080. * Updates a vertex of a particle : it can be overwritten by the user.
  19081. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  19082. * @param particle the current particle
  19083. * @param vertex the current index of the current particle
  19084. * @param pt the index of the current vertex in the particle shape
  19085. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  19086. * @example : just set a vertex particle position
  19087. * @returns the updated vertex
  19088. */
  19089. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  19090. /**
  19091. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  19092. * This does nothing and may be overwritten by the user.
  19093. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19094. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19095. * @param update the boolean update value actually passed to setParticles()
  19096. */
  19097. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19098. /**
  19099. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  19100. * This will be passed three parameters.
  19101. * This does nothing and may be overwritten by the user.
  19102. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19103. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19104. * @param update the boolean update value actually passed to setParticles()
  19105. */
  19106. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19107. }
  19108. }
  19109. declare module BABYLON {
  19110. interface PhysicsImpostorJoint {
  19111. mainImpostor: PhysicsImpostor;
  19112. connectedImpostor: PhysicsImpostor;
  19113. joint: PhysicsJoint;
  19114. }
  19115. class PhysicsEngine {
  19116. private _physicsPlugin;
  19117. gravity: Vector3;
  19118. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  19119. setGravity(gravity: Vector3): void;
  19120. /**
  19121. * Set the time step of the physics engine.
  19122. * default is 1/60.
  19123. * To slow it down, enter 1/600 for example.
  19124. * To speed it up, 1/30
  19125. * @param {number} newTimeStep the new timestep to apply to this world.
  19126. */
  19127. setTimeStep(newTimeStep?: number): void;
  19128. /**
  19129. * Get the time step of the physics engine.
  19130. */
  19131. getTimeStep(): number;
  19132. dispose(): void;
  19133. getPhysicsPluginName(): string;
  19134. static Epsilon: number;
  19135. private _impostors;
  19136. private _joints;
  19137. /**
  19138. * Adding a new impostor for the impostor tracking.
  19139. * This will be done by the impostor itself.
  19140. * @param {PhysicsImpostor} impostor the impostor to add
  19141. */
  19142. addImpostor(impostor: PhysicsImpostor): void;
  19143. /**
  19144. * Remove an impostor from the engine.
  19145. * This impostor and its mesh will not longer be updated by the physics engine.
  19146. * @param {PhysicsImpostor} impostor the impostor to remove
  19147. */
  19148. removeImpostor(impostor: PhysicsImpostor): void;
  19149. /**
  19150. * Add a joint to the physics engine
  19151. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  19152. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  19153. * @param {PhysicsJoint} the joint that will connect both impostors.
  19154. */
  19155. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19156. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19157. /**
  19158. * Called by the scene. no need to call it.
  19159. */
  19160. _step(delta: number): void;
  19161. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19162. getImpostors(): Array<PhysicsImpostor>;
  19163. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19164. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19165. }
  19166. interface IPhysicsEnginePlugin {
  19167. world: any;
  19168. name: string;
  19169. setGravity(gravity: Vector3): void;
  19170. setTimeStep(timeStep: number): void;
  19171. getTimeStep(): number;
  19172. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19173. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19174. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19175. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19176. removePhysicsBody(impostor: PhysicsImpostor): void;
  19177. generateJoint(joint: PhysicsImpostorJoint): void;
  19178. removeJoint(joint: PhysicsImpostorJoint): void;
  19179. isSupported(): boolean;
  19180. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19181. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19182. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19183. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19184. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19185. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19186. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19187. getBodyMass(impostor: PhysicsImpostor): number;
  19188. getBodyFriction(impostor: PhysicsImpostor): number;
  19189. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19190. getBodyRestitution(impostor: PhysicsImpostor): number;
  19191. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19192. sleepBody(impostor: PhysicsImpostor): void;
  19193. wakeUpBody(impostor: PhysicsImpostor): void;
  19194. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19195. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19196. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19197. getRadius(impostor: PhysicsImpostor): number;
  19198. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19199. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19200. dispose(): void;
  19201. }
  19202. }
  19203. declare module BABYLON {
  19204. class PhysicsHelper {
  19205. private _scene;
  19206. private _physicsEngine;
  19207. constructor(scene: Scene);
  19208. /**
  19209. * @param {Vector3} origin the origin of the explosion
  19210. * @param {number} radius the explosion radius
  19211. * @param {number} strength the explosion strength
  19212. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  19213. */
  19214. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  19215. /**
  19216. * @param {Vector3} origin the origin of the explosion
  19217. * @param {number} radius the explosion radius
  19218. * @param {number} strength the explosion strength
  19219. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  19220. */
  19221. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  19222. /**
  19223. * @param {Vector3} origin the origin of the explosion
  19224. * @param {number} radius the explosion radius
  19225. * @param {number} strength the explosion strength
  19226. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  19227. */
  19228. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  19229. /**
  19230. * @param {Vector3} origin the origin of the updraft
  19231. * @param {number} radius the radius of the updraft
  19232. * @param {number} strength the strength of the updraft
  19233. * @param {number} height the height of the updraft
  19234. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  19235. */
  19236. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  19237. /**
  19238. * @param {Vector3} origin the of the vortex
  19239. * @param {number} radius the radius of the vortex
  19240. * @param {number} strength the strength of the vortex
  19241. * @param {number} height the height of the vortex
  19242. */
  19243. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  19244. }
  19245. /***** Radial explosion *****/
  19246. class PhysicsRadialExplosionEvent {
  19247. private _scene;
  19248. private _sphere;
  19249. private _sphereOptions;
  19250. private _rays;
  19251. private _dataFetched;
  19252. constructor(scene: Scene);
  19253. /**
  19254. * Returns the data related to the radial explosion event (sphere & rays).
  19255. * @returns {PhysicsRadialExplosionEventData}
  19256. */
  19257. getData(): PhysicsRadialExplosionEventData;
  19258. /**
  19259. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  19260. * @param impostor
  19261. * @param {Vector3} origin the origin of the explosion
  19262. * @param {number} radius the explosion radius
  19263. * @param {number} strength the explosion strength
  19264. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  19265. * @returns {Nullable<PhysicsForceAndContactPoint>}
  19266. */
  19267. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  19268. /**
  19269. * Disposes the sphere.
  19270. * @param {bolean} force
  19271. */
  19272. dispose(force?: boolean): void;
  19273. /*** Helpers ***/
  19274. private _prepareSphere();
  19275. private _intersectsWithSphere(impostor, origin, radius);
  19276. }
  19277. /***** Gravitational Field *****/
  19278. class PhysicsGravitationalFieldEvent {
  19279. private _physicsHelper;
  19280. private _scene;
  19281. private _origin;
  19282. private _radius;
  19283. private _strength;
  19284. private _falloff;
  19285. private _tickCallback;
  19286. private _sphere;
  19287. private _dataFetched;
  19288. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  19289. /**
  19290. * Returns the data related to the gravitational field event (sphere).
  19291. * @returns {PhysicsGravitationalFieldEventData}
  19292. */
  19293. getData(): PhysicsGravitationalFieldEventData;
  19294. /**
  19295. * Enables the gravitational field.
  19296. */
  19297. enable(): void;
  19298. /**
  19299. * Disables the gravitational field.
  19300. */
  19301. disable(): void;
  19302. /**
  19303. * Disposes the sphere.
  19304. * @param {bolean} force
  19305. */
  19306. dispose(force?: boolean): void;
  19307. private _tick();
  19308. }
  19309. /***** Updraft *****/
  19310. class PhysicsUpdraftEvent {
  19311. private _scene;
  19312. private _origin;
  19313. private _radius;
  19314. private _strength;
  19315. private _height;
  19316. private _updraftMode;
  19317. private _physicsEngine;
  19318. private _originTop;
  19319. private _originDirection;
  19320. private _tickCallback;
  19321. private _cylinder;
  19322. private _cylinderPosition;
  19323. private _dataFetched;
  19324. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  19325. /**
  19326. * Returns the data related to the updraft event (cylinder).
  19327. * @returns {PhysicsUpdraftEventData}
  19328. */
  19329. getData(): PhysicsUpdraftEventData;
  19330. /**
  19331. * Enables the updraft.
  19332. */
  19333. enable(): void;
  19334. /**
  19335. * Disables the cortex.
  19336. */
  19337. disable(): void;
  19338. /**
  19339. * Disposes the sphere.
  19340. * @param {bolean} force
  19341. */
  19342. dispose(force?: boolean): void;
  19343. private getImpostorForceAndContactPoint(impostor);
  19344. private _tick();
  19345. /*** Helpers ***/
  19346. private _prepareCylinder();
  19347. private _intersectsWithCylinder(impostor);
  19348. }
  19349. /***** Vortex *****/
  19350. class PhysicsVortexEvent {
  19351. private _scene;
  19352. private _origin;
  19353. private _radius;
  19354. private _strength;
  19355. private _height;
  19356. private _physicsEngine;
  19357. private _originTop;
  19358. private _centripetalForceThreshold;
  19359. private _updraftMultiplier;
  19360. private _tickCallback;
  19361. private _cylinder;
  19362. private _cylinderPosition;
  19363. private _dataFetched;
  19364. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  19365. /**
  19366. * Returns the data related to the vortex event (cylinder).
  19367. * @returns {PhysicsVortexEventData}
  19368. */
  19369. getData(): PhysicsVortexEventData;
  19370. /**
  19371. * Enables the vortex.
  19372. */
  19373. enable(): void;
  19374. /**
  19375. * Disables the cortex.
  19376. */
  19377. disable(): void;
  19378. /**
  19379. * Disposes the sphere.
  19380. * @param {bolean} force
  19381. */
  19382. dispose(force?: boolean): void;
  19383. private getImpostorForceAndContactPoint(impostor);
  19384. private _tick();
  19385. /*** Helpers ***/
  19386. private _prepareCylinder();
  19387. private _intersectsWithCylinder(impostor);
  19388. }
  19389. /***** Enums *****/
  19390. /**
  19391. * The strenght of the force in correspondence to the distance of the affected object
  19392. */
  19393. enum PhysicsRadialImpulseFalloff {
  19394. Constant = 0,
  19395. Linear = 1,
  19396. }
  19397. /**
  19398. * The strenght of the force in correspondence to the distance of the affected object
  19399. */
  19400. enum PhysicsUpdraftMode {
  19401. Center = 0,
  19402. Perpendicular = 1,
  19403. }
  19404. /***** Data interfaces *****/
  19405. interface PhysicsForceAndContactPoint {
  19406. force: Vector3;
  19407. contactPoint: Vector3;
  19408. }
  19409. interface PhysicsRadialExplosionEventData {
  19410. sphere: Mesh;
  19411. rays: Array<Ray>;
  19412. }
  19413. interface PhysicsGravitationalFieldEventData {
  19414. sphere: Mesh;
  19415. }
  19416. interface PhysicsUpdraftEventData {
  19417. cylinder: Mesh;
  19418. }
  19419. interface PhysicsVortexEventData {
  19420. cylinder: Mesh;
  19421. }
  19422. }
  19423. declare module BABYLON {
  19424. interface PhysicsImpostorParameters {
  19425. mass: number;
  19426. friction?: number;
  19427. restitution?: number;
  19428. nativeOptions?: any;
  19429. ignoreParent?: boolean;
  19430. disableBidirectionalTransformation?: boolean;
  19431. }
  19432. interface IPhysicsEnabledObject {
  19433. position: Vector3;
  19434. rotationQuaternion: Nullable<Quaternion>;
  19435. scaling: Vector3;
  19436. rotation?: Vector3;
  19437. parent?: any;
  19438. getBoundingInfo(): BoundingInfo;
  19439. computeWorldMatrix(force: boolean): Matrix;
  19440. getWorldMatrix?(): Matrix;
  19441. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19442. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19443. getIndices?(): Nullable<IndicesArray>;
  19444. getScene?(): Scene;
  19445. getAbsolutePosition(): Vector3;
  19446. getAbsolutePivotPoint(): Vector3;
  19447. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19448. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19449. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19450. getClassName(): string;
  19451. }
  19452. class PhysicsImpostor {
  19453. object: IPhysicsEnabledObject;
  19454. type: number;
  19455. private _options;
  19456. private _scene;
  19457. static DEFAULT_OBJECT_SIZE: Vector3;
  19458. static IDENTITY_QUATERNION: Quaternion;
  19459. private _physicsEngine;
  19460. private _physicsBody;
  19461. private _bodyUpdateRequired;
  19462. private _onBeforePhysicsStepCallbacks;
  19463. private _onAfterPhysicsStepCallbacks;
  19464. private _onPhysicsCollideCallbacks;
  19465. private _deltaPosition;
  19466. private _deltaRotation;
  19467. private _deltaRotationConjugated;
  19468. private _parent;
  19469. private _isDisposed;
  19470. private static _tmpVecs;
  19471. private static _tmpQuat;
  19472. readonly isDisposed: boolean;
  19473. mass: number;
  19474. friction: number;
  19475. restitution: number;
  19476. uniqueId: number;
  19477. private _joints;
  19478. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19479. /**
  19480. * This function will completly initialize this impostor.
  19481. * It will create a new body - but only if this mesh has no parent.
  19482. * If it has, this impostor will not be used other than to define the impostor
  19483. * of the child mesh.
  19484. */
  19485. _init(): void;
  19486. private _getPhysicsParent();
  19487. /**
  19488. * Should a new body be generated.
  19489. */
  19490. isBodyInitRequired(): boolean;
  19491. setScalingUpdated(updated: boolean): void;
  19492. /**
  19493. * Force a regeneration of this or the parent's impostor's body.
  19494. * Use under cautious - This will remove all joints already implemented.
  19495. */
  19496. forceUpdate(): void;
  19497. /**
  19498. * Gets the body that holds this impostor. Either its own, or its parent.
  19499. */
  19500. /**
  19501. * Set the physics body. Used mainly by the physics engine/plugin
  19502. */
  19503. physicsBody: any;
  19504. parent: Nullable<PhysicsImpostor>;
  19505. resetUpdateFlags(): void;
  19506. getObjectExtendSize(): Vector3;
  19507. getObjectCenter(): Vector3;
  19508. /**
  19509. * Get a specific parametes from the options parameter.
  19510. */
  19511. getParam(paramName: string): any;
  19512. /**
  19513. * Sets a specific parameter in the options given to the physics plugin
  19514. */
  19515. setParam(paramName: string, value: number): void;
  19516. /**
  19517. * Specifically change the body's mass option. Won't recreate the physics body object
  19518. */
  19519. setMass(mass: number): void;
  19520. getLinearVelocity(): Nullable<Vector3>;
  19521. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19522. getAngularVelocity(): Nullable<Vector3>;
  19523. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19524. /**
  19525. * Execute a function with the physics plugin native code.
  19526. * Provide a function the will have two variables - the world object and the physics body object.
  19527. */
  19528. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19529. /**
  19530. * Register a function that will be executed before the physics world is stepping forward.
  19531. */
  19532. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19533. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19534. /**
  19535. * Register a function that will be executed after the physics step
  19536. */
  19537. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19538. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19539. /**
  19540. * register a function that will be executed when this impostor collides against a different body.
  19541. */
  19542. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19543. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19544. private _tmpQuat;
  19545. private _tmpQuat2;
  19546. getParentsRotation(): Quaternion;
  19547. /**
  19548. * this function is executed by the physics engine.
  19549. */
  19550. beforeStep: () => void;
  19551. /**
  19552. * this function is executed by the physics engine.
  19553. */
  19554. afterStep: () => void;
  19555. /**
  19556. * Legacy collision detection event support
  19557. */
  19558. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19559. onCollide: (e: {
  19560. body: any;
  19561. }) => void;
  19562. /**
  19563. * Apply a force
  19564. */
  19565. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19566. /**
  19567. * Apply an impulse
  19568. */
  19569. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19570. /**
  19571. * A help function to create a joint.
  19572. */
  19573. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19574. /**
  19575. * Add a joint to this impostor with a different impostor.
  19576. */
  19577. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19578. /**
  19579. * Will keep this body still, in a sleep mode.
  19580. */
  19581. sleep(): PhysicsImpostor;
  19582. /**
  19583. * Wake the body up.
  19584. */
  19585. wakeUp(): PhysicsImpostor;
  19586. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19587. dispose(): void;
  19588. setDeltaPosition(position: Vector3): void;
  19589. setDeltaRotation(rotation: Quaternion): void;
  19590. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19591. getRadius(): number;
  19592. /**
  19593. * Sync a bone with this impostor
  19594. * @param bone The bone to sync to the impostor.
  19595. * @param boneMesh The mesh that the bone is influencing.
  19596. * @param jointPivot The pivot of the joint / bone in local space.
  19597. * @param distToJoint Optional distance from the impostor to the joint.
  19598. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19599. */
  19600. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19601. /**
  19602. * Sync impostor to a bone
  19603. * @param bone The bone that the impostor will be synced to.
  19604. * @param boneMesh The mesh that the bone is influencing.
  19605. * @param jointPivot The pivot of the joint / bone in local space.
  19606. * @param distToJoint Optional distance from the impostor to the joint.
  19607. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19608. * @param boneAxis Optional vector3 axis the bone is aligned with
  19609. */
  19610. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19611. static NoImpostor: number;
  19612. static SphereImpostor: number;
  19613. static BoxImpostor: number;
  19614. static PlaneImpostor: number;
  19615. static MeshImpostor: number;
  19616. static CylinderImpostor: number;
  19617. static ParticleImpostor: number;
  19618. static HeightmapImpostor: number;
  19619. }
  19620. }
  19621. declare module BABYLON {
  19622. interface PhysicsJointData {
  19623. mainPivot?: Vector3;
  19624. connectedPivot?: Vector3;
  19625. mainAxis?: Vector3;
  19626. connectedAxis?: Vector3;
  19627. collision?: boolean;
  19628. nativeParams?: any;
  19629. }
  19630. /**
  19631. * This is a holder class for the physics joint created by the physics plugin.
  19632. * It holds a set of functions to control the underlying joint.
  19633. */
  19634. class PhysicsJoint {
  19635. type: number;
  19636. jointData: PhysicsJointData;
  19637. private _physicsJoint;
  19638. protected _physicsPlugin: IPhysicsEnginePlugin;
  19639. constructor(type: number, jointData: PhysicsJointData);
  19640. physicsJoint: any;
  19641. physicsPlugin: IPhysicsEnginePlugin;
  19642. /**
  19643. * Execute a function that is physics-plugin specific.
  19644. * @param {Function} func the function that will be executed.
  19645. * It accepts two parameters: the physics world and the physics joint.
  19646. */
  19647. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19648. static DistanceJoint: number;
  19649. static HingeJoint: number;
  19650. static BallAndSocketJoint: number;
  19651. static WheelJoint: number;
  19652. static SliderJoint: number;
  19653. static PrismaticJoint: number;
  19654. static UniversalJoint: number;
  19655. static Hinge2Joint: number;
  19656. static PointToPointJoint: number;
  19657. static SpringJoint: number;
  19658. static LockJoint: number;
  19659. }
  19660. /**
  19661. * A class representing a physics distance joint.
  19662. */
  19663. class DistanceJoint extends PhysicsJoint {
  19664. constructor(jointData: DistanceJointData);
  19665. /**
  19666. * Update the predefined distance.
  19667. */
  19668. updateDistance(maxDistance: number, minDistance?: number): void;
  19669. }
  19670. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19671. constructor(type: number, jointData: PhysicsJointData);
  19672. /**
  19673. * Set the motor values.
  19674. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19675. * @param {number} force the force to apply
  19676. * @param {number} maxForce max force for this motor.
  19677. */
  19678. setMotor(force?: number, maxForce?: number): void;
  19679. /**
  19680. * Set the motor's limits.
  19681. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19682. */
  19683. setLimit(upperLimit: number, lowerLimit?: number): void;
  19684. }
  19685. /**
  19686. * This class represents a single hinge physics joint
  19687. */
  19688. class HingeJoint extends MotorEnabledJoint {
  19689. constructor(jointData: PhysicsJointData);
  19690. /**
  19691. * Set the motor values.
  19692. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19693. * @param {number} force the force to apply
  19694. * @param {number} maxForce max force for this motor.
  19695. */
  19696. setMotor(force?: number, maxForce?: number): void;
  19697. /**
  19698. * Set the motor's limits.
  19699. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19700. */
  19701. setLimit(upperLimit: number, lowerLimit?: number): void;
  19702. }
  19703. /**
  19704. * This class represents a dual hinge physics joint (same as wheel joint)
  19705. */
  19706. class Hinge2Joint extends MotorEnabledJoint {
  19707. constructor(jointData: PhysicsJointData);
  19708. /**
  19709. * Set the motor values.
  19710. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19711. * @param {number} force the force to apply
  19712. * @param {number} maxForce max force for this motor.
  19713. * @param {motorIndex} the motor's index, 0 or 1.
  19714. */
  19715. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19716. /**
  19717. * Set the motor limits.
  19718. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19719. * @param {number} upperLimit the upper limit
  19720. * @param {number} lowerLimit lower limit
  19721. * @param {motorIndex} the motor's index, 0 or 1.
  19722. */
  19723. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19724. }
  19725. interface IMotorEnabledJoint {
  19726. physicsJoint: any;
  19727. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19728. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19729. }
  19730. interface DistanceJointData extends PhysicsJointData {
  19731. maxDistance: number;
  19732. }
  19733. interface SpringJointData extends PhysicsJointData {
  19734. length: number;
  19735. stiffness: number;
  19736. damping: number;
  19737. }
  19738. }
  19739. declare module BABYLON {
  19740. class ReflectionProbe {
  19741. name: string;
  19742. private _scene;
  19743. private _renderTargetTexture;
  19744. private _projectionMatrix;
  19745. private _viewMatrix;
  19746. private _target;
  19747. private _add;
  19748. private _attachedMesh;
  19749. private _invertYAxis;
  19750. position: Vector3;
  19751. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  19752. samples: number;
  19753. refreshRate: number;
  19754. getScene(): Scene;
  19755. readonly cubeTexture: RenderTargetTexture;
  19756. readonly renderList: Nullable<AbstractMesh[]>;
  19757. attachToMesh(mesh: AbstractMesh): void;
  19758. /**
  19759. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19760. *
  19761. * @param renderingGroupId The rendering group id corresponding to its index
  19762. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19763. */
  19764. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19765. dispose(): void;
  19766. }
  19767. }
  19768. declare module BABYLON {
  19769. class BoundingBoxRenderer {
  19770. frontColor: Color3;
  19771. backColor: Color3;
  19772. showBackLines: boolean;
  19773. renderList: SmartArray<BoundingBox>;
  19774. private _scene;
  19775. private _colorShader;
  19776. private _vertexBuffers;
  19777. private _indexBuffer;
  19778. constructor(scene: Scene);
  19779. private _prepareRessources();
  19780. private _createIndexBuffer();
  19781. _rebuild(): void;
  19782. reset(): void;
  19783. render(): void;
  19784. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  19785. dispose(): void;
  19786. }
  19787. }
  19788. declare module BABYLON {
  19789. /**
  19790. * This represents a depth renderer in Babylon.
  19791. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  19792. */
  19793. class DepthRenderer {
  19794. private _scene;
  19795. private _depthMap;
  19796. private _effect;
  19797. private _cachedDefines;
  19798. private _camera;
  19799. /**
  19800. * Instantiates a depth renderer
  19801. * @param scene The scene the renderer belongs to
  19802. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  19803. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  19804. */
  19805. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  19806. /**
  19807. * Creates the depth rendering effect and checks if the effect is ready.
  19808. * @param subMesh The submesh to be used to render the depth map of
  19809. * @param useInstances If multiple world instances should be used
  19810. * @returns if the depth renderer is ready to render the depth map
  19811. */
  19812. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  19813. /**
  19814. * Gets the texture which the depth map will be written to.
  19815. * @returns The depth map texture
  19816. */
  19817. getDepthMap(): RenderTargetTexture;
  19818. /**
  19819. * Disposes of the depth renderer.
  19820. */
  19821. dispose(): void;
  19822. }
  19823. }
  19824. declare module BABYLON {
  19825. class EdgesRenderer {
  19826. edgesWidthScalerForOrthographic: number;
  19827. edgesWidthScalerForPerspective: number;
  19828. private _source;
  19829. private _linesPositions;
  19830. private _linesNormals;
  19831. private _linesIndices;
  19832. private _epsilon;
  19833. private _indicesCount;
  19834. private _lineShader;
  19835. private _ib;
  19836. private _buffers;
  19837. private _checkVerticesInsteadOfIndices;
  19838. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19839. private _prepareRessources();
  19840. _rebuild(): void;
  19841. dispose(): void;
  19842. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  19843. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  19844. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  19845. _generateEdgesLines(): void;
  19846. render(): void;
  19847. }
  19848. }
  19849. declare module BABYLON {
  19850. /**
  19851. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  19852. */
  19853. class GeometryBufferRenderer {
  19854. private _scene;
  19855. private _multiRenderTarget;
  19856. private _ratio;
  19857. private _enablePosition;
  19858. protected _effect: Effect;
  19859. protected _cachedDefines: string;
  19860. /**
  19861. * Set the render list (meshes to be rendered) used in the G buffer.
  19862. */
  19863. renderList: Mesh[];
  19864. /**
  19865. * Gets wether or not G buffer are supported by the running hardware.
  19866. * This requires draw buffer supports
  19867. */
  19868. readonly isSupported: boolean;
  19869. /**
  19870. * Gets wether or not position are enabled for the G buffer.
  19871. */
  19872. /**
  19873. * Sets wether or not position are enabled for the G buffer.
  19874. */
  19875. enablePosition: boolean;
  19876. /**
  19877. * Gets the scene associated with the buffer.
  19878. */
  19879. readonly scene: Scene;
  19880. /**
  19881. * Gets the ratio used by the buffer during its creation.
  19882. * How big is the buffer related to the main canvas.
  19883. */
  19884. readonly ratio: number;
  19885. /**
  19886. * Creates a new G Buffer for the scene. @see GeometryBufferRenderer
  19887. * @param scene The scene the buffer belongs to
  19888. * @param ratio How big is the buffer related to the main canvas.
  19889. */
  19890. constructor(scene: Scene, ratio?: number);
  19891. /**
  19892. * Checks wether everything is ready to render a submesh to the G buffer.
  19893. * @param subMesh the submesh to check readiness for
  19894. * @param useInstances is the mesh drawn using instance or not
  19895. * @returns true if ready otherwise false
  19896. */
  19897. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  19898. /**
  19899. * Gets the current underlying G Buffer.
  19900. * @returns the buffer
  19901. */
  19902. getGBuffer(): MultiRenderTarget;
  19903. /**
  19904. * Gets the number of samples used to render the buffer (anti aliasing).
  19905. */
  19906. /**
  19907. * Sets the number of samples used to render the buffer (anti aliasing).
  19908. */
  19909. samples: number;
  19910. /**
  19911. * Disposes the renderer and frees up associated resources.
  19912. */
  19913. dispose(): void;
  19914. protected _createRenderTargets(): void;
  19915. }
  19916. }
  19917. declare module BABYLON {
  19918. class OutlineRenderer {
  19919. private _scene;
  19920. private _effect;
  19921. private _cachedDefines;
  19922. zOffset: number;
  19923. constructor(scene: Scene);
  19924. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  19925. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  19926. }
  19927. }
  19928. declare module BABYLON {
  19929. class RenderingGroup {
  19930. index: number;
  19931. private _scene;
  19932. private _opaqueSubMeshes;
  19933. private _transparentSubMeshes;
  19934. private _alphaTestSubMeshes;
  19935. private _depthOnlySubMeshes;
  19936. private _particleSystems;
  19937. private _spriteManagers;
  19938. private _opaqueSortCompareFn;
  19939. private _alphaTestSortCompareFn;
  19940. private _transparentSortCompareFn;
  19941. private _renderOpaque;
  19942. private _renderAlphaTest;
  19943. private _renderTransparent;
  19944. private _edgesRenderers;
  19945. onBeforeTransparentRendering: () => void;
  19946. /**
  19947. * Set the opaque sort comparison function.
  19948. * If null the sub meshes will be render in the order they were created
  19949. */
  19950. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19951. /**
  19952. * Set the alpha test sort comparison function.
  19953. * If null the sub meshes will be render in the order they were created
  19954. */
  19955. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19956. /**
  19957. * Set the transparent sort comparison function.
  19958. * If null the sub meshes will be render in the order they were created
  19959. */
  19960. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19961. /**
  19962. * Creates a new rendering group.
  19963. * @param index The rendering group index
  19964. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19965. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19966. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19967. */
  19968. 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>);
  19969. /**
  19970. * Render all the sub meshes contained in the group.
  19971. * @param customRenderFunction Used to override the default render behaviour of the group.
  19972. * @returns true if rendered some submeshes.
  19973. */
  19974. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19975. /**
  19976. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19977. * @param subMeshes The submeshes to render
  19978. */
  19979. private renderOpaqueSorted(subMeshes);
  19980. /**
  19981. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19982. * @param subMeshes The submeshes to render
  19983. */
  19984. private renderAlphaTestSorted(subMeshes);
  19985. /**
  19986. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19987. * @param subMeshes The submeshes to render
  19988. */
  19989. private renderTransparentSorted(subMeshes);
  19990. /**
  19991. * Renders the submeshes in a specified order.
  19992. * @param subMeshes The submeshes to sort before render
  19993. * @param sortCompareFn The comparison function use to sort
  19994. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19995. * @param transparent Specifies to activate blending if true
  19996. */
  19997. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  19998. /**
  19999. * Renders the submeshes in the order they were dispatched (no sort applied).
  20000. * @param subMeshes The submeshes to render
  20001. */
  20002. private static renderUnsorted(subMeshes);
  20003. /**
  20004. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20005. * are rendered back to front if in the same alpha index.
  20006. *
  20007. * @param a The first submesh
  20008. * @param b The second submesh
  20009. * @returns The result of the comparison
  20010. */
  20011. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20012. /**
  20013. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20014. * are rendered back to front.
  20015. *
  20016. * @param a The first submesh
  20017. * @param b The second submesh
  20018. * @returns The result of the comparison
  20019. */
  20020. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20021. /**
  20022. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20023. * are rendered front to back (prevent overdraw).
  20024. *
  20025. * @param a The first submesh
  20026. * @param b The second submesh
  20027. * @returns The result of the comparison
  20028. */
  20029. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20030. /**
  20031. * Resets the different lists of submeshes to prepare a new frame.
  20032. */
  20033. prepare(): void;
  20034. dispose(): void;
  20035. /**
  20036. * Inserts the submesh in its correct queue depending on its material.
  20037. * @param subMesh The submesh to dispatch
  20038. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20039. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20040. */
  20041. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20042. dispatchSprites(spriteManager: SpriteManager): void;
  20043. dispatchParticles(particleSystem: IParticleSystem): void;
  20044. private _renderParticles(activeMeshes);
  20045. private _renderSprites();
  20046. }
  20047. }
  20048. declare module BABYLON {
  20049. class RenderingManager {
  20050. /**
  20051. * The max id used for rendering groups (not included)
  20052. */
  20053. static MAX_RENDERINGGROUPS: number;
  20054. /**
  20055. * The min id used for rendering groups (included)
  20056. */
  20057. static MIN_RENDERINGGROUPS: number;
  20058. /**
  20059. * Used to globally prevent autoclearing scenes.
  20060. */
  20061. static AUTOCLEAR: boolean;
  20062. private _scene;
  20063. private _renderingGroups;
  20064. private _depthStencilBufferAlreadyCleaned;
  20065. private _autoClearDepthStencil;
  20066. private _customOpaqueSortCompareFn;
  20067. private _customAlphaTestSortCompareFn;
  20068. private _customTransparentSortCompareFn;
  20069. private _renderinGroupInfo;
  20070. constructor(scene: Scene);
  20071. private _clearDepthStencilBuffer(depth?, stencil?);
  20072. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20073. reset(): void;
  20074. dispose(): void;
  20075. /**
  20076. * Clear the info related to rendering groups preventing retention points during dispose.
  20077. */
  20078. freeRenderingGroups(): void;
  20079. private _prepareRenderingGroup(renderingGroupId);
  20080. dispatchSprites(spriteManager: SpriteManager): void;
  20081. dispatchParticles(particleSystem: IParticleSystem): void;
  20082. /**
  20083. * @param subMesh The submesh to dispatch
  20084. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20085. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20086. */
  20087. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20088. /**
  20089. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20090. * This allowed control for front to back rendering or reversly depending of the special needs.
  20091. *
  20092. * @param renderingGroupId The rendering group id corresponding to its index
  20093. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20094. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20095. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20096. */
  20097. 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;
  20098. /**
  20099. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20100. *
  20101. * @param renderingGroupId The rendering group id corresponding to its index
  20102. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20103. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20104. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20105. */
  20106. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20107. }
  20108. }
  20109. declare module BABYLON {
  20110. class AnaglyphPostProcess extends PostProcess {
  20111. private _passedProcess;
  20112. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  20113. }
  20114. }
  20115. declare module BABYLON {
  20116. class BlackAndWhitePostProcess extends PostProcess {
  20117. degree: number;
  20118. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20119. }
  20120. }
  20121. declare module BABYLON {
  20122. /**
  20123. * The Blur Post Process which blurs an image based on a kernel and direction.
  20124. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20125. */
  20126. class BlurPostProcess extends PostProcess {
  20127. /** The direction in which to blur the image. */ direction: Vector2;
  20128. private blockCompilation;
  20129. protected _kernel: number;
  20130. protected _idealKernel: number;
  20131. protected _packedFloat: boolean;
  20132. private _staticDefines;
  20133. /**
  20134. * Gets the length in pixels of the blur sample region
  20135. */
  20136. /**
  20137. * Sets the length in pixels of the blur sample region
  20138. */
  20139. kernel: number;
  20140. /**
  20141. * Gets wether or not the blur is unpacking/repacking floats
  20142. */
  20143. /**
  20144. * Sets wether or not the blur needs to unpack/repack floats
  20145. */
  20146. packedFloat: boolean;
  20147. /**
  20148. * Creates a new instance of @see BlurPostProcess
  20149. * @param name The name of the effect.
  20150. * @param direction The direction in which to blur the image.
  20151. * @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.
  20152. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20153. * @param camera The camera to apply the render pass to.
  20154. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20155. * @param engine The engine which the post process will be applied. (default: current engine)
  20156. * @param reusable If the post process can be reused on the same frame. (default: false)
  20157. * @param textureType Type of textures used when performing the post process. (default: 0)
  20158. * @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)
  20159. */
  20160. 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);
  20161. /**
  20162. * Updates the effect with the current post process compile time values and recompiles the shader.
  20163. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20164. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20165. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20166. * @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
  20167. * @param onCompiled Called when the shader has been compiled.
  20168. * @param onError Called if there is an error when compiling a shader.
  20169. */
  20170. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20171. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20172. /**
  20173. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20174. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20175. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20176. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20177. * The gaps between physical kernels are compensated for in the weighting of the samples
  20178. * @param idealKernel Ideal blur kernel.
  20179. * @return Nearest best kernel.
  20180. */
  20181. protected _nearestBestKernel(idealKernel: number): number;
  20182. /**
  20183. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20184. * @param x The point on the Gaussian distribution to sample.
  20185. * @return the value of the Gaussian function at x.
  20186. */
  20187. protected _gaussianWeight(x: number): number;
  20188. /**
  20189. * Generates a string that can be used as a floating point number in GLSL.
  20190. * @param x Value to print.
  20191. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20192. * @return GLSL float string.
  20193. */
  20194. protected _glslFloat(x: number, decimalFigures?: number): string;
  20195. }
  20196. }
  20197. declare module BABYLON {
  20198. /**
  20199. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  20200. */
  20201. class ChromaticAberrationPostProcess extends PostProcess {
  20202. /**
  20203. * The amount of seperation of rgb channels (default: 30)
  20204. */
  20205. aberrationAmount: number;
  20206. /**
  20207. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  20208. */
  20209. radialIntensity: number;
  20210. /**
  20211. * 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))
  20212. */
  20213. direction: Vector2;
  20214. /**
  20215. * 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))
  20216. */
  20217. centerPosition: Vector2;
  20218. /**
  20219. * Creates a new instance of @see ChromaticAberrationPostProcess
  20220. * @param name The name of the effect.
  20221. * @param screenWidth The width of the screen to apply the effect on.
  20222. * @param screenHeight The height of the screen to apply the effect on.
  20223. * @param options The required width/height ratio to downsize to before computing the render pass.
  20224. * @param camera The camera to apply the render pass to.
  20225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20226. * @param engine The engine which the post process will be applied. (default: current engine)
  20227. * @param reusable If the post process can be reused on the same frame. (default: false)
  20228. * @param textureType Type of textures used when performing the post process. (default: 0)
  20229. * @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)
  20230. */
  20231. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20232. }
  20233. }
  20234. declare module BABYLON {
  20235. /**
  20236. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  20237. */
  20238. class CircleOfConfusionPostProcess extends PostProcess {
  20239. /**
  20240. * 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.
  20241. */
  20242. lensSize: number;
  20243. /**
  20244. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  20245. */
  20246. fStop: number;
  20247. /**
  20248. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  20249. */
  20250. focusDistance: number;
  20251. /**
  20252. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  20253. */
  20254. focalLength: number;
  20255. private _depthTexture;
  20256. /**
  20257. * Creates a new instance of @see CircleOfConfusionPostProcess
  20258. * @param name The name of the effect.
  20259. * @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.
  20260. * @param options The required width/height ratio to downsize to before computing the render pass.
  20261. * @param camera The camera to apply the render pass to.
  20262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20263. * @param engine The engine which the post process will be applied. (default: current engine)
  20264. * @param reusable If the post process can be reused on the same frame. (default: false)
  20265. * @param textureType Type of textures used when performing the post process. (default: 0)
  20266. * @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)
  20267. */
  20268. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20269. /**
  20270. * 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.
  20271. */
  20272. depthTexture: RenderTargetTexture;
  20273. }
  20274. }
  20275. declare module BABYLON {
  20276. class ColorCorrectionPostProcess extends PostProcess {
  20277. private _colorTableTexture;
  20278. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20279. }
  20280. }
  20281. declare module BABYLON {
  20282. /**
  20283. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  20284. * input texture to perform effects such as edge detection or sharpening
  20285. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  20286. */
  20287. class ConvolutionPostProcess extends PostProcess {
  20288. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  20289. /**
  20290. * Creates a new instance of @see ConvolutionPostProcess
  20291. * @param name The name of the effect.
  20292. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  20293. * @param options The required width/height ratio to downsize to before computing the render pass.
  20294. * @param camera The camera to apply the render pass to.
  20295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20296. * @param engine The engine which the post process will be applied. (default: current engine)
  20297. * @param reusable If the post process can be reused on the same frame. (default: false)
  20298. * @param textureType Type of textures used when performing the post process. (default: 0)
  20299. */
  20300. 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);
  20301. /**
  20302. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  20303. */
  20304. static EdgeDetect0Kernel: number[];
  20305. /**
  20306. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  20307. */
  20308. static EdgeDetect1Kernel: number[];
  20309. /**
  20310. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  20311. */
  20312. static EdgeDetect2Kernel: number[];
  20313. /**
  20314. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  20315. */
  20316. static SharpenKernel: number[];
  20317. /**
  20318. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  20319. */
  20320. static EmbossKernel: number[];
  20321. /**
  20322. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  20323. */
  20324. static GaussianKernel: number[];
  20325. }
  20326. }
  20327. declare module BABYLON {
  20328. /**
  20329. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  20330. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  20331. * based on samples that have a large difference in distance than the center pixel.
  20332. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  20333. */
  20334. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  20335. direction: Vector2;
  20336. /**
  20337. * Creates a new instance of @see CircleOfConfusionPostProcess
  20338. * @param name The name of the effect.
  20339. * @param scene The scene the effect belongs to.
  20340. * @param direction The direction the blur should be applied.
  20341. * @param kernel The size of the kernel used to blur.
  20342. * @param options The required width/height ratio to downsize to before computing the render pass.
  20343. * @param camera The camera to apply the render pass to.
  20344. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  20345. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  20346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20347. * @param engine The engine which the post process will be applied. (default: current engine)
  20348. * @param reusable If the post process can be reused on the same frame. (default: false)
  20349. * @param textureType Type of textures used when performing the post process. (default: 0)
  20350. * @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)
  20351. */
  20352. 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);
  20353. }
  20354. }
  20355. declare module BABYLON {
  20356. /**
  20357. * Specifies the level of max blur that should be applied when using the depth of field effect
  20358. */
  20359. enum DepthOfFieldEffectBlurLevel {
  20360. /**
  20361. * Subtle blur
  20362. */
  20363. Low = 0,
  20364. /**
  20365. * Medium blur
  20366. */
  20367. Medium = 1,
  20368. /**
  20369. * Large blur
  20370. */
  20371. High = 2,
  20372. }
  20373. /**
  20374. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  20375. */
  20376. class DepthOfFieldEffect extends PostProcessRenderEffect {
  20377. private _circleOfConfusion;
  20378. private _depthOfFieldBlurX;
  20379. private _depthOfFieldBlurY;
  20380. /**
  20381. * Private, last post process of dof
  20382. */
  20383. _depthOfFieldMerge: DepthOfFieldMergePostProcess;
  20384. private _effects;
  20385. /**
  20386. * The focal the length of the camera used in the effect
  20387. */
  20388. focalLength: number;
  20389. /**
  20390. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  20391. */
  20392. fStop: number;
  20393. /**
  20394. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  20395. */
  20396. focusDistance: number;
  20397. /**
  20398. * 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.
  20399. */
  20400. lensSize: number;
  20401. /**
  20402. * Creates a new instance of @see DepthOfFieldEffect
  20403. * @param scene The scene the effect belongs to.
  20404. * @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.
  20405. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  20406. * @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)
  20407. */
  20408. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  20409. /**
  20410. * 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.
  20411. */
  20412. depthTexture: RenderTargetTexture;
  20413. /**
  20414. * Disposes each of the internal effects for a given camera.
  20415. * @param camera The camera to dispose the effect on.
  20416. */
  20417. disposeEffects(camera: Camera): void;
  20418. /**
  20419. * Internal
  20420. */
  20421. _updateEffects(): void;
  20422. /**
  20423. * Internal
  20424. * @returns if all the contained post processes are ready.
  20425. */
  20426. _isReady(): boolean;
  20427. }
  20428. }
  20429. declare module BABYLON {
  20430. /**
  20431. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  20432. */
  20433. class DepthOfFieldMergePostProcess extends PostProcess {
  20434. private blurSteps;
  20435. /**
  20436. * Creates a new instance of @see CircleOfConfusionPostProcess
  20437. * @param name The name of the effect.
  20438. * @param original The non-blurred image to be modified
  20439. * @param circleOfConfusion The circle of confusion post process that will determine how blurred each pixel should become.
  20440. * @param blurSteps Incrimental bluring post processes.
  20441. * @param options The required width/height ratio to downsize to before computing the render pass.
  20442. * @param camera The camera to apply the render pass to.
  20443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20444. * @param engine The engine which the post process will be applied. (default: current engine)
  20445. * @param reusable If the post process can be reused on the same frame. (default: false)
  20446. * @param textureType Type of textures used when performing the post process. (default: 0)
  20447. * @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)
  20448. */
  20449. 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);
  20450. /**
  20451. * Updates the effect with the current post process compile time values and recompiles the shader.
  20452. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20453. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20454. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20455. * @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
  20456. * @param onCompiled Called when the shader has been compiled.
  20457. * @param onError Called if there is an error when compiling a shader.
  20458. */
  20459. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20460. }
  20461. }
  20462. declare module BABYLON {
  20463. class DisplayPassPostProcess extends PostProcess {
  20464. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20465. }
  20466. }
  20467. declare module BABYLON {
  20468. class FilterPostProcess extends PostProcess {
  20469. kernelMatrix: Matrix;
  20470. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20471. }
  20472. }
  20473. declare module BABYLON {
  20474. class FxaaPostProcess extends PostProcess {
  20475. texelWidth: number;
  20476. texelHeight: number;
  20477. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  20478. }
  20479. }
  20480. declare module BABYLON {
  20481. class HighlightsPostProcess extends PostProcess {
  20482. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  20483. }
  20484. }
  20485. declare module BABYLON {
  20486. class ImageProcessingPostProcess extends PostProcess {
  20487. /**
  20488. * Default configuration related to image processing available in the PBR Material.
  20489. */
  20490. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  20491. /**
  20492. * Gets the image processing configuration used either in this material.
  20493. */
  20494. /**
  20495. * Sets the Default image processing configuration used either in the this material.
  20496. *
  20497. * If sets to null, the scene one is in use.
  20498. */
  20499. imageProcessingConfiguration: ImageProcessingConfiguration;
  20500. /**
  20501. * Keep track of the image processing observer to allow dispose and replace.
  20502. */
  20503. private _imageProcessingObserver;
  20504. /**
  20505. * Attaches a new image processing configuration to the PBR Material.
  20506. * @param configuration
  20507. */
  20508. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  20509. /**
  20510. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  20511. */
  20512. /**
  20513. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  20514. */
  20515. colorCurves: Nullable<ColorCurves>;
  20516. /**
  20517. * Gets wether the color curves effect is enabled.
  20518. */
  20519. /**
  20520. * Sets wether the color curves effect is enabled.
  20521. */
  20522. colorCurvesEnabled: boolean;
  20523. /**
  20524. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  20525. */
  20526. /**
  20527. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  20528. */
  20529. colorGradingTexture: Nullable<BaseTexture>;
  20530. /**
  20531. * Gets wether the color grading effect is enabled.
  20532. */
  20533. /**
  20534. * Gets wether the color grading effect is enabled.
  20535. */
  20536. colorGradingEnabled: boolean;
  20537. /**
  20538. * Gets exposure used in the effect.
  20539. */
  20540. /**
  20541. * Sets exposure used in the effect.
  20542. */
  20543. exposure: number;
  20544. /**
  20545. * Gets wether tonemapping is enabled or not.
  20546. */
  20547. /**
  20548. * Sets wether tonemapping is enabled or not
  20549. */
  20550. toneMappingEnabled: boolean;
  20551. /**
  20552. * Gets contrast used in the effect.
  20553. */
  20554. /**
  20555. * Sets contrast used in the effect.
  20556. */
  20557. contrast: number;
  20558. /**
  20559. * Gets Vignette stretch size.
  20560. */
  20561. /**
  20562. * Sets Vignette stretch size.
  20563. */
  20564. vignetteStretch: number;
  20565. /**
  20566. * Gets Vignette centre X Offset.
  20567. */
  20568. /**
  20569. * Sets Vignette centre X Offset.
  20570. */
  20571. vignetteCentreX: number;
  20572. /**
  20573. * Gets Vignette centre Y Offset.
  20574. */
  20575. /**
  20576. * Sets Vignette centre Y Offset.
  20577. */
  20578. vignetteCentreY: number;
  20579. /**
  20580. * Gets Vignette weight or intensity of the vignette effect.
  20581. */
  20582. /**
  20583. * Sets Vignette weight or intensity of the vignette effect.
  20584. */
  20585. vignetteWeight: number;
  20586. /**
  20587. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  20588. * if vignetteEnabled is set to true.
  20589. */
  20590. /**
  20591. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  20592. * if vignetteEnabled is set to true.
  20593. */
  20594. vignetteColor: Color4;
  20595. /**
  20596. * Gets Camera field of view used by the Vignette effect.
  20597. */
  20598. /**
  20599. * Sets Camera field of view used by the Vignette effect.
  20600. */
  20601. vignetteCameraFov: number;
  20602. /**
  20603. * Gets the vignette blend mode allowing different kind of effect.
  20604. */
  20605. /**
  20606. * Sets the vignette blend mode allowing different kind of effect.
  20607. */
  20608. vignetteBlendMode: number;
  20609. /**
  20610. * Gets wether the vignette effect is enabled.
  20611. */
  20612. /**
  20613. * Sets wether the vignette effect is enabled.
  20614. */
  20615. vignetteEnabled: boolean;
  20616. /**
  20617. * Gets wether the grain effect is enabled.
  20618. */
  20619. /**
  20620. * Sets wether the grain effect is enabled.
  20621. */
  20622. grainEnabled: boolean;
  20623. /**
  20624. * Gets the grain effect's intensity.
  20625. */
  20626. /**
  20627. * Sets the grain effect's intensity.
  20628. */
  20629. grainIntensity: number;
  20630. /**
  20631. * Gets wether the grain effect is animated.
  20632. */
  20633. /**
  20634. * Sets wether the grain effect is animated.
  20635. */
  20636. grainAnimated: boolean;
  20637. private _fromLinearSpace;
  20638. /**
  20639. * Gets wether the input of the processing is in Gamma or Linear Space.
  20640. */
  20641. /**
  20642. * Sets wether the input of the processing is in Gamma or Linear Space.
  20643. */
  20644. fromLinearSpace: boolean;
  20645. /**
  20646. * Defines cache preventing GC.
  20647. */
  20648. private _defines;
  20649. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  20650. getClassName(): string;
  20651. protected _updateParameters(): void;
  20652. dispose(camera?: Camera): void;
  20653. }
  20654. }
  20655. declare module BABYLON {
  20656. class PassPostProcess extends PostProcess {
  20657. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20658. }
  20659. }
  20660. declare module BABYLON {
  20661. type PostProcessOptions = {
  20662. width: number;
  20663. height: number;
  20664. };
  20665. /**
  20666. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20667. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20668. */
  20669. class PostProcess {
  20670. /** Name of the PostProcess. */ name: string;
  20671. /**
  20672. * Width of the texture to apply the post process on
  20673. */
  20674. width: number;
  20675. /**
  20676. * Height of the texture to apply the post process on
  20677. */
  20678. height: number;
  20679. /**
  20680. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20681. */
  20682. _outputTexture: Nullable<InternalTexture>;
  20683. /**
  20684. * Sampling mode used by the shader
  20685. * See https://doc.babylonjs.com/classes/3.1/texture
  20686. */
  20687. renderTargetSamplingMode: number;
  20688. /**
  20689. * Clear color to use when screen clearing
  20690. */
  20691. clearColor: Color4;
  20692. /**
  20693. * If the buffer needs to be cleared before applying the post process. (default: true)
  20694. * Should be set to false if shader will overwrite all previous pixels.
  20695. */
  20696. autoClear: boolean;
  20697. /**
  20698. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20699. */
  20700. alphaMode: number;
  20701. /**
  20702. * Sets the setAlphaBlendConstants of the babylon engine
  20703. */
  20704. alphaConstants: Color4;
  20705. /**
  20706. * Animations to be used for the post processing
  20707. */
  20708. animations: Animation[];
  20709. /**
  20710. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20711. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20712. */
  20713. enablePixelPerfectMode: boolean;
  20714. /**
  20715. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20716. */
  20717. scaleMode: number;
  20718. /**
  20719. * Force textures to be a power of two (default: false)
  20720. */
  20721. alwaysForcePOT: boolean;
  20722. /**
  20723. * Number of sample textures (default: 1)
  20724. */
  20725. samples: number;
  20726. /**
  20727. * Modify the scale of the post process to be the same as the viewport (default: false)
  20728. */
  20729. adaptScaleToCurrentViewport: boolean;
  20730. private _camera;
  20731. private _scene;
  20732. private _engine;
  20733. private _options;
  20734. private _reusable;
  20735. private _textureType;
  20736. /**
  20737. * Smart array of input and output textures for the post process.
  20738. */
  20739. _textures: SmartArray<InternalTexture>;
  20740. /**
  20741. * The index in _textures that corresponds to the output texture.
  20742. */
  20743. _currentRenderTextureInd: number;
  20744. private _effect;
  20745. private _samplers;
  20746. private _fragmentUrl;
  20747. private _vertexUrl;
  20748. private _parameters;
  20749. private _scaleRatio;
  20750. protected _indexParameters: any;
  20751. private _shareOutputWithPostProcess;
  20752. private _texelSize;
  20753. private _forcedOutputTexture;
  20754. /**
  20755. * An event triggered when the postprocess is activated.
  20756. * @type {BABYLON.Observable}
  20757. */
  20758. onActivateObservable: Observable<Camera>;
  20759. private _onActivateObserver;
  20760. /**
  20761. * A function that is added to the onActivateObservable
  20762. */
  20763. onActivate: Nullable<(camera: Camera) => void>;
  20764. /**
  20765. * An event triggered when the postprocess changes its size.
  20766. * @type {BABYLON.Observable}
  20767. */
  20768. onSizeChangedObservable: Observable<PostProcess>;
  20769. private _onSizeChangedObserver;
  20770. /**
  20771. * A function that is added to the onSizeChangedObservable
  20772. */
  20773. onSizeChanged: (postProcess: PostProcess) => void;
  20774. /**
  20775. * An event triggered when the postprocess applies its effect.
  20776. * @type {BABYLON.Observable}
  20777. */
  20778. onApplyObservable: Observable<Effect>;
  20779. private _onApplyObserver;
  20780. /**
  20781. * A function that is added to the onApplyObservable
  20782. */
  20783. onApply: (effect: Effect) => void;
  20784. /**
  20785. * An event triggered before rendering the postprocess
  20786. * @type {BABYLON.Observable}
  20787. */
  20788. onBeforeRenderObservable: Observable<Effect>;
  20789. private _onBeforeRenderObserver;
  20790. /**
  20791. * A function that is added to the onBeforeRenderObservable
  20792. */
  20793. onBeforeRender: (effect: Effect) => void;
  20794. /**
  20795. * An event triggered after rendering the postprocess
  20796. * @type {BABYLON.Observable}
  20797. */
  20798. onAfterRenderObservable: Observable<Effect>;
  20799. private _onAfterRenderObserver;
  20800. /**
  20801. * A function that is added to the onAfterRenderObservable
  20802. */
  20803. onAfterRender: (efect: Effect) => void;
  20804. /**
  20805. * 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
  20806. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20807. */
  20808. inputTexture: InternalTexture;
  20809. /**
  20810. * Gets the camera which post process is applied to.
  20811. * @returns The camera the post process is applied to.
  20812. */
  20813. getCamera(): Camera;
  20814. /**
  20815. * Gets the texel size of the postprocess.
  20816. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20817. */
  20818. readonly texelSize: Vector2;
  20819. /**
  20820. * Creates a new instance of @see PostProcess
  20821. * @param name The name of the PostProcess.
  20822. * @param fragmentUrl The url of the fragment shader to be used.
  20823. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20824. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20825. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20826. * @param camera The camera to apply the render pass to.
  20827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20828. * @param engine The engine which the post process will be applied. (default: current engine)
  20829. * @param reusable If the post process can be reused on the same frame. (default: false)
  20830. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20831. * @param textureType Type of textures used when performing the post process. (default: 0)
  20832. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20833. * @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
  20834. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20835. */
  20836. 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);
  20837. /**
  20838. * Gets the engine which this post process belongs to.
  20839. * @returns The engine the post process was enabled with.
  20840. */
  20841. getEngine(): Engine;
  20842. /**
  20843. * The effect that is created when initializing the post process.
  20844. * @returns The created effect corrisponding the the postprocess.
  20845. */
  20846. getEffect(): Effect;
  20847. /**
  20848. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20849. * @param postProcess The post process to share the output with.
  20850. * @returns This post process.
  20851. */
  20852. shareOutputWith(postProcess: PostProcess): PostProcess;
  20853. /**
  20854. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20855. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20856. */
  20857. useOwnOutput(): void;
  20858. /**
  20859. * Updates the effect with the current post process compile time values and recompiles the shader.
  20860. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20861. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20862. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20863. * @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
  20864. * @param onCompiled Called when the shader has been compiled.
  20865. * @param onError Called if there is an error when compiling a shader.
  20866. */
  20867. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20868. /**
  20869. * The post process is reusable if it can be used multiple times within one frame.
  20870. * @returns If the post process is reusable
  20871. */
  20872. isReusable(): boolean;
  20873. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20874. markTextureDirty(): void;
  20875. /**
  20876. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20877. * 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.
  20878. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20879. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20880. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20881. * @returns The target texture that was bound to be written to.
  20882. */
  20883. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20884. /**
  20885. * If the post process is supported.
  20886. */
  20887. readonly isSupported: boolean;
  20888. /**
  20889. * The aspect ratio of the output texture.
  20890. */
  20891. readonly aspectRatio: number;
  20892. /**
  20893. * Get a value indicating if the post-process is ready to be used
  20894. * @returns true if the post-process is ready (shader is compiled)
  20895. */
  20896. isReady(): boolean;
  20897. /**
  20898. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20899. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  20900. */
  20901. apply(): Nullable<Effect>;
  20902. private _disposeTextures();
  20903. /**
  20904. * Disposes the post process.
  20905. * @param camera The camera to dispose the post process on.
  20906. */
  20907. dispose(camera?: Camera): void;
  20908. }
  20909. }
  20910. declare module BABYLON {
  20911. /**
  20912. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20913. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20914. */
  20915. class PostProcessManager {
  20916. private _scene;
  20917. private _indexBuffer;
  20918. private _vertexBuffers;
  20919. /**
  20920. * Creates a new instance of @see PostProcess
  20921. * @param scene The scene that the post process is associated with.
  20922. */
  20923. constructor(scene: Scene);
  20924. private _prepareBuffers();
  20925. private _buildIndexBuffer();
  20926. /**
  20927. * Rebuilds the vertex buffers of the manager.
  20928. */
  20929. _rebuild(): void;
  20930. /**
  20931. * Prepares a frame to be run through a post process.
  20932. * @param sourceTexture The input texture to the post procesess. (default: null)
  20933. * @param postProcesses An array of post processes to be run. (default: null)
  20934. * @returns True if the post processes were able to be run.
  20935. */
  20936. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20937. /**
  20938. * Manually render a set of post processes to a texture.
  20939. * @param postProcesses An array of post processes to be run.
  20940. * @param targetTexture The target texture to render to.
  20941. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20942. */
  20943. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  20944. /**
  20945. * Finalize the result of the output of the postprocesses.
  20946. * @param doNotPresent If true the result will not be displayed to the screen.
  20947. * @param targetTexture The target texture to render to.
  20948. * @param faceIndex The index of the face to bind the target texture to.
  20949. * @param postProcesses The array of post processes to render.
  20950. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20951. */
  20952. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20953. /**
  20954. * Disposes of the post process manager.
  20955. */
  20956. dispose(): void;
  20957. }
  20958. }
  20959. declare module BABYLON {
  20960. class RefractionPostProcess extends PostProcess {
  20961. color: Color3;
  20962. depth: number;
  20963. colorLevel: number;
  20964. private _refTexture;
  20965. private _ownRefractionTexture;
  20966. /**
  20967. * Gets or sets the refraction texture
  20968. * Please note that you are responsible for disposing the texture if you set it manually
  20969. */
  20970. refractionTexture: Texture;
  20971. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20972. dispose(camera: Camera): void;
  20973. }
  20974. }
  20975. declare module BABYLON {
  20976. /**
  20977. * The SharpenPostProcess applies a sharpen kernel to every pixel
  20978. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  20979. */
  20980. class SharpenPostProcess extends PostProcess {
  20981. /**
  20982. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  20983. */
  20984. colorAmount: number;
  20985. /**
  20986. * How much sharpness should be applied (default: 0.3)
  20987. */
  20988. edgeAmount: number;
  20989. /**
  20990. * Creates a new instance of @see ConvolutionPostProcess
  20991. * @param name The name of the effect.
  20992. * @param options The required width/height ratio to downsize to before computing the render pass.
  20993. * @param camera The camera to apply the render pass to.
  20994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20995. * @param engine The engine which the post process will be applied. (default: current engine)
  20996. * @param reusable If the post process can be reused on the same frame. (default: false)
  20997. * @param textureType Type of textures used when performing the post process. (default: 0)
  20998. * @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)
  20999. */
  21000. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  21001. }
  21002. }
  21003. declare module BABYLON {
  21004. class StereoscopicInterlacePostProcess extends PostProcess {
  21005. private _stepSize;
  21006. private _passedProcess;
  21007. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  21008. }
  21009. }
  21010. declare module BABYLON {
  21011. enum TonemappingOperator {
  21012. Hable = 0,
  21013. Reinhard = 1,
  21014. HejiDawson = 2,
  21015. Photographic = 3,
  21016. }
  21017. class TonemapPostProcess extends PostProcess {
  21018. private _operator;
  21019. exposureAdjustment: number;
  21020. constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  21021. }
  21022. }
  21023. declare module BABYLON {
  21024. class VolumetricLightScatteringPostProcess extends PostProcess {
  21025. private _volumetricLightScatteringPass;
  21026. private _volumetricLightScatteringRTT;
  21027. private _viewPort;
  21028. private _screenCoordinates;
  21029. private _cachedDefines;
  21030. /**
  21031. * If not undefined, the mesh position is computed from the attached node position
  21032. * @type {{position: Vector3}}
  21033. */
  21034. attachedNode: {
  21035. position: Vector3;
  21036. };
  21037. /**
  21038. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  21039. * @type {Vector3}
  21040. */
  21041. customMeshPosition: Vector3;
  21042. /**
  21043. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  21044. * @type {boolean}
  21045. */
  21046. useCustomMeshPosition: boolean;
  21047. /**
  21048. * If the post-process should inverse the light scattering direction
  21049. * @type {boolean}
  21050. */
  21051. invert: boolean;
  21052. /**
  21053. * The internal mesh used by the post-process
  21054. * @type {boolean}
  21055. */
  21056. mesh: Mesh;
  21057. useDiffuseColor: boolean;
  21058. /**
  21059. * Array containing the excluded meshes not rendered in the internal pass
  21060. */
  21061. excludedMeshes: AbstractMesh[];
  21062. /**
  21063. * Controls the overall intensity of the post-process
  21064. * @type {number}
  21065. */
  21066. exposure: number;
  21067. /**
  21068. * Dissipates each sample's contribution in range [0, 1]
  21069. * @type {number}
  21070. */
  21071. decay: number;
  21072. /**
  21073. * Controls the overall intensity of each sample
  21074. * @type {number}
  21075. */
  21076. weight: number;
  21077. /**
  21078. * Controls the density of each sample
  21079. * @type {number}
  21080. */
  21081. density: number;
  21082. /**
  21083. * @constructor
  21084. * @param {string} name - The post-process name
  21085. * @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)
  21086. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  21087. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  21088. * @param {number} samples - The post-process quality, default 100
  21089. * @param {number} samplingMode - The post-process filtering mode
  21090. * @param {BABYLON.Engine} engine - The babylon engine
  21091. * @param {boolean} reusable - If the post-process is reusable
  21092. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  21093. */
  21094. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  21095. getClassName(): string;
  21096. private _isReady(subMesh, useInstances);
  21097. /**
  21098. * Sets the new light position for light scattering effect
  21099. * @param {BABYLON.Vector3} The new custom light position
  21100. */
  21101. setCustomMeshPosition(position: Vector3): void;
  21102. /**
  21103. * Returns the light position for light scattering effect
  21104. * @return {BABYLON.Vector3} The custom light position
  21105. */
  21106. getCustomMeshPosition(): Vector3;
  21107. /**
  21108. * Disposes the internal assets and detaches the post-process from the camera
  21109. */
  21110. dispose(camera: Camera): void;
  21111. /**
  21112. * Returns the render target texture used by the post-process
  21113. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  21114. */
  21115. getPass(): RenderTargetTexture;
  21116. private _meshExcluded(mesh);
  21117. private _createPass(scene, ratio);
  21118. private _updateMeshScreenCoordinates(scene);
  21119. /**
  21120. * Creates a default mesh for the Volumeric Light Scattering post-process
  21121. * @param {string} The mesh name
  21122. * @param {BABYLON.Scene} The scene where to create the mesh
  21123. * @return {BABYLON.Mesh} the default mesh
  21124. */
  21125. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  21126. }
  21127. }
  21128. declare module BABYLON {
  21129. class VRDistortionCorrectionPostProcess extends PostProcess {
  21130. private _isRightEye;
  21131. private _distortionFactors;
  21132. private _postProcessScaleFactor;
  21133. private _lensCenterOffset;
  21134. private _scaleIn;
  21135. private _scaleFactor;
  21136. private _lensCenter;
  21137. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  21138. }
  21139. }
  21140. declare module BABYLON {
  21141. class Sprite {
  21142. name: string;
  21143. position: Vector3;
  21144. color: Color4;
  21145. width: number;
  21146. height: number;
  21147. angle: number;
  21148. cellIndex: number;
  21149. invertU: number;
  21150. invertV: number;
  21151. disposeWhenFinishedAnimating: boolean;
  21152. animations: Animation[];
  21153. isPickable: boolean;
  21154. actionManager: ActionManager;
  21155. private _animationStarted;
  21156. private _loopAnimation;
  21157. private _fromIndex;
  21158. private _toIndex;
  21159. private _delay;
  21160. private _direction;
  21161. private _manager;
  21162. private _time;
  21163. private _onAnimationEnd;
  21164. size: number;
  21165. constructor(name: string, manager: SpriteManager);
  21166. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  21167. stopAnimation(): void;
  21168. _animate(deltaTime: number): void;
  21169. dispose(): void;
  21170. }
  21171. }
  21172. declare module BABYLON {
  21173. class SpriteManager {
  21174. name: string;
  21175. sprites: Sprite[];
  21176. renderingGroupId: number;
  21177. layerMask: number;
  21178. fogEnabled: boolean;
  21179. isPickable: boolean;
  21180. cellWidth: number;
  21181. cellHeight: number;
  21182. /**
  21183. * An event triggered when the manager is disposed.
  21184. * @type {BABYLON.Observable}
  21185. */
  21186. onDisposeObservable: Observable<SpriteManager>;
  21187. private _onDisposeObserver;
  21188. onDispose: () => void;
  21189. private _capacity;
  21190. private _spriteTexture;
  21191. private _epsilon;
  21192. private _scene;
  21193. private _vertexData;
  21194. private _buffer;
  21195. private _vertexBuffers;
  21196. private _indexBuffer;
  21197. private _effectBase;
  21198. private _effectFog;
  21199. texture: Texture;
  21200. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  21201. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  21202. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  21203. render(): void;
  21204. dispose(): void;
  21205. }
  21206. }
  21207. declare module BABYLON {
  21208. class _AlphaState {
  21209. private _isAlphaBlendDirty;
  21210. private _isBlendFunctionParametersDirty;
  21211. private _isBlendEquationParametersDirty;
  21212. private _isBlendConstantsDirty;
  21213. private _alphaBlend;
  21214. private _blendFunctionParameters;
  21215. private _blendEquationParameters;
  21216. private _blendConstants;
  21217. /**
  21218. * Initializes the state.
  21219. */
  21220. constructor();
  21221. readonly isDirty: boolean;
  21222. alphaBlend: boolean;
  21223. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  21224. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  21225. setAlphaEquationParameters(rgb: number, alpha: number): void;
  21226. reset(): void;
  21227. apply(gl: WebGLRenderingContext): void;
  21228. }
  21229. }
  21230. declare module BABYLON {
  21231. class _DepthCullingState {
  21232. private _isDepthTestDirty;
  21233. private _isDepthMaskDirty;
  21234. private _isDepthFuncDirty;
  21235. private _isCullFaceDirty;
  21236. private _isCullDirty;
  21237. private _isZOffsetDirty;
  21238. private _isFrontFaceDirty;
  21239. private _depthTest;
  21240. private _depthMask;
  21241. private _depthFunc;
  21242. private _cull;
  21243. private _cullFace;
  21244. private _zOffset;
  21245. private _frontFace;
  21246. /**
  21247. * Initializes the state.
  21248. */
  21249. constructor();
  21250. readonly isDirty: boolean;
  21251. zOffset: number;
  21252. cullFace: Nullable<number>;
  21253. cull: Nullable<boolean>;
  21254. depthFunc: Nullable<number>;
  21255. depthMask: boolean;
  21256. depthTest: boolean;
  21257. frontFace: Nullable<number>;
  21258. reset(): void;
  21259. apply(gl: WebGLRenderingContext): void;
  21260. }
  21261. }
  21262. declare module BABYLON {
  21263. class _StencilState {
  21264. private _isStencilTestDirty;
  21265. private _isStencilMaskDirty;
  21266. private _isStencilFuncDirty;
  21267. private _isStencilOpDirty;
  21268. private _stencilTest;
  21269. private _stencilMask;
  21270. private _stencilFunc;
  21271. private _stencilFuncRef;
  21272. private _stencilFuncMask;
  21273. private _stencilOpStencilFail;
  21274. private _stencilOpDepthFail;
  21275. private _stencilOpStencilDepthPass;
  21276. readonly isDirty: boolean;
  21277. stencilFunc: number;
  21278. stencilFuncRef: number;
  21279. stencilFuncMask: number;
  21280. stencilOpStencilFail: number;
  21281. stencilOpDepthFail: number;
  21282. stencilOpStencilDepthPass: number;
  21283. stencilMask: number;
  21284. stencilTest: boolean;
  21285. constructor();
  21286. reset(): void;
  21287. apply(gl: WebGLRenderingContext): void;
  21288. }
  21289. }
  21290. declare module BABYLON {
  21291. class AndOrNotEvaluator {
  21292. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  21293. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  21294. private static _SimplifyNegation(booleanString);
  21295. }
  21296. }
  21297. declare module BABYLON {
  21298. /**
  21299. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  21300. */
  21301. enum AssetTaskState {
  21302. /**
  21303. * Initialization
  21304. */
  21305. INIT = 0,
  21306. /**
  21307. * Running
  21308. */
  21309. RUNNING = 1,
  21310. /**
  21311. * Done
  21312. */
  21313. DONE = 2,
  21314. /**
  21315. * Error
  21316. */
  21317. ERROR = 3,
  21318. }
  21319. /**
  21320. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  21321. */
  21322. abstract class AbstractAssetTask {
  21323. /**
  21324. * Task name
  21325. */ name: string;
  21326. /**
  21327. * Callback called when the task is successful
  21328. */
  21329. onSuccess: (task: any) => void;
  21330. /**
  21331. * Callback called when the task is successful
  21332. */
  21333. onError: (task: any, message?: string, exception?: any) => void;
  21334. /**
  21335. * Creates a new {BABYLON.AssetsManager}
  21336. * @param name defines the name of the task
  21337. */
  21338. constructor(
  21339. /**
  21340. * Task name
  21341. */ name: string);
  21342. private _isCompleted;
  21343. private _taskState;
  21344. private _errorObject;
  21345. /**
  21346. * Get if the task is completed
  21347. */
  21348. readonly isCompleted: boolean;
  21349. /**
  21350. * Gets the current state of the task
  21351. */
  21352. readonly taskState: AssetTaskState;
  21353. /**
  21354. * Gets the current error object (if task is in error)
  21355. */
  21356. readonly errorObject: {
  21357. message?: string;
  21358. exception?: any;
  21359. };
  21360. /**
  21361. * Internal only
  21362. * @ignore
  21363. */
  21364. _setErrorObject(message?: string, exception?: any): void;
  21365. /**
  21366. * Execute the current task
  21367. * @param scene defines the scene where you want your assets to be loaded
  21368. * @param onSuccess is a callback called when the task is successfully executed
  21369. * @param onError is a callback called if an error occurs
  21370. */
  21371. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21372. /**
  21373. * Execute the current task
  21374. * @param scene defines the scene where you want your assets to be loaded
  21375. * @param onSuccess is a callback called when the task is successfully executed
  21376. * @param onError is a callback called if an error occurs
  21377. */
  21378. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21379. private onErrorCallback(onError, message?, exception?);
  21380. private onDoneCallback(onSuccess, onError);
  21381. }
  21382. /**
  21383. * Define the interface used by progress events raised during assets loading
  21384. */
  21385. interface IAssetsProgressEvent {
  21386. /**
  21387. * Defines the number of remaining tasks to process
  21388. */
  21389. remainingCount: number;
  21390. /**
  21391. * Defines the total number of tasks
  21392. */
  21393. totalCount: number;
  21394. /**
  21395. * Defines the task that was just processed
  21396. */
  21397. task: AbstractAssetTask;
  21398. }
  21399. /**
  21400. * Class used to share progress information about assets loading
  21401. */
  21402. class AssetsProgressEvent implements IAssetsProgressEvent {
  21403. /**
  21404. * Defines the number of remaining tasks to process
  21405. */
  21406. remainingCount: number;
  21407. /**
  21408. * Defines the total number of tasks
  21409. */
  21410. totalCount: number;
  21411. /**
  21412. * Defines the task that was just processed
  21413. */
  21414. task: AbstractAssetTask;
  21415. /**
  21416. * Creates a {BABYLON.AssetsProgressEvent}
  21417. * @param remainingCount defines the number of remaining tasks to process
  21418. * @param totalCount defines the total number of tasks
  21419. * @param task defines the task that was just processed
  21420. */
  21421. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  21422. }
  21423. /**
  21424. * Define a task used by {BABYLON.AssetsManager} to load meshes
  21425. */
  21426. class MeshAssetTask extends AbstractAssetTask {
  21427. /**
  21428. * Defines the name of the task
  21429. */
  21430. name: string;
  21431. /**
  21432. * Defines the list of mesh's names you want to load
  21433. */
  21434. meshesNames: any;
  21435. /**
  21436. * Defines the root url to use as a base to load your meshes and associated resources
  21437. */
  21438. rootUrl: string;
  21439. /**
  21440. * Defines the filename of the scene to load from
  21441. */
  21442. sceneFilename: string;
  21443. /**
  21444. * Gets the list of loaded meshes
  21445. */
  21446. loadedMeshes: Array<AbstractMesh>;
  21447. /**
  21448. * Gets the list of loaded particle systems
  21449. */
  21450. loadedParticleSystems: Array<ParticleSystem>;
  21451. /**
  21452. * Gets the list of loaded skeletons
  21453. */
  21454. loadedSkeletons: Array<Skeleton>;
  21455. /**
  21456. * Callback called when the task is successful
  21457. */
  21458. onSuccess: (task: MeshAssetTask) => void;
  21459. /**
  21460. * Callback called when the task is successful
  21461. */
  21462. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  21463. /**
  21464. * Creates a new {BABYLON.MeshAssetTask}
  21465. * @param name defines the name of the task
  21466. * @param meshesNames defines the list of mesh's names you want to load
  21467. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  21468. * @param sceneFilename defines the filename of the scene to load from
  21469. */
  21470. constructor(
  21471. /**
  21472. * Defines the name of the task
  21473. */
  21474. name: string,
  21475. /**
  21476. * Defines the list of mesh's names you want to load
  21477. */
  21478. meshesNames: any,
  21479. /**
  21480. * Defines the root url to use as a base to load your meshes and associated resources
  21481. */
  21482. rootUrl: string,
  21483. /**
  21484. * Defines the filename of the scene to load from
  21485. */
  21486. sceneFilename: string);
  21487. /**
  21488. * Execute the current task
  21489. * @param scene defines the scene where you want your assets to be loaded
  21490. * @param onSuccess is a callback called when the task is successfully executed
  21491. * @param onError is a callback called if an error occurs
  21492. */
  21493. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21494. }
  21495. /**
  21496. * Define a task used by {BABYLON.AssetsManager} to load text content
  21497. */
  21498. class TextFileAssetTask extends AbstractAssetTask {
  21499. /**
  21500. * Defines the name of the task
  21501. */
  21502. name: string;
  21503. /**
  21504. * Defines the location of the file to load
  21505. */
  21506. url: string;
  21507. /**
  21508. * Gets the loaded text string
  21509. */
  21510. text: string;
  21511. /**
  21512. * Callback called when the task is successful
  21513. */
  21514. onSuccess: (task: TextFileAssetTask) => void;
  21515. /**
  21516. * Callback called when the task is successful
  21517. */
  21518. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  21519. /**
  21520. * Creates a new TextFileAssetTask object
  21521. * @param name defines the name of the task
  21522. * @param url defines the location of the file to load
  21523. */
  21524. constructor(
  21525. /**
  21526. * Defines the name of the task
  21527. */
  21528. name: string,
  21529. /**
  21530. * Defines the location of the file to load
  21531. */
  21532. url: string);
  21533. /**
  21534. * Execute the current task
  21535. * @param scene defines the scene where you want your assets to be loaded
  21536. * @param onSuccess is a callback called when the task is successfully executed
  21537. * @param onError is a callback called if an error occurs
  21538. */
  21539. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21540. }
  21541. /**
  21542. * Define a task used by {BABYLON.AssetsManager} to load binary data
  21543. */
  21544. class BinaryFileAssetTask extends AbstractAssetTask {
  21545. /**
  21546. * Defines the name of the task
  21547. */
  21548. name: string;
  21549. /**
  21550. * Defines the location of the file to load
  21551. */
  21552. url: string;
  21553. /**
  21554. * Gets the lodaded data (as an array buffer)
  21555. */
  21556. data: ArrayBuffer;
  21557. /**
  21558. * Callback called when the task is successful
  21559. */
  21560. onSuccess: (task: BinaryFileAssetTask) => void;
  21561. /**
  21562. * Callback called when the task is successful
  21563. */
  21564. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  21565. /**
  21566. * Creates a new BinaryFileAssetTask object
  21567. * @param name defines the name of the new task
  21568. * @param url defines the location of the file to load
  21569. */
  21570. constructor(
  21571. /**
  21572. * Defines the name of the task
  21573. */
  21574. name: string,
  21575. /**
  21576. * Defines the location of the file to load
  21577. */
  21578. url: string);
  21579. /**
  21580. * Execute the current task
  21581. * @param scene defines the scene where you want your assets to be loaded
  21582. * @param onSuccess is a callback called when the task is successfully executed
  21583. * @param onError is a callback called if an error occurs
  21584. */
  21585. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21586. }
  21587. /**
  21588. * Define a task used by {BABYLON.AssetsManager} to load images
  21589. */
  21590. class ImageAssetTask extends AbstractAssetTask {
  21591. /**
  21592. * Defines the name of the task
  21593. */
  21594. name: string;
  21595. /**
  21596. * Defines the location of the image to load
  21597. */
  21598. url: string;
  21599. /**
  21600. * Gets the loaded images
  21601. */
  21602. image: HTMLImageElement;
  21603. /**
  21604. * Callback called when the task is successful
  21605. */
  21606. onSuccess: (task: ImageAssetTask) => void;
  21607. /**
  21608. * Callback called when the task is successful
  21609. */
  21610. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  21611. /**
  21612. * Creates a new ImageAssetTask
  21613. * @param name defines the name of the task
  21614. * @param url defines the location of the image to load
  21615. */
  21616. constructor(
  21617. /**
  21618. * Defines the name of the task
  21619. */
  21620. name: string,
  21621. /**
  21622. * Defines the location of the image to load
  21623. */
  21624. url: string);
  21625. /**
  21626. * Execute the current task
  21627. * @param scene defines the scene where you want your assets to be loaded
  21628. * @param onSuccess is a callback called when the task is successfully executed
  21629. * @param onError is a callback called if an error occurs
  21630. */
  21631. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21632. }
  21633. /**
  21634. * Defines the interface used by texture loading tasks
  21635. */
  21636. interface ITextureAssetTask<TEX extends BaseTexture> {
  21637. /**
  21638. * Gets the loaded texture
  21639. */
  21640. texture: TEX;
  21641. }
  21642. /**
  21643. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  21644. */
  21645. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  21646. /**
  21647. * Defines the name of the task
  21648. */
  21649. name: string;
  21650. /**
  21651. * Defines the location of the file to load
  21652. */
  21653. url: string;
  21654. /**
  21655. * Defines if mipmap should not be generated (default is false)
  21656. */
  21657. noMipmap: boolean | undefined;
  21658. /**
  21659. * Defines if texture must be inverted on Y axis (default is false)
  21660. */
  21661. invertY: boolean | undefined;
  21662. /**
  21663. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  21664. */
  21665. samplingMode: number;
  21666. /**
  21667. * Gets the loaded texture
  21668. */
  21669. texture: Texture;
  21670. /**
  21671. * Callback called when the task is successful
  21672. */
  21673. onSuccess: (task: TextureAssetTask) => void;
  21674. /**
  21675. * Callback called when the task is successful
  21676. */
  21677. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  21678. /**
  21679. * Creates a new TextureAssetTask object
  21680. * @param name defines the name of the task
  21681. * @param url defines the location of the file to load
  21682. * @param noMipmap defines if mipmap should not be generated (default is false)
  21683. * @param invertY defines if texture must be inverted on Y axis (default is false)
  21684. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  21685. */
  21686. constructor(
  21687. /**
  21688. * Defines the name of the task
  21689. */
  21690. name: string,
  21691. /**
  21692. * Defines the location of the file to load
  21693. */
  21694. url: string,
  21695. /**
  21696. * Defines if mipmap should not be generated (default is false)
  21697. */
  21698. noMipmap?: boolean | undefined,
  21699. /**
  21700. * Defines if texture must be inverted on Y axis (default is false)
  21701. */
  21702. invertY?: boolean | undefined,
  21703. /**
  21704. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  21705. */
  21706. samplingMode?: number);
  21707. /**
  21708. * Execute the current task
  21709. * @param scene defines the scene where you want your assets to be loaded
  21710. * @param onSuccess is a callback called when the task is successfully executed
  21711. * @param onError is a callback called if an error occurs
  21712. */
  21713. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21714. }
  21715. /**
  21716. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  21717. */
  21718. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  21719. /**
  21720. * Defines the name of the task
  21721. */
  21722. name: string;
  21723. /**
  21724. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  21725. */
  21726. url: string;
  21727. /**
  21728. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  21729. */
  21730. extensions: string[] | undefined;
  21731. /**
  21732. * Defines if mipmaps should not be generated (default is false)
  21733. */
  21734. noMipmap: boolean | undefined;
  21735. /**
  21736. * Defines the explicit list of files (undefined by default)
  21737. */
  21738. files: string[] | undefined;
  21739. /**
  21740. * Gets the loaded texture
  21741. */
  21742. texture: CubeTexture;
  21743. /**
  21744. * Callback called when the task is successful
  21745. */
  21746. onSuccess: (task: CubeTextureAssetTask) => void;
  21747. /**
  21748. * Callback called when the task is successful
  21749. */
  21750. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  21751. /**
  21752. * Creates a new CubeTextureAssetTask
  21753. * @param name defines the name of the task
  21754. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  21755. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  21756. * @param noMipmap defines if mipmaps should not be generated (default is false)
  21757. * @param files defines the explicit list of files (undefined by default)
  21758. */
  21759. constructor(
  21760. /**
  21761. * Defines the name of the task
  21762. */
  21763. name: string,
  21764. /**
  21765. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  21766. */
  21767. url: string,
  21768. /**
  21769. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  21770. */
  21771. extensions?: string[] | undefined,
  21772. /**
  21773. * Defines if mipmaps should not be generated (default is false)
  21774. */
  21775. noMipmap?: boolean | undefined,
  21776. /**
  21777. * Defines the explicit list of files (undefined by default)
  21778. */
  21779. files?: string[] | undefined);
  21780. /**
  21781. * Execute the current task
  21782. * @param scene defines the scene where you want your assets to be loaded
  21783. * @param onSuccess is a callback called when the task is successfully executed
  21784. * @param onError is a callback called if an error occurs
  21785. */
  21786. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21787. }
  21788. /**
  21789. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  21790. */
  21791. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  21792. /**
  21793. * Defines the name of the task
  21794. */
  21795. name: string;
  21796. /**
  21797. * Defines the location of the file to load
  21798. */
  21799. url: string;
  21800. /**
  21801. * 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.
  21802. */
  21803. size: number | undefined;
  21804. /**
  21805. * Defines if mipmaps should not be generated (default is false)
  21806. */
  21807. noMipmap: boolean;
  21808. /**
  21809. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  21810. */
  21811. generateHarmonics: boolean;
  21812. /**
  21813. * 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)
  21814. */
  21815. useInGammaSpace: boolean;
  21816. /**
  21817. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  21818. */
  21819. usePMREMGenerator: boolean;
  21820. /**
  21821. * Gets the loaded texture
  21822. */
  21823. texture: HDRCubeTexture;
  21824. /**
  21825. * Callback called when the task is successful
  21826. */
  21827. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  21828. /**
  21829. * Callback called when the task is successful
  21830. */
  21831. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  21832. /**
  21833. * Creates a new HDRCubeTextureAssetTask object
  21834. * @param name defines the name of the task
  21835. * @param url defines the location of the file to load
  21836. * @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.
  21837. * @param noMipmap defines if mipmaps should not be generated (default is false)
  21838. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  21839. * @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)
  21840. * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  21841. */
  21842. constructor(
  21843. /**
  21844. * Defines the name of the task
  21845. */
  21846. name: string,
  21847. /**
  21848. * Defines the location of the file to load
  21849. */
  21850. url: string,
  21851. /**
  21852. * 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.
  21853. */
  21854. size?: number | undefined,
  21855. /**
  21856. * Defines if mipmaps should not be generated (default is false)
  21857. */
  21858. noMipmap?: boolean,
  21859. /**
  21860. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  21861. */
  21862. generateHarmonics?: boolean,
  21863. /**
  21864. * 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)
  21865. */
  21866. useInGammaSpace?: boolean,
  21867. /**
  21868. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  21869. */
  21870. usePMREMGenerator?: boolean);
  21871. /**
  21872. * Execute the current task
  21873. * @param scene defines the scene where you want your assets to be loaded
  21874. * @param onSuccess is a callback called when the task is successfully executed
  21875. * @param onError is a callback called if an error occurs
  21876. */
  21877. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21878. }
  21879. /**
  21880. * This class can be used to easily import assets into a scene
  21881. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  21882. */
  21883. class AssetsManager {
  21884. private _scene;
  21885. private _isLoading;
  21886. protected _tasks: AbstractAssetTask[];
  21887. protected _waitingTasksCount: number;
  21888. protected _totalTasksCount: number;
  21889. /**
  21890. * Callback called when all tasks are processed
  21891. */
  21892. onFinish: (tasks: AbstractAssetTask[]) => void;
  21893. /**
  21894. * Callback called when a task is successful
  21895. */
  21896. onTaskSuccess: (task: AbstractAssetTask) => void;
  21897. /**
  21898. * Callback called when a task had an error
  21899. */
  21900. onTaskError: (task: AbstractAssetTask) => void;
  21901. /**
  21902. * Callback called when a task is done (whatever the result is)
  21903. */
  21904. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  21905. /**
  21906. * Observable called when all tasks are processed
  21907. */
  21908. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  21909. /**
  21910. * Observable called when a task had an error
  21911. */
  21912. onTaskErrorObservable: Observable<AbstractAssetTask>;
  21913. /**
  21914. * Observable called when a task is successful
  21915. */
  21916. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  21917. /**
  21918. * Observable called when a task is done (whatever the result is)
  21919. */
  21920. onProgressObservable: Observable<IAssetsProgressEvent>;
  21921. /**
  21922. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  21923. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  21924. */
  21925. useDefaultLoadingScreen: boolean;
  21926. /**
  21927. * Creates a new AssetsManager
  21928. * @param scene defines the scene to work on
  21929. */
  21930. constructor(scene: Scene);
  21931. /**
  21932. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  21933. * @param taskName defines the name of the new task
  21934. * @param meshesNames defines the name of meshes to load
  21935. * @param rootUrl defines the root url to use to locate files
  21936. * @param sceneFilename defines the filename of the scene file
  21937. * @returns a new {BABYLON.MeshAssetTask} object
  21938. */
  21939. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  21940. /**
  21941. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  21942. * @param taskName defines the name of the new task
  21943. * @param url defines the url of the file to load
  21944. * @returns a new {BABYLON.TextFileAssetTask} object
  21945. */
  21946. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  21947. /**
  21948. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  21949. * @param taskName defines the name of the new task
  21950. * @param url defines the url of the file to load
  21951. * @returns a new {BABYLON.BinaryFileAssetTask} object
  21952. */
  21953. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  21954. /**
  21955. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  21956. * @param taskName defines the name of the new task
  21957. * @param url defines the url of the file to load
  21958. * @returns a new {BABYLON.ImageAssetTask} object
  21959. */
  21960. addImageTask(taskName: string, url: string): ImageAssetTask;
  21961. /**
  21962. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  21963. * @param taskName defines the name of the new task
  21964. * @param url defines the url of the file to load
  21965. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  21966. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  21967. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  21968. * @returns a new {BABYLON.TextureAssetTask} object
  21969. */
  21970. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  21971. /**
  21972. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  21973. * @param taskName defines the name of the new task
  21974. * @param url defines the url of the file to load
  21975. * @param extensions defines the extension to use to load the cube map (can be null)
  21976. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  21977. * @param files defines the list of files to load (can be null)
  21978. * @returns a new {BABYLON.CubeTextureAssetTask} object
  21979. */
  21980. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  21981. /**
  21982. *
  21983. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  21984. * @param taskName defines the name of the new task
  21985. * @param url defines the url of the file to load
  21986. * @param size defines the size you want for the cubemap (can be null)
  21987. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  21988. * @param generateHarmonics defines if you want to automatically generate (true by default)
  21989. * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
  21990. * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
  21991. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  21992. */
  21993. addHDRCubeTextureTask(taskName: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): HDRCubeTextureAssetTask;
  21994. private _decreaseWaitingTasksCount(task);
  21995. private _runTask(task);
  21996. /**
  21997. * Reset the {BABYLON.AssetsManager} and remove all tasks
  21998. * @return the current instance of the {BABYLON.AssetsManager}
  21999. */
  22000. reset(): AssetsManager;
  22001. /**
  22002. * Start the loading process
  22003. * @return the current instance of the {BABYLON.AssetsManager}
  22004. */
  22005. load(): AssetsManager;
  22006. }
  22007. }
  22008. declare module BABYLON {
  22009. class Database {
  22010. private callbackManifestChecked;
  22011. private currentSceneUrl;
  22012. private db;
  22013. private _enableSceneOffline;
  22014. private _enableTexturesOffline;
  22015. private manifestVersionFound;
  22016. private mustUpdateRessources;
  22017. private hasReachedQuota;
  22018. private isSupported;
  22019. private idbFactory;
  22020. static IsUASupportingBlobStorage: boolean;
  22021. static IDBStorageEnabled: boolean;
  22022. readonly enableSceneOffline: boolean;
  22023. readonly enableTexturesOffline: boolean;
  22024. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  22025. static parseURL: (url: string) => string;
  22026. static ReturnFullUrlLocation: (url: string) => string;
  22027. checkManifestFile(): void;
  22028. openAsync(successCallback: () => void, errorCallback: () => void): void;
  22029. loadImageFromDB(url: string, image: HTMLImageElement): void;
  22030. private _loadImageFromDBAsync(url, image, notInDBCallback);
  22031. private _saveImageIntoDBAsync(url, image);
  22032. private _checkVersionFromDB(url, versionLoaded);
  22033. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  22034. private _saveVersionIntoDBAsync(url, callback);
  22035. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  22036. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  22037. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  22038. }
  22039. }
  22040. declare module BABYLON {
  22041. interface DDSInfo {
  22042. width: number;
  22043. height: number;
  22044. mipmapCount: number;
  22045. isFourCC: boolean;
  22046. isRGB: boolean;
  22047. isLuminance: boolean;
  22048. isCube: boolean;
  22049. isCompressed: boolean;
  22050. dxgiFormat: number;
  22051. textureType: number;
  22052. }
  22053. class DDSTools {
  22054. static StoreLODInAlphaChannel: boolean;
  22055. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  22056. private static _FloatView;
  22057. private static _Int32View;
  22058. private static _ToHalfFloat(value);
  22059. private static _FromHalfFloat(value);
  22060. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  22061. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  22062. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  22063. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  22064. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  22065. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  22066. private static _ExtractLongWordOrder(value);
  22067. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  22068. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  22069. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  22070. }
  22071. }
  22072. declare module BABYLON {
  22073. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  22074. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22075. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22076. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22077. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22078. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22079. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22080. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22081. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22082. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22083. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22084. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22085. class SerializationHelper {
  22086. static Serialize<T>(entity: T, serializationObject?: any): any;
  22087. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  22088. static Clone<T>(creationFunction: () => T, source: T): T;
  22089. static Instanciate<T>(creationFunction: () => T, source: T): T;
  22090. }
  22091. }
  22092. declare module BABYLON {
  22093. /**
  22094. * Wrapper class for promise with external resolve and reject.
  22095. */
  22096. class Deferred<T> {
  22097. /**
  22098. * The promise associated with this deferred object.
  22099. */
  22100. readonly promise: Promise<T>;
  22101. private _resolve;
  22102. private _reject;
  22103. /**
  22104. * The resolve method of the promise associated with this deferred object.
  22105. */
  22106. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  22107. /**
  22108. * The reject method of the promise associated with this deferred object.
  22109. */
  22110. readonly reject: (reason?: any) => void;
  22111. /**
  22112. * Constructor for this deferred object.
  22113. */
  22114. constructor();
  22115. }
  22116. }
  22117. declare module Earcut {
  22118. /**
  22119. * The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
  22120. * @param data is a flat array of vertice coordinates like [x0, y0, x1, y1, x2, y2, ...].
  22121. * @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).
  22122. * @param dim is the number of coordinates per vertice in the input array (2 by default).
  22123. */
  22124. function earcut(data: number[], holeIndices: number[], dim: number): Array<number>;
  22125. /**
  22126. * return a percentage difference between the polygon area and its triangulation area;
  22127. * used to verify correctness of triangulation
  22128. */
  22129. function deviation(data: number[], holeIndices: number[], dim: number, triangles: number[]): number;
  22130. /**
  22131. * turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
  22132. */
  22133. function flatten(data: number[][][]): {
  22134. vertices: number[];
  22135. holes: number[];
  22136. dimensions: number;
  22137. };
  22138. }
  22139. declare module BABYLON {
  22140. class FilesInput {
  22141. static FilesToLoad: {
  22142. [key: string]: File;
  22143. };
  22144. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  22145. private _engine;
  22146. private _currentScene;
  22147. private _sceneLoadedCallback;
  22148. private _progressCallback;
  22149. private _additionalRenderLoopLogicCallback;
  22150. private _textureLoadingCallback;
  22151. private _startingProcessingFilesCallback;
  22152. private _onReloadCallback;
  22153. private _errorCallback;
  22154. private _elementToMonitor;
  22155. private _sceneFileToLoad;
  22156. private _filesToLoad;
  22157. 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);
  22158. private _dragEnterHandler;
  22159. private _dragOverHandler;
  22160. private _dropHandler;
  22161. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  22162. dispose(): void;
  22163. private renderFunction();
  22164. private drag(e);
  22165. private drop(eventDrop);
  22166. private _traverseFolder(folder, files, remaining, callback);
  22167. private _processFiles(files);
  22168. loadFiles(event: any): void;
  22169. private _processReload();
  22170. reload(): void;
  22171. }
  22172. }
  22173. declare module BABYLON {
  22174. /**
  22175. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  22176. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  22177. */
  22178. class KhronosTextureContainer {
  22179. arrayBuffer: any;
  22180. static HEADER_LEN: number;
  22181. static COMPRESSED_2D: number;
  22182. static COMPRESSED_3D: number;
  22183. static TEX_2D: number;
  22184. static TEX_3D: number;
  22185. glType: number;
  22186. glTypeSize: number;
  22187. glFormat: number;
  22188. glInternalFormat: number;
  22189. glBaseInternalFormat: number;
  22190. pixelWidth: number;
  22191. pixelHeight: number;
  22192. pixelDepth: number;
  22193. numberOfArrayElements: number;
  22194. numberOfFaces: number;
  22195. numberOfMipmapLevels: number;
  22196. bytesOfKeyValueData: number;
  22197. loadType: number;
  22198. /**
  22199. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  22200. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  22201. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  22202. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  22203. */
  22204. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  22205. switchEndainness(val: number): number;
  22206. /**
  22207. * It is assumed that the texture has already been created & is currently bound
  22208. */
  22209. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  22210. private _upload2DCompressedLevels(gl, loadMipmaps);
  22211. }
  22212. }
  22213. declare module BABYLON {
  22214. /**
  22215. * A class serves as a medium between the observable and its observers
  22216. */
  22217. class EventState {
  22218. /**
  22219. * Create a new EventState
  22220. * @param mask defines the mask associated with this state
  22221. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  22222. * @param target defines the original target of the state
  22223. * @param currentTarget defines the current target of the state
  22224. */
  22225. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  22226. /**
  22227. * Initialize the current event state
  22228. * @param mask defines the mask associated with this state
  22229. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  22230. * @param target defines the original target of the state
  22231. * @param currentTarget defines the current target of the state
  22232. * @returns the current event state
  22233. */
  22234. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  22235. /**
  22236. * An Observer can set this property to true to prevent subsequent observers of being notified
  22237. */
  22238. skipNextObservers: boolean;
  22239. /**
  22240. * Get the mask value that were used to trigger the event corresponding to this EventState object
  22241. */
  22242. mask: number;
  22243. /**
  22244. * The object that originally notified the event
  22245. */
  22246. target?: any;
  22247. /**
  22248. * The current object in the bubbling phase
  22249. */
  22250. currentTarget?: any;
  22251. /**
  22252. * This will be populated with the return value of the last function that was executed.
  22253. * If it is the first function in the callback chain it will be the event data.
  22254. */
  22255. lastReturnValue?: any;
  22256. }
  22257. /**
  22258. * Represent an Observer registered to a given Observable object.
  22259. */
  22260. class Observer<T> {
  22261. /**
  22262. * Defines the callback to call when the observer is notified
  22263. */
  22264. callback: (eventData: T, eventState: EventState) => void;
  22265. /**
  22266. * Defines the mask of the observer (used to filter notifications)
  22267. */
  22268. mask: number;
  22269. /**
  22270. * Defines the current scope used to restore the JS context
  22271. */
  22272. scope: any;
  22273. /** @ignore */
  22274. _willBeUnregistered: boolean;
  22275. /**
  22276. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  22277. */
  22278. unregisterOnNextCall: boolean;
  22279. /**
  22280. * Creates a new observer
  22281. * @param callback defines the callback to call when the observer is notified
  22282. * @param mask defines the mask of the observer (used to filter notifications)
  22283. * @param scope defines the current scope used to restore the JS context
  22284. */
  22285. constructor(
  22286. /**
  22287. * Defines the callback to call when the observer is notified
  22288. */
  22289. callback: (eventData: T, eventState: EventState) => void,
  22290. /**
  22291. * Defines the mask of the observer (used to filter notifications)
  22292. */
  22293. mask: number,
  22294. /**
  22295. * Defines the current scope used to restore the JS context
  22296. */
  22297. scope?: any);
  22298. }
  22299. /**
  22300. * Represent a list of observers registered to multiple Observables object.
  22301. */
  22302. class MultiObserver<T> {
  22303. private _observers;
  22304. private _observables;
  22305. /**
  22306. * Release associated resources
  22307. */
  22308. dispose(): void;
  22309. /**
  22310. * Raise a callback when one of the observable will notify
  22311. * @param observables defines a list of observables to watch
  22312. * @param callback defines the callback to call on notification
  22313. * @param mask defines the mask used to filter notifications
  22314. * @param scope defines the current scope used to restore the JS context
  22315. * @returns the new MultiObserver
  22316. */
  22317. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  22318. }
  22319. /**
  22320. * The Observable class is a simple implementation of the Observable pattern.
  22321. * 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.
  22322. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  22323. * 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).
  22324. * 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.
  22325. */
  22326. class Observable<T> {
  22327. private _observers;
  22328. private _eventState;
  22329. private _onObserverAdded;
  22330. /**
  22331. * Creates a new observable
  22332. * @param onObserverAdded defines a callback to call when a new observer is added
  22333. */
  22334. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  22335. /**
  22336. * Create a new Observer with the specified callback
  22337. * @param callback the callback that will be executed for that Observer
  22338. * @param mask the mask used to filter observers
  22339. * @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.
  22340. * @param scope optional scope for the callback to be called from
  22341. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  22342. * @returns the new observer created for the callback
  22343. */
  22344. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  22345. /**
  22346. * Remove an Observer from the Observable object
  22347. * @param observer the instance of the Observer to remove
  22348. * @returns false if it doesn't belong to this Observable
  22349. */
  22350. remove(observer: Nullable<Observer<T>>): boolean;
  22351. /**
  22352. * Remove a callback from the Observable object
  22353. * @param callback the callback to remove
  22354. * @param scope optional scope. If used only the callbacks with this scope will be removed
  22355. * @returns false if it doesn't belong to this Observable
  22356. */
  22357. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  22358. private _deferUnregister(observer);
  22359. /**
  22360. * Notify all Observers by calling their respective callback with the given data
  22361. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  22362. * @param eventData defines the data to send to all observers
  22363. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  22364. * @param target defines the original target of the state
  22365. * @param currentTarget defines the current target of the state
  22366. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  22367. */
  22368. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  22369. /**
  22370. * Calling this will execute each callback, expecting it to be a promise or return a value.
  22371. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  22372. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  22373. * and it is crucial that all callbacks will be executed.
  22374. * The order of the callbacks is kept, callbacks are not executed parallel.
  22375. *
  22376. * @param eventData The data to be sent to each callback
  22377. * @param mask is used to filter observers defaults to -1
  22378. * @param target defines the callback target (see EventState)
  22379. * @param currentTarget defines he current object in the bubbling phase
  22380. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  22381. */
  22382. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  22383. /**
  22384. * Notify a specific observer
  22385. * @param observer defines the observer to notify
  22386. * @param eventData defines the data to be sent to each callback
  22387. * @param mask is used to filter observers defaults to -1
  22388. */
  22389. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  22390. /**
  22391. * Gets a boolean indicating if the observable has at least one observer
  22392. * @returns true is the Observable has at least one Observer registered
  22393. */
  22394. hasObservers(): boolean;
  22395. /**
  22396. * Clear the list of observers
  22397. */
  22398. clear(): void;
  22399. /**
  22400. * Clone the current observable
  22401. * @returns a new observable
  22402. */
  22403. clone(): Observable<T>;
  22404. /**
  22405. * Does this observable handles observer registered with a given mask
  22406. * @param mask defines the mask to be tested
  22407. * @return whether or not one observer registered with the given mask is handeled
  22408. **/
  22409. hasSpecificMask(mask?: number): boolean;
  22410. }
  22411. }
  22412. declare module BABYLON {
  22413. /**
  22414. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  22415. */
  22416. class PerformanceMonitor {
  22417. private _enabled;
  22418. private _rollingFrameTime;
  22419. private _lastFrameTimeMs;
  22420. /**
  22421. * constructor
  22422. * @param frameSampleSize The number of samples required to saturate the sliding window
  22423. */
  22424. constructor(frameSampleSize?: number);
  22425. /**
  22426. * Samples current frame
  22427. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  22428. */
  22429. sampleFrame(timeMs?: number): void;
  22430. /**
  22431. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  22432. * @return Average frame time in milliseconds
  22433. */
  22434. readonly averageFrameTime: number;
  22435. /**
  22436. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  22437. * @return Frame time variance in milliseconds squared
  22438. */
  22439. readonly averageFrameTimeVariance: number;
  22440. /**
  22441. * Returns the frame time of the most recent frame
  22442. * @return Frame time in milliseconds
  22443. */
  22444. readonly instantaneousFrameTime: number;
  22445. /**
  22446. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  22447. * @return Framerate in frames per second
  22448. */
  22449. readonly averageFPS: number;
  22450. /**
  22451. * Returns the average framerate in frames per second using the most recent frame time
  22452. * @return Framerate in frames per second
  22453. */
  22454. readonly instantaneousFPS: number;
  22455. /**
  22456. * Returns true if enough samples have been taken to completely fill the sliding window
  22457. * @return true if saturated
  22458. */
  22459. readonly isSaturated: boolean;
  22460. /**
  22461. * Enables contributions to the sliding window sample set
  22462. */
  22463. enable(): void;
  22464. /**
  22465. * Disables contributions to the sliding window sample set
  22466. * Samples will not be interpolated over the disabled period
  22467. */
  22468. disable(): void;
  22469. /**
  22470. * Returns true if sampling is enabled
  22471. * @return true if enabled
  22472. */
  22473. readonly isEnabled: boolean;
  22474. /**
  22475. * Resets performance monitor
  22476. */
  22477. reset(): void;
  22478. }
  22479. /**
  22480. * RollingAverage
  22481. *
  22482. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  22483. */
  22484. class RollingAverage {
  22485. /**
  22486. * Current average
  22487. */
  22488. average: number;
  22489. /**
  22490. * Current variance
  22491. */
  22492. variance: number;
  22493. protected _samples: Array<number>;
  22494. protected _sampleCount: number;
  22495. protected _pos: number;
  22496. protected _m2: number;
  22497. /**
  22498. * constructor
  22499. * @param length The number of samples required to saturate the sliding window
  22500. */
  22501. constructor(length: number);
  22502. /**
  22503. * Adds a sample to the sample set
  22504. * @param v The sample value
  22505. */
  22506. add(v: number): void;
  22507. /**
  22508. * Returns previously added values or null if outside of history or outside the sliding window domain
  22509. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  22510. * @return Value previously recorded with add() or null if outside of range
  22511. */
  22512. history(i: number): number;
  22513. /**
  22514. * Returns true if enough samples have been taken to completely fill the sliding window
  22515. * @return true if sample-set saturated
  22516. */
  22517. isSaturated(): boolean;
  22518. /**
  22519. * Resets the rolling average (equivalent to 0 samples taken so far)
  22520. */
  22521. reset(): void;
  22522. /**
  22523. * Wraps a value around the sample range boundaries
  22524. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  22525. * @return Wrapped position in sample range
  22526. */
  22527. protected _wrapPosition(i: number): number;
  22528. }
  22529. }
  22530. declare module BABYLON {
  22531. /**
  22532. * Helper class that provides a small promise polyfill
  22533. */
  22534. class PromisePolyfill {
  22535. /**
  22536. * Static function used to check if the polyfill is required
  22537. * If this is the case then the function will inject the polyfill to window.Promise
  22538. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  22539. */
  22540. static Apply(force?: boolean): void;
  22541. }
  22542. }
  22543. declare module BABYLON {
  22544. /**
  22545. * Defines the root class used to create scene optimization to use with SceneOptimizer
  22546. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22547. */
  22548. class SceneOptimization {
  22549. /**
  22550. * Defines the priority of this optimization (0 by default which means first in the list)
  22551. */
  22552. priority: number;
  22553. /**
  22554. * Gets a string describing the action executed by the current optimization
  22555. * @returns description string
  22556. */
  22557. getDescription(): string;
  22558. /**
  22559. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22560. * @param scene defines the current scene where to apply this optimization
  22561. * @param optimizer defines the current optimizer
  22562. * @returns true if everything that can be done was applied
  22563. */
  22564. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22565. /**
  22566. * Creates the SceneOptimization object
  22567. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  22568. * @param desc defines the description associated with the optimization
  22569. */
  22570. constructor(
  22571. /**
  22572. * Defines the priority of this optimization (0 by default which means first in the list)
  22573. */
  22574. priority?: number);
  22575. }
  22576. /**
  22577. * Defines an optimization used to reduce the size of render target textures
  22578. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22579. */
  22580. class TextureOptimization extends SceneOptimization {
  22581. /**
  22582. * Defines the priority of this optimization (0 by default which means first in the list)
  22583. */
  22584. priority: number;
  22585. /**
  22586. * 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
  22587. */
  22588. maximumSize: number;
  22589. /**
  22590. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  22591. */
  22592. step: number;
  22593. /**
  22594. * Gets a string describing the action executed by the current optimization
  22595. * @returns description string
  22596. */
  22597. getDescription(): string;
  22598. /**
  22599. * Creates the TextureOptimization object
  22600. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  22601. * @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
  22602. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  22603. */
  22604. constructor(
  22605. /**
  22606. * Defines the priority of this optimization (0 by default which means first in the list)
  22607. */
  22608. priority?: number,
  22609. /**
  22610. * 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
  22611. */
  22612. maximumSize?: number,
  22613. /**
  22614. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  22615. */
  22616. step?: number);
  22617. /**
  22618. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22619. * @param scene defines the current scene where to apply this optimization
  22620. * @param optimizer defines the current optimizer
  22621. * @returns true if everything that can be done was applied
  22622. */
  22623. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22624. }
  22625. /**
  22626. * Defines an optimization used to increase or decrease the rendering resolution
  22627. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22628. */
  22629. class HardwareScalingOptimization extends SceneOptimization {
  22630. /**
  22631. * Defines the priority of this optimization (0 by default which means first in the list)
  22632. */
  22633. priority: number;
  22634. /**
  22635. * Defines the maximum scale to use (2 by default)
  22636. */
  22637. maximumScale: number;
  22638. /**
  22639. * Defines the step to use between two passes (0.5 by default)
  22640. */
  22641. step: number;
  22642. private _currentScale;
  22643. private _directionOffset;
  22644. /**
  22645. * Gets a string describing the action executed by the current optimization
  22646. * @return description string
  22647. */
  22648. getDescription(): string;
  22649. /**
  22650. * Creates the HardwareScalingOptimization object
  22651. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  22652. * @param maximumScale defines the maximum scale to use (2 by default)
  22653. * @param step defines the step to use between two passes (0.5 by default)
  22654. */
  22655. constructor(
  22656. /**
  22657. * Defines the priority of this optimization (0 by default which means first in the list)
  22658. */
  22659. priority?: number,
  22660. /**
  22661. * Defines the maximum scale to use (2 by default)
  22662. */
  22663. maximumScale?: number,
  22664. /**
  22665. * Defines the step to use between two passes (0.5 by default)
  22666. */
  22667. step?: number);
  22668. /**
  22669. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22670. * @param scene defines the current scene where to apply this optimization
  22671. * @param optimizer defines the current optimizer
  22672. * @returns true if everything that can be done was applied
  22673. */
  22674. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22675. }
  22676. /**
  22677. * Defines an optimization used to remove shadows
  22678. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22679. */
  22680. class ShadowsOptimization extends SceneOptimization {
  22681. /**
  22682. * Gets a string describing the action executed by the current optimization
  22683. * @return description string
  22684. */
  22685. getDescription(): string;
  22686. /**
  22687. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22688. * @param scene defines the current scene where to apply this optimization
  22689. * @param optimizer defines the current optimizer
  22690. * @returns true if everything that can be done was applied
  22691. */
  22692. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22693. }
  22694. /**
  22695. * Defines an optimization used to turn post-processes off
  22696. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22697. */
  22698. class PostProcessesOptimization extends SceneOptimization {
  22699. /**
  22700. * Gets a string describing the action executed by the current optimization
  22701. * @return description string
  22702. */
  22703. getDescription(): string;
  22704. /**
  22705. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22706. * @param scene defines the current scene where to apply this optimization
  22707. * @param optimizer defines the current optimizer
  22708. * @returns true if everything that can be done was applied
  22709. */
  22710. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22711. }
  22712. /**
  22713. * Defines an optimization used to turn lens flares off
  22714. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22715. */
  22716. class LensFlaresOptimization extends SceneOptimization {
  22717. /**
  22718. * Gets a string describing the action executed by the current optimization
  22719. * @return description string
  22720. */
  22721. getDescription(): string;
  22722. /**
  22723. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22724. * @param scene defines the current scene where to apply this optimization
  22725. * @param optimizer defines the current optimizer
  22726. * @returns true if everything that can be done was applied
  22727. */
  22728. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22729. }
  22730. /**
  22731. * Defines an optimization based on user defined callback.
  22732. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22733. */
  22734. class CustomOptimization extends SceneOptimization {
  22735. /**
  22736. * Callback called to apply the custom optimization.
  22737. */
  22738. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  22739. /**
  22740. * Callback called to get custom description
  22741. */
  22742. onGetDescription: () => string;
  22743. /**
  22744. * Gets a string describing the action executed by the current optimization
  22745. * @returns description string
  22746. */
  22747. getDescription(): string;
  22748. /**
  22749. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22750. * @param scene defines the current scene where to apply this optimization
  22751. * @param optimizer defines the current optimizer
  22752. * @returns true if everything that can be done was applied
  22753. */
  22754. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22755. }
  22756. /**
  22757. * Defines an optimization used to turn particles off
  22758. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22759. */
  22760. class ParticlesOptimization extends SceneOptimization {
  22761. /**
  22762. * Gets a string describing the action executed by the current optimization
  22763. * @return description string
  22764. */
  22765. getDescription(): string;
  22766. /**
  22767. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22768. * @param scene defines the current scene where to apply this optimization
  22769. * @param optimizer defines the current optimizer
  22770. * @returns true if everything that can be done was applied
  22771. */
  22772. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22773. }
  22774. /**
  22775. * Defines an optimization used to turn render targets off
  22776. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22777. */
  22778. class RenderTargetsOptimization extends SceneOptimization {
  22779. /**
  22780. * Gets a string describing the action executed by the current optimization
  22781. * @return description string
  22782. */
  22783. getDescription(): string;
  22784. /**
  22785. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22786. * @param scene defines the current scene where to apply this optimization
  22787. * @param optimizer defines the current optimizer
  22788. * @returns true if everything that can be done was applied
  22789. */
  22790. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22791. }
  22792. /**
  22793. * Defines an optimization used to merge meshes with compatible materials
  22794. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22795. */
  22796. class MergeMeshesOptimization extends SceneOptimization {
  22797. private static _UpdateSelectionTree;
  22798. /**
  22799. * Gets or sets a boolean which defines if optimization octree has to be updated
  22800. */
  22801. /**
  22802. * Gets or sets a boolean which defines if optimization octree has to be updated
  22803. */
  22804. static UpdateSelectionTree: boolean;
  22805. /**
  22806. * Gets a string describing the action executed by the current optimization
  22807. * @return description string
  22808. */
  22809. getDescription(): string;
  22810. private _canBeMerged;
  22811. /**
  22812. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22813. * @param scene defines the current scene where to apply this optimization
  22814. * @param optimizer defines the current optimizer
  22815. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  22816. * @returns true if everything that can be done was applied
  22817. */
  22818. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  22819. }
  22820. /**
  22821. * Defines a list of options used by SceneOptimizer
  22822. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22823. */
  22824. class SceneOptimizerOptions {
  22825. /**
  22826. * Defines the target frame rate to reach (60 by default)
  22827. */
  22828. targetFrameRate: number;
  22829. /**
  22830. * Defines the interval between two checkes (2000ms by default)
  22831. */
  22832. trackerDuration: number;
  22833. /**
  22834. * Gets the list of optimizations to apply
  22835. */
  22836. optimizations: SceneOptimization[];
  22837. /**
  22838. * Creates a new list of options used by SceneOptimizer
  22839. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  22840. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  22841. */
  22842. constructor(
  22843. /**
  22844. * Defines the target frame rate to reach (60 by default)
  22845. */
  22846. targetFrameRate?: number,
  22847. /**
  22848. * Defines the interval between two checkes (2000ms by default)
  22849. */
  22850. trackerDuration?: number);
  22851. /**
  22852. * Add a new optimization
  22853. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  22854. * @returns the current SceneOptimizerOptions
  22855. */
  22856. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  22857. /**
  22858. * Add a new custom optimization
  22859. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  22860. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  22861. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  22862. * @returns the current SceneOptimizerOptions
  22863. */
  22864. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  22865. /**
  22866. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  22867. * @param targetFrameRate defines the target frame rate (60 by default)
  22868. * @returns a SceneOptimizerOptions object
  22869. */
  22870. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  22871. /**
  22872. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  22873. * @param targetFrameRate defines the target frame rate (60 by default)
  22874. * @returns a SceneOptimizerOptions object
  22875. */
  22876. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  22877. /**
  22878. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  22879. * @param targetFrameRate defines the target frame rate (60 by default)
  22880. * @returns a SceneOptimizerOptions object
  22881. */
  22882. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  22883. }
  22884. /**
  22885. * Class used to run optimizations in order to reach a target frame rate
  22886. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22887. */
  22888. class SceneOptimizer implements IDisposable {
  22889. private _isRunning;
  22890. private _options;
  22891. private _scene;
  22892. private _currentPriorityLevel;
  22893. private _targetFrameRate;
  22894. private _trackerDuration;
  22895. private _currentFrameRate;
  22896. private _sceneDisposeObserver;
  22897. private _improvementMode;
  22898. /**
  22899. * Defines an observable called when the optimizer reaches the target frame rate
  22900. */
  22901. onSuccessObservable: Observable<SceneOptimizer>;
  22902. /**
  22903. * Defines an observable called when the optimizer enables an optimization
  22904. */
  22905. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  22906. /**
  22907. * Defines an observable called when the optimizer is not able to reach the target frame rate
  22908. */
  22909. onFailureObservable: Observable<SceneOptimizer>;
  22910. /**
  22911. * Gets a boolean indicating if the optimizer is in improvement mode
  22912. */
  22913. readonly isInImprovementMode: boolean;
  22914. /**
  22915. * Gets the current priority level (0 at start)
  22916. */
  22917. readonly currentPriorityLevel: number;
  22918. /**
  22919. * Gets the current frame rate checked by the SceneOptimizer
  22920. */
  22921. readonly currentFrameRate: number;
  22922. /**
  22923. * Gets or sets the current target frame rate (60 by default)
  22924. */
  22925. /**
  22926. * Gets or sets the current target frame rate (60 by default)
  22927. */
  22928. targetFrameRate: number;
  22929. /**
  22930. * Gets or sets the current interval between two checks (every 2000ms by default)
  22931. */
  22932. /**
  22933. * Gets or sets the current interval between two checks (every 2000ms by default)
  22934. */
  22935. trackerDuration: number;
  22936. /**
  22937. * Gets the list of active optimizations
  22938. */
  22939. readonly optimizations: SceneOptimization[];
  22940. /**
  22941. * Creates a new SceneOptimizer
  22942. * @param scene defines the scene to work on
  22943. * @param options defines the options to use with the SceneOptimizer
  22944. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  22945. * @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)
  22946. */
  22947. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  22948. /**
  22949. * Stops the current optimizer
  22950. */
  22951. stop(): void;
  22952. /**
  22953. * Reset the optimizer to initial step (current priority level = 0)
  22954. */
  22955. reset(): void;
  22956. /**
  22957. * Start the optimizer. By default it will try to reach a specific framerate
  22958. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  22959. */
  22960. start(): void;
  22961. private _checkCurrentState();
  22962. /**
  22963. * Release all resources
  22964. */
  22965. dispose(): void;
  22966. /**
  22967. * Helper function to create a SceneOptimizer with one single line of code
  22968. * @param scene defines the scene to work on
  22969. * @param options defines the options to use with the SceneOptimizer
  22970. * @param onSuccess defines a callback to call on success
  22971. * @param onFailure defines a callback to call on failure
  22972. * @returns the new SceneOptimizer object
  22973. */
  22974. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  22975. }
  22976. }
  22977. declare module BABYLON {
  22978. class SceneSerializer {
  22979. static ClearCache(): void;
  22980. static Serialize(scene: Scene): any;
  22981. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  22982. }
  22983. }
  22984. declare module BABYLON {
  22985. class SmartArray<T> {
  22986. data: Array<T>;
  22987. length: number;
  22988. protected _id: number;
  22989. [index: number]: T;
  22990. constructor(capacity: number);
  22991. push(value: T): void;
  22992. forEach(func: (content: T) => void): void;
  22993. sort(compareFn: (a: T, b: T) => number): void;
  22994. reset(): void;
  22995. dispose(): void;
  22996. concat(array: any): void;
  22997. indexOf(value: T): number;
  22998. contains(value: T): boolean;
  22999. private static _GlobalId;
  23000. }
  23001. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  23002. private _duplicateId;
  23003. [index: number]: T;
  23004. push(value: T): void;
  23005. pushNoDuplicate(value: T): boolean;
  23006. reset(): void;
  23007. concatWithNoDuplicate(array: any): void;
  23008. }
  23009. }
  23010. declare module BABYLON {
  23011. /**
  23012. * This class implement a typical dictionary using a string as key and the generic type T as value.
  23013. * The underlying implementation relies on an associative array to ensure the best performances.
  23014. * The value can be anything including 'null' but except 'undefined'
  23015. */
  23016. class StringDictionary<T> {
  23017. /**
  23018. * This will clear this dictionary and copy the content from the 'source' one.
  23019. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  23020. * @param source the dictionary to take the content from and copy to this dictionary
  23021. */
  23022. copyFrom(source: StringDictionary<T>): void;
  23023. /**
  23024. * Get a value based from its key
  23025. * @param key the given key to get the matching value from
  23026. * @return the value if found, otherwise undefined is returned
  23027. */
  23028. get(key: string): T | undefined;
  23029. /**
  23030. * Get a value from its key or add it if it doesn't exist.
  23031. * This method will ensure you that a given key/data will be present in the dictionary.
  23032. * @param key the given key to get the matching value from
  23033. * @param factory the factory that will create the value if the key is not present in the dictionary.
  23034. * The factory will only be invoked if there's no data for the given key.
  23035. * @return the value corresponding to the key.
  23036. */
  23037. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  23038. /**
  23039. * Get a value from its key if present in the dictionary otherwise add it
  23040. * @param key the key to get the value from
  23041. * @param val if there's no such key/value pair in the dictionary add it with this value
  23042. * @return the value corresponding to the key
  23043. */
  23044. getOrAdd(key: string, val: T): T;
  23045. /**
  23046. * Check if there's a given key in the dictionary
  23047. * @param key the key to check for
  23048. * @return true if the key is present, false otherwise
  23049. */
  23050. contains(key: string): boolean;
  23051. /**
  23052. * Add a new key and its corresponding value
  23053. * @param key the key to add
  23054. * @param value the value corresponding to the key
  23055. * @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
  23056. */
  23057. add(key: string, value: T): boolean;
  23058. set(key: string, value: T): boolean;
  23059. /**
  23060. * Get the element of the given key and remove it from the dictionary
  23061. * @param key
  23062. */
  23063. getAndRemove(key: string): Nullable<T>;
  23064. /**
  23065. * Remove a key/value from the dictionary.
  23066. * @param key the key to remove
  23067. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  23068. */
  23069. remove(key: string): boolean;
  23070. /**
  23071. * Clear the whole content of the dictionary
  23072. */
  23073. clear(): void;
  23074. readonly count: number;
  23075. /**
  23076. * Execute a callback on each key/val of the dictionary.
  23077. * Note that you can remove any element in this dictionary in the callback implementation
  23078. * @param callback the callback to execute on a given key/value pair
  23079. */
  23080. forEach(callback: (key: string, val: T) => void): void;
  23081. /**
  23082. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  23083. * If the callback returns null or undefined the method will iterate to the next key/value pair
  23084. * Note that you can remove any element in this dictionary in the callback implementation
  23085. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  23086. */
  23087. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  23088. private _count;
  23089. private _data;
  23090. }
  23091. }
  23092. declare module BABYLON {
  23093. class Tags {
  23094. static EnableFor(obj: any): void;
  23095. static DisableFor(obj: any): void;
  23096. static HasTags(obj: any): boolean;
  23097. static GetTags(obj: any, asString?: boolean): any;
  23098. static AddTagsTo(obj: any, tagsString: string): void;
  23099. static _AddTagTo(obj: any, tag: string): void;
  23100. static RemoveTagsFrom(obj: any, tagsString: string): void;
  23101. static _RemoveTagFrom(obj: any, tag: string): void;
  23102. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  23103. }
  23104. }
  23105. declare module BABYLON {
  23106. class TextureTools {
  23107. /**
  23108. * Uses the GPU to create a copy texture rescaled at a given size
  23109. * @param texture Texture to copy from
  23110. * @param width Desired width
  23111. * @param height Desired height
  23112. * @return Generated texture
  23113. */
  23114. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  23115. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  23116. private static _environmentBRDFBase64Texture;
  23117. }
  23118. }
  23119. declare module BABYLON {
  23120. class TGATools {
  23121. private static _TYPE_INDEXED;
  23122. private static _TYPE_RGB;
  23123. private static _TYPE_GREY;
  23124. private static _TYPE_RLE_INDEXED;
  23125. private static _TYPE_RLE_RGB;
  23126. private static _TYPE_RLE_GREY;
  23127. private static _ORIGIN_MASK;
  23128. private static _ORIGIN_SHIFT;
  23129. private static _ORIGIN_BL;
  23130. private static _ORIGIN_BR;
  23131. private static _ORIGIN_UL;
  23132. private static _ORIGIN_UR;
  23133. static GetTGAHeader(data: Uint8Array): any;
  23134. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  23135. 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;
  23136. 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;
  23137. 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;
  23138. 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;
  23139. 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;
  23140. 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;
  23141. }
  23142. }
  23143. declare module BABYLON {
  23144. interface IAnimatable {
  23145. animations: Array<Animation>;
  23146. }
  23147. class LoadFileError extends Error {
  23148. request: XMLHttpRequest | undefined;
  23149. private static _setPrototypeOf;
  23150. constructor(message: string, request?: XMLHttpRequest | undefined);
  23151. }
  23152. class RetryStrategy {
  23153. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  23154. }
  23155. interface IFileRequest {
  23156. /**
  23157. * Raised when the request is complete (success or error).
  23158. */
  23159. onCompleteObservable: Observable<IFileRequest>;
  23160. /**
  23161. * Aborts the request for a file.
  23162. */
  23163. abort: () => void;
  23164. }
  23165. class Tools {
  23166. static BaseUrl: string;
  23167. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  23168. /**
  23169. * Default behaviour for cors in the application.
  23170. * It can be a string if the expected behavior is identical in the entire app.
  23171. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  23172. */
  23173. static CorsBehavior: string | ((url: string | string[]) => string);
  23174. static UseFallbackTexture: boolean;
  23175. /**
  23176. * Use this object to register external classes like custom textures or material
  23177. * to allow the laoders to instantiate them
  23178. */
  23179. static RegisteredExternalClasses: {
  23180. [key: string]: Object;
  23181. };
  23182. static fallbackTexture: string;
  23183. /**
  23184. * Interpolates between a and b via alpha
  23185. * @param a The lower value (returned when alpha = 0)
  23186. * @param b The upper value (returned when alpha = 1)
  23187. * @param alpha The interpolation-factor
  23188. * @return The mixed value
  23189. */
  23190. static Mix(a: number, b: number, alpha: number): number;
  23191. static Instantiate(className: string): any;
  23192. /**
  23193. * Provides a slice function that will work even on IE
  23194. * @param data defines the array to slice
  23195. * @returns the new sliced array
  23196. */
  23197. static Slice(data: FloatArray): FloatArray;
  23198. static SetImmediate(action: () => void): void;
  23199. static IsExponentOfTwo(value: number): boolean;
  23200. /**
  23201. * Find the next highest power of two.
  23202. * @param x Number to start search from.
  23203. * @return Next highest power of two.
  23204. */
  23205. static CeilingPOT(x: number): number;
  23206. /**
  23207. * Find the next lowest power of two.
  23208. * @param x Number to start search from.
  23209. * @return Next lowest power of two.
  23210. */
  23211. static FloorPOT(x: number): number;
  23212. /**
  23213. * Find the nearest power of two.
  23214. * @param x Number to start search from.
  23215. * @return Next nearest power of two.
  23216. */
  23217. static NearestPOT(x: number): number;
  23218. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  23219. static GetFilename(path: string): string;
  23220. /**
  23221. * Extracts the "folder" part of a path (everything before the filename).
  23222. * @param uri The URI to extract the info from
  23223. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  23224. * @returns The "folder" part of the path
  23225. */
  23226. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  23227. static GetDOMTextContent(element: HTMLElement): string;
  23228. static ToDegrees(angle: number): number;
  23229. static ToRadians(angle: number): number;
  23230. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  23231. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  23232. minimum: Vector3;
  23233. maximum: Vector3;
  23234. };
  23235. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  23236. minimum: Vector3;
  23237. maximum: Vector3;
  23238. };
  23239. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  23240. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  23241. minimum: Vector2;
  23242. maximum: Vector2;
  23243. };
  23244. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  23245. static GetPointerPrefix(): string;
  23246. /**
  23247. * @param func - the function to be called
  23248. * @param requester - the object that will request the next frame. Falls back to window.
  23249. */
  23250. static QueueNewFrame(func: () => void, requester?: any): number;
  23251. static RequestFullscreen(element: HTMLElement): void;
  23252. static ExitFullscreen(): void;
  23253. static SetCorsBehavior(url: string | string[], element: {
  23254. crossOrigin: string | null;
  23255. }): void;
  23256. static CleanUrl(url: string): string;
  23257. static PreprocessUrl: (url: string) => string;
  23258. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  23259. 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;
  23260. /**
  23261. * Load a script (identified by an url). When the url returns, the
  23262. * content of this file is added into a new script element, attached to the DOM (body element)
  23263. */
  23264. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  23265. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (this: MSBaseReader, ev: ProgressEvent) => any): IFileRequest;
  23266. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (this: MSBaseReader, ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  23267. static FileAsURL(content: string): string;
  23268. static Format(value: number, decimals?: number): string;
  23269. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  23270. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  23271. static IsEmpty(obj: any): boolean;
  23272. static RegisterTopRootEvents(events: {
  23273. name: string;
  23274. handler: Nullable<(e: FocusEvent) => any>;
  23275. }[]): void;
  23276. static UnregisterTopRootEvents(events: {
  23277. name: string;
  23278. handler: Nullable<(e: FocusEvent) => any>;
  23279. }[]): void;
  23280. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  23281. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  23282. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  23283. /**
  23284. * Generates an image screenshot from the specified camera.
  23285. *
  23286. * @param engine The engine to use for rendering
  23287. * @param camera The camera to use for rendering
  23288. * @param size This parameter can be set to a single number or to an object with the
  23289. * following (optional) properties: precision, width, height. If a single number is passed,
  23290. * it will be used for both width and height. If an object is passed, the screenshot size
  23291. * will be derived from the parameters. The precision property is a multiplier allowing
  23292. * rendering at a higher or lower resolution.
  23293. * @param successCallback The callback receives a single parameter which contains the
  23294. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  23295. * src parameter of an <img> to display it.
  23296. * @param mimeType The MIME type of the screenshot image (default: image/png).
  23297. * Check your browser for supported MIME types.
  23298. * @param samples Texture samples (default: 1)
  23299. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  23300. * @param fileName A name for for the downloaded file.
  23301. * @constructor
  23302. */
  23303. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  23304. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  23305. /**
  23306. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23307. * Be aware Math.random() could cause collisions, but:
  23308. * "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"
  23309. */
  23310. static RandomId(): string;
  23311. /**
  23312. * Test if the given uri is a base64 string.
  23313. * @param uri The uri to test
  23314. * @return True if the uri is a base64 string or false otherwise.
  23315. */
  23316. static IsBase64(uri: string): boolean;
  23317. /**
  23318. * Decode the given base64 uri.
  23319. * @param uri The uri to decode
  23320. * @return The decoded base64 data.
  23321. */
  23322. static DecodeBase64(uri: string): ArrayBuffer;
  23323. private static _NoneLogLevel;
  23324. private static _MessageLogLevel;
  23325. private static _WarningLogLevel;
  23326. private static _ErrorLogLevel;
  23327. private static _LogCache;
  23328. static errorsCount: number;
  23329. static OnNewCacheEntry: (entry: string) => void;
  23330. static readonly NoneLogLevel: number;
  23331. static readonly MessageLogLevel: number;
  23332. static readonly WarningLogLevel: number;
  23333. static readonly ErrorLogLevel: number;
  23334. static readonly AllLogLevel: number;
  23335. private static _AddLogEntry(entry);
  23336. private static _FormatMessage(message);
  23337. private static _LogDisabled(message);
  23338. private static _LogEnabled(message);
  23339. private static _WarnDisabled(message);
  23340. private static _WarnEnabled(message);
  23341. private static _ErrorDisabled(message);
  23342. private static _ErrorEnabled(message);
  23343. static Log: (message: string) => void;
  23344. static Warn: (message: string) => void;
  23345. static Error: (message: string) => void;
  23346. static readonly LogCache: string;
  23347. static ClearLogCache(): void;
  23348. static LogLevels: number;
  23349. static IsWindowObjectExist(): boolean;
  23350. private static _PerformanceNoneLogLevel;
  23351. private static _PerformanceUserMarkLogLevel;
  23352. private static _PerformanceConsoleLogLevel;
  23353. private static _performance;
  23354. static readonly PerformanceNoneLogLevel: number;
  23355. static readonly PerformanceUserMarkLogLevel: number;
  23356. static readonly PerformanceConsoleLogLevel: number;
  23357. static PerformanceLogLevel: number;
  23358. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  23359. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  23360. static _StartUserMark(counterName: string, condition?: boolean): void;
  23361. static _EndUserMark(counterName: string, condition?: boolean): void;
  23362. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  23363. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  23364. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  23365. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  23366. static readonly Now: number;
  23367. /**
  23368. * This method will return the name of the class used to create the instance of the given object.
  23369. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  23370. * @param object the object to get the class name from
  23371. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  23372. */
  23373. static GetClassName(object: any, isType?: boolean): string;
  23374. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  23375. /**
  23376. * This method will return the name of the full name of the class, including its owning module (if any).
  23377. * 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).
  23378. * @param object the object to get the class name from
  23379. * @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.
  23380. */
  23381. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  23382. /**
  23383. * 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.
  23384. * @param array
  23385. */
  23386. static arrayOrStringFeeder(array: any): (i: number) => number;
  23387. /**
  23388. * Compute the hashCode of a stream of number
  23389. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  23390. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  23391. * @return the hash code computed
  23392. */
  23393. static hashCodeFromStream(feeder: (index: number) => number): number;
  23394. /**
  23395. * Returns a promise that resolves after the given amount of time.
  23396. * @param delay Number of milliseconds to delay
  23397. * @returns Promise that resolves after the given amount of time
  23398. */
  23399. static DelayAsync(delay: number): Promise<void>;
  23400. }
  23401. /**
  23402. * This class is used to track a performance counter which is number based.
  23403. * The user has access to many properties which give statistics of different nature
  23404. *
  23405. * The implementer can track two kinds of Performance Counter: time and count
  23406. * 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.
  23407. * 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.
  23408. */
  23409. class PerfCounter {
  23410. static Enabled: boolean;
  23411. /**
  23412. * Returns the smallest value ever
  23413. */
  23414. readonly min: number;
  23415. /**
  23416. * Returns the biggest value ever
  23417. */
  23418. readonly max: number;
  23419. /**
  23420. * Returns the average value since the performance counter is running
  23421. */
  23422. readonly average: number;
  23423. /**
  23424. * Returns the average value of the last second the counter was monitored
  23425. */
  23426. readonly lastSecAverage: number;
  23427. /**
  23428. * Returns the current value
  23429. */
  23430. readonly current: number;
  23431. readonly total: number;
  23432. readonly count: number;
  23433. constructor();
  23434. /**
  23435. * Call this method to start monitoring a new frame.
  23436. * 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.
  23437. */
  23438. fetchNewFrame(): void;
  23439. /**
  23440. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  23441. * @param newCount the count value to add to the monitored count
  23442. * @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.
  23443. */
  23444. addCount(newCount: number, fetchResult: boolean): void;
  23445. /**
  23446. * Start monitoring this performance counter
  23447. */
  23448. beginMonitoring(): void;
  23449. /**
  23450. * Compute the time lapsed since the previous beginMonitoring() call.
  23451. * @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
  23452. */
  23453. endMonitoring(newFrame?: boolean): void;
  23454. private _fetchResult();
  23455. private _startMonitoringTime;
  23456. private _min;
  23457. private _max;
  23458. private _average;
  23459. private _current;
  23460. private _totalValueCount;
  23461. private _totalAccumulated;
  23462. private _lastSecAverage;
  23463. private _lastSecAccumulated;
  23464. private _lastSecTime;
  23465. private _lastSecValueCount;
  23466. }
  23467. /**
  23468. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  23469. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  23470. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  23471. * @param name The name of the class, case should be preserved
  23472. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  23473. */
  23474. function className(name: string, module?: string): (target: Object) => void;
  23475. /**
  23476. * An implementation of a loop for asynchronous functions.
  23477. */
  23478. class AsyncLoop {
  23479. iterations: number;
  23480. private _fn;
  23481. private _successCallback;
  23482. index: number;
  23483. private _done;
  23484. /**
  23485. * Constroctor.
  23486. * @param iterations the number of iterations.
  23487. * @param _fn the function to run each iteration
  23488. * @param _successCallback the callback that will be called upon succesful execution
  23489. * @param offset starting offset.
  23490. */
  23491. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  23492. /**
  23493. * Execute the next iteration. Must be called after the last iteration was finished.
  23494. */
  23495. executeNext(): void;
  23496. /**
  23497. * Break the loop and run the success callback.
  23498. */
  23499. breakLoop(): void;
  23500. /**
  23501. * Helper function
  23502. */
  23503. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  23504. /**
  23505. * A for-loop that will run a given number of iterations synchronous and the rest async.
  23506. * @param iterations total number of iterations
  23507. * @param syncedIterations number of synchronous iterations in each async iteration.
  23508. * @param fn the function to call each iteration.
  23509. * @param callback a success call back that will be called when iterating stops.
  23510. * @param breakFunction a break condition (optional)
  23511. * @param timeout timeout settings for the setTimeout function. default - 0.
  23512. * @constructor
  23513. */
  23514. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  23515. }
  23516. }
  23517. declare module BABYLON {
  23518. enum JoystickAxis {
  23519. X = 0,
  23520. Y = 1,
  23521. Z = 2,
  23522. }
  23523. class VirtualJoystick {
  23524. reverseLeftRight: boolean;
  23525. reverseUpDown: boolean;
  23526. deltaPosition: Vector3;
  23527. pressed: boolean;
  23528. private static _globalJoystickIndex;
  23529. private static vjCanvas;
  23530. private static vjCanvasContext;
  23531. private static vjCanvasWidth;
  23532. private static vjCanvasHeight;
  23533. private static halfWidth;
  23534. private _action;
  23535. private _axisTargetedByLeftAndRight;
  23536. private _axisTargetedByUpAndDown;
  23537. private _joystickSensibility;
  23538. private _inversedSensibility;
  23539. private _joystickPointerID;
  23540. private _joystickColor;
  23541. private _joystickPointerPos;
  23542. private _joystickPreviousPointerPos;
  23543. private _joystickPointerStartPos;
  23544. private _deltaJoystickVector;
  23545. private _leftJoystick;
  23546. private _touches;
  23547. private _onPointerDownHandlerRef;
  23548. private _onPointerMoveHandlerRef;
  23549. private _onPointerUpHandlerRef;
  23550. private _onResize;
  23551. constructor(leftJoystick?: boolean);
  23552. setJoystickSensibility(newJoystickSensibility: number): void;
  23553. private _onPointerDown(e);
  23554. private _onPointerMove(e);
  23555. private _onPointerUp(e);
  23556. /**
  23557. * Change the color of the virtual joystick
  23558. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  23559. */
  23560. setJoystickColor(newColor: string): void;
  23561. setActionOnTouch(action: () => any): void;
  23562. setAxisForLeftRight(axis: JoystickAxis): void;
  23563. setAxisForUpDown(axis: JoystickAxis): void;
  23564. private _drawVirtualJoystick();
  23565. releaseCanvas(): void;
  23566. }
  23567. }
  23568. declare module BABYLON {
  23569. /**
  23570. * Helper class to push actions to a pool of workers.
  23571. */
  23572. class WorkerPool implements IDisposable {
  23573. private _workerInfos;
  23574. private _pendingActions;
  23575. /**
  23576. * Constructor
  23577. * @param workers Array of workers to use for actions
  23578. */
  23579. constructor(workers: Array<Worker>);
  23580. /**
  23581. * Terminates all workers and clears any pending actions.
  23582. */
  23583. dispose(): void;
  23584. /**
  23585. * Pushes an action to the worker pool. If all the workers are active, the action will be
  23586. * pended until a worker has completed its action.
  23587. * @param action The action to perform. Call onComplete when the action is complete.
  23588. */
  23589. push(action: (worker: Worker, onComplete: () => void) => void): void;
  23590. private _execute(workerInfo, action);
  23591. }
  23592. }
  23593. declare module BABYLON {
  23594. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  23595. readonly name: string;
  23596. private _zoomStopsAnimation;
  23597. private _idleRotationSpeed;
  23598. private _idleRotationWaitTime;
  23599. private _idleRotationSpinupTime;
  23600. /**
  23601. * Gets the flag that indicates if user zooming should stop animation.
  23602. */
  23603. /**
  23604. * Sets the flag that indicates if user zooming should stop animation.
  23605. */
  23606. zoomStopsAnimation: boolean;
  23607. /**
  23608. * Gets the default speed at which the camera rotates around the model.
  23609. */
  23610. /**
  23611. * Sets the default speed at which the camera rotates around the model.
  23612. */
  23613. idleRotationSpeed: number;
  23614. /**
  23615. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  23616. */
  23617. /**
  23618. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  23619. */
  23620. idleRotationWaitTime: number;
  23621. /**
  23622. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  23623. */
  23624. /**
  23625. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  23626. */
  23627. idleRotationSpinupTime: number;
  23628. /**
  23629. * Gets a value indicating if the camera is currently rotating because of this behavior
  23630. */
  23631. readonly rotationInProgress: boolean;
  23632. private _onPrePointerObservableObserver;
  23633. private _onAfterCheckInputsObserver;
  23634. private _attachedCamera;
  23635. private _isPointerDown;
  23636. private _lastFrameTime;
  23637. private _lastInteractionTime;
  23638. private _cameraRotationSpeed;
  23639. init(): void;
  23640. attach(camera: ArcRotateCamera): void;
  23641. detach(): void;
  23642. /**
  23643. * Returns true if user is scrolling.
  23644. * @return true if user is scrolling.
  23645. */
  23646. private _userIsZooming();
  23647. private _lastFrameRadius;
  23648. private _shouldAnimationStopForInteraction();
  23649. /**
  23650. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  23651. */
  23652. private _applyUserInteraction();
  23653. private _userIsMoving();
  23654. }
  23655. }
  23656. declare module BABYLON {
  23657. /**
  23658. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  23659. */
  23660. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  23661. readonly name: string;
  23662. /**
  23663. * The easing function used by animations
  23664. */
  23665. static EasingFunction: BackEase;
  23666. /**
  23667. * The easing mode used by animations
  23668. */
  23669. static EasingMode: number;
  23670. /**
  23671. * The duration of the animation, in milliseconds
  23672. */
  23673. transitionDuration: number;
  23674. /**
  23675. * Length of the distance animated by the transition when lower radius is reached
  23676. */
  23677. lowerRadiusTransitionRange: number;
  23678. /**
  23679. * Length of the distance animated by the transition when upper radius is reached
  23680. */
  23681. upperRadiusTransitionRange: number;
  23682. private _autoTransitionRange;
  23683. /**
  23684. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  23685. */
  23686. /**
  23687. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  23688. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  23689. */
  23690. autoTransitionRange: boolean;
  23691. private _attachedCamera;
  23692. private _onAfterCheckInputsObserver;
  23693. private _onMeshTargetChangedObserver;
  23694. init(): void;
  23695. attach(camera: ArcRotateCamera): void;
  23696. detach(): void;
  23697. private _radiusIsAnimating;
  23698. private _radiusBounceTransition;
  23699. private _animatables;
  23700. private _cachedWheelPrecision;
  23701. /**
  23702. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  23703. * @param radiusLimit The limit to check against.
  23704. * @return Bool to indicate if at limit.
  23705. */
  23706. private _isRadiusAtLimit(radiusLimit);
  23707. /**
  23708. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  23709. * @param radiusDelta The delta by which to animate to. Can be negative.
  23710. */
  23711. private _applyBoundRadiusAnimation(radiusDelta);
  23712. /**
  23713. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  23714. */
  23715. protected _clearAnimationLocks(): void;
  23716. /**
  23717. * Stops and removes all animations that have been applied to the camera
  23718. */
  23719. stopAllAnimations(): void;
  23720. }
  23721. }
  23722. declare module BABYLON {
  23723. class FramingBehavior implements Behavior<ArcRotateCamera> {
  23724. readonly name: string;
  23725. private _mode;
  23726. private _radiusScale;
  23727. private _positionScale;
  23728. private _defaultElevation;
  23729. private _elevationReturnTime;
  23730. private _elevationReturnWaitTime;
  23731. private _zoomStopsAnimation;
  23732. private _framingTime;
  23733. /**
  23734. * The easing function used by animations
  23735. */
  23736. static EasingFunction: ExponentialEase;
  23737. /**
  23738. * The easing mode used by animations
  23739. */
  23740. static EasingMode: number;
  23741. /**
  23742. * Gets current mode used by the behavior.
  23743. */
  23744. /**
  23745. * Sets the current mode used by the behavior
  23746. */
  23747. mode: number;
  23748. /**
  23749. * Gets the scale applied to the radius
  23750. */
  23751. /**
  23752. * Sets the scale applied to the radius (1 by default)
  23753. */
  23754. radiusScale: number;
  23755. /**
  23756. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  23757. */
  23758. /**
  23759. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  23760. */
  23761. positionScale: number;
  23762. /**
  23763. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  23764. * behaviour is triggered, in radians.
  23765. */
  23766. /**
  23767. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  23768. * behaviour is triggered, in radians.
  23769. */
  23770. defaultElevation: number;
  23771. /**
  23772. * Gets the time (in milliseconds) taken to return to the default beta position.
  23773. * Negative value indicates camera should not return to default.
  23774. */
  23775. /**
  23776. * Sets the time (in milliseconds) taken to return to the default beta position.
  23777. * Negative value indicates camera should not return to default.
  23778. */
  23779. elevationReturnTime: number;
  23780. /**
  23781. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  23782. */
  23783. /**
  23784. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  23785. */
  23786. elevationReturnWaitTime: number;
  23787. /**
  23788. * Gets the flag that indicates if user zooming should stop animation.
  23789. */
  23790. /**
  23791. * Sets the flag that indicates if user zooming should stop animation.
  23792. */
  23793. zoomStopsAnimation: boolean;
  23794. /**
  23795. * Gets the transition time when framing the mesh, in milliseconds
  23796. */
  23797. /**
  23798. * Sets the transition time when framing the mesh, in milliseconds
  23799. */
  23800. framingTime: number;
  23801. private _onPrePointerObservableObserver;
  23802. private _onAfterCheckInputsObserver;
  23803. private _onMeshTargetChangedObserver;
  23804. private _attachedCamera;
  23805. private _isPointerDown;
  23806. private _lastInteractionTime;
  23807. init(): void;
  23808. attach(camera: ArcRotateCamera): void;
  23809. detach(): void;
  23810. private _animatables;
  23811. private _betaIsAnimating;
  23812. private _betaTransition;
  23813. private _radiusTransition;
  23814. private _vectorTransition;
  23815. /**
  23816. * Targets the given mesh and updates zoom level accordingly.
  23817. * @param mesh The mesh to target.
  23818. * @param radius Optional. If a cached radius position already exists, overrides default.
  23819. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23820. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23821. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23822. */
  23823. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23824. /**
  23825. * Targets the given mesh with its children and updates zoom level accordingly.
  23826. * @param mesh The mesh to target.
  23827. * @param radius Optional. If a cached radius position already exists, overrides default.
  23828. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23829. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23830. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23831. */
  23832. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23833. /**
  23834. * Targets the given meshes with their children and updates zoom level accordingly.
  23835. * @param meshes The mesh to target.
  23836. * @param radius Optional. If a cached radius position already exists, overrides default.
  23837. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23838. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23839. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23840. */
  23841. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23842. /**
  23843. * Targets the given mesh and updates zoom level accordingly.
  23844. * @param mesh The mesh to target.
  23845. * @param radius Optional. If a cached radius position already exists, overrides default.
  23846. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23847. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23848. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23849. */
  23850. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23851. /**
  23852. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  23853. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  23854. * frustum width.
  23855. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  23856. * to fully enclose the mesh in the viewing frustum.
  23857. */
  23858. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  23859. /**
  23860. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  23861. * is automatically returned to its default position (expected to be above ground plane).
  23862. */
  23863. private _maintainCameraAboveGround();
  23864. /**
  23865. * Returns the frustum slope based on the canvas ratio and camera FOV
  23866. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  23867. */
  23868. private _getFrustumSlope();
  23869. /**
  23870. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  23871. */
  23872. private _clearAnimationLocks();
  23873. /**
  23874. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  23875. */
  23876. private _applyUserInteraction();
  23877. /**
  23878. * Stops and removes all animations that have been applied to the camera
  23879. */
  23880. stopAllAnimations(): void;
  23881. /**
  23882. * Gets a value indicating if the user is moving the camera
  23883. */
  23884. readonly isUserIsMoving: boolean;
  23885. /**
  23886. * The camera can move all the way towards the mesh.
  23887. */
  23888. static IgnoreBoundsSizeMode: number;
  23889. /**
  23890. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  23891. */
  23892. static FitFrustumSidesMode: number;
  23893. }
  23894. }
  23895. declare module BABYLON {
  23896. interface IOctreeContainer<T> {
  23897. blocks: Array<OctreeBlock<T>>;
  23898. }
  23899. class Octree<T> {
  23900. maxDepth: number;
  23901. blocks: Array<OctreeBlock<T>>;
  23902. dynamicContent: T[];
  23903. private _maxBlockCapacity;
  23904. private _selectionContent;
  23905. private _creationFunc;
  23906. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  23907. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  23908. addMesh(entry: T): void;
  23909. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  23910. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  23911. intersectsRay(ray: Ray): SmartArray<T>;
  23912. 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;
  23913. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  23914. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  23915. }
  23916. }
  23917. declare module BABYLON {
  23918. class OctreeBlock<T> {
  23919. entries: T[];
  23920. blocks: Array<OctreeBlock<T>>;
  23921. private _depth;
  23922. private _maxDepth;
  23923. private _capacity;
  23924. private _minPoint;
  23925. private _maxPoint;
  23926. private _boundingVectors;
  23927. private _creationFunc;
  23928. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  23929. readonly capacity: number;
  23930. readonly minPoint: Vector3;
  23931. readonly maxPoint: Vector3;
  23932. addEntry(entry: T): void;
  23933. addEntries(entries: T[]): void;
  23934. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  23935. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  23936. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  23937. createInnerBlocks(): void;
  23938. }
  23939. }
  23940. declare module BABYLON {
  23941. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  23942. camera: ArcRotateCamera;
  23943. gamepad: Nullable<Gamepad>;
  23944. private _onGamepadConnectedObserver;
  23945. private _onGamepadDisconnectedObserver;
  23946. gamepadRotationSensibility: number;
  23947. gamepadMoveSensibility: number;
  23948. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23949. detachControl(element: Nullable<HTMLElement>): void;
  23950. checkInputs(): void;
  23951. getClassName(): string;
  23952. getSimpleName(): string;
  23953. }
  23954. }
  23955. declare module BABYLON {
  23956. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  23957. camera: ArcRotateCamera;
  23958. private _keys;
  23959. keysUp: number[];
  23960. keysDown: number[];
  23961. keysLeft: number[];
  23962. keysRight: number[];
  23963. keysReset: number[];
  23964. panningSensibility: number;
  23965. zoomingSensibility: number;
  23966. useAltToZoom: boolean;
  23967. private _ctrlPressed;
  23968. private _altPressed;
  23969. private _onCanvasBlurObserver;
  23970. private _onKeyboardObserver;
  23971. private _engine;
  23972. private _scene;
  23973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23974. detachControl(element: Nullable<HTMLElement>): void;
  23975. checkInputs(): void;
  23976. getClassName(): string;
  23977. getSimpleName(): string;
  23978. }
  23979. }
  23980. declare module BABYLON {
  23981. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  23982. camera: ArcRotateCamera;
  23983. private _wheel;
  23984. private _observer;
  23985. wheelPrecision: number;
  23986. /**
  23987. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  23988. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  23989. */
  23990. wheelDeltaPercentage: number;
  23991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23992. detachControl(element: Nullable<HTMLElement>): void;
  23993. getClassName(): string;
  23994. getSimpleName(): string;
  23995. }
  23996. }
  23997. declare module BABYLON {
  23998. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  23999. camera: ArcRotateCamera;
  24000. buttons: number[];
  24001. angularSensibilityX: number;
  24002. angularSensibilityY: number;
  24003. pinchPrecision: number;
  24004. /**
  24005. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  24006. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  24007. */
  24008. pinchDeltaPercentage: number;
  24009. panningSensibility: number;
  24010. multiTouchPanning: boolean;
  24011. multiTouchPanAndZoom: boolean;
  24012. private _isPanClick;
  24013. pinchInwards: boolean;
  24014. private _pointerInput;
  24015. private _observer;
  24016. private _onMouseMove;
  24017. private _onGestureStart;
  24018. private _onGesture;
  24019. private _MSGestureHandler;
  24020. private _onLostFocus;
  24021. private _onContextMenu;
  24022. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24023. detachControl(element: Nullable<HTMLElement>): void;
  24024. getClassName(): string;
  24025. getSimpleName(): string;
  24026. }
  24027. }
  24028. declare module BABYLON {
  24029. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  24030. camera: ArcRotateCamera;
  24031. alphaCorrection: number;
  24032. betaCorrection: number;
  24033. gammaCorrection: number;
  24034. private _alpha;
  24035. private _gamma;
  24036. private _dirty;
  24037. private _deviceOrientationHandler;
  24038. constructor();
  24039. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24040. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  24041. checkInputs(): void;
  24042. detachControl(element: Nullable<HTMLElement>): void;
  24043. getClassName(): string;
  24044. getSimpleName(): string;
  24045. }
  24046. }
  24047. declare module BABYLON {
  24048. /**
  24049. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  24050. * Screen rotation is taken into account.
  24051. */
  24052. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  24053. private _camera;
  24054. private _screenOrientationAngle;
  24055. private _constantTranform;
  24056. private _screenQuaternion;
  24057. private _alpha;
  24058. private _beta;
  24059. private _gamma;
  24060. constructor();
  24061. camera: FreeCamera;
  24062. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24063. private _orientationChanged;
  24064. private _deviceOrientation;
  24065. detachControl(element: Nullable<HTMLElement>): void;
  24066. checkInputs(): void;
  24067. getClassName(): string;
  24068. getSimpleName(): string;
  24069. }
  24070. }
  24071. declare module BABYLON {
  24072. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  24073. camera: FreeCamera;
  24074. gamepad: Nullable<Gamepad>;
  24075. private _onGamepadConnectedObserver;
  24076. private _onGamepadDisconnectedObserver;
  24077. gamepadAngularSensibility: number;
  24078. gamepadMoveSensibility: number;
  24079. private _cameraTransform;
  24080. private _deltaTransform;
  24081. private _vector3;
  24082. private _vector2;
  24083. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24084. detachControl(element: Nullable<HTMLElement>): void;
  24085. checkInputs(): void;
  24086. getClassName(): string;
  24087. getSimpleName(): string;
  24088. }
  24089. }
  24090. declare module BABYLON {
  24091. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  24092. camera: FreeCamera;
  24093. private _keys;
  24094. private _onCanvasBlurObserver;
  24095. private _onKeyboardObserver;
  24096. private _engine;
  24097. private _scene;
  24098. keysUp: number[];
  24099. keysDown: number[];
  24100. keysLeft: number[];
  24101. keysRight: number[];
  24102. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24103. detachControl(element: Nullable<HTMLElement>): void;
  24104. checkInputs(): void;
  24105. getClassName(): string;
  24106. _onLostFocus(e: FocusEvent): void;
  24107. getSimpleName(): string;
  24108. }
  24109. }
  24110. declare module BABYLON {
  24111. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24112. touchEnabled: boolean;
  24113. camera: FreeCamera;
  24114. buttons: number[];
  24115. angularSensibility: number;
  24116. private _pointerInput;
  24117. private _onMouseMove;
  24118. private _observer;
  24119. private previousPosition;
  24120. constructor(touchEnabled?: boolean);
  24121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24122. detachControl(element: Nullable<HTMLElement>): void;
  24123. getClassName(): string;
  24124. getSimpleName(): string;
  24125. }
  24126. }
  24127. declare module BABYLON {
  24128. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24129. camera: FreeCamera;
  24130. private _offsetX;
  24131. private _offsetY;
  24132. private _pointerPressed;
  24133. private _pointerInput;
  24134. private _observer;
  24135. private _onLostFocus;
  24136. touchAngularSensibility: number;
  24137. touchMoveSensibility: number;
  24138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24139. detachControl(element: Nullable<HTMLElement>): void;
  24140. checkInputs(): void;
  24141. getClassName(): string;
  24142. getSimpleName(): string;
  24143. }
  24144. }
  24145. declare module BABYLON {
  24146. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  24147. camera: FreeCamera;
  24148. private _leftjoystick;
  24149. private _rightjoystick;
  24150. getLeftJoystick(): VirtualJoystick;
  24151. getRightJoystick(): VirtualJoystick;
  24152. checkInputs(): void;
  24153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24154. detachControl(element: Nullable<HTMLElement>): void;
  24155. getClassName(): string;
  24156. getSimpleName(): string;
  24157. }
  24158. }
  24159. declare module BABYLON {
  24160. class VRCameraMetrics {
  24161. hResolution: number;
  24162. vResolution: number;
  24163. hScreenSize: number;
  24164. vScreenSize: number;
  24165. vScreenCenter: number;
  24166. eyeToScreenDistance: number;
  24167. lensSeparationDistance: number;
  24168. interpupillaryDistance: number;
  24169. distortionK: number[];
  24170. chromaAbCorrection: number[];
  24171. postProcessScaleFactor: number;
  24172. lensCenterOffset: number;
  24173. compensateDistortion: boolean;
  24174. readonly aspectRatio: number;
  24175. readonly aspectRatioFov: number;
  24176. readonly leftHMatrix: Matrix;
  24177. readonly rightHMatrix: Matrix;
  24178. readonly leftPreViewMatrix: Matrix;
  24179. readonly rightPreViewMatrix: Matrix;
  24180. static GetDefault(): VRCameraMetrics;
  24181. }
  24182. }
  24183. declare module BABYLON {
  24184. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  24185. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  24186. getClassName(): string;
  24187. }
  24188. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  24189. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  24190. getClassName(): string;
  24191. }
  24192. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  24193. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  24194. getClassName(): string;
  24195. }
  24196. }
  24197. declare module BABYLON {
  24198. /**
  24199. * Options to modify the vr teleportation behavior.
  24200. */
  24201. interface VRTeleportationOptions {
  24202. /**
  24203. * The name of the mesh which should be used as the teleportation floor. (default: null)
  24204. */
  24205. floorMeshName?: string;
  24206. /**
  24207. * A list of meshes to be used as the teleportation floor. (default: empty)
  24208. */
  24209. floorMeshes?: Mesh[];
  24210. }
  24211. /**
  24212. * Options to modify the vr experience helper's behavior.
  24213. */
  24214. interface VRExperienceHelperOptions extends WebVROptions {
  24215. /**
  24216. * Create a DeviceOrientationCamera to be used as your out of vr camera.
  24217. */
  24218. createDeviceOrientationCamera?: boolean;
  24219. /**
  24220. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
  24221. */
  24222. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  24223. }
  24224. /**
  24225. * Helps to quickly add VR support to an existing scene.
  24226. * See http://doc.babylonjs.com/how_to/webvr_helper
  24227. */
  24228. class VRExperienceHelper {
  24229. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  24230. private _scene;
  24231. private _position;
  24232. private _btnVR;
  24233. private _btnVRDisplayed;
  24234. private _webVRsupported;
  24235. private _webVRready;
  24236. private _webVRrequesting;
  24237. private _webVRpresenting;
  24238. private _fullscreenVRpresenting;
  24239. private _canvas;
  24240. private _webVRCamera;
  24241. private _vrDeviceOrientationCamera;
  24242. private _deviceOrientationCamera;
  24243. private _existingCamera;
  24244. private _onKeyDown;
  24245. private _onVrDisplayPresentChange;
  24246. private _onVRDisplayChanged;
  24247. private _onVRRequestPresentStart;
  24248. private _onVRRequestPresentComplete;
  24249. /**
  24250. * Observable raised when entering VR.
  24251. */
  24252. onEnteringVRObservable: Observable<VRExperienceHelper>;
  24253. /**
  24254. * Observable raised when exiting VR.
  24255. */
  24256. onExitingVRObservable: Observable<VRExperienceHelper>;
  24257. /**
  24258. * Observable raised when controller mesh is loaded.
  24259. */
  24260. onControllerMeshLoadedObservable: Observable<WebVRController>;
  24261. /** Return this.onEnteringVRObservable
  24262. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  24263. */
  24264. readonly onEnteringVR: Observable<VRExperienceHelper>;
  24265. /** Return this.onExitingVRObservable
  24266. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  24267. */
  24268. readonly onExitingVR: Observable<VRExperienceHelper>;
  24269. /** Return this.onControllerMeshLoadedObservable
  24270. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  24271. */
  24272. readonly onControllerMeshLoaded: Observable<WebVRController>;
  24273. private _rayLength;
  24274. private _useCustomVRButton;
  24275. private _teleportationRequested;
  24276. private _teleportActive;
  24277. private _floorMeshName;
  24278. private _floorMeshesCollection;
  24279. private _rotationAllowed;
  24280. private _teleportBackwardsVector;
  24281. private _rotationRightAsked;
  24282. private _rotationLeftAsked;
  24283. private _teleportationTarget;
  24284. private _isDefaultTeleportationTarget;
  24285. private _postProcessMove;
  24286. private _teleportationFillColor;
  24287. private _teleportationBorderColor;
  24288. private _rotationAngle;
  24289. private _haloCenter;
  24290. private _cameraGazer;
  24291. private _padSensibilityUp;
  24292. private _padSensibilityDown;
  24293. private leftController;
  24294. private rightController;
  24295. /**
  24296. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  24297. */
  24298. onNewMeshSelected: Observable<AbstractMesh>;
  24299. /**
  24300. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  24301. */
  24302. onNewMeshPicked: Observable<PickingInfo>;
  24303. private _circleEase;
  24304. /**
  24305. * Observable raised before camera teleportation
  24306. */
  24307. onBeforeCameraTeleport: Observable<Vector3>;
  24308. /**
  24309. * Observable raised after camera teleportation
  24310. */
  24311. onAfterCameraTeleport: Observable<Vector3>;
  24312. /**
  24313. * Observable raised when current selected mesh gets unselected
  24314. */
  24315. onSelectedMeshUnselected: Observable<AbstractMesh>;
  24316. private _raySelectionPredicate;
  24317. /**
  24318. * To be optionaly changed by user to define custom ray selection
  24319. */
  24320. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  24321. /**
  24322. * To be optionaly changed by user to define custom selection logic (after ray selection)
  24323. */
  24324. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  24325. /**
  24326. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  24327. */
  24328. teleportationEnabled: boolean;
  24329. private _defaultHeight;
  24330. private _teleportationInitialized;
  24331. private _interactionsEnabled;
  24332. private _interactionsRequested;
  24333. private _displayGaze;
  24334. private _displayLaserPointer;
  24335. /**
  24336. * The mesh used to display where the user is going to teleport.
  24337. */
  24338. /**
  24339. * Sets the mesh to be used to display where the user is going to teleport.
  24340. */
  24341. teleportationTarget: Mesh;
  24342. /**
  24343. * The mesh used to display where the user is selecting,
  24344. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  24345. * See http://doc.babylonjs.com/resources/baking_transformations
  24346. */
  24347. gazeTrackerMesh: Mesh;
  24348. /**
  24349. * If the ray of the gaze should be displayed.
  24350. */
  24351. /**
  24352. * Sets if the ray of the gaze should be displayed.
  24353. */
  24354. displayGaze: boolean;
  24355. /**
  24356. * If the ray of the LaserPointer should be displayed.
  24357. */
  24358. /**
  24359. * Sets if the ray of the LaserPointer should be displayed.
  24360. */
  24361. displayLaserPointer: boolean;
  24362. /**
  24363. * The deviceOrientationCamera used as the camera when not in VR.
  24364. */
  24365. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  24366. /**
  24367. * Based on the current WebVR support, returns the current VR camera used.
  24368. */
  24369. readonly currentVRCamera: Nullable<Camera>;
  24370. /**
  24371. * The webVRCamera which is used when in VR.
  24372. */
  24373. readonly webVRCamera: WebVRFreeCamera;
  24374. /**
  24375. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  24376. */
  24377. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  24378. private readonly _teleportationRequestInitiated;
  24379. /**
  24380. * Instantiates a VRExperienceHelper.
  24381. * Helps to quickly add VR support to an existing scene.
  24382. * @param scene The scene the VRExperienceHelper belongs to.
  24383. * @param webVROptions Options to modify the vr experience helper's behavior.
  24384. */
  24385. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  24386. private _onDefaultMeshLoaded(webVRController);
  24387. private _onResize;
  24388. private _onFullscreenChange;
  24389. /**
  24390. * Gets a value indicating if we are currently in VR mode.
  24391. */
  24392. readonly isInVRMode: boolean;
  24393. private onVrDisplayPresentChange();
  24394. private onVRDisplayChanged(eventArgs);
  24395. private moveButtonToBottomRight();
  24396. private displayVRButton();
  24397. private updateButtonVisibility();
  24398. /**
  24399. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  24400. * Otherwise, will use the fullscreen API.
  24401. */
  24402. enterVR(): void;
  24403. /**
  24404. * Attempt to exit VR, or fullscreen.
  24405. */
  24406. exitVR(): void;
  24407. /**
  24408. * The position of the vr experience helper.
  24409. */
  24410. /**
  24411. * Sets the position of the vr experience helper.
  24412. */
  24413. position: Vector3;
  24414. /**
  24415. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  24416. */
  24417. enableInteractions(): void;
  24418. private beforeRender;
  24419. private _isTeleportationFloor(mesh);
  24420. /**
  24421. * Adds a floor mesh to be used for teleportation.
  24422. * @param floorMesh the mesh to be used for teleportation.
  24423. */
  24424. addFloorMesh(floorMesh: Mesh): void;
  24425. /**
  24426. * Removes a floor mesh from being used for teleportation.
  24427. * @param floorMesh the mesh to be removed.
  24428. */
  24429. removeFloorMesh(floorMesh: Mesh): void;
  24430. /**
  24431. * Enables interactions and teleportation using the VR controllers and gaze.
  24432. * @param vrTeleportationOptions options to modify teleportation behavior.
  24433. */
  24434. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  24435. private _onNewGamepadConnected;
  24436. private _tryEnableInteractionOnController;
  24437. private _onNewGamepadDisconnected;
  24438. private _enableInteractionOnController(controller);
  24439. private _checkTeleportWithRay(stateObject, gazer);
  24440. private _checkRotate(stateObject, gazer);
  24441. private _checkTeleportBackwards(stateObject, gazer);
  24442. private _enableTeleportationOnController(controller);
  24443. private _createTeleportationCircles();
  24444. private _displayTeleportationTarget();
  24445. private _hideTeleportationTarget();
  24446. private _rotateCamera(right);
  24447. private _moveTeleportationSelectorTo(hit, gazer);
  24448. private _workingVector;
  24449. private _workingQuaternion;
  24450. private _workingMatrix;
  24451. private _teleportCamera(location);
  24452. private _castRayAndSelectObject(gazer);
  24453. private _notifySelectedMeshUnselected(mesh);
  24454. /**
  24455. * Sets the color of the laser ray from the vr controllers.
  24456. * @param color new color for the ray.
  24457. */
  24458. changeLaserColor(color: Color3): void;
  24459. /**
  24460. * Sets the color of the ray from the vr headsets gaze.
  24461. * @param color new color for the ray.
  24462. */
  24463. changeGazeColor(color: Color3): void;
  24464. /**
  24465. * Exits VR and disposes of the vr experience helper
  24466. */
  24467. dispose(): void;
  24468. /**
  24469. * Gets the name of the VRExperienceHelper class
  24470. * @returns "VRExperienceHelper"
  24471. */
  24472. getClassName(): string;
  24473. }
  24474. }
  24475. declare var HMDVRDevice: any;
  24476. declare var VRDisplay: any;
  24477. declare var VRFrameData: any;
  24478. declare module BABYLON {
  24479. /**
  24480. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  24481. * IMPORTANT!! The data is right-hand data.
  24482. * @export
  24483. * @interface DevicePose
  24484. */
  24485. interface DevicePose {
  24486. /**
  24487. * The position of the device, values in array are [x,y,z].
  24488. */
  24489. readonly position?: Float32Array;
  24490. /**
  24491. * The linearVelocity of the device, values in array are [x,y,z].
  24492. */
  24493. readonly linearVelocity?: Float32Array;
  24494. /**
  24495. * The linearAcceleration of the device, values in array are [x,y,z].
  24496. */
  24497. readonly linearAcceleration?: Float32Array;
  24498. /**
  24499. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  24500. */
  24501. readonly orientation?: Float32Array;
  24502. /**
  24503. * The angularVelocity of the device, values in array are [x,y,z].
  24504. */
  24505. readonly angularVelocity?: Float32Array;
  24506. /**
  24507. * The angularAcceleration of the device, values in array are [x,y,z].
  24508. */
  24509. readonly angularAcceleration?: Float32Array;
  24510. }
  24511. /**
  24512. * Interface representing a pose controlled object in Babylon.
  24513. * A pose controlled object has both regular pose values as well as pose values
  24514. * from an external device such as a VR head mounted display
  24515. */
  24516. interface PoseControlled {
  24517. /**
  24518. * The position of the object in babylon space.
  24519. */
  24520. position: Vector3;
  24521. /**
  24522. * The rotation quaternion of the object in babylon space.
  24523. */
  24524. rotationQuaternion: Quaternion;
  24525. /**
  24526. * The position of the device in babylon space.
  24527. */
  24528. devicePosition?: Vector3;
  24529. /**
  24530. * The rotation quaternion of the device in babylon space.
  24531. */
  24532. deviceRotationQuaternion: Quaternion;
  24533. /**
  24534. * The raw pose coming from the device.
  24535. */
  24536. rawPose: Nullable<DevicePose>;
  24537. /**
  24538. * The scale of the device to be used when translating from device space to babylon space.
  24539. */
  24540. deviceScaleFactor: number;
  24541. /**
  24542. * Updates the poseControlled values based on the input device pose.
  24543. * @param poseData the pose data to update the object with
  24544. */
  24545. updateFromDevice(poseData: DevicePose): void;
  24546. }
  24547. /**
  24548. * Set of options to customize the webVRCamera
  24549. */
  24550. interface WebVROptions {
  24551. /**
  24552. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  24553. */
  24554. trackPosition?: boolean;
  24555. /**
  24556. * Sets the scale of the vrDevice in babylon space. (default: 1)
  24557. */
  24558. positionScale?: number;
  24559. /**
  24560. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  24561. */
  24562. displayName?: string;
  24563. /**
  24564. * Should the native controller meshes be initialized. (default: true)
  24565. */
  24566. controllerMeshes?: boolean;
  24567. /**
  24568. * Creating a default HemiLight only on controllers. (default: true)
  24569. */
  24570. defaultLightingOnControllers?: boolean;
  24571. /**
  24572. * If you don't want to use the default VR button of the helper. (default: false)
  24573. */
  24574. useCustomVRButton?: boolean;
  24575. /**
  24576. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  24577. */
  24578. customVRButton?: HTMLButtonElement;
  24579. /**
  24580. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  24581. */
  24582. rayLength?: number;
  24583. /**
  24584. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  24585. */
  24586. defaultHeight?: number;
  24587. }
  24588. /**
  24589. * This represents a WebVR camera.
  24590. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  24591. * @example http://doc.babylonjs.com/how_to/webvr_camera
  24592. */
  24593. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  24594. private webVROptions;
  24595. /**
  24596. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  24597. */
  24598. _vrDevice: any;
  24599. /**
  24600. * The rawPose of the vrDevice.
  24601. */
  24602. rawPose: Nullable<DevicePose>;
  24603. private _onVREnabled;
  24604. private _specsVersion;
  24605. private _attached;
  24606. private _frameData;
  24607. protected _descendants: Array<Node>;
  24608. private _deviceRoomPosition;
  24609. private _deviceRoomRotationQuaternion;
  24610. private _standingMatrix;
  24611. /**
  24612. * Represents device position in babylon space.
  24613. */
  24614. devicePosition: Vector3;
  24615. /**
  24616. * Represents device rotation in babylon space.
  24617. */
  24618. deviceRotationQuaternion: Quaternion;
  24619. /**
  24620. * The scale of the device to be used when translating from device space to babylon space.
  24621. */
  24622. deviceScaleFactor: number;
  24623. private _deviceToWorld;
  24624. private _worldToDevice;
  24625. /**
  24626. * References to the webVR controllers for the vrDevice.
  24627. */
  24628. controllers: Array<WebVRController>;
  24629. /**
  24630. * Emits an event when a controller is attached.
  24631. */
  24632. onControllersAttachedObservable: Observable<WebVRController[]>;
  24633. /**
  24634. * Emits an event when a controller's mesh has been loaded;
  24635. */
  24636. onControllerMeshLoadedObservable: Observable<WebVRController>;
  24637. /**
  24638. * If the rig cameras be used as parent instead of this camera.
  24639. */
  24640. rigParenting: boolean;
  24641. private _lightOnControllers;
  24642. private _defaultHeight?;
  24643. /**
  24644. * Instantiates a WebVRFreeCamera.
  24645. * @param name The name of the WebVRFreeCamera
  24646. * @param position The starting anchor position for the camera
  24647. * @param scene The scene the camera belongs to
  24648. * @param webVROptions a set of customizable options for the webVRCamera
  24649. */
  24650. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  24651. /**
  24652. * Gets the device distance from the ground in meters.
  24653. * @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.
  24654. */
  24655. deviceDistanceToRoomGround(): number;
  24656. /**
  24657. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  24658. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  24659. */
  24660. useStandingMatrix(callback?: (bool: boolean) => void): void;
  24661. /**
  24662. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  24663. * @returns A promise with a boolean set to if the standing matrix is supported.
  24664. */
  24665. useStandingMatrixAsync(): Promise<boolean>;
  24666. /**
  24667. * Disposes the camera
  24668. */
  24669. dispose(): void;
  24670. /**
  24671. * Gets a vrController by name.
  24672. * @param name The name of the controller to retreive
  24673. * @returns the controller matching the name specified or null if not found
  24674. */
  24675. getControllerByName(name: string): Nullable<WebVRController>;
  24676. private _leftController;
  24677. /**
  24678. * The controller corrisponding to the users left hand.
  24679. */
  24680. readonly leftController: Nullable<WebVRController>;
  24681. private _rightController;
  24682. /**
  24683. * The controller corrisponding to the users right hand.
  24684. */
  24685. readonly rightController: Nullable<WebVRController>;
  24686. /**
  24687. * Casts a ray forward from the vrCamera's gaze.
  24688. * @param length Length of the ray (default: 100)
  24689. * @returns the ray corrisponding to the gaze
  24690. */
  24691. getForwardRay(length?: number): Ray;
  24692. /**
  24693. * Updates the camera based on device's frame data
  24694. */
  24695. _checkInputs(): void;
  24696. /**
  24697. * Updates the poseControlled values based on the input device pose.
  24698. * @param poseData Pose coming from the device
  24699. */
  24700. updateFromDevice(poseData: DevicePose): void;
  24701. /**
  24702. * WebVR's attach control will start broadcasting frames to the device.
  24703. * Note that in certain browsers (chrome for example) this function must be called
  24704. * within a user-interaction callback. Example:
  24705. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  24706. *
  24707. * @param element html element to attach the vrDevice to
  24708. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  24709. */
  24710. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24711. /**
  24712. * Detaches the camera from the html element and disables VR
  24713. *
  24714. * @param element html element to detach from
  24715. */
  24716. detachControl(element: HTMLElement): void;
  24717. /**
  24718. * @returns the name of this class
  24719. */
  24720. getClassName(): string;
  24721. /**
  24722. * Calls resetPose on the vrDisplay
  24723. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  24724. */
  24725. resetToCurrentRotation(): void;
  24726. /**
  24727. * Updates the rig cameras (left and right eye)
  24728. */
  24729. _updateRigCameras(): void;
  24730. private _workingVector;
  24731. private _oneVector;
  24732. private _workingMatrix;
  24733. private updateCacheCalled;
  24734. /**
  24735. * Updates the cached values of the camera
  24736. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  24737. */
  24738. _updateCache(ignoreParentClass?: boolean): void;
  24739. /**
  24740. * Updates the current device position and rotation in the babylon world
  24741. */
  24742. update(): void;
  24743. /**
  24744. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  24745. * @returns an identity matrix
  24746. */
  24747. _getViewMatrix(): Matrix;
  24748. /**
  24749. * This function is called by the two RIG cameras.
  24750. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  24751. */
  24752. protected _getWebVRViewMatrix(): Matrix;
  24753. protected _getWebVRProjectionMatrix(): Matrix;
  24754. private _onGamepadConnectedObserver;
  24755. private _onGamepadDisconnectedObserver;
  24756. /**
  24757. * Initializes the controllers and their meshes
  24758. */
  24759. initControllers(): void;
  24760. }
  24761. }
  24762. declare module BABYLON {
  24763. /**
  24764. * Google Daydream controller
  24765. */
  24766. class DaydreamController extends WebVRController {
  24767. /**
  24768. * Base Url for the controller model.
  24769. */
  24770. static MODEL_BASE_URL: string;
  24771. /**
  24772. * File name for the controller model.
  24773. */
  24774. static MODEL_FILENAME: string;
  24775. /**
  24776. * Gamepad Id prefix used to identify Daydream Controller.
  24777. */
  24778. static readonly GAMEPAD_ID_PREFIX: string;
  24779. constructor(vrGamepad: any);
  24780. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24781. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24782. }
  24783. }
  24784. declare module BABYLON {
  24785. class GearVRController extends WebVRController {
  24786. static MODEL_BASE_URL: string;
  24787. static MODEL_FILENAME: string;
  24788. static readonly GAMEPAD_ID_PREFIX: string;
  24789. private readonly _buttonIndexToObservableNameMap;
  24790. constructor(vrGamepad: any);
  24791. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24792. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24793. }
  24794. }
  24795. declare module BABYLON {
  24796. class GenericController extends WebVRController {
  24797. static readonly MODEL_BASE_URL: string;
  24798. static readonly MODEL_FILENAME: string;
  24799. constructor(vrGamepad: any);
  24800. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24801. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24802. }
  24803. }
  24804. declare module BABYLON {
  24805. class OculusTouchController extends WebVRController {
  24806. static MODEL_BASE_URL: string;
  24807. static MODEL_LEFT_FILENAME: string;
  24808. static MODEL_RIGHT_FILENAME: string;
  24809. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  24810. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  24811. constructor(vrGamepad: any);
  24812. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24813. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24814. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24815. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24816. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24817. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24818. }
  24819. }
  24820. declare module BABYLON {
  24821. enum PoseEnabledControllerType {
  24822. VIVE = 0,
  24823. OCULUS = 1,
  24824. WINDOWS = 2,
  24825. GEAR_VR = 3,
  24826. /**
  24827. * Google Daydream
  24828. */
  24829. DAYDREAM = 4,
  24830. GENERIC = 5,
  24831. }
  24832. interface MutableGamepadButton {
  24833. value: number;
  24834. touched: boolean;
  24835. pressed: boolean;
  24836. }
  24837. interface ExtendedGamepadButton extends GamepadButton {
  24838. readonly pressed: boolean;
  24839. readonly touched: boolean;
  24840. readonly value: number;
  24841. }
  24842. class PoseEnabledControllerHelper {
  24843. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  24844. }
  24845. class PoseEnabledController extends Gamepad implements PoseControlled {
  24846. private _deviceRoomPosition;
  24847. private _deviceRoomRotationQuaternion;
  24848. devicePosition: Vector3;
  24849. deviceRotationQuaternion: Quaternion;
  24850. deviceScaleFactor: number;
  24851. position: Vector3;
  24852. rotationQuaternion: Quaternion;
  24853. controllerType: PoseEnabledControllerType;
  24854. private _calculatedPosition;
  24855. private _calculatedRotation;
  24856. rawPose: DevicePose;
  24857. _mesh: Nullable<AbstractMesh>;
  24858. private _poseControlledCamera;
  24859. private _leftHandSystemQuaternion;
  24860. _deviceToWorld: Matrix;
  24861. /**
  24862. * Node to be used when casting a ray from the controller
  24863. */
  24864. _pointingPoseNode: Nullable<AbstractMesh>;
  24865. /**
  24866. * Name of the child mesh that can be used to cast a ray from the controller
  24867. */
  24868. static readonly POINTING_POSE: string;
  24869. constructor(browserGamepad: any);
  24870. private _workingMatrix;
  24871. update(): void;
  24872. updateFromDevice(poseData: DevicePose): void;
  24873. attachToMesh(mesh: AbstractMesh): void;
  24874. attachToPoseControlledCamera(camera: TargetCamera): void;
  24875. dispose(): void;
  24876. readonly mesh: Nullable<AbstractMesh>;
  24877. getForwardRay(length?: number): Ray;
  24878. }
  24879. }
  24880. declare module BABYLON {
  24881. class ViveController extends WebVRController {
  24882. static MODEL_BASE_URL: string;
  24883. static MODEL_FILENAME: string;
  24884. constructor(vrGamepad: any);
  24885. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24886. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24887. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24888. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24889. /**
  24890. * Vive mapping:
  24891. * 0: touchpad
  24892. * 1: trigger
  24893. * 2: left AND right buttons
  24894. * 3: menu button
  24895. */
  24896. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24897. }
  24898. }
  24899. declare module BABYLON {
  24900. abstract class WebVRController extends PoseEnabledController {
  24901. protected _defaultModel: AbstractMesh;
  24902. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  24903. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24904. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24905. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  24906. onPadValuesChangedObservable: Observable<StickValues>;
  24907. protected _buttons: Array<MutableGamepadButton>;
  24908. private _onButtonStateChange;
  24909. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  24910. pad: StickValues;
  24911. hand: string;
  24912. readonly defaultModel: AbstractMesh;
  24913. constructor(vrGamepad: any);
  24914. update(): void;
  24915. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24916. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24917. private _setButtonValue(newState, currentState, buttonIndex);
  24918. private _changes;
  24919. private _checkChanges(newState, currentState);
  24920. dispose(): void;
  24921. }
  24922. }
  24923. declare module BABYLON {
  24924. class WindowsMotionController extends WebVRController {
  24925. static MODEL_BASE_URL: string;
  24926. static MODEL_LEFT_FILENAME: string;
  24927. static MODEL_RIGHT_FILENAME: string;
  24928. static readonly GAMEPAD_ID_PREFIX: string;
  24929. private static readonly GAMEPAD_ID_PATTERN;
  24930. private _loadedMeshInfo;
  24931. private readonly _mapping;
  24932. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  24933. onTrackpadValuesChangedObservable: Observable<StickValues>;
  24934. trackpad: StickValues;
  24935. constructor(vrGamepad: any);
  24936. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24937. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24938. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24939. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24940. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24941. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  24942. /**
  24943. * Called once per frame by the engine.
  24944. */
  24945. update(): void;
  24946. /**
  24947. * Called once for each button that changed state since the last frame
  24948. * @param buttonIdx Which button index changed
  24949. * @param state New state of the button
  24950. * @param changes Which properties on the state changed since last frame
  24951. */
  24952. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24953. protected lerpButtonTransform(buttonName: string, buttonValue: number): void;
  24954. protected lerpAxisTransform(axis: number, axisValue: number): void;
  24955. /**
  24956. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  24957. * @param scene scene in which to add meshes
  24958. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  24959. */
  24960. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  24961. /**
  24962. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  24963. * can be transformed by button presses and axes values, based on this._mapping.
  24964. *
  24965. * @param scene scene in which the meshes exist
  24966. * @param meshes list of meshes that make up the controller model to process
  24967. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  24968. */
  24969. private processModel(scene, meshes);
  24970. private createMeshInfo(rootNode);
  24971. getForwardRay(length?: number): Ray;
  24972. dispose(): void;
  24973. }
  24974. }
  24975. declare module BABYLON {
  24976. }
  24977. declare module BABYLON {
  24978. /**
  24979. * Interface to implement to create a shadow generator compatible with BJS.
  24980. */
  24981. interface IShadowGenerator {
  24982. /**
  24983. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  24984. * @returns The render target texture if present otherwise, null
  24985. */
  24986. getShadowMap(): Nullable<RenderTargetTexture>;
  24987. /**
  24988. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  24989. * @returns The render target texture if the shadow map is present otherwise, null
  24990. */
  24991. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  24992. /**
  24993. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  24994. * @param subMesh The submesh we want to render in the shadow map
  24995. * @param useInstances Defines wether will draw in the map using instances
  24996. * @returns true if ready otherwise, false
  24997. */
  24998. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24999. /**
  25000. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  25001. * @param defines Defines of the material we want to update
  25002. * @param lightIndex Index of the light in the enabled light list of the material
  25003. */
  25004. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  25005. /**
  25006. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  25007. * defined in the generator but impacting the effect).
  25008. * It implies the unifroms available on the materials are the standard BJS ones.
  25009. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  25010. * @param effect The effect we are binfing the information for
  25011. */
  25012. bindShadowLight(lightIndex: string, effect: Effect): void;
  25013. /**
  25014. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  25015. * (eq to shadow prjection matrix * light transform matrix)
  25016. * @returns The transform matrix used to create the shadow map
  25017. */
  25018. getTransformMatrix(): Matrix;
  25019. /**
  25020. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  25021. * Cube and 2D textures for instance.
  25022. */
  25023. recreateShadowMap(): void;
  25024. /**
  25025. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  25026. * @param onCompiled Callback triggered at the and of the effects compilation
  25027. * @param options Sets of optional options forcing the compilation with different modes
  25028. */
  25029. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  25030. useInstances: boolean;
  25031. }>): void;
  25032. /**
  25033. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  25034. * @param options Sets of optional options forcing the compilation with different modes
  25035. * @returns A promise that resolves when the compilation completes
  25036. */
  25037. forceCompilationAsync(options?: Partial<{
  25038. useInstances: boolean;
  25039. }>): Promise<void>;
  25040. /**
  25041. * Serializes the shadow generator setup to a json object.
  25042. * @returns The serialized JSON object
  25043. */
  25044. serialize(): any;
  25045. /**
  25046. * Disposes the Shadow map and related Textures and effects.
  25047. */
  25048. dispose(): void;
  25049. }
  25050. /**
  25051. * Default implementation of @see IShadowGenerator.
  25052. * This is the main object responsible of generating shadows in the framework.
  25053. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  25054. */
  25055. class ShadowGenerator implements IShadowGenerator {
  25056. /**
  25057. * Shadow generator mode None: no filtering applied.
  25058. */
  25059. static readonly FILTER_NONE: number;
  25060. /**
  25061. * Shadow generator mode ESM: Exponential Shadow Mapping.
  25062. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  25063. */
  25064. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  25065. /**
  25066. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  25067. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  25068. */
  25069. static readonly FILTER_POISSONSAMPLING: number;
  25070. /**
  25071. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  25072. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  25073. */
  25074. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  25075. /**
  25076. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  25077. * edge artifacts on steep falloff.
  25078. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  25079. */
  25080. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  25081. /**
  25082. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  25083. * edge artifacts on steep falloff.
  25084. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  25085. */
  25086. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  25087. /**
  25088. * Shadow generator mode PCF: Percentage Closer Filtering
  25089. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  25090. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  25091. */
  25092. static readonly FILTER_PCF: number;
  25093. /**
  25094. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  25095. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  25096. * Contact Hardening
  25097. */
  25098. static readonly FILTER_PCSS: number;
  25099. /**
  25100. * Reserved for PCF and PCSS
  25101. * Highest Quality.
  25102. *
  25103. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  25104. *
  25105. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  25106. */
  25107. static readonly QUALITY_HIGH: number;
  25108. /**
  25109. * Reserved for PCF and PCSS
  25110. * Good tradeoff for quality/perf cross devices
  25111. *
  25112. * Execute PCF on a 3*3 kernel.
  25113. *
  25114. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  25115. */
  25116. static readonly QUALITY_MEDIUM: number;
  25117. /**
  25118. * Reserved for PCF and PCSS
  25119. * The lowest quality but the fastest.
  25120. *
  25121. * Execute PCF on a 1*1 kernel.
  25122. *
  25123. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  25124. */
  25125. static readonly QUALITY_LOW: number;
  25126. private _bias;
  25127. /**
  25128. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  25129. */
  25130. /**
  25131. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  25132. */
  25133. bias: number;
  25134. private _normalBias;
  25135. /**
  25136. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  25137. */
  25138. /**
  25139. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  25140. */
  25141. normalBias: number;
  25142. private _blurBoxOffset;
  25143. /**
  25144. * Gets the blur box offset: offset applied during the blur pass.
  25145. * Only usefull if useKernelBlur = false
  25146. */
  25147. /**
  25148. * Sets the blur box offset: offset applied during the blur pass.
  25149. * Only usefull if useKernelBlur = false
  25150. */
  25151. blurBoxOffset: number;
  25152. private _blurScale;
  25153. /**
  25154. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  25155. * 2 means half of the size.
  25156. */
  25157. /**
  25158. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  25159. * 2 means half of the size.
  25160. */
  25161. blurScale: number;
  25162. private _blurKernel;
  25163. /**
  25164. * Gets the blur kernel: kernel size of the blur pass.
  25165. * Only usefull if useKernelBlur = true
  25166. */
  25167. /**
  25168. * Sets the blur kernel: kernel size of the blur pass.
  25169. * Only usefull if useKernelBlur = true
  25170. */
  25171. blurKernel: number;
  25172. private _useKernelBlur;
  25173. /**
  25174. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  25175. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  25176. */
  25177. /**
  25178. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  25179. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  25180. */
  25181. useKernelBlur: boolean;
  25182. private _depthScale;
  25183. /**
  25184. * Gets the depth scale used in ESM mode.
  25185. */
  25186. /**
  25187. * Sets the depth scale used in ESM mode.
  25188. * This can override the scale stored on the light.
  25189. */
  25190. depthScale: number;
  25191. private _filter;
  25192. /**
  25193. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  25194. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  25195. */
  25196. /**
  25197. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  25198. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  25199. */
  25200. filter: number;
  25201. /**
  25202. * Gets if the current filter is set to Poisson Sampling.
  25203. */
  25204. /**
  25205. * Sets the current filter to Poisson Sampling.
  25206. */
  25207. usePoissonSampling: boolean;
  25208. /**
  25209. * Gets if the current filter is set to VSM.
  25210. * DEPRECATED. Should use useExponentialShadowMap instead.
  25211. */
  25212. /**
  25213. * Sets the current filter is to VSM.
  25214. * DEPRECATED. Should use useExponentialShadowMap instead.
  25215. */
  25216. useVarianceShadowMap: boolean;
  25217. /**
  25218. * Gets if the current filter is set to blurred VSM.
  25219. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  25220. */
  25221. /**
  25222. * Sets the current filter is to blurred VSM.
  25223. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  25224. */
  25225. useBlurVarianceShadowMap: boolean;
  25226. /**
  25227. * Gets if the current filter is set to ESM.
  25228. */
  25229. /**
  25230. * Sets the current filter is to ESM.
  25231. */
  25232. useExponentialShadowMap: boolean;
  25233. /**
  25234. * Gets if the current filter is set to filtered ESM.
  25235. */
  25236. /**
  25237. * Gets if the current filter is set to filtered ESM.
  25238. */
  25239. useBlurExponentialShadowMap: boolean;
  25240. /**
  25241. * Gets if the current filter is set to "close ESM" (using the inverse of the
  25242. * exponential to prevent steep falloff artifacts).
  25243. */
  25244. /**
  25245. * Sets the current filter to "close ESM" (using the inverse of the
  25246. * exponential to prevent steep falloff artifacts).
  25247. */
  25248. useCloseExponentialShadowMap: boolean;
  25249. /**
  25250. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  25251. * exponential to prevent steep falloff artifacts).
  25252. */
  25253. /**
  25254. * Sets the current filter to filtered "close ESM" (using the inverse of the
  25255. * exponential to prevent steep falloff artifacts).
  25256. */
  25257. useBlurCloseExponentialShadowMap: boolean;
  25258. /**
  25259. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  25260. */
  25261. /**
  25262. * Sets the current filter to "PCF" (percentage closer filtering).
  25263. */
  25264. usePercentageCloserFiltering: boolean;
  25265. private _filteringQuality;
  25266. /**
  25267. * Gets the PCF or PCSS Quality.
  25268. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  25269. */
  25270. /**
  25271. * Sets the PCF or PCSS Quality.
  25272. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  25273. */
  25274. filteringQuality: number;
  25275. /**
  25276. * Gets if the current filter is set to "PCSS" (contact hardening).
  25277. */
  25278. /**
  25279. * Sets the current filter to "PCSS" (contact hardening).
  25280. */
  25281. useContactHardeningShadow: boolean;
  25282. private _contactHardeningLightSizeUVRatio;
  25283. /**
  25284. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  25285. * Using a ratio helps keeping shape stability independently of the map size.
  25286. *
  25287. * It does not account for the light projection as it was having too much
  25288. * instability during the light setup or during light position changes.
  25289. *
  25290. * Only valid if useContactHardeningShadow is true.
  25291. */
  25292. /**
  25293. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  25294. * Using a ratio helps keeping shape stability independently of the map size.
  25295. *
  25296. * It does not account for the light projection as it was having too much
  25297. * instability during the light setup or during light position changes.
  25298. *
  25299. * Only valid if useContactHardeningShadow is true.
  25300. */
  25301. contactHardeningLightSizeUVRatio: number;
  25302. private _darkness;
  25303. /**
  25304. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  25305. * 0 means strongest and 1 would means no shadow.
  25306. * @returns the darkness.
  25307. */
  25308. getDarkness(): number;
  25309. /**
  25310. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  25311. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  25312. * @returns the shadow generator allowing fluent coding.
  25313. */
  25314. setDarkness(darkness: number): ShadowGenerator;
  25315. private _transparencyShadow;
  25316. /**
  25317. * Sets the ability to have transparent shadow (boolean).
  25318. * @param transparent True if transparent else False
  25319. * @returns the shadow generator allowing fluent coding
  25320. */
  25321. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  25322. private _shadowMap;
  25323. private _shadowMap2;
  25324. /**
  25325. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  25326. * @returns The render target texture if present otherwise, null
  25327. */
  25328. getShadowMap(): Nullable<RenderTargetTexture>;
  25329. /**
  25330. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  25331. * @returns The render target texture if the shadow map is present otherwise, null
  25332. */
  25333. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  25334. /**
  25335. * Helper function to add a mesh and its descendants to the list of shadow casters.
  25336. * @param mesh Mesh to add
  25337. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  25338. * @returns the Shadow Generator itself
  25339. */
  25340. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  25341. /**
  25342. * Helper function to remove a mesh and its descendants from the list of shadow casters
  25343. * @param mesh Mesh to remove
  25344. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  25345. * @returns the Shadow Generator itself
  25346. */
  25347. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  25348. /**
  25349. * Controls the extent to which the shadows fade out at the edge of the frustum
  25350. * Used only by directionals and spots
  25351. */
  25352. frustumEdgeFalloff: number;
  25353. private _light;
  25354. /**
  25355. * Returns the associated light object.
  25356. * @returns the light generating the shadow
  25357. */
  25358. getLight(): IShadowLight;
  25359. /**
  25360. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  25361. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  25362. * It might on the other hand introduce peter panning.
  25363. */
  25364. forceBackFacesOnly: boolean;
  25365. private _scene;
  25366. private _lightDirection;
  25367. private _effect;
  25368. private _viewMatrix;
  25369. private _projectionMatrix;
  25370. private _transformMatrix;
  25371. private _cachedPosition;
  25372. private _cachedDirection;
  25373. private _cachedDefines;
  25374. private _currentRenderID;
  25375. private _boxBlurPostprocess;
  25376. private _kernelBlurXPostprocess;
  25377. private _kernelBlurYPostprocess;
  25378. private _blurPostProcesses;
  25379. private _mapSize;
  25380. private _currentFaceIndex;
  25381. private _currentFaceIndexCache;
  25382. private _textureType;
  25383. private _defaultTextureMatrix;
  25384. /**
  25385. * Creates a ShadowGenerator object.
  25386. * A ShadowGenerator is the required tool to use the shadows.
  25387. * Each light casting shadows needs to use its own ShadowGenerator.
  25388. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  25389. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  25390. * @param light The light object generating the shadows.
  25391. * @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.
  25392. */
  25393. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  25394. private _initializeGenerator();
  25395. private _initializeShadowMap();
  25396. private _initializeBlurRTTAndPostProcesses();
  25397. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  25398. private _renderSubMeshForShadowMap(subMesh);
  25399. private _applyFilterValues();
  25400. /**
  25401. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  25402. * @param onCompiled Callback triggered at the and of the effects compilation
  25403. * @param options Sets of optional options forcing the compilation with different modes
  25404. */
  25405. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  25406. useInstances: boolean;
  25407. }>): void;
  25408. /**
  25409. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  25410. * @param options Sets of optional options forcing the compilation with different modes
  25411. * @returns A promise that resolves when the compilation completes
  25412. */
  25413. forceCompilationAsync(options?: Partial<{
  25414. useInstances: boolean;
  25415. }>): Promise<void>;
  25416. /**
  25417. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  25418. * @param subMesh The submesh we want to render in the shadow map
  25419. * @param useInstances Defines wether will draw in the map using instances
  25420. * @returns true if ready otherwise, false
  25421. */
  25422. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25423. /**
  25424. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  25425. * @param defines Defines of the material we want to update
  25426. * @param lightIndex Index of the light in the enabled light list of the material
  25427. */
  25428. prepareDefines(defines: any, lightIndex: number): void;
  25429. /**
  25430. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  25431. * defined in the generator but impacting the effect).
  25432. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  25433. * @param effect The effect we are binfing the information for
  25434. */
  25435. bindShadowLight(lightIndex: string, effect: Effect): void;
  25436. /**
  25437. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  25438. * (eq to shadow prjection matrix * light transform matrix)
  25439. * @returns The transform matrix used to create the shadow map
  25440. */
  25441. getTransformMatrix(): Matrix;
  25442. /**
  25443. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  25444. * Cube and 2D textures for instance.
  25445. */
  25446. recreateShadowMap(): void;
  25447. private _disposeBlurPostProcesses();
  25448. private _disposeRTTandPostProcesses();
  25449. /**
  25450. * Disposes the ShadowGenerator.
  25451. * Returns nothing.
  25452. */
  25453. dispose(): void;
  25454. /**
  25455. * Serializes the shadow generator setup to a json object.
  25456. * @returns The serialized JSON object
  25457. */
  25458. serialize(): any;
  25459. /**
  25460. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  25461. * @param parsedShadowGenerator The JSON object to parse
  25462. * @param scene The scene to create the shadow map for
  25463. * @returns The parsed shadow generator
  25464. */
  25465. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  25466. }
  25467. }
  25468. declare module BABYLON {
  25469. /**
  25470. * Background material used to create an efficient environement around your scene.
  25471. */
  25472. class BackgroundMaterial extends PushMaterial {
  25473. /**
  25474. * Standard reflectance value at parallel view angle.
  25475. */
  25476. static StandardReflectance0: number;
  25477. /**
  25478. * Standard reflectance value at grazing angle.
  25479. */
  25480. static StandardReflectance90: number;
  25481. protected _primaryColor: Color3;
  25482. /**
  25483. * Key light Color (multiply against the R channel of the environement texture)
  25484. */
  25485. primaryColor: Color3;
  25486. protected _primaryLevel: float;
  25487. /**
  25488. * Key light Level (allowing HDR output of the background)
  25489. */
  25490. primaryLevel: float;
  25491. protected _secondaryColor: Color3;
  25492. /**
  25493. * Secondary light Color (multiply against the G channel of the environement texture)
  25494. */
  25495. secondaryColor: Color3;
  25496. protected _secondaryLevel: float;
  25497. /**
  25498. * Secondary light Level (allowing HDR output of the background)
  25499. */
  25500. secondaryLevel: float;
  25501. protected _tertiaryColor: Color3;
  25502. /**
  25503. * Tertiary light Color (multiply against the B channel of the environement texture)
  25504. */
  25505. tertiaryColor: Color3;
  25506. protected _tertiaryLevel: float;
  25507. /**
  25508. * Tertiary light Level (allowing HDR output of the background)
  25509. */
  25510. tertiaryLevel: float;
  25511. protected _reflectionTexture: Nullable<BaseTexture>;
  25512. /**
  25513. * Reflection Texture used in the material.
  25514. * Should be author in a specific way for the best result (refer to the documentation).
  25515. */
  25516. reflectionTexture: Nullable<BaseTexture>;
  25517. protected _reflectionBlur: float;
  25518. /**
  25519. * Reflection Texture level of blur.
  25520. *
  25521. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  25522. * texture twice.
  25523. */
  25524. reflectionBlur: float;
  25525. protected _diffuseTexture: Nullable<BaseTexture>;
  25526. /**
  25527. * Diffuse Texture used in the material.
  25528. * Should be author in a specific way for the best result (refer to the documentation).
  25529. */
  25530. diffuseTexture: Nullable<BaseTexture>;
  25531. protected _shadowLights: Nullable<IShadowLight[]>;
  25532. /**
  25533. * Specify the list of lights casting shadow on the material.
  25534. * All scene shadow lights will be included if null.
  25535. */
  25536. shadowLights: Nullable<IShadowLight[]>;
  25537. protected _shadowBlurScale: int;
  25538. /**
  25539. * For the lights having a blurred shadow generator, this can add a second blur pass in order to reach
  25540. * soft lighting on the background.
  25541. */
  25542. shadowBlurScale: int;
  25543. protected _shadowLevel: float;
  25544. /**
  25545. * Helps adjusting the shadow to a softer level if required.
  25546. * 0 means black shadows and 1 means no shadows.
  25547. */
  25548. shadowLevel: float;
  25549. protected _sceneCenter: Vector3;
  25550. /**
  25551. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  25552. * It is usually zero but might be interesting to modify according to your setup.
  25553. */
  25554. sceneCenter: Vector3;
  25555. protected _opacityFresnel: boolean;
  25556. /**
  25557. * This helps specifying that the material is falling off to the sky box at grazing angle.
  25558. * This helps ensuring a nice transition when the camera goes under the ground.
  25559. */
  25560. opacityFresnel: boolean;
  25561. protected _reflectionFresnel: boolean;
  25562. /**
  25563. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  25564. * This helps adding a mirror texture on the ground.
  25565. */
  25566. reflectionFresnel: boolean;
  25567. protected _reflectionFalloffDistance: number;
  25568. /**
  25569. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  25570. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  25571. */
  25572. reflectionFalloffDistance: number;
  25573. protected _reflectionAmount: number;
  25574. /**
  25575. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  25576. */
  25577. reflectionAmount: number;
  25578. protected _reflectionReflectance0: number;
  25579. /**
  25580. * This specifies the weight of the reflection at grazing angle.
  25581. */
  25582. reflectionReflectance0: number;
  25583. protected _reflectionReflectance90: number;
  25584. /**
  25585. * This specifies the weight of the reflection at a perpendicular point of view.
  25586. */
  25587. reflectionReflectance90: number;
  25588. /**
  25589. * Sets the reflection reflectance fresnel values according to the default standard
  25590. * empirically know to work well :-)
  25591. */
  25592. reflectionStandardFresnelWeight: number;
  25593. protected _useRGBColor: boolean;
  25594. /**
  25595. * Helps to directly use the maps channels instead of their level.
  25596. */
  25597. useRGBColor: boolean;
  25598. protected _enableNoise: boolean;
  25599. /**
  25600. * This helps reducing the banding effect that could occur on the background.
  25601. */
  25602. enableNoise: boolean;
  25603. /**
  25604. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  25605. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  25606. * Recommended to be keep at 1.0 except for special cases.
  25607. */
  25608. fovMultiplier: number;
  25609. private _fovMultiplier;
  25610. /**
  25611. * Enable the FOV adjustment feature controlled by fovMultiplier.
  25612. * @type {boolean}
  25613. */
  25614. useEquirectangularFOV: boolean;
  25615. private _maxSimultaneousLights;
  25616. /**
  25617. * Number of Simultaneous lights allowed on the material.
  25618. */
  25619. maxSimultaneousLights: int;
  25620. /**
  25621. * Default configuration related to image processing available in the Background Material.
  25622. */
  25623. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25624. /**
  25625. * Keep track of the image processing observer to allow dispose and replace.
  25626. */
  25627. private _imageProcessingObserver;
  25628. /**
  25629. * Attaches a new image processing configuration to the PBR Material.
  25630. * @param configuration (if null the scene configuration will be use)
  25631. */
  25632. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25633. /**
  25634. * Gets the image processing configuration used either in this material.
  25635. */
  25636. /**
  25637. * Sets the Default image processing configuration used either in the this material.
  25638. *
  25639. * If sets to null, the scene one is in use.
  25640. */
  25641. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  25642. /**
  25643. * Gets wether the color curves effect is enabled.
  25644. */
  25645. /**
  25646. * Sets wether the color curves effect is enabled.
  25647. */
  25648. cameraColorCurvesEnabled: boolean;
  25649. /**
  25650. * Gets wether the color grading effect is enabled.
  25651. */
  25652. /**
  25653. * Gets wether the color grading effect is enabled.
  25654. */
  25655. cameraColorGradingEnabled: boolean;
  25656. /**
  25657. * Gets wether tonemapping is enabled or not.
  25658. */
  25659. /**
  25660. * Sets wether tonemapping is enabled or not
  25661. */
  25662. cameraToneMappingEnabled: boolean;
  25663. /**
  25664. * The camera exposure used on this material.
  25665. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25666. * This corresponds to a photographic exposure.
  25667. */
  25668. /**
  25669. * The camera exposure used on this material.
  25670. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25671. * This corresponds to a photographic exposure.
  25672. */
  25673. cameraExposure: float;
  25674. /**
  25675. * Gets The camera contrast used on this material.
  25676. */
  25677. /**
  25678. * Sets The camera contrast used on this material.
  25679. */
  25680. cameraContrast: float;
  25681. /**
  25682. * Gets the Color Grading 2D Lookup Texture.
  25683. */
  25684. /**
  25685. * Sets the Color Grading 2D Lookup Texture.
  25686. */
  25687. cameraColorGradingTexture: Nullable<BaseTexture>;
  25688. /**
  25689. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25690. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25691. * 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;
  25692. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25693. */
  25694. /**
  25695. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25696. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25697. * 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;
  25698. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25699. */
  25700. cameraColorCurves: Nullable<ColorCurves>;
  25701. /**
  25702. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  25703. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  25704. */
  25705. switchToBGR: boolean;
  25706. private _renderTargets;
  25707. private _reflectionControls;
  25708. /**
  25709. * Instantiates a Background Material in the given scene
  25710. * @param name The friendly name of the material
  25711. * @param scene The scene to add the material to
  25712. */
  25713. constructor(name: string, scene: Scene);
  25714. /**
  25715. * The entire material has been created in order to prevent overdraw.
  25716. * @returns false
  25717. */
  25718. needAlphaTesting(): boolean;
  25719. /**
  25720. * The entire material has been created in order to prevent overdraw.
  25721. * @returns true if blending is enable
  25722. */
  25723. needAlphaBlending(): boolean;
  25724. /**
  25725. * Checks wether the material is ready to be rendered for a given mesh.
  25726. * @param mesh The mesh to render
  25727. * @param subMesh The submesh to check against
  25728. * @param useInstances Specify wether or not the material is used with instances
  25729. * @returns true if all the dependencies are ready (Textures, Effects...)
  25730. */
  25731. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25732. /**
  25733. * Build the uniform buffer used in the material.
  25734. */
  25735. buildUniformLayout(): void;
  25736. /**
  25737. * Unbind the material.
  25738. */
  25739. unbind(): void;
  25740. /**
  25741. * Bind only the world matrix to the material.
  25742. * @param world The world matrix to bind.
  25743. */
  25744. bindOnlyWorldMatrix(world: Matrix): void;
  25745. /**
  25746. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  25747. * @param world The world matrix to bind.
  25748. * @param subMesh The submesh to bind for.
  25749. */
  25750. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25751. /**
  25752. * Dispose the material.
  25753. * @param forceDisposeEffect Force disposal of the associated effect.
  25754. * @param forceDisposeTextures Force disposal of the associated textures.
  25755. */
  25756. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25757. /**
  25758. * Clones the material.
  25759. * @param name The cloned name.
  25760. * @returns The cloned material.
  25761. */
  25762. clone(name: string): BackgroundMaterial;
  25763. /**
  25764. * Serializes the current material to its JSON representation.
  25765. * @returns The JSON representation.
  25766. */
  25767. serialize(): any;
  25768. /**
  25769. * Gets the class name of the material
  25770. * @returns "BackgroundMaterial"
  25771. */
  25772. getClassName(): string;
  25773. /**
  25774. * Parse a JSON input to create back a background material.
  25775. * @param source The JSON data to parse
  25776. * @param scene The scene to create the parsed material in
  25777. * @param rootUrl The root url of the assets the material depends upon
  25778. * @returns the instantiated BackgroundMaterial.
  25779. */
  25780. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  25781. }
  25782. }
  25783. declare module BABYLON {
  25784. /**
  25785. * The Physically based material base class of BJS.
  25786. *
  25787. * This offers the main features of a standard PBR material.
  25788. * For more information, please refer to the documentation :
  25789. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  25790. */
  25791. abstract class PBRBaseMaterial extends PushMaterial {
  25792. /**
  25793. * Intensity of the direct lights e.g. the four lights available in your scene.
  25794. * This impacts both the direct diffuse and specular highlights.
  25795. */
  25796. protected _directIntensity: number;
  25797. /**
  25798. * Intensity of the emissive part of the material.
  25799. * This helps controlling the emissive effect without modifying the emissive color.
  25800. */
  25801. protected _emissiveIntensity: number;
  25802. /**
  25803. * Intensity of the environment e.g. how much the environment will light the object
  25804. * either through harmonics for rough material or through the refelction for shiny ones.
  25805. */
  25806. protected _environmentIntensity: number;
  25807. /**
  25808. * This is a special control allowing the reduction of the specular highlights coming from the
  25809. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  25810. */
  25811. protected _specularIntensity: number;
  25812. /**
  25813. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  25814. */
  25815. private _lightingInfos;
  25816. /**
  25817. * Debug Control allowing disabling the bump map on this material.
  25818. */
  25819. protected _disableBumpMap: boolean;
  25820. /**
  25821. * AKA Diffuse Texture in standard nomenclature.
  25822. */
  25823. protected _albedoTexture: BaseTexture;
  25824. /**
  25825. * AKA Occlusion Texture in other nomenclature.
  25826. */
  25827. protected _ambientTexture: BaseTexture;
  25828. /**
  25829. * AKA Occlusion Texture Intensity in other nomenclature.
  25830. */
  25831. protected _ambientTextureStrength: number;
  25832. /**
  25833. * Stores the alpha values in a texture.
  25834. */
  25835. protected _opacityTexture: BaseTexture;
  25836. /**
  25837. * Stores the reflection values in a texture.
  25838. */
  25839. protected _reflectionTexture: BaseTexture;
  25840. /**
  25841. * Stores the refraction values in a texture.
  25842. */
  25843. protected _refractionTexture: BaseTexture;
  25844. /**
  25845. * Stores the emissive values in a texture.
  25846. */
  25847. protected _emissiveTexture: BaseTexture;
  25848. /**
  25849. * AKA Specular texture in other nomenclature.
  25850. */
  25851. protected _reflectivityTexture: BaseTexture;
  25852. /**
  25853. * Used to switch from specular/glossiness to metallic/roughness workflow.
  25854. */
  25855. protected _metallicTexture: BaseTexture;
  25856. /**
  25857. * Specifies the metallic scalar of the metallic/roughness workflow.
  25858. * Can also be used to scale the metalness values of the metallic texture.
  25859. */
  25860. protected _metallic: number;
  25861. /**
  25862. * Specifies the roughness scalar of the metallic/roughness workflow.
  25863. * Can also be used to scale the roughness values of the metallic texture.
  25864. */
  25865. protected _roughness: number;
  25866. /**
  25867. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  25868. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  25869. */
  25870. protected _microSurfaceTexture: BaseTexture;
  25871. /**
  25872. * Stores surface normal data used to displace a mesh in a texture.
  25873. */
  25874. protected _bumpTexture: BaseTexture;
  25875. /**
  25876. * Stores the pre-calculated light information of a mesh in a texture.
  25877. */
  25878. protected _lightmapTexture: BaseTexture;
  25879. /**
  25880. * The color of a material in ambient lighting.
  25881. */
  25882. protected _ambientColor: Color3;
  25883. /**
  25884. * AKA Diffuse Color in other nomenclature.
  25885. */
  25886. protected _albedoColor: Color3;
  25887. /**
  25888. * AKA Specular Color in other nomenclature.
  25889. */
  25890. protected _reflectivityColor: Color3;
  25891. /**
  25892. * The color applied when light is reflected from a material.
  25893. */
  25894. protected _reflectionColor: Color3;
  25895. /**
  25896. * The color applied when light is emitted from a material.
  25897. */
  25898. protected _emissiveColor: Color3;
  25899. /**
  25900. * AKA Glossiness in other nomenclature.
  25901. */
  25902. protected _microSurface: number;
  25903. /**
  25904. * source material index of refraction (IOR)' / 'destination material IOR.
  25905. */
  25906. protected _indexOfRefraction: number;
  25907. /**
  25908. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  25909. */
  25910. protected _invertRefractionY: boolean;
  25911. /**
  25912. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25913. * Materials half opaque for instance using refraction could benefit from this control.
  25914. */
  25915. protected _linkRefractionWithTransparency: boolean;
  25916. /**
  25917. * Specifies that the material will use the light map as a show map.
  25918. */
  25919. protected _useLightmapAsShadowmap: boolean;
  25920. /**
  25921. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  25922. * makes the reflect vector face the model (under horizon).
  25923. */
  25924. protected _useHorizonOcclusion: boolean;
  25925. /**
  25926. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  25927. * too much the area relying on ambient texture to define their ambient occlusion.
  25928. */
  25929. protected _useRadianceOcclusion: boolean;
  25930. /**
  25931. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  25932. */
  25933. protected _useAlphaFromAlbedoTexture: boolean;
  25934. /**
  25935. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  25936. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  25937. */
  25938. protected _useSpecularOverAlpha: boolean;
  25939. /**
  25940. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  25941. */
  25942. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  25943. /**
  25944. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  25945. */
  25946. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  25947. /**
  25948. * Specifies if the metallic texture contains the roughness information in its green channel.
  25949. */
  25950. protected _useRoughnessFromMetallicTextureGreen: boolean;
  25951. /**
  25952. * Specifies if the metallic texture contains the metallness information in its blue channel.
  25953. */
  25954. protected _useMetallnessFromMetallicTextureBlue: boolean;
  25955. /**
  25956. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  25957. */
  25958. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  25959. /**
  25960. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  25961. */
  25962. protected _useAmbientInGrayScale: boolean;
  25963. /**
  25964. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  25965. * The material will try to infer what glossiness each pixel should be.
  25966. */
  25967. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  25968. /**
  25969. * BJS is using an harcoded light falloff based on a manually sets up range.
  25970. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  25971. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  25972. */
  25973. protected _usePhysicalLightFalloff: boolean;
  25974. /**
  25975. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  25976. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  25977. */
  25978. protected _useRadianceOverAlpha: boolean;
  25979. /**
  25980. * Allows using an object space normal map (instead of tangent space).
  25981. */
  25982. protected _useObjectSpaceNormalMap: boolean;
  25983. /**
  25984. * Allows using the bump map in parallax mode.
  25985. */
  25986. protected _useParallax: boolean;
  25987. /**
  25988. * Allows using the bump map in parallax occlusion mode.
  25989. */
  25990. protected _useParallaxOcclusion: boolean;
  25991. /**
  25992. * Controls the scale bias of the parallax mode.
  25993. */
  25994. protected _parallaxScaleBias: number;
  25995. /**
  25996. * If sets to true, disables all the lights affecting the material.
  25997. */
  25998. protected _disableLighting: boolean;
  25999. /**
  26000. * Number of Simultaneous lights allowed on the material.
  26001. */
  26002. protected _maxSimultaneousLights: number;
  26003. /**
  26004. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  26005. */
  26006. protected _invertNormalMapX: boolean;
  26007. /**
  26008. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  26009. */
  26010. protected _invertNormalMapY: boolean;
  26011. /**
  26012. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26013. */
  26014. protected _twoSidedLighting: boolean;
  26015. /**
  26016. * Defines the alpha limits in alpha test mode.
  26017. */
  26018. protected _alphaCutOff: number;
  26019. /**
  26020. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26021. */
  26022. protected _forceAlphaTest: boolean;
  26023. /**
  26024. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26025. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26026. */
  26027. protected _useAlphaFresnel: boolean;
  26028. /**
  26029. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26030. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26031. */
  26032. protected _useLinearAlphaFresnel: boolean;
  26033. /**
  26034. * The transparency mode of the material.
  26035. */
  26036. protected _transparencyMode: Nullable<number>;
  26037. /**
  26038. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  26039. * from cos thetav and roughness:
  26040. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  26041. */
  26042. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  26043. /**
  26044. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26045. */
  26046. protected _forceIrradianceInFragment: boolean;
  26047. /**
  26048. * Force normal to face away from face.
  26049. */
  26050. protected _forceNormalForward: boolean;
  26051. /**
  26052. * Default configuration related to image processing available in the PBR Material.
  26053. */
  26054. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26055. /**
  26056. * Keep track of the image processing observer to allow dispose and replace.
  26057. */
  26058. private _imageProcessingObserver;
  26059. /**
  26060. * Attaches a new image processing configuration to the PBR Material.
  26061. * @param configuration
  26062. */
  26063. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26064. /**
  26065. * Stores the available render targets.
  26066. */
  26067. private _renderTargets;
  26068. /**
  26069. * Sets the global ambient color for the material used in lighting calculations.
  26070. */
  26071. private _globalAmbientColor;
  26072. /**
  26073. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  26074. */
  26075. private _useLogarithmicDepth;
  26076. /**
  26077. * If set to true, no lighting calculations will be applied.
  26078. */
  26079. private _unlit;
  26080. /**
  26081. * Instantiates a new PBRMaterial instance.
  26082. *
  26083. * @param name The material name
  26084. * @param scene The scene the material will be use in.
  26085. */
  26086. constructor(name: string, scene: Scene);
  26087. /**
  26088. * Gets the name of the material class.
  26089. */
  26090. getClassName(): string;
  26091. /**
  26092. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26093. */
  26094. /**
  26095. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26096. */
  26097. useLogarithmicDepth: boolean;
  26098. /**
  26099. * Gets the current transparency mode.
  26100. */
  26101. /**
  26102. * Sets the transparency mode of the material.
  26103. */
  26104. transparencyMode: Nullable<number>;
  26105. /**
  26106. * Returns true if alpha blending should be disabled.
  26107. */
  26108. private readonly _disableAlphaBlending;
  26109. /**
  26110. * Specifies whether or not this material should be rendered in alpha blend mode.
  26111. */
  26112. needAlphaBlending(): boolean;
  26113. /**
  26114. * Specifies if the mesh will require alpha blending.
  26115. * @param mesh - BJS mesh.
  26116. */
  26117. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  26118. /**
  26119. * Specifies whether or not this material should be rendered in alpha test mode.
  26120. */
  26121. needAlphaTesting(): boolean;
  26122. /**
  26123. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  26124. */
  26125. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  26126. /**
  26127. * Gets the texture used for the alpha test.
  26128. */
  26129. getAlphaTestTexture(): BaseTexture;
  26130. /**
  26131. * Stores the reflectivity values based on metallic roughness workflow.
  26132. */
  26133. private static _scaledReflectivity;
  26134. /**
  26135. * Specifies that the submesh is ready to be used.
  26136. * @param mesh - BJS mesh.
  26137. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  26138. * @param useInstances - Specifies that instances should be used.
  26139. * @returns - boolean indicating that the submesh is ready or not.
  26140. */
  26141. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26142. /**
  26143. * Specifies if the material uses metallic roughness workflow.
  26144. * @returns boolean specifiying if the material uses metallic roughness workflow.
  26145. */
  26146. isMetallicWorkflow(): boolean;
  26147. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  26148. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  26149. /**
  26150. * Force shader compilation
  26151. */
  26152. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  26153. clipPlane: boolean;
  26154. }>): void;
  26155. /**
  26156. * Initializes the uniform buffer layout for the shader.
  26157. */
  26158. buildUniformLayout(): void;
  26159. /**
  26160. * Unbinds the textures.
  26161. */
  26162. unbind(): void;
  26163. /**
  26164. * Binds the submesh data.
  26165. * @param world - The world matrix.
  26166. * @param mesh - The BJS mesh.
  26167. * @param subMesh - A submesh of the BJS mesh.
  26168. */
  26169. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26170. /**
  26171. * Returns the animatable textures.
  26172. * @returns - Array of animatable textures.
  26173. */
  26174. getAnimatables(): IAnimatable[];
  26175. /**
  26176. * Returns the texture used for reflections.
  26177. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  26178. */
  26179. private _getReflectionTexture();
  26180. /**
  26181. * Returns the texture used for refraction or null if none is used.
  26182. * @returns - Refection texture if present. If no refraction texture and refraction
  26183. * is linked with transparency, returns environment texture. Otherwise, returns null.
  26184. */
  26185. private _getRefractionTexture();
  26186. /**
  26187. * Disposes the resources of the material.
  26188. * @param forceDisposeEffect - Forces the disposal of effects.
  26189. * @param forceDisposeTextures - Forces the disposal of all textures.
  26190. */
  26191. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26192. }
  26193. }
  26194. declare module BABYLON {
  26195. /**
  26196. * The Physically based simple base material of BJS.
  26197. *
  26198. * This enables better naming and convention enforcements on top of the pbrMaterial.
  26199. * It is used as the base class for both the specGloss and metalRough conventions.
  26200. */
  26201. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  26202. /**
  26203. * Number of Simultaneous lights allowed on the material.
  26204. */
  26205. maxSimultaneousLights: number;
  26206. /**
  26207. * If sets to true, disables all the lights affecting the material.
  26208. */
  26209. disableLighting: boolean;
  26210. /**
  26211. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  26212. */
  26213. environmentTexture: BaseTexture;
  26214. /**
  26215. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26216. */
  26217. invertNormalMapX: boolean;
  26218. /**
  26219. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26220. */
  26221. invertNormalMapY: boolean;
  26222. /**
  26223. * Normal map used in the model.
  26224. */
  26225. normalTexture: BaseTexture;
  26226. /**
  26227. * Emissivie color used to self-illuminate the model.
  26228. */
  26229. emissiveColor: Color3;
  26230. /**
  26231. * Emissivie texture used to self-illuminate the model.
  26232. */
  26233. emissiveTexture: BaseTexture;
  26234. /**
  26235. * Occlusion Channel Strenght.
  26236. */
  26237. occlusionStrength: number;
  26238. /**
  26239. * Occlusion Texture of the material (adding extra occlusion effects).
  26240. */
  26241. occlusionTexture: BaseTexture;
  26242. /**
  26243. * Defines the alpha limits in alpha test mode.
  26244. */
  26245. alphaCutOff: number;
  26246. /**
  26247. * Gets the current double sided mode.
  26248. */
  26249. /**
  26250. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26251. */
  26252. doubleSided: boolean;
  26253. lightmapTexture: BaseTexture;
  26254. useLightmapAsShadowmap: boolean;
  26255. /**
  26256. * Return the active textures of the material.
  26257. */
  26258. getActiveTextures(): BaseTexture[];
  26259. hasTexture(texture: BaseTexture): boolean;
  26260. /**
  26261. * Instantiates a new PBRMaterial instance.
  26262. *
  26263. * @param name The material name
  26264. * @param scene The scene the material will be use in.
  26265. */
  26266. constructor(name: string, scene: Scene);
  26267. getClassName(): string;
  26268. }
  26269. }
  26270. declare module BABYLON {
  26271. /**
  26272. * The Physically based material of BJS.
  26273. *
  26274. * This offers the main features of a standard PBR material.
  26275. * For more information, please refer to the documentation :
  26276. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  26277. */
  26278. class PBRMaterial extends PBRBaseMaterial {
  26279. private static _PBRMATERIAL_OPAQUE;
  26280. /**
  26281. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26282. */
  26283. static readonly PBRMATERIAL_OPAQUE: number;
  26284. /**
  26285. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26286. */
  26287. private static _PBRMATERIAL_ALPHATEST;
  26288. /**
  26289. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26290. */
  26291. static readonly PBRMATERIAL_ALPHATEST: number;
  26292. /**
  26293. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26294. */
  26295. private static _PBRMATERIAL_ALPHABLEND;
  26296. /**
  26297. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26298. */
  26299. static readonly PBRMATERIAL_ALPHABLEND: number;
  26300. /**
  26301. * 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.
  26302. * They are also discarded below the alpha cutoff threshold to improve performances.
  26303. */
  26304. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  26305. /**
  26306. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26307. * They are also discarded below the alpha cutoff threshold to improve performances.
  26308. */
  26309. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26310. /**
  26311. * Intensity of the direct lights e.g. the four lights available in your scene.
  26312. * This impacts both the direct diffuse and specular highlights.
  26313. */
  26314. directIntensity: number;
  26315. /**
  26316. * Intensity of the emissive part of the material.
  26317. * This helps controlling the emissive effect without modifying the emissive color.
  26318. */
  26319. emissiveIntensity: number;
  26320. /**
  26321. * Intensity of the environment e.g. how much the environment will light the object
  26322. * either through harmonics for rough material or through the refelction for shiny ones.
  26323. */
  26324. environmentIntensity: number;
  26325. /**
  26326. * This is a special control allowing the reduction of the specular highlights coming from the
  26327. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26328. */
  26329. specularIntensity: number;
  26330. /**
  26331. * Debug Control allowing disabling the bump map on this material.
  26332. */
  26333. disableBumpMap: boolean;
  26334. /**
  26335. * AKA Diffuse Texture in standard nomenclature.
  26336. */
  26337. albedoTexture: BaseTexture;
  26338. /**
  26339. * AKA Occlusion Texture in other nomenclature.
  26340. */
  26341. ambientTexture: BaseTexture;
  26342. /**
  26343. * AKA Occlusion Texture Intensity in other nomenclature.
  26344. */
  26345. ambientTextureStrength: number;
  26346. /**
  26347. * Stores the alpha values in a texture.
  26348. */
  26349. opacityTexture: BaseTexture;
  26350. /**
  26351. * Stores the reflection values in a texture.
  26352. */
  26353. reflectionTexture: Nullable<BaseTexture>;
  26354. /**
  26355. * Stores the emissive values in a texture.
  26356. */
  26357. emissiveTexture: BaseTexture;
  26358. /**
  26359. * AKA Specular texture in other nomenclature.
  26360. */
  26361. reflectivityTexture: BaseTexture;
  26362. /**
  26363. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26364. */
  26365. metallicTexture: BaseTexture;
  26366. /**
  26367. * Specifies the metallic scalar of the metallic/roughness workflow.
  26368. * Can also be used to scale the metalness values of the metallic texture.
  26369. */
  26370. metallic: number;
  26371. /**
  26372. * Specifies the roughness scalar of the metallic/roughness workflow.
  26373. * Can also be used to scale the roughness values of the metallic texture.
  26374. */
  26375. roughness: number;
  26376. /**
  26377. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  26378. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26379. */
  26380. microSurfaceTexture: BaseTexture;
  26381. /**
  26382. * Stores surface normal data used to displace a mesh in a texture.
  26383. */
  26384. bumpTexture: BaseTexture;
  26385. /**
  26386. * Stores the pre-calculated light information of a mesh in a texture.
  26387. */
  26388. lightmapTexture: BaseTexture;
  26389. /**
  26390. * Stores the refracted light information in a texture.
  26391. */
  26392. refractionTexture: BaseTexture;
  26393. /**
  26394. * The color of a material in ambient lighting.
  26395. */
  26396. ambientColor: Color3;
  26397. /**
  26398. * AKA Diffuse Color in other nomenclature.
  26399. */
  26400. albedoColor: Color3;
  26401. /**
  26402. * AKA Specular Color in other nomenclature.
  26403. */
  26404. reflectivityColor: Color3;
  26405. /**
  26406. * The color reflected from the material.
  26407. */
  26408. reflectionColor: Color3;
  26409. /**
  26410. * The color emitted from the material.
  26411. */
  26412. emissiveColor: Color3;
  26413. /**
  26414. * AKA Glossiness in other nomenclature.
  26415. */
  26416. microSurface: number;
  26417. /**
  26418. * source material index of refraction (IOR)' / 'destination material IOR.
  26419. */
  26420. indexOfRefraction: number;
  26421. /**
  26422. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  26423. */
  26424. invertRefractionY: boolean;
  26425. /**
  26426. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26427. * Materials half opaque for instance using refraction could benefit from this control.
  26428. */
  26429. linkRefractionWithTransparency: boolean;
  26430. useLightmapAsShadowmap: boolean;
  26431. /**
  26432. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26433. */
  26434. useAlphaFromAlbedoTexture: boolean;
  26435. /**
  26436. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26437. */
  26438. forceAlphaTest: boolean;
  26439. /**
  26440. * Defines the alpha limits in alpha test mode.
  26441. */
  26442. alphaCutOff: number;
  26443. /**
  26444. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  26445. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26446. */
  26447. useSpecularOverAlpha: boolean;
  26448. /**
  26449. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26450. */
  26451. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26452. /**
  26453. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26454. */
  26455. useRoughnessFromMetallicTextureAlpha: boolean;
  26456. /**
  26457. * Specifies if the metallic texture contains the roughness information in its green channel.
  26458. */
  26459. useRoughnessFromMetallicTextureGreen: boolean;
  26460. /**
  26461. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26462. */
  26463. useMetallnessFromMetallicTextureBlue: boolean;
  26464. /**
  26465. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26466. */
  26467. useAmbientOcclusionFromMetallicTextureRed: boolean;
  26468. /**
  26469. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26470. */
  26471. useAmbientInGrayScale: boolean;
  26472. /**
  26473. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26474. * The material will try to infer what glossiness each pixel should be.
  26475. */
  26476. useAutoMicroSurfaceFromReflectivityMap: boolean;
  26477. /**
  26478. * BJS is using an harcoded light falloff based on a manually sets up range.
  26479. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  26480. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  26481. */
  26482. usePhysicalLightFalloff: boolean;
  26483. /**
  26484. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26485. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26486. */
  26487. useRadianceOverAlpha: boolean;
  26488. /**
  26489. * Allows using an object space normal map (instead of tangent space).
  26490. */
  26491. useObjectSpaceNormalMap: boolean;
  26492. /**
  26493. * Allows using the bump map in parallax mode.
  26494. */
  26495. useParallax: boolean;
  26496. /**
  26497. * Allows using the bump map in parallax occlusion mode.
  26498. */
  26499. useParallaxOcclusion: boolean;
  26500. /**
  26501. * Controls the scale bias of the parallax mode.
  26502. */
  26503. parallaxScaleBias: number;
  26504. /**
  26505. * If sets to true, disables all the lights affecting the material.
  26506. */
  26507. disableLighting: boolean;
  26508. /**
  26509. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26510. */
  26511. forceIrradianceInFragment: boolean;
  26512. /**
  26513. * Number of Simultaneous lights allowed on the material.
  26514. */
  26515. maxSimultaneousLights: number;
  26516. /**
  26517. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26518. */
  26519. invertNormalMapX: boolean;
  26520. /**
  26521. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26522. */
  26523. invertNormalMapY: boolean;
  26524. /**
  26525. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26526. */
  26527. twoSidedLighting: boolean;
  26528. /**
  26529. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26530. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26531. */
  26532. useAlphaFresnel: boolean;
  26533. /**
  26534. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26535. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26536. */
  26537. useLinearAlphaFresnel: boolean;
  26538. /**
  26539. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26540. * And/Or occlude the blended part.
  26541. */
  26542. environmentBRDFTexture: Nullable<BaseTexture>;
  26543. /**
  26544. * Force normal to face away from face.
  26545. */
  26546. forceNormalForward: boolean;
  26547. /**
  26548. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26549. * makes the reflect vector face the model (under horizon).
  26550. */
  26551. useHorizonOcclusion: boolean;
  26552. /**
  26553. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26554. * too much the area relying on ambient texture to define their ambient occlusion.
  26555. */
  26556. useRadianceOcclusion: boolean;
  26557. /**
  26558. * If set to true, no lighting calculations will be applied.
  26559. */
  26560. unlit: boolean;
  26561. /**
  26562. * Gets the image processing configuration used either in this material.
  26563. */
  26564. /**
  26565. * Sets the Default image processing configuration used either in the this material.
  26566. *
  26567. * If sets to null, the scene one is in use.
  26568. */
  26569. imageProcessingConfiguration: ImageProcessingConfiguration;
  26570. /**
  26571. * Gets wether the color curves effect is enabled.
  26572. */
  26573. /**
  26574. * Sets wether the color curves effect is enabled.
  26575. */
  26576. cameraColorCurvesEnabled: boolean;
  26577. /**
  26578. * Gets wether the color grading effect is enabled.
  26579. */
  26580. /**
  26581. * Gets wether the color grading effect is enabled.
  26582. */
  26583. cameraColorGradingEnabled: boolean;
  26584. /**
  26585. * Gets wether tonemapping is enabled or not.
  26586. */
  26587. /**
  26588. * Sets wether tonemapping is enabled or not
  26589. */
  26590. cameraToneMappingEnabled: boolean;
  26591. /**
  26592. * The camera exposure used on this material.
  26593. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26594. * This corresponds to a photographic exposure.
  26595. */
  26596. /**
  26597. * The camera exposure used on this material.
  26598. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26599. * This corresponds to a photographic exposure.
  26600. */
  26601. cameraExposure: number;
  26602. /**
  26603. * Gets The camera contrast used on this material.
  26604. */
  26605. /**
  26606. * Sets The camera contrast used on this material.
  26607. */
  26608. cameraContrast: number;
  26609. /**
  26610. * Gets the Color Grading 2D Lookup Texture.
  26611. */
  26612. /**
  26613. * Sets the Color Grading 2D Lookup Texture.
  26614. */
  26615. cameraColorGradingTexture: Nullable<BaseTexture>;
  26616. /**
  26617. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26618. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26619. * 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;
  26620. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26621. */
  26622. /**
  26623. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26624. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26625. * 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;
  26626. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26627. */
  26628. cameraColorCurves: Nullable<ColorCurves>;
  26629. /**
  26630. * Instantiates a new PBRMaterial instance.
  26631. *
  26632. * @param name The material name
  26633. * @param scene The scene the material will be use in.
  26634. */
  26635. constructor(name: string, scene: Scene);
  26636. /**
  26637. * Returns the name of this material class.
  26638. */
  26639. getClassName(): string;
  26640. /**
  26641. * Returns an array of the actively used textures.
  26642. * @returns - Array of BaseTextures
  26643. */
  26644. getActiveTextures(): BaseTexture[];
  26645. /**
  26646. * Checks to see if a texture is used in the material.
  26647. * @param texture - Base texture to use.
  26648. * @returns - Boolean specifying if a texture is used in the material.
  26649. */
  26650. hasTexture(texture: BaseTexture): boolean;
  26651. /**
  26652. * Makes a duplicate of the current material.
  26653. * @param name - name to use for the new material.
  26654. */
  26655. clone(name: string): PBRMaterial;
  26656. /**
  26657. * Serializes this PBR Material.
  26658. * @returns - An object with the serialized material.
  26659. */
  26660. serialize(): any;
  26661. /**
  26662. * Parses a PBR Material from a serialized object.
  26663. * @param source - Serialized object.
  26664. * @param scene - BJS scene instance.
  26665. * @param rootUrl - url for the scene object
  26666. * @returns - PBRMaterial
  26667. */
  26668. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  26669. }
  26670. }
  26671. declare module BABYLON {
  26672. /**
  26673. * The PBR material of BJS following the metal roughness convention.
  26674. *
  26675. * This fits to the PBR convention in the GLTF definition:
  26676. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  26677. */
  26678. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  26679. /**
  26680. * The base color has two different interpretations depending on the value of metalness.
  26681. * When the material is a metal, the base color is the specific measured reflectance value
  26682. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  26683. * of the material.
  26684. */
  26685. baseColor: Color3;
  26686. /**
  26687. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  26688. * well as opacity information in the alpha channel.
  26689. */
  26690. baseTexture: BaseTexture;
  26691. /**
  26692. * Specifies the metallic scalar value of the material.
  26693. * Can also be used to scale the metalness values of the metallic texture.
  26694. */
  26695. metallic: number;
  26696. /**
  26697. * Specifies the roughness scalar value of the material.
  26698. * Can also be used to scale the roughness values of the metallic texture.
  26699. */
  26700. roughness: number;
  26701. /**
  26702. * Texture containing both the metallic value in the B channel and the
  26703. * roughness value in the G channel to keep better precision.
  26704. */
  26705. metallicRoughnessTexture: BaseTexture;
  26706. /**
  26707. * Instantiates a new PBRMetalRoughnessMaterial instance.
  26708. *
  26709. * @param name The material name
  26710. * @param scene The scene the material will be use in.
  26711. */
  26712. constructor(name: string, scene: Scene);
  26713. /**
  26714. * Return the currrent class name of the material.
  26715. */
  26716. getClassName(): string;
  26717. /**
  26718. * Return the active textures of the material.
  26719. */
  26720. getActiveTextures(): BaseTexture[];
  26721. /**
  26722. * Checks to see if a texture is used in the material.
  26723. * @param texture - Base texture to use.
  26724. * @returns - Boolean specifying if a texture is used in the material.
  26725. */
  26726. hasTexture(texture: BaseTexture): boolean;
  26727. /**
  26728. * Makes a duplicate of the current material.
  26729. * @param name - name to use for the new material.
  26730. */
  26731. clone(name: string): PBRMetallicRoughnessMaterial;
  26732. /**
  26733. * Serialize the material to a parsable JSON object.
  26734. */
  26735. serialize(): any;
  26736. /**
  26737. * Parses a JSON object correponding to the serialize function.
  26738. */
  26739. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  26740. }
  26741. }
  26742. declare module BABYLON {
  26743. /**
  26744. * The PBR material of BJS following the specular glossiness convention.
  26745. *
  26746. * This fits to the PBR convention in the GLTF definition:
  26747. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  26748. */
  26749. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  26750. /**
  26751. * Specifies the diffuse color of the material.
  26752. */
  26753. diffuseColor: Color3;
  26754. /**
  26755. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  26756. * channel.
  26757. */
  26758. diffuseTexture: BaseTexture;
  26759. /**
  26760. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  26761. */
  26762. specularColor: Color3;
  26763. /**
  26764. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  26765. */
  26766. glossiness: number;
  26767. /**
  26768. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  26769. */
  26770. specularGlossinessTexture: BaseTexture;
  26771. /**
  26772. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  26773. *
  26774. * @param name The material name
  26775. * @param scene The scene the material will be use in.
  26776. */
  26777. constructor(name: string, scene: Scene);
  26778. /**
  26779. * Return the currrent class name of the material.
  26780. */
  26781. getClassName(): string;
  26782. /**
  26783. * Return the active textures of the material.
  26784. */
  26785. getActiveTextures(): BaseTexture[];
  26786. /**
  26787. * Checks to see if a texture is used in the material.
  26788. * @param texture - Base texture to use.
  26789. * @returns - Boolean specifying if a texture is used in the material.
  26790. */
  26791. hasTexture(texture: BaseTexture): boolean;
  26792. /**
  26793. * Makes a duplicate of the current material.
  26794. * @param name - name to use for the new material.
  26795. */
  26796. clone(name: string): PBRSpecularGlossinessMaterial;
  26797. /**
  26798. * Serialize the material to a parsable JSON object.
  26799. */
  26800. serialize(): any;
  26801. /**
  26802. * Parses a JSON object correponding to the serialize function.
  26803. */
  26804. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  26805. }
  26806. }
  26807. declare module BABYLON {
  26808. class BaseTexture {
  26809. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26810. name: string;
  26811. private _hasAlpha;
  26812. hasAlpha: boolean;
  26813. getAlphaFromRGB: boolean;
  26814. level: number;
  26815. coordinatesIndex: number;
  26816. private _coordinatesMode;
  26817. /**
  26818. * How a texture is mapped.
  26819. *
  26820. * | Value | Type | Description |
  26821. * | ----- | ----------------------------------- | ----------- |
  26822. * | 0 | EXPLICIT_MODE | |
  26823. * | 1 | SPHERICAL_MODE | |
  26824. * | 2 | PLANAR_MODE | |
  26825. * | 3 | CUBIC_MODE | |
  26826. * | 4 | PROJECTION_MODE | |
  26827. * | 5 | SKYBOX_MODE | |
  26828. * | 6 | INVCUBIC_MODE | |
  26829. * | 7 | EQUIRECTANGULAR_MODE | |
  26830. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26831. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26832. */
  26833. coordinatesMode: number;
  26834. /**
  26835. * | Value | Type | Description |
  26836. * | ----- | ------------------ | ----------- |
  26837. * | 0 | CLAMP_ADDRESSMODE | |
  26838. * | 1 | WRAP_ADDRESSMODE | |
  26839. * | 2 | MIRROR_ADDRESSMODE | |
  26840. */
  26841. wrapU: number;
  26842. /**
  26843. * | Value | Type | Description |
  26844. * | ----- | ------------------ | ----------- |
  26845. * | 0 | CLAMP_ADDRESSMODE | |
  26846. * | 1 | WRAP_ADDRESSMODE | |
  26847. * | 2 | MIRROR_ADDRESSMODE | |
  26848. */
  26849. wrapV: number;
  26850. /**
  26851. * | Value | Type | Description |
  26852. * | ----- | ------------------ | ----------- |
  26853. * | 0 | CLAMP_ADDRESSMODE | |
  26854. * | 1 | WRAP_ADDRESSMODE | |
  26855. * | 2 | MIRROR_ADDRESSMODE | |
  26856. */
  26857. wrapR: number;
  26858. anisotropicFilteringLevel: number;
  26859. isCube: boolean;
  26860. is3D: boolean;
  26861. gammaSpace: boolean;
  26862. invertZ: boolean;
  26863. lodLevelInAlpha: boolean;
  26864. lodGenerationOffset: number;
  26865. lodGenerationScale: number;
  26866. isRenderTarget: boolean;
  26867. readonly uid: string;
  26868. toString(): string;
  26869. getClassName(): string;
  26870. animations: Animation[];
  26871. /**
  26872. * An event triggered when the texture is disposed.
  26873. * @type {BABYLON.Observable}
  26874. */
  26875. onDisposeObservable: Observable<BaseTexture>;
  26876. private _onDisposeObserver;
  26877. onDispose: () => void;
  26878. delayLoadState: number;
  26879. private _scene;
  26880. _texture: Nullable<InternalTexture>;
  26881. private _uid;
  26882. readonly isBlocking: boolean;
  26883. constructor(scene: Nullable<Scene>);
  26884. getScene(): Nullable<Scene>;
  26885. getTextureMatrix(): Matrix;
  26886. getReflectionTextureMatrix(): Matrix;
  26887. getInternalTexture(): Nullable<InternalTexture>;
  26888. isReadyOrNotBlocking(): boolean;
  26889. isReady(): boolean;
  26890. getSize(): ISize;
  26891. getBaseSize(): ISize;
  26892. scale(ratio: number): void;
  26893. readonly canRescale: boolean;
  26894. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  26895. _rebuild(): void;
  26896. delayLoad(): void;
  26897. clone(): Nullable<BaseTexture>;
  26898. readonly textureType: number;
  26899. readonly textureFormat: number;
  26900. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  26901. releaseInternalTexture(): void;
  26902. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26903. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26904. readonly _lodTextureMid: Nullable<BaseTexture>;
  26905. readonly _lodTextureLow: Nullable<BaseTexture>;
  26906. dispose(): void;
  26907. serialize(): any;
  26908. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26909. }
  26910. }
  26911. declare module BABYLON {
  26912. /**
  26913. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  26914. * It can help converting any input color in a desired output one. This can then be used to create effects
  26915. * from sepia, black and white to sixties or futuristic rendering...
  26916. *
  26917. * The only supported format is currently 3dl.
  26918. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  26919. */
  26920. class ColorGradingTexture extends BaseTexture {
  26921. /**
  26922. * The current texture matrix. (will always be identity in color grading texture)
  26923. */
  26924. private _textureMatrix;
  26925. /**
  26926. * The texture URL.
  26927. */
  26928. url: string;
  26929. /**
  26930. * Empty line regex stored for GC.
  26931. */
  26932. private static _noneEmptyLineRegex;
  26933. private _engine;
  26934. /**
  26935. * Instantiates a ColorGradingTexture from the following parameters.
  26936. *
  26937. * @param url The location of the color gradind data (currently only supporting 3dl)
  26938. * @param scene The scene the texture will be used in
  26939. */
  26940. constructor(url: string, scene: Scene);
  26941. /**
  26942. * Returns the texture matrix used in most of the material.
  26943. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  26944. */
  26945. getTextureMatrix(): Matrix;
  26946. /**
  26947. * Occurs when the file being loaded is a .3dl LUT file.
  26948. */
  26949. private load3dlTexture();
  26950. /**
  26951. * Starts the loading process of the texture.
  26952. */
  26953. private loadTexture();
  26954. /**
  26955. * Clones the color gradind texture.
  26956. */
  26957. clone(): ColorGradingTexture;
  26958. /**
  26959. * Called during delayed load for textures.
  26960. */
  26961. delayLoad(): void;
  26962. /**
  26963. * Parses a color grading texture serialized by Babylon.
  26964. * @param parsedTexture The texture information being parsedTexture
  26965. * @param scene The scene to load the texture in
  26966. * @param rootUrl The root url of the data assets to load
  26967. * @return A color gradind texture
  26968. */
  26969. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  26970. /**
  26971. * Serializes the LUT texture to json format.
  26972. */
  26973. serialize(): any;
  26974. }
  26975. }
  26976. declare module BABYLON {
  26977. class CubeTexture extends BaseTexture {
  26978. url: string;
  26979. coordinatesMode: number;
  26980. /**
  26981. * Gets or sets the center of the bounding box associated with the cube texture
  26982. * It must define where the camera used to render the texture was set
  26983. */
  26984. boundingBoxPosition: Vector3;
  26985. private _boundingBoxSize;
  26986. /**
  26987. * Gets or sets the size of the bounding box associated with the cube texture
  26988. * When defined, the cubemap will switch to local mode
  26989. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  26990. * @example https://www.babylonjs-playground.com/#RNASML
  26991. */
  26992. boundingBoxSize: Vector3;
  26993. private _noMipmap;
  26994. private _files;
  26995. private _extensions;
  26996. private _textureMatrix;
  26997. private _format;
  26998. private _prefiltered;
  26999. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  27000. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  27001. 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);
  27002. delayLoad(): void;
  27003. getReflectionTextureMatrix(): Matrix;
  27004. setReflectionTextureMatrix(value: Matrix): void;
  27005. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  27006. clone(): CubeTexture;
  27007. }
  27008. }
  27009. declare module BABYLON {
  27010. class DynamicTexture extends Texture {
  27011. private _generateMipMaps;
  27012. private _canvas;
  27013. private _context;
  27014. private _engine;
  27015. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  27016. readonly canRescale: boolean;
  27017. private _recreate(textureSize);
  27018. scale(ratio: number): void;
  27019. scaleTo(width: number, height: number): void;
  27020. getContext(): CanvasRenderingContext2D;
  27021. clear(): void;
  27022. update(invertY?: boolean): void;
  27023. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  27024. clone(): DynamicTexture;
  27025. _rebuild(): void;
  27026. }
  27027. }
  27028. declare module BABYLON {
  27029. /**
  27030. * This represents a texture coming from an HDR input.
  27031. *
  27032. * The only supported format is currently panorama picture stored in RGBE format.
  27033. * Example of such files can be found on HDRLib: http://hdrlib.com/
  27034. */
  27035. class HDRCubeTexture extends BaseTexture {
  27036. private static _facesMapping;
  27037. private _useInGammaSpace;
  27038. private _generateHarmonics;
  27039. private _noMipmap;
  27040. private _textureMatrix;
  27041. private _size;
  27042. private _usePMREMGenerator;
  27043. private _isBABYLONPreprocessed;
  27044. private _onLoad;
  27045. private _onError;
  27046. /**
  27047. * The texture URL.
  27048. */
  27049. url: string;
  27050. /**
  27051. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  27052. */
  27053. coordinatesMode: number;
  27054. /**
  27055. * Specifies wether the texture has been generated through the PMREMGenerator tool.
  27056. * This is usefull at run time to apply the good shader.
  27057. */
  27058. isPMREM: boolean;
  27059. protected _isBlocking: boolean;
  27060. /**
  27061. * Gets wether or not the texture is blocking during loading.
  27062. */
  27063. /**
  27064. * Sets wether or not the texture is blocking during loading.
  27065. */
  27066. isBlocking: boolean;
  27067. /**
  27068. * Gets or sets the center of the bounding box associated with the cube texture
  27069. * It must define where the camera used to render the texture was set
  27070. */
  27071. boundingBoxPosition: Vector3;
  27072. private _boundingBoxSize;
  27073. /**
  27074. * Gets or sets the size of the bounding box associated with the cube texture
  27075. * When defined, the cubemap will switch to local mode
  27076. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  27077. * @example https://www.babylonjs-playground.com/#RNASML
  27078. */
  27079. boundingBoxSize: Vector3;
  27080. /**
  27081. * Instantiates an HDRTexture from the following parameters.
  27082. *
  27083. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  27084. * @param scene The scene the texture will be used in
  27085. * @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.
  27086. * @param noMipmap Forces to not generate the mipmap if true
  27087. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  27088. * @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)
  27089. * @param usePMREMGenerator Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
  27090. */
  27091. 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>);
  27092. /**
  27093. * Occurs when the file is a preprocessed .babylon.hdr file.
  27094. */
  27095. private loadBabylonTexture();
  27096. /**
  27097. * Occurs when the file is raw .hdr file.
  27098. */
  27099. private loadHDRTexture();
  27100. /**
  27101. * Starts the loading process of the texture.
  27102. */
  27103. private loadTexture();
  27104. clone(): HDRCubeTexture;
  27105. delayLoad(): void;
  27106. getReflectionTextureMatrix(): Matrix;
  27107. setReflectionTextureMatrix(value: Matrix): void;
  27108. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  27109. serialize(): any;
  27110. /**
  27111. * Saves as a file the data contained in the texture in a binary format.
  27112. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  27113. * as the spherical used in the lighting.
  27114. * @param url The HDR file url.
  27115. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  27116. * @param onError Method called if any error happens during download.
  27117. * @return The packed binary data.
  27118. */
  27119. static generateBabylonHDROnDisk(url: string, size: number, onError?: Nullable<(() => void)>): void;
  27120. /**
  27121. * Serializes the data contained in the texture in a binary format.
  27122. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  27123. * as the spherical used in the lighting.
  27124. * @param url The HDR file url.
  27125. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  27126. * @param onError Method called if any error happens during download.
  27127. * @return The packed binary data.
  27128. */
  27129. static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer: ArrayBuffer) => void), onError?: Nullable<(() => void)>): void;
  27130. }
  27131. }
  27132. declare module BABYLON {
  27133. /**
  27134. * Class used to store data associated with WebGL texture data for the engine
  27135. * This class should not be used directly
  27136. */
  27137. class InternalTexture implements IInternalTextureTracker {
  27138. /**
  27139. * The source of the texture data is unknown
  27140. */
  27141. static DATASOURCE_UNKNOWN: number;
  27142. /**
  27143. * Texture data comes from an URL
  27144. */
  27145. static DATASOURCE_URL: number;
  27146. /**
  27147. * Texture data is only used for temporary storage
  27148. */
  27149. static DATASOURCE_TEMP: number;
  27150. /**
  27151. * Texture data comes from raw data (ArrayBuffer)
  27152. */
  27153. static DATASOURCE_RAW: number;
  27154. /**
  27155. * Texture content is dynamic (video or dynamic texture)
  27156. */
  27157. static DATASOURCE_DYNAMIC: number;
  27158. /**
  27159. * Texture content is generated by rendering to it
  27160. */
  27161. static DATASOURCE_RENDERTARGET: number;
  27162. /**
  27163. * Texture content is part of a multi render target process
  27164. */
  27165. static DATASOURCE_MULTIRENDERTARGET: number;
  27166. /**
  27167. * Texture data comes from a cube data file
  27168. */
  27169. static DATASOURCE_CUBE: number;
  27170. /**
  27171. * Texture data comes from a raw cube data
  27172. */
  27173. static DATASOURCE_CUBERAW: number;
  27174. /**
  27175. * Texture data come from a prefiltered cube data file
  27176. */
  27177. static DATASOURCE_CUBEPREFILTERED: number;
  27178. /**
  27179. * Texture content is raw 3D data
  27180. */
  27181. static DATASOURCE_RAW3D: number;
  27182. /**
  27183. * Texture content is a depth texture
  27184. */
  27185. static DATASOURCE_DEPTHTEXTURE: number;
  27186. /**
  27187. * Defines if the texture is ready
  27188. */
  27189. isReady: boolean;
  27190. /**
  27191. * Defines if the texture is a cube texture
  27192. */
  27193. isCube: boolean;
  27194. /**
  27195. * Defines if the texture contains 3D data
  27196. */
  27197. is3D: boolean;
  27198. /**
  27199. * Gets the URL used to load this texture
  27200. */
  27201. url: string;
  27202. /**
  27203. * Gets the sampling mode of the texture
  27204. */
  27205. samplingMode: number;
  27206. /**
  27207. * Gets a boolean indicating if the texture needs mipmaps generation
  27208. */
  27209. generateMipMaps: boolean;
  27210. /**
  27211. * Gets the number of samples used by the texture (WebGL2+ only)
  27212. */
  27213. samples: number;
  27214. /**
  27215. * Gets the type of the texture
  27216. */
  27217. type: number;
  27218. /**
  27219. * Gets the format of the texture
  27220. */
  27221. format: number;
  27222. /**
  27223. * Observable called when the texture is loaded
  27224. */
  27225. onLoadedObservable: Observable<InternalTexture>;
  27226. /**
  27227. * Gets the width of the texture
  27228. */
  27229. width: number;
  27230. /**
  27231. * Gets the height of the texture
  27232. */
  27233. height: number;
  27234. /**
  27235. * Gets the depth of the texture
  27236. */
  27237. depth: number;
  27238. /**
  27239. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27240. */
  27241. baseWidth: number;
  27242. /**
  27243. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27244. */
  27245. baseHeight: number;
  27246. /**
  27247. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27248. */
  27249. baseDepth: number;
  27250. /**
  27251. * Gets a boolean indicating if the texture is inverted on Y axis
  27252. */
  27253. invertY: boolean;
  27254. /**
  27255. * Gets or set the previous tracker in the list
  27256. */
  27257. previous: Nullable<IInternalTextureTracker>;
  27258. /**
  27259. * Gets or set the next tracker in the list
  27260. */
  27261. next: Nullable<IInternalTextureTracker>;
  27262. /** @ignore */
  27263. _initialSlot: number;
  27264. /** @ignore */
  27265. _designatedSlot: number;
  27266. /** @ignore */
  27267. _dataSource: number;
  27268. /** @ignore */
  27269. _buffer: Nullable<ArrayBuffer | HTMLImageElement>;
  27270. /** @ignore */
  27271. _bufferView: Nullable<ArrayBufferView>;
  27272. /** @ignore */
  27273. _bufferViewArray: Nullable<ArrayBufferView[]>;
  27274. /** @ignore */
  27275. _size: number;
  27276. /** @ignore */
  27277. _extension: string;
  27278. /** @ignore */
  27279. _files: Nullable<string[]>;
  27280. /** @ignore */
  27281. _workingCanvas: HTMLCanvasElement;
  27282. /** @ignore */
  27283. _workingContext: CanvasRenderingContext2D;
  27284. /** @ignore */
  27285. _framebuffer: Nullable<WebGLFramebuffer>;
  27286. /** @ignore */
  27287. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  27288. /** @ignore */
  27289. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  27290. /** @ignore */
  27291. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  27292. /** @ignore */
  27293. _attachments: Nullable<number[]>;
  27294. /** @ignore */
  27295. _cachedCoordinatesMode: Nullable<number>;
  27296. /** @ignore */
  27297. _cachedWrapU: Nullable<number>;
  27298. /** @ignore */
  27299. _cachedWrapV: Nullable<number>;
  27300. /** @ignore */
  27301. _cachedWrapR: Nullable<number>;
  27302. /** @ignore */
  27303. _cachedAnisotropicFilteringLevel: Nullable<number>;
  27304. /** @ignore */
  27305. _isDisabled: boolean;
  27306. /** @ignore */
  27307. _compression: Nullable<string>;
  27308. /** @ignore */
  27309. _generateStencilBuffer: boolean;
  27310. /** @ignore */
  27311. _generateDepthBuffer: boolean;
  27312. /** @ignore */
  27313. _comparisonFunction: number;
  27314. /** @ignore */
  27315. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  27316. /** @ignore */
  27317. _lodGenerationScale: number;
  27318. /** @ignore */
  27319. _lodGenerationOffset: number;
  27320. /** @ignore */
  27321. _lodTextureHigh: BaseTexture;
  27322. /** @ignore */
  27323. _lodTextureMid: BaseTexture;
  27324. /** @ignore */
  27325. _lodTextureLow: BaseTexture;
  27326. /** @ignore */
  27327. _webGLTexture: Nullable<WebGLTexture>;
  27328. /** @ignore */
  27329. _references: number;
  27330. private _engine;
  27331. /**
  27332. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  27333. */
  27334. readonly dataSource: number;
  27335. /**
  27336. * Creates a new InternalTexture
  27337. * @param engine defines the engine to use
  27338. * @param dataSource defines the type of data that will be used
  27339. */
  27340. constructor(engine: Engine, dataSource: number);
  27341. /**
  27342. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  27343. */
  27344. incrementReferences(): void;
  27345. /**
  27346. * Change the size of the texture (not the size of the content)
  27347. * @param width defines the new width
  27348. * @param height defines the new height
  27349. * @param depth defines the new depth (1 by default)
  27350. */
  27351. updateSize(width: int, height: int, depth?: int): void;
  27352. /** @ignore */
  27353. _rebuild(): void;
  27354. private _swapAndDie(target);
  27355. /**
  27356. * Dispose the current allocated resources
  27357. */
  27358. dispose(): void;
  27359. }
  27360. }
  27361. declare module BABYLON {
  27362. /**
  27363. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  27364. */
  27365. interface IInternalTextureTracker {
  27366. /**
  27367. * Gets or set the previous tracker in the list
  27368. */
  27369. previous: Nullable<IInternalTextureTracker>;
  27370. /**
  27371. * Gets or set the next tracker in the list
  27372. */
  27373. next: Nullable<IInternalTextureTracker>;
  27374. }
  27375. /**
  27376. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  27377. */
  27378. class DummyInternalTextureTracker {
  27379. /**
  27380. * Gets or set the previous tracker in the list
  27381. */
  27382. previous: Nullable<IInternalTextureTracker>;
  27383. /**
  27384. * Gets or set the next tracker in the list
  27385. */
  27386. next: Nullable<IInternalTextureTracker>;
  27387. }
  27388. }
  27389. declare module BABYLON {
  27390. class MirrorTexture extends RenderTargetTexture {
  27391. mirrorPlane: Plane;
  27392. private _transformMatrix;
  27393. private _mirrorMatrix;
  27394. private _savedViewMatrix;
  27395. private _blurX;
  27396. private _blurY;
  27397. private _adaptiveBlurKernel;
  27398. private _blurKernelX;
  27399. private _blurKernelY;
  27400. private _blurRatio;
  27401. blurRatio: number;
  27402. adaptiveBlurKernel: number;
  27403. blurKernel: number;
  27404. blurKernelX: number;
  27405. blurKernelY: number;
  27406. private _autoComputeBlurKernel();
  27407. protected _onRatioRescale(): void;
  27408. constructor(name: string, size: number | {
  27409. width: number;
  27410. height: number;
  27411. } | {
  27412. ratio: number;
  27413. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  27414. private _preparePostProcesses();
  27415. clone(): MirrorTexture;
  27416. serialize(): any;
  27417. }
  27418. }
  27419. declare module BABYLON {
  27420. interface IMultiRenderTargetOptions {
  27421. generateMipMaps?: boolean;
  27422. types?: number[];
  27423. samplingModes?: number[];
  27424. generateDepthBuffer?: boolean;
  27425. generateStencilBuffer?: boolean;
  27426. generateDepthTexture?: boolean;
  27427. textureCount?: number;
  27428. doNotChangeAspectRatio?: boolean;
  27429. defaultType?: number;
  27430. }
  27431. class MultiRenderTarget extends RenderTargetTexture {
  27432. private _internalTextures;
  27433. private _textures;
  27434. readonly isSupported: boolean;
  27435. private _multiRenderTargetOptions;
  27436. readonly textures: Texture[];
  27437. readonly depthTexture: Texture;
  27438. wrapU: number;
  27439. wrapV: number;
  27440. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  27441. _rebuild(): void;
  27442. private _createInternalTextures();
  27443. private _createTextures();
  27444. samples: number;
  27445. resize(size: any): void;
  27446. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  27447. dispose(): void;
  27448. releaseInternalTextures(): void;
  27449. }
  27450. }
  27451. declare module BABYLON {
  27452. class RawTexture extends Texture {
  27453. format: number;
  27454. private _engine;
  27455. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  27456. update(data: ArrayBufferView): void;
  27457. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  27458. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  27459. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  27460. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  27461. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  27462. }
  27463. }
  27464. declare module BABYLON {
  27465. /**
  27466. * Creates a refraction texture used by refraction channel of the standard material.
  27467. * @param name the texture name
  27468. * @param size size of the underlying texture
  27469. * @param scene root scene
  27470. */
  27471. class RefractionTexture extends RenderTargetTexture {
  27472. refractionPlane: Plane;
  27473. depth: number;
  27474. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  27475. clone(): RefractionTexture;
  27476. serialize(): any;
  27477. }
  27478. }
  27479. declare module BABYLON {
  27480. class RenderTargetTexture extends Texture {
  27481. isCube: boolean;
  27482. static _REFRESHRATE_RENDER_ONCE: number;
  27483. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  27484. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  27485. static readonly REFRESHRATE_RENDER_ONCE: number;
  27486. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  27487. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  27488. /**
  27489. * Use this predicate to dynamically define the list of mesh you want to render.
  27490. * If set, the renderList property will be overwritten.
  27491. */
  27492. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  27493. /**
  27494. * Use this list to define the list of mesh you want to render.
  27495. */
  27496. renderList: Nullable<Array<AbstractMesh>>;
  27497. renderParticles: boolean;
  27498. renderSprites: boolean;
  27499. coordinatesMode: number;
  27500. activeCamera: Nullable<Camera>;
  27501. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  27502. useCameraPostProcesses: boolean;
  27503. ignoreCameraViewport: boolean;
  27504. private _postProcessManager;
  27505. private _postProcesses;
  27506. private _resizeObserver;
  27507. /**
  27508. * An event triggered when the texture is unbind.
  27509. * @type {BABYLON.Observable}
  27510. */
  27511. onBeforeBindObservable: Observable<RenderTargetTexture>;
  27512. /**
  27513. * An event triggered when the texture is unbind.
  27514. * @type {BABYLON.Observable}
  27515. */
  27516. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  27517. private _onAfterUnbindObserver;
  27518. onAfterUnbind: () => void;
  27519. /**
  27520. * An event triggered before rendering the texture
  27521. * @type {BABYLON.Observable}
  27522. */
  27523. onBeforeRenderObservable: Observable<number>;
  27524. private _onBeforeRenderObserver;
  27525. onBeforeRender: (faceIndex: number) => void;
  27526. /**
  27527. * An event triggered after rendering the texture
  27528. * @type {BABYLON.Observable}
  27529. */
  27530. onAfterRenderObservable: Observable<number>;
  27531. private _onAfterRenderObserver;
  27532. onAfterRender: (faceIndex: number) => void;
  27533. /**
  27534. * An event triggered after the texture clear
  27535. * @type {BABYLON.Observable}
  27536. */
  27537. onClearObservable: Observable<Engine>;
  27538. private _onClearObserver;
  27539. onClear: (Engine: Engine) => void;
  27540. clearColor: Color4;
  27541. protected _size: number | {
  27542. width: number;
  27543. height: number;
  27544. };
  27545. protected _initialSizeParameter: number | {
  27546. width: number;
  27547. height: number;
  27548. } | {
  27549. ratio: number;
  27550. };
  27551. protected _sizeRatio: Nullable<number>;
  27552. _generateMipMaps: boolean;
  27553. protected _renderingManager: RenderingManager;
  27554. _waitingRenderList: string[];
  27555. protected _doNotChangeAspectRatio: boolean;
  27556. protected _currentRefreshId: number;
  27557. protected _refreshRate: number;
  27558. protected _textureMatrix: Matrix;
  27559. protected _samples: number;
  27560. protected _renderTargetOptions: RenderTargetCreationOptions;
  27561. readonly renderTargetOptions: RenderTargetCreationOptions;
  27562. protected _engine: Engine;
  27563. protected _onRatioRescale(): void;
  27564. /**
  27565. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  27566. * It must define where the camera used to render the texture is set
  27567. */
  27568. boundingBoxPosition: Vector3;
  27569. private _boundingBoxSize;
  27570. /**
  27571. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  27572. * When defined, the cubemap will switch to local mode
  27573. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  27574. * @example https://www.babylonjs-playground.com/#RNASML
  27575. */
  27576. boundingBoxSize: Vector3;
  27577. /**
  27578. * In case the RTT has been created with a depth texture, get the associated
  27579. * depth texture.
  27580. * Otherwise, return null.
  27581. */
  27582. depthStencilTexture: Nullable<InternalTexture>;
  27583. /**
  27584. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  27585. * or used a shadow, depth texture...
  27586. * @param name The friendly name of the texture
  27587. * @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)
  27588. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  27589. * @param generateMipMaps True if mip maps need to be generated after render.
  27590. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  27591. * @param type The type of the buffer in the RTT (int, half float, float...)
  27592. * @param isCube True if a cube texture needs to be created
  27593. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  27594. * @param generateDepthBuffer True to generate a depth buffer
  27595. * @param generateStencilBuffer True to generate a stencil buffer
  27596. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  27597. */
  27598. constructor(name: string, size: number | {
  27599. width: number;
  27600. height: number;
  27601. } | {
  27602. ratio: number;
  27603. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  27604. /**
  27605. * Creates a depth stencil texture.
  27606. * This is only available in WebGL 2 or with the depth texture extension available.
  27607. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  27608. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  27609. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  27610. */
  27611. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  27612. private _processSizeParameter(size);
  27613. samples: number;
  27614. resetRefreshCounter(): void;
  27615. refreshRate: number;
  27616. addPostProcess(postProcess: PostProcess): void;
  27617. clearPostProcesses(dispose?: boolean): void;
  27618. removePostProcess(postProcess: PostProcess): void;
  27619. _shouldRender(): boolean;
  27620. getRenderSize(): number;
  27621. getRenderWidth(): number;
  27622. getRenderHeight(): number;
  27623. readonly canRescale: boolean;
  27624. scale(ratio: number): void;
  27625. getReflectionTextureMatrix(): Matrix;
  27626. resize(size: number | {
  27627. width: number;
  27628. height: number;
  27629. } | {
  27630. ratio: number;
  27631. }): void;
  27632. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  27633. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  27634. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  27635. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  27636. /**
  27637. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  27638. * This allowed control for front to back rendering or reversly depending of the special needs.
  27639. *
  27640. * @param renderingGroupId The rendering group id corresponding to its index
  27641. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  27642. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  27643. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  27644. */
  27645. 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;
  27646. /**
  27647. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  27648. *
  27649. * @param renderingGroupId The rendering group id corresponding to its index
  27650. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  27651. */
  27652. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  27653. clone(): RenderTargetTexture;
  27654. serialize(): any;
  27655. disposeFramebufferObjects(): void;
  27656. dispose(): void;
  27657. _rebuild(): void;
  27658. /**
  27659. * Clear the info related to rendering groups preventing retention point in material dispose.
  27660. */
  27661. freeRenderingGroups(): void;
  27662. }
  27663. }
  27664. declare module BABYLON {
  27665. class Texture extends BaseTexture {
  27666. static NEAREST_SAMPLINGMODE: number;
  27667. static NEAREST_NEAREST_MIPLINEAR: number;
  27668. static BILINEAR_SAMPLINGMODE: number;
  27669. static LINEAR_LINEAR_MIPNEAREST: number;
  27670. static TRILINEAR_SAMPLINGMODE: number;
  27671. static LINEAR_LINEAR_MIPLINEAR: number;
  27672. static NEAREST_NEAREST_MIPNEAREST: number;
  27673. static NEAREST_LINEAR_MIPNEAREST: number;
  27674. static NEAREST_LINEAR_MIPLINEAR: number;
  27675. static NEAREST_LINEAR: number;
  27676. static NEAREST_NEAREST: number;
  27677. static LINEAR_NEAREST_MIPNEAREST: number;
  27678. static LINEAR_NEAREST_MIPLINEAR: number;
  27679. static LINEAR_LINEAR: number;
  27680. static LINEAR_NEAREST: number;
  27681. static EXPLICIT_MODE: number;
  27682. static SPHERICAL_MODE: number;
  27683. static PLANAR_MODE: number;
  27684. static CUBIC_MODE: number;
  27685. static PROJECTION_MODE: number;
  27686. static SKYBOX_MODE: number;
  27687. static INVCUBIC_MODE: number;
  27688. static EQUIRECTANGULAR_MODE: number;
  27689. static FIXED_EQUIRECTANGULAR_MODE: number;
  27690. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27691. static CLAMP_ADDRESSMODE: number;
  27692. static WRAP_ADDRESSMODE: number;
  27693. static MIRROR_ADDRESSMODE: number;
  27694. /**
  27695. * 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
  27696. */
  27697. static UseSerializedUrlIfAny: boolean;
  27698. url: Nullable<string>;
  27699. uOffset: number;
  27700. vOffset: number;
  27701. uScale: number;
  27702. vScale: number;
  27703. uAng: number;
  27704. vAng: number;
  27705. wAng: number;
  27706. readonly noMipmap: boolean;
  27707. private _noMipmap;
  27708. _invertY: boolean;
  27709. private _rowGenerationMatrix;
  27710. private _cachedTextureMatrix;
  27711. private _projectionModeMatrix;
  27712. private _t0;
  27713. private _t1;
  27714. private _t2;
  27715. private _cachedUOffset;
  27716. private _cachedVOffset;
  27717. private _cachedUScale;
  27718. private _cachedVScale;
  27719. private _cachedUAng;
  27720. private _cachedVAng;
  27721. private _cachedWAng;
  27722. private _cachedProjectionMatrixId;
  27723. private _cachedCoordinatesMode;
  27724. _samplingMode: number;
  27725. private _buffer;
  27726. private _deleteBuffer;
  27727. protected _format: Nullable<number>;
  27728. private _delayedOnLoad;
  27729. private _delayedOnError;
  27730. protected _onLoadObservable: Nullable<Observable<Texture>>;
  27731. protected _isBlocking: boolean;
  27732. isBlocking: boolean;
  27733. readonly samplingMode: number;
  27734. 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);
  27735. updateURL(url: string): void;
  27736. delayLoad(): void;
  27737. updateSamplingMode(samplingMode: number): void;
  27738. private _prepareRowForTextureGeneration(x, y, z, t);
  27739. getTextureMatrix(): Matrix;
  27740. getReflectionTextureMatrix(): Matrix;
  27741. clone(): Texture;
  27742. readonly onLoadObservable: Observable<Texture>;
  27743. serialize(): any;
  27744. getClassName(): string;
  27745. dispose(): void;
  27746. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  27747. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  27748. 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;
  27749. }
  27750. }
  27751. declare module BABYLON {
  27752. /**
  27753. * Settings for finer control over video usage
  27754. */
  27755. interface VideoTextureSettings {
  27756. /**
  27757. * Applies `autoplay` to video, if specified
  27758. */
  27759. autoPlay?: boolean;
  27760. /**
  27761. * Applies `loop` to video, if specified
  27762. */
  27763. loop?: boolean;
  27764. /**
  27765. * Automatically updates internal texture from video at every frame in the render loop
  27766. */
  27767. autoUpdateTexture: boolean;
  27768. }
  27769. class VideoTexture extends Texture {
  27770. /**
  27771. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27772. */
  27773. readonly autoUpdateTexture: boolean;
  27774. /**
  27775. * The video instance used by the texture internally
  27776. */
  27777. readonly video: HTMLVideoElement;
  27778. private _generateMipMaps;
  27779. private _engine;
  27780. /**
  27781. * Creates a video texture.
  27782. * Sample : https://doc.babylonjs.com/how_to/video_texture
  27783. * @param {string | null} name optional name, will detect from video source, if not defined
  27784. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  27785. * @param {BABYLON.Scene} scene is obviously the current scene.
  27786. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27787. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  27788. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27789. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  27790. */
  27791. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27792. private _getName(src);
  27793. private _getVideo(src);
  27794. private _createInternalTexture;
  27795. private reset;
  27796. /**
  27797. * Internal method to initiate `update`.
  27798. */
  27799. _rebuild(): void;
  27800. /**
  27801. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27802. */
  27803. update(): void;
  27804. /**
  27805. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27806. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27807. */
  27808. updateTexture(isVisible: boolean): void;
  27809. protected _updateInternalTexture: (e?: Event | undefined) => void;
  27810. /**
  27811. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27812. * @param url New url.
  27813. */
  27814. updateURL(url: string): void;
  27815. dispose(): void;
  27816. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27817. minWidth: number;
  27818. maxWidth: number;
  27819. minHeight: number;
  27820. maxHeight: number;
  27821. deviceId: string;
  27822. }): void;
  27823. }
  27824. }
  27825. declare var DracoDecoderModule: any;
  27826. declare module BABYLON {
  27827. /**
  27828. * Draco compression (https://google.github.io/draco/)
  27829. */
  27830. class DracoCompression implements IDisposable {
  27831. private _workerPool;
  27832. /**
  27833. * Gets the url to the draco decoder if available.
  27834. */
  27835. static DecoderUrl: Nullable<string>;
  27836. /**
  27837. * Constructor
  27838. * @param numWorkers The number of workers for async operations
  27839. */
  27840. constructor(numWorkers?: number);
  27841. /**
  27842. * Stop all async operations and release resources.
  27843. */
  27844. dispose(): void;
  27845. /**
  27846. * Decode Draco compressed mesh data to vertex data.
  27847. * @param data The array buffer view for the Draco compression data
  27848. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  27849. * @returns A promise that resolves with the decoded vertex data
  27850. */
  27851. decodeMeshAsync(data: ArrayBufferView, attributes: {
  27852. [kind: string]: number;
  27853. }): Promise<VertexData>;
  27854. /**
  27855. * The worker function that gets converted to a blob url to pass into a worker.
  27856. */
  27857. private static _Worker();
  27858. private static _GetDefaultDecoderUrl();
  27859. }
  27860. }
  27861. declare module BABYLON {
  27862. /**
  27863. * Particle emitter emitting particles from the inside of a box.
  27864. * It emits the particles randomly between 2 given directions.
  27865. */
  27866. class BoxParticleEmitter implements IParticleEmitterType {
  27867. /**
  27868. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  27869. */
  27870. direction1: Vector3;
  27871. /**
  27872. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  27873. */
  27874. direction2: Vector3;
  27875. /**
  27876. * 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.
  27877. */
  27878. minEmitBox: Vector3;
  27879. /**
  27880. * 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.
  27881. */
  27882. maxEmitBox: Vector3;
  27883. /**
  27884. * Creates a new instance of @see BoxParticleEmitter
  27885. */
  27886. constructor();
  27887. /**
  27888. * Called by the particle System when the direction is computed for the created particle.
  27889. * @param emitPower is the power of the particle (speed)
  27890. * @param worldMatrix is the world matrix of the particle system
  27891. * @param directionToUpdate is the direction vector to update with the result
  27892. * @param particle is the particle we are computed the direction for
  27893. */
  27894. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  27895. /**
  27896. * Called by the particle System when the position is computed for the created particle.
  27897. * @param worldMatrix is the world matrix of the particle system
  27898. * @param positionToUpdate is the position vector to update with the result
  27899. * @param particle is the particle we are computed the position for
  27900. */
  27901. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  27902. /**
  27903. * Clones the current emitter and returns a copy of it
  27904. * @returns the new emitter
  27905. */
  27906. clone(): BoxParticleEmitter;
  27907. /**
  27908. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  27909. * @param effect defines the update shader
  27910. */
  27911. applyToShader(effect: Effect): void;
  27912. /**
  27913. * Returns a string to use to update the GPU particles update shader
  27914. * @returns a string containng the defines string
  27915. */
  27916. getEffectDefines(): string;
  27917. /**
  27918. * Returns the string "BoxEmitter"
  27919. * @returns a string containing the class name
  27920. */
  27921. getClassName(): string;
  27922. /**
  27923. * Serializes the particle system to a JSON object.
  27924. * @returns the JSON object
  27925. */
  27926. serialize(): any;
  27927. /**
  27928. * Parse properties from a JSON object
  27929. * @param serializationObject defines the JSON object
  27930. */
  27931. parse(serializationObject: any): void;
  27932. }
  27933. }
  27934. declare module BABYLON {
  27935. /**
  27936. * Particle emitter emitting particles from the inside of a cone.
  27937. * It emits the particles alongside the cone volume from the base to the particle.
  27938. * The emission direction might be randomized.
  27939. */
  27940. class ConeParticleEmitter implements IParticleEmitterType {
  27941. /**
  27942. * The radius of the emission cone.
  27943. */
  27944. angle: number;
  27945. /**
  27946. * The cone base angle.
  27947. */
  27948. directionRandomizer: number;
  27949. private _radius;
  27950. private _height;
  27951. /**
  27952. * Gets the radius of the emission cone.
  27953. */
  27954. /**
  27955. * Sets the radius of the emission cone.
  27956. */
  27957. radius: number;
  27958. /**
  27959. * Creates a new instance of @see ConeParticleEmitter
  27960. * @param radius the radius of the emission cone (1 by default)
  27961. * @param angles the cone base angle (PI by default)
  27962. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  27963. */
  27964. constructor(radius?: number,
  27965. /**
  27966. * The radius of the emission cone.
  27967. */
  27968. angle?: number,
  27969. /**
  27970. * The cone base angle.
  27971. */
  27972. directionRandomizer?: number);
  27973. /**
  27974. * Called by the particle System when the direction is computed for the created particle.
  27975. * @param emitPower is the power of the particle (speed)
  27976. * @param worldMatrix is the world matrix of the particle system
  27977. * @param directionToUpdate is the direction vector to update with the result
  27978. * @param particle is the particle we are computed the direction for
  27979. */
  27980. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  27981. /**
  27982. * Called by the particle System when the position is computed for the created particle.
  27983. * @param worldMatrix is the world matrix of the particle system
  27984. * @param positionToUpdate is the position vector to update with the result
  27985. * @param particle is the particle we are computed the position for
  27986. */
  27987. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  27988. /**
  27989. * Clones the current emitter and returns a copy of it
  27990. * @returns the new emitter
  27991. */
  27992. clone(): ConeParticleEmitter;
  27993. /**
  27994. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  27995. * @param effect defines the update shader
  27996. */
  27997. applyToShader(effect: Effect): void;
  27998. /**
  27999. * Returns a string to use to update the GPU particles update shader
  28000. * @returns a string containng the defines string
  28001. */
  28002. getEffectDefines(): string;
  28003. /**
  28004. * Returns the string "BoxEmitter"
  28005. * @returns a string containing the class name
  28006. */
  28007. getClassName(): string;
  28008. /**
  28009. * Serializes the particle system to a JSON object.
  28010. * @returns the JSON object
  28011. */
  28012. serialize(): any;
  28013. /**
  28014. * Parse properties from a JSON object
  28015. * @param serializationObject defines the JSON object
  28016. */
  28017. parse(serializationObject: any): void;
  28018. }
  28019. }
  28020. declare module BABYLON {
  28021. /**
  28022. * Particle emitter represents a volume emitting particles.
  28023. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  28024. */
  28025. interface IParticleEmitterType {
  28026. /**
  28027. * Called by the particle System when the direction is computed for the created particle.
  28028. * @param emitPower is the power of the particle (speed)
  28029. * @param worldMatrix is the world matrix of the particle system
  28030. * @param directionToUpdate is the direction vector to update with the result
  28031. * @param particle is the particle we are computed the direction for
  28032. */
  28033. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  28034. /**
  28035. * Called by the particle System when the position is computed for the created particle.
  28036. * @param worldMatrix is the world matrix of the particle system
  28037. * @param positionToUpdate is the position vector to update with the result
  28038. * @param particle is the particle we are computed the position for
  28039. */
  28040. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  28041. /**
  28042. * Clones the current emitter and returns a copy of it
  28043. * @returns the new emitter
  28044. */
  28045. clone(): IParticleEmitterType;
  28046. /**
  28047. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  28048. * @param effect defines the update shader
  28049. */
  28050. applyToShader(effect: Effect): void;
  28051. /**
  28052. * Returns a string to use to update the GPU particles update shader
  28053. * @returns the effect defines string
  28054. */
  28055. getEffectDefines(): string;
  28056. /**
  28057. * Returns a string representing the class name
  28058. * @returns a string containing the class name
  28059. */
  28060. getClassName(): string;
  28061. /**
  28062. * Serializes the particle system to a JSON object.
  28063. * @returns the JSON object
  28064. */
  28065. serialize(): any;
  28066. /**
  28067. * Parse properties from a JSON object
  28068. * @param serializationObject defines the JSON object
  28069. */
  28070. parse(serializationObject: any): void;
  28071. }
  28072. }
  28073. declare module BABYLON {
  28074. /**
  28075. * Particle emitter emitting particles from the inside of a sphere.
  28076. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  28077. */
  28078. class SphereParticleEmitter implements IParticleEmitterType {
  28079. /**
  28080. * The radius of the emission sphere.
  28081. */
  28082. radius: number;
  28083. /**
  28084. * How much to randomize the particle direction [0-1].
  28085. */
  28086. directionRandomizer: number;
  28087. /**
  28088. * Creates a new instance of @see SphereParticleEmitter
  28089. * @param radius the radius of the emission sphere (1 by default)
  28090. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  28091. */
  28092. constructor(
  28093. /**
  28094. * The radius of the emission sphere.
  28095. */
  28096. radius?: number,
  28097. /**
  28098. * How much to randomize the particle direction [0-1].
  28099. */
  28100. directionRandomizer?: number);
  28101. /**
  28102. * Called by the particle System when the direction is computed for the created particle.
  28103. * @param emitPower is the power of the particle (speed)
  28104. * @param worldMatrix is the world matrix of the particle system
  28105. * @param directionToUpdate is the direction vector to update with the result
  28106. * @param particle is the particle we are computed the direction for
  28107. */
  28108. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  28109. /**
  28110. * Called by the particle System when the position is computed for the created particle.
  28111. * @param worldMatrix is the world matrix of the particle system
  28112. * @param positionToUpdate is the position vector to update with the result
  28113. * @param particle is the particle we are computed the position for
  28114. */
  28115. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  28116. /**
  28117. * Clones the current emitter and returns a copy of it
  28118. * @returns the new emitter
  28119. */
  28120. clone(): SphereParticleEmitter;
  28121. /**
  28122. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  28123. * @param effect defines the update shader
  28124. */
  28125. applyToShader(effect: Effect): void;
  28126. /**
  28127. * Returns a string to use to update the GPU particles update shader
  28128. * @returns a string containng the defines string
  28129. */
  28130. getEffectDefines(): string;
  28131. /**
  28132. * Returns the string "SphereParticleEmitter"
  28133. * @returns a string containing the class name
  28134. */
  28135. getClassName(): string;
  28136. /**
  28137. * Serializes the particle system to a JSON object.
  28138. * @returns the JSON object
  28139. */
  28140. serialize(): any;
  28141. /**
  28142. * Parse properties from a JSON object
  28143. * @param serializationObject defines the JSON object
  28144. */
  28145. parse(serializationObject: any): void;
  28146. }
  28147. /**
  28148. * Particle emitter emitting particles from the inside of a sphere.
  28149. * It emits the particles randomly between two vectors.
  28150. */
  28151. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  28152. /**
  28153. * The min limit of the emission direction.
  28154. */
  28155. direction1: Vector3;
  28156. /**
  28157. * The max limit of the emission direction.
  28158. */
  28159. direction2: Vector3;
  28160. /**
  28161. * Creates a new instance of @see SphereDirectedParticleEmitter
  28162. * @param radius the radius of the emission sphere (1 by default)
  28163. * @param direction1 the min limit of the emission direction (up vector by default)
  28164. * @param direction2 the max limit of the emission direction (up vector by default)
  28165. */
  28166. constructor(radius?: number,
  28167. /**
  28168. * The min limit of the emission direction.
  28169. */
  28170. direction1?: Vector3,
  28171. /**
  28172. * The max limit of the emission direction.
  28173. */
  28174. direction2?: Vector3);
  28175. /**
  28176. * Called by the particle System when the direction is computed for the created particle.
  28177. * @param emitPower is the power of the particle (speed)
  28178. * @param worldMatrix is the world matrix of the particle system
  28179. * @param directionToUpdate is the direction vector to update with the result
  28180. * @param particle is the particle we are computed the direction for
  28181. */
  28182. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  28183. /**
  28184. * Clones the current emitter and returns a copy of it
  28185. * @returns the new emitter
  28186. */
  28187. clone(): SphereDirectedParticleEmitter;
  28188. /**
  28189. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  28190. * @param effect defines the update shader
  28191. */
  28192. applyToShader(effect: Effect): void;
  28193. /**
  28194. * Returns a string to use to update the GPU particles update shader
  28195. * @returns a string containng the defines string
  28196. */
  28197. getEffectDefines(): string;
  28198. /**
  28199. * Returns the string "SphereDirectedParticleEmitter"
  28200. * @returns a string containing the class name
  28201. */
  28202. getClassName(): string;
  28203. /**
  28204. * Serializes the particle system to a JSON object.
  28205. * @returns the JSON object
  28206. */
  28207. serialize(): any;
  28208. /**
  28209. * Parse properties from a JSON object
  28210. * @param serializationObject defines the JSON object
  28211. */
  28212. parse(serializationObject: any): void;
  28213. }
  28214. }
  28215. declare module BABYLON {
  28216. class CannonJSPlugin implements IPhysicsEnginePlugin {
  28217. private _useDeltaForWorldStep;
  28218. world: any;
  28219. name: string;
  28220. private _physicsMaterials;
  28221. private _fixedTimeStep;
  28222. BJSCANNON: any;
  28223. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  28224. setGravity(gravity: Vector3): void;
  28225. setTimeStep(timeStep: number): void;
  28226. getTimeStep(): number;
  28227. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28228. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28229. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28230. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28231. private _processChildMeshes(mainImpostor);
  28232. removePhysicsBody(impostor: PhysicsImpostor): void;
  28233. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  28234. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  28235. private _addMaterial(name, friction, restitution);
  28236. private _checkWithEpsilon(value);
  28237. private _createShape(impostor);
  28238. private _createHeightmap(object, pointDepth?);
  28239. private _minus90X;
  28240. private _plus90X;
  28241. private _tmpPosition;
  28242. private _tmpDeltaPosition;
  28243. private _tmpUnityRotation;
  28244. private _updatePhysicsBodyTransformation(impostor);
  28245. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28246. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28247. isSupported(): boolean;
  28248. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  28249. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  28250. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28251. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28252. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28253. getBodyMass(impostor: PhysicsImpostor): number;
  28254. getBodyFriction(impostor: PhysicsImpostor): number;
  28255. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28256. getBodyRestitution(impostor: PhysicsImpostor): number;
  28257. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28258. sleepBody(impostor: PhysicsImpostor): void;
  28259. wakeUpBody(impostor: PhysicsImpostor): void;
  28260. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28261. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  28262. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  28263. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28264. getRadius(impostor: PhysicsImpostor): number;
  28265. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28266. dispose(): void;
  28267. private _extendNamespace();
  28268. }
  28269. }
  28270. declare module BABYLON {
  28271. class OimoJSPlugin implements IPhysicsEnginePlugin {
  28272. world: any;
  28273. name: string;
  28274. BJSOIMO: any;
  28275. constructor(iterations?: number);
  28276. setGravity(gravity: Vector3): void;
  28277. setTimeStep(timeStep: number): void;
  28278. getTimeStep(): number;
  28279. private _tmpImpostorsArray;
  28280. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28281. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28282. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28283. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28284. private _tmpPositionVector;
  28285. removePhysicsBody(impostor: PhysicsImpostor): void;
  28286. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  28287. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  28288. isSupported(): boolean;
  28289. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28290. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28291. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  28292. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  28293. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28294. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28295. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28296. getBodyMass(impostor: PhysicsImpostor): number;
  28297. getBodyFriction(impostor: PhysicsImpostor): number;
  28298. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28299. getBodyRestitution(impostor: PhysicsImpostor): number;
  28300. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28301. sleepBody(impostor: PhysicsImpostor): void;
  28302. wakeUpBody(impostor: PhysicsImpostor): void;
  28303. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28304. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28305. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28306. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28307. getRadius(impostor: PhysicsImpostor): number;
  28308. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28309. dispose(): void;
  28310. }
  28311. }
  28312. declare module BABYLON {
  28313. /**
  28314. * This represents a set of one or more post processes in Babylon.
  28315. * A post process can be used to apply a shader to a texture after it is rendered.
  28316. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  28317. */
  28318. class PostProcessRenderEffect {
  28319. private _postProcesses;
  28320. private _getPostProcesses;
  28321. private _singleInstance;
  28322. private _cameras;
  28323. private _indicesForCamera;
  28324. /**
  28325. * Name of the effect
  28326. */
  28327. _name: string;
  28328. /**
  28329. * Instantiates a post process render effect.
  28330. * A post process can be used to apply a shader to a texture after it is rendered.
  28331. * @param engine The engine the effect is tied to
  28332. * @param name The name of the effect
  28333. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  28334. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  28335. */
  28336. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  28337. /**
  28338. * Checks if all the post processes in the effect are supported.
  28339. */
  28340. readonly isSupported: boolean;
  28341. /**
  28342. * Updates the current state of the effect
  28343. */
  28344. _update(): void;
  28345. /**
  28346. * Attaches the effect on cameras
  28347. * @param cameras The camera to attach to.
  28348. */
  28349. _attachCameras(cameras: Camera): void;
  28350. /**
  28351. * Attaches the effect on cameras
  28352. * @param cameras The camera to attach to.
  28353. */
  28354. _attachCameras(cameras: Camera[]): void;
  28355. /**
  28356. * Detatches the effect on cameras
  28357. * @param cameras The camera to detatch from.
  28358. */
  28359. _detachCameras(cameras: Camera): void;
  28360. /**
  28361. * Detatches the effect on cameras
  28362. * @param cameras The camera to detatch from.
  28363. */
  28364. _detachCameras(cameras: Camera[]): void;
  28365. /**
  28366. * Enables the effect on given cameras
  28367. * @param cameras The camera to enable.
  28368. */
  28369. _enable(cameras: Camera): void;
  28370. /**
  28371. * Enables the effect on given cameras
  28372. * @param cameras The camera to enable.
  28373. */
  28374. _enable(cameras: Nullable<Camera[]>): void;
  28375. /**
  28376. * Disables the effect on the given cameras
  28377. * @param cameras The camera to disable.
  28378. */
  28379. _disable(cameras: Camera): void;
  28380. /**
  28381. * Disables the effect on the given cameras
  28382. * @param cameras The camera to disable.
  28383. */
  28384. _disable(cameras: Nullable<Camera[]>): void;
  28385. /**
  28386. * Gets a list of the post processes contained in the effect.
  28387. * @param camera The camera to get the post processes on.
  28388. * @returns The list of the post processes in the effect.
  28389. */
  28390. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  28391. }
  28392. }
  28393. declare module BABYLON {
  28394. class PostProcessRenderPipeline {
  28395. private engine;
  28396. private _renderEffects;
  28397. private _renderEffectsForIsolatedPass;
  28398. protected _cameras: Camera[];
  28399. _name: string;
  28400. constructor(engine: Engine, name: string);
  28401. getClassName(): string;
  28402. readonly isSupported: boolean;
  28403. addEffect(renderEffect: PostProcessRenderEffect): void;
  28404. _rebuild(): void;
  28405. _enableEffect(renderEffectName: string, cameras: Camera): void;
  28406. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  28407. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  28408. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  28409. _attachCameras(cameras: Camera, unique: boolean): void;
  28410. _attachCameras(cameras: Camera[], unique: boolean): void;
  28411. _detachCameras(cameras: Camera): void;
  28412. _detachCameras(cameras: Nullable<Camera[]>): void;
  28413. _update(): void;
  28414. _reset(): void;
  28415. protected _enableMSAAOnFirstPostProcess(): boolean;
  28416. dispose(): void;
  28417. }
  28418. }
  28419. declare module BABYLON {
  28420. class PostProcessRenderPipelineManager {
  28421. private _renderPipelines;
  28422. constructor();
  28423. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  28424. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  28425. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  28426. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  28427. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  28428. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  28429. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  28430. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  28431. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  28432. update(): void;
  28433. _rebuild(): void;
  28434. dispose(): void;
  28435. }
  28436. }
  28437. declare module BABYLON {
  28438. /**
  28439. * Helper class dealing with the extraction of spherical polynomial dataArray
  28440. * from a cube map.
  28441. */
  28442. class CubeMapToSphericalPolynomialTools {
  28443. private static FileFaces;
  28444. /**
  28445. * Converts a texture to the according Spherical Polynomial data.
  28446. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28447. *
  28448. * @param texture The texture to extract the information from.
  28449. * @return The Spherical Polynomial data.
  28450. */
  28451. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28452. /**
  28453. * Converts a cubemap to the according Spherical Polynomial data.
  28454. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28455. *
  28456. * @param cubeInfo The Cube map to extract the information from.
  28457. * @return The Spherical Polynomial data.
  28458. */
  28459. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28460. }
  28461. }
  28462. declare module BABYLON {
  28463. /**
  28464. * Header information of HDR texture files.
  28465. */
  28466. interface HDRInfo {
  28467. /**
  28468. * The height of the texture in pixels.
  28469. */
  28470. height: number;
  28471. /**
  28472. * The width of the texture in pixels.
  28473. */
  28474. width: number;
  28475. /**
  28476. * The index of the beginning of the data in the binary file.
  28477. */
  28478. dataPosition: number;
  28479. }
  28480. /**
  28481. * This groups tools to convert HDR texture to native colors array.
  28482. */
  28483. class HDRTools {
  28484. private static Ldexp(mantissa, exponent);
  28485. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  28486. private static readStringLine(uint8array, startIndex);
  28487. /**
  28488. * Reads header information from an RGBE texture stored in a native array.
  28489. * More information on this format are available here:
  28490. * https://en.wikipedia.org/wiki/RGBE_image_format
  28491. *
  28492. * @param uint8array The binary file stored in native array.
  28493. * @return The header information.
  28494. */
  28495. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  28496. /**
  28497. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  28498. * This RGBE texture needs to store the information as a panorama.
  28499. *
  28500. * More information on this format are available here:
  28501. * https://en.wikipedia.org/wiki/RGBE_image_format
  28502. *
  28503. * @param buffer The binary file stored in an array buffer.
  28504. * @param size The expected size of the extracted cubemap.
  28505. * @return The Cube Map information.
  28506. */
  28507. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  28508. /**
  28509. * Returns the pixels data extracted from an RGBE texture.
  28510. * This pixels will be stored left to right up to down in the R G B order in one array.
  28511. *
  28512. * More information on this format are available here:
  28513. * https://en.wikipedia.org/wiki/RGBE_image_format
  28514. *
  28515. * @param uint8array The binary file stored in an array buffer.
  28516. * @param hdrInfo The header information of the file.
  28517. * @return The pixels data in RGB right to left up to down order.
  28518. */
  28519. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  28520. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  28521. }
  28522. }
  28523. declare module BABYLON {
  28524. /**
  28525. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28526. */
  28527. interface CubeMapInfo {
  28528. /**
  28529. * The pixel array for the front face.
  28530. * This is stored in format, left to right, up to down format.
  28531. */
  28532. front: Nullable<ArrayBufferView>;
  28533. /**
  28534. * The pixel array for the back face.
  28535. * This is stored in format, left to right, up to down format.
  28536. */
  28537. back: Nullable<ArrayBufferView>;
  28538. /**
  28539. * The pixel array for the left face.
  28540. * This is stored in format, left to right, up to down format.
  28541. */
  28542. left: Nullable<ArrayBufferView>;
  28543. /**
  28544. * The pixel array for the right face.
  28545. * This is stored in format, left to right, up to down format.
  28546. */
  28547. right: Nullable<ArrayBufferView>;
  28548. /**
  28549. * The pixel array for the up face.
  28550. * This is stored in format, left to right, up to down format.
  28551. */
  28552. up: Nullable<ArrayBufferView>;
  28553. /**
  28554. * The pixel array for the down face.
  28555. * This is stored in format, left to right, up to down format.
  28556. */
  28557. down: Nullable<ArrayBufferView>;
  28558. /**
  28559. * The size of the cubemap stored.
  28560. *
  28561. * Each faces will be size * size pixels.
  28562. */
  28563. size: number;
  28564. /**
  28565. * The format of the texture.
  28566. *
  28567. * RGBA, RGB.
  28568. */
  28569. format: number;
  28570. /**
  28571. * The type of the texture data.
  28572. *
  28573. * UNSIGNED_INT, FLOAT.
  28574. */
  28575. type: number;
  28576. /**
  28577. * Specifies whether the texture is in gamma space.
  28578. */
  28579. gammaSpace: boolean;
  28580. }
  28581. /**
  28582. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  28583. */
  28584. class PanoramaToCubeMapTools {
  28585. private static FACE_FRONT;
  28586. private static FACE_BACK;
  28587. private static FACE_RIGHT;
  28588. private static FACE_LEFT;
  28589. private static FACE_DOWN;
  28590. private static FACE_UP;
  28591. /**
  28592. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28593. *
  28594. * @param float32Array The source data.
  28595. * @param inputWidth The width of the input panorama.
  28596. * @param inputhHeight The height of the input panorama.
  28597. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28598. * @return The cubemap data
  28599. */
  28600. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28601. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  28602. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  28603. }
  28604. }
  28605. declare module BABYLON {
  28606. class CustomProceduralTexture extends ProceduralTexture {
  28607. private _animate;
  28608. private _time;
  28609. private _config;
  28610. private _texturePath;
  28611. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  28612. private loadJson(jsonUrl);
  28613. isReady(): boolean;
  28614. render(useCameraPostProcess?: boolean): void;
  28615. updateTextures(): void;
  28616. updateShaderUniforms(): void;
  28617. animate: boolean;
  28618. }
  28619. }
  28620. declare module BABYLON {
  28621. class ProceduralTexture extends Texture {
  28622. isCube: boolean;
  28623. private _size;
  28624. _generateMipMaps: boolean;
  28625. isEnabled: boolean;
  28626. private _currentRefreshId;
  28627. private _refreshRate;
  28628. onGenerated: () => void;
  28629. private _vertexBuffers;
  28630. private _indexBuffer;
  28631. private _effect;
  28632. private _uniforms;
  28633. private _samplers;
  28634. private _fragment;
  28635. _textures: {
  28636. [key: string]: Texture;
  28637. };
  28638. private _floats;
  28639. private _floatsArrays;
  28640. private _colors3;
  28641. private _colors4;
  28642. private _vectors2;
  28643. private _vectors3;
  28644. private _matrices;
  28645. private _fallbackTexture;
  28646. private _fallbackTextureUsed;
  28647. private _engine;
  28648. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  28649. private _createIndexBuffer();
  28650. _rebuild(): void;
  28651. reset(): void;
  28652. isReady(): boolean;
  28653. resetRefreshCounter(): void;
  28654. setFragment(fragment: any): void;
  28655. refreshRate: number;
  28656. _shouldRender(): boolean;
  28657. getRenderSize(): number;
  28658. resize(size: number, generateMipMaps: boolean): void;
  28659. private _checkUniform(uniformName);
  28660. setTexture(name: string, texture: Texture): ProceduralTexture;
  28661. setFloat(name: string, value: number): ProceduralTexture;
  28662. setFloats(name: string, value: number[]): ProceduralTexture;
  28663. setColor3(name: string, value: Color3): ProceduralTexture;
  28664. setColor4(name: string, value: Color4): ProceduralTexture;
  28665. setVector2(name: string, value: Vector2): ProceduralTexture;
  28666. setVector3(name: string, value: Vector3): ProceduralTexture;
  28667. setMatrix(name: string, value: Matrix): ProceduralTexture;
  28668. render(useCameraPostProcess?: boolean): void;
  28669. clone(): ProceduralTexture;
  28670. dispose(): void;
  28671. }
  28672. }
  28673. declare module BABYLON {
  28674. /**
  28675. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  28676. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  28677. */
  28678. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  28679. private _scene;
  28680. private _originalCameras;
  28681. /**
  28682. * ID of the sharpen post process,
  28683. */
  28684. readonly SharpenPostProcessId: string;
  28685. /**
  28686. * ID of the pass post process used for bloom,
  28687. */
  28688. readonly PassPostProcessId: string;
  28689. /**
  28690. * ID of the highlight post process used for bloom,
  28691. */
  28692. readonly HighLightsPostProcessId: string;
  28693. /**
  28694. * ID of the blurX post process used for bloom,
  28695. */
  28696. readonly BlurXPostProcessId: string;
  28697. /**
  28698. * ID of the blurY post process used for bloom,
  28699. */
  28700. readonly BlurYPostProcessId: string;
  28701. /**
  28702. * ID of the copy back post process used for bloom,
  28703. */
  28704. readonly CopyBackPostProcessId: string;
  28705. /**
  28706. * ID of the image processing post process;
  28707. */
  28708. readonly ImageProcessingPostProcessId: string;
  28709. /**
  28710. * ID of the Fast Approximate Anti-Aliasing post process;
  28711. */
  28712. readonly FxaaPostProcessId: string;
  28713. /**
  28714. * ID of the final merge post process;
  28715. */
  28716. readonly FinalMergePostProcessId: string;
  28717. /**
  28718. * ID of the chromatic aberration post process,
  28719. */
  28720. readonly ChromaticAberrationPostProcessId: string;
  28721. /**
  28722. * Sharpen post process which will apply a sharpen convolution to enhance edges
  28723. */
  28724. sharpen: SharpenPostProcess;
  28725. private _sharpenEffect;
  28726. /**
  28727. * First pass of bloom to capture the original image texture for later use.
  28728. */
  28729. pass: PassPostProcess;
  28730. /**
  28731. * Second pass of bloom used to brighten bright portions of the image.
  28732. */
  28733. highlights: HighlightsPostProcess;
  28734. /**
  28735. * BlurX post process used in coordination with blurY to guassian blur the highlighted image.
  28736. */
  28737. blurX: BlurPostProcess;
  28738. /**
  28739. * BlurY post process used in coordination with blurX to guassian blur the highlighted image.
  28740. */
  28741. blurY: BlurPostProcess;
  28742. /**
  28743. * Final pass run for bloom to copy the resulting bloom texture back to screen.
  28744. */
  28745. copyBack: PassPostProcess;
  28746. /**
  28747. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  28748. */
  28749. depthOfField: DepthOfFieldEffect;
  28750. /**
  28751. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  28752. */
  28753. fxaa: FxaaPostProcess;
  28754. /**
  28755. * Image post processing pass used to perform operations such as tone mapping or color grading.
  28756. */
  28757. imageProcessing: ImageProcessingPostProcess;
  28758. /**
  28759. * Final post process to merge results of all previous passes
  28760. */
  28761. finalMerge: PassPostProcess;
  28762. /**
  28763. * Chromatic aberration post process which will shift rgb colors in the image
  28764. */
  28765. chromaticAberration: ChromaticAberrationPostProcess;
  28766. private _chromaticAberrationEffect;
  28767. /**
  28768. * Animations which can be used to tweak settings over a period of time
  28769. */
  28770. animations: Animation[];
  28771. private _sharpenEnabled;
  28772. private _bloomEnabled;
  28773. private _depthOfFieldEnabled;
  28774. private _depthOfFieldBlurLevel;
  28775. private _fxaaEnabled;
  28776. private _msaaEnabled;
  28777. private _imageProcessingEnabled;
  28778. private _defaultPipelineTextureType;
  28779. private _bloomScale;
  28780. private _chromaticAberrationEnabled;
  28781. private _buildAllowed;
  28782. /**
  28783. * Enable or disable the sharpen process from the pipeline
  28784. */
  28785. sharpenEnabled: boolean;
  28786. /**
  28787. * Specifies the size of the bloom blur kernel, relative to the final output size
  28788. */
  28789. bloomKernel: number;
  28790. /**
  28791. * Specifies the weight of the bloom in the final rendering
  28792. */
  28793. private _bloomWeight;
  28794. private _hdr;
  28795. /**
  28796. * The strength of the bloom.
  28797. */
  28798. bloomWeight: number;
  28799. /**
  28800. * The scale of the bloom, lower value will provide better performance.
  28801. */
  28802. bloomScale: number;
  28803. /**
  28804. * Enable or disable the bloom from the pipeline
  28805. */
  28806. bloomEnabled: boolean;
  28807. /**
  28808. * If the depth of field is enabled.
  28809. */
  28810. depthOfFieldEnabled: boolean;
  28811. /**
  28812. * Blur level of the depth of field effect. (Higher blur will effect performance)
  28813. */
  28814. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  28815. /**
  28816. * If the anti aliasing is enabled.
  28817. */
  28818. fxaaEnabled: boolean;
  28819. /**
  28820. * If the multisample anti-aliasing is enabled.
  28821. */
  28822. msaaEnabled: boolean;
  28823. /**
  28824. * If image processing is enabled.
  28825. */
  28826. imageProcessingEnabled: boolean;
  28827. /**
  28828. * Enable or disable the chromaticAberration process from the pipeline
  28829. */
  28830. chromaticAberrationEnabled: boolean;
  28831. /**
  28832. * @constructor
  28833. * @param {string} name - The rendering pipeline name
  28834. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  28835. * @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)
  28836. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  28837. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
  28838. */
  28839. constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild?: boolean);
  28840. /**
  28841. * Force the compilation of the entire pipeline.
  28842. */
  28843. prepare(): void;
  28844. private _prevPostProcess;
  28845. private _prevPrevPostProcess;
  28846. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  28847. private _buildPipeline();
  28848. private _disposePostProcesses(disposeNonRecreated?);
  28849. /**
  28850. * Dispose of the pipeline and stop all post processes
  28851. */
  28852. dispose(): void;
  28853. /**
  28854. * Serialize the rendering pipeline (Used when exporting)
  28855. * @returns the serialized object
  28856. */
  28857. serialize(): any;
  28858. /**
  28859. * Parse the serialized pipeline
  28860. * @param source Source pipeline.
  28861. * @param scene The scene to load the pipeline to.
  28862. * @param rootUrl The URL of the serialized pipeline.
  28863. * @returns An instantiated pipeline from the serialized object.
  28864. */
  28865. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  28866. }
  28867. }
  28868. declare module BABYLON {
  28869. class LensRenderingPipeline extends PostProcessRenderPipeline {
  28870. /**
  28871. * The chromatic aberration PostProcess id in the pipeline
  28872. * @type {string}
  28873. */
  28874. LensChromaticAberrationEffect: string;
  28875. /**
  28876. * The highlights enhancing PostProcess id in the pipeline
  28877. * @type {string}
  28878. */
  28879. HighlightsEnhancingEffect: string;
  28880. /**
  28881. * The depth-of-field PostProcess id in the pipeline
  28882. * @type {string}
  28883. */
  28884. LensDepthOfFieldEffect: string;
  28885. private _scene;
  28886. private _depthTexture;
  28887. private _grainTexture;
  28888. private _chromaticAberrationPostProcess;
  28889. private _highlightsPostProcess;
  28890. private _depthOfFieldPostProcess;
  28891. private _edgeBlur;
  28892. private _grainAmount;
  28893. private _chromaticAberration;
  28894. private _distortion;
  28895. private _highlightsGain;
  28896. private _highlightsThreshold;
  28897. private _dofDistance;
  28898. private _dofAperture;
  28899. private _dofDarken;
  28900. private _dofPentagon;
  28901. private _blurNoise;
  28902. /**
  28903. * @constructor
  28904. *
  28905. * Effect parameters are as follow:
  28906. * {
  28907. * chromatic_aberration: number; // from 0 to x (1 for realism)
  28908. * edge_blur: number; // from 0 to x (1 for realism)
  28909. * distortion: number; // from 0 to x (1 for realism)
  28910. * grain_amount: number; // from 0 to 1
  28911. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  28912. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  28913. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  28914. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  28915. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  28916. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  28917. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  28918. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  28919. * }
  28920. * Note: if an effect parameter is unset, effect is disabled
  28921. *
  28922. * @param {string} name - The rendering pipeline name
  28923. * @param {object} parameters - An object containing all parameters (see above)
  28924. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  28925. * @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)
  28926. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  28927. */
  28928. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  28929. setEdgeBlur(amount: number): void;
  28930. disableEdgeBlur(): void;
  28931. setGrainAmount(amount: number): void;
  28932. disableGrain(): void;
  28933. setChromaticAberration(amount: number): void;
  28934. disableChromaticAberration(): void;
  28935. setEdgeDistortion(amount: number): void;
  28936. disableEdgeDistortion(): void;
  28937. setFocusDistance(amount: number): void;
  28938. disableDepthOfField(): void;
  28939. setAperture(amount: number): void;
  28940. setDarkenOutOfFocus(amount: number): void;
  28941. enablePentagonBokeh(): void;
  28942. disablePentagonBokeh(): void;
  28943. enableNoiseBlur(): void;
  28944. disableNoiseBlur(): void;
  28945. setHighlightsGain(amount: number): void;
  28946. setHighlightsThreshold(amount: number): void;
  28947. disableHighlights(): void;
  28948. /**
  28949. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  28950. */
  28951. dispose(disableDepthRender?: boolean): void;
  28952. private _createChromaticAberrationPostProcess(ratio);
  28953. private _createHighlightsPostProcess(ratio);
  28954. private _createDepthOfFieldPostProcess(ratio);
  28955. private _createGrainTexture();
  28956. }
  28957. }
  28958. declare module BABYLON {
  28959. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  28960. /**
  28961. * The PassPostProcess id in the pipeline that contains the original scene color
  28962. * @type {string}
  28963. */
  28964. SSAOOriginalSceneColorEffect: string;
  28965. /**
  28966. * The SSAO PostProcess id in the pipeline
  28967. * @type {string}
  28968. */
  28969. SSAORenderEffect: string;
  28970. /**
  28971. * The horizontal blur PostProcess id in the pipeline
  28972. * @type {string}
  28973. */
  28974. SSAOBlurHRenderEffect: string;
  28975. /**
  28976. * The vertical blur PostProcess id in the pipeline
  28977. * @type {string}
  28978. */
  28979. SSAOBlurVRenderEffect: string;
  28980. /**
  28981. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  28982. * @type {string}
  28983. */
  28984. SSAOCombineRenderEffect: string;
  28985. /**
  28986. * The output strength of the SSAO post-process. Default value is 1.0.
  28987. * @type {number}
  28988. */
  28989. totalStrength: number;
  28990. /**
  28991. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  28992. * @type {number}
  28993. */
  28994. maxZ: number;
  28995. /**
  28996. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  28997. * @type {number}
  28998. */
  28999. minZAspect: number;
  29000. /**
  29001. * Number of samples used for the SSAO calculations. Default value is 8
  29002. * @type {number}
  29003. */
  29004. private _samples;
  29005. /**
  29006. * Dynamically generated sphere sampler.
  29007. * @type {number[]}
  29008. */
  29009. private _sampleSphere;
  29010. /**
  29011. * Blur filter offsets
  29012. * @type {number[]}
  29013. */
  29014. private _samplerOffsets;
  29015. samples: number;
  29016. /**
  29017. * Are we using bilateral blur ?
  29018. * @type {boolean}
  29019. */
  29020. private _expensiveBlur;
  29021. expensiveBlur: boolean;
  29022. /**
  29023. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  29024. * @type {number}
  29025. */
  29026. radius: number;
  29027. /**
  29028. * The base color of the SSAO post-process
  29029. * The final result is "base + ssao" between [0, 1]
  29030. * @type {number}
  29031. */
  29032. base: number;
  29033. /**
  29034. * Support test.
  29035. * @type {boolean}
  29036. */
  29037. static readonly IsSupported: boolean;
  29038. private _scene;
  29039. private _depthTexture;
  29040. private _normalTexture;
  29041. private _randomTexture;
  29042. private _originalColorPostProcess;
  29043. private _ssaoPostProcess;
  29044. private _blurHPostProcess;
  29045. private _blurVPostProcess;
  29046. private _ssaoCombinePostProcess;
  29047. private _firstUpdate;
  29048. /**
  29049. * @constructor
  29050. * @param {string} name - The rendering pipeline name
  29051. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  29052. * @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 }
  29053. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  29054. */
  29055. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  29056. /**
  29057. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  29058. */
  29059. dispose(disableGeometryBufferRenderer?: boolean): void;
  29060. private _createBlurPostProcess(ssaoRatio, blurRatio);
  29061. _rebuild(): void;
  29062. private _generateHemisphere();
  29063. private _createSSAOPostProcess(ratio);
  29064. private _createSSAOCombinePostProcess(ratio);
  29065. private _createRandomTexture();
  29066. }
  29067. }
  29068. declare module BABYLON {
  29069. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  29070. /**
  29071. * The PassPostProcess id in the pipeline that contains the original scene color
  29072. * @type {string}
  29073. */
  29074. SSAOOriginalSceneColorEffect: string;
  29075. /**
  29076. * The SSAO PostProcess id in the pipeline
  29077. * @type {string}
  29078. */
  29079. SSAORenderEffect: string;
  29080. /**
  29081. * The horizontal blur PostProcess id in the pipeline
  29082. * @type {string}
  29083. */
  29084. SSAOBlurHRenderEffect: string;
  29085. /**
  29086. * The vertical blur PostProcess id in the pipeline
  29087. * @type {string}
  29088. */
  29089. SSAOBlurVRenderEffect: string;
  29090. /**
  29091. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  29092. * @type {string}
  29093. */
  29094. SSAOCombineRenderEffect: string;
  29095. /**
  29096. * The output strength of the SSAO post-process. Default value is 1.0.
  29097. * @type {number}
  29098. */
  29099. totalStrength: number;
  29100. /**
  29101. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  29102. * @type {number}
  29103. */
  29104. radius: number;
  29105. /**
  29106. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  29107. * Must not be equal to fallOff and superior to fallOff.
  29108. * Default value is 0.975
  29109. * @type {number}
  29110. */
  29111. area: number;
  29112. /**
  29113. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  29114. * Must not be equal to area and inferior to area.
  29115. * Default value is 0.0
  29116. * @type {number}
  29117. */
  29118. fallOff: number;
  29119. /**
  29120. * The base color of the SSAO post-process
  29121. * The final result is "base + ssao" between [0, 1]
  29122. * @type {number}
  29123. */
  29124. base: number;
  29125. private _scene;
  29126. private _depthTexture;
  29127. private _randomTexture;
  29128. private _originalColorPostProcess;
  29129. private _ssaoPostProcess;
  29130. private _blurHPostProcess;
  29131. private _blurVPostProcess;
  29132. private _ssaoCombinePostProcess;
  29133. private _firstUpdate;
  29134. /**
  29135. * @constructor
  29136. * @param {string} name - The rendering pipeline name
  29137. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  29138. * @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 }
  29139. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  29140. */
  29141. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  29142. /**
  29143. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  29144. */
  29145. dispose(disableDepthRender?: boolean): void;
  29146. private _createBlurPostProcess(ratio);
  29147. _rebuild(): void;
  29148. private _createSSAOPostProcess(ratio);
  29149. private _createSSAOCombinePostProcess(ratio);
  29150. private _createRandomTexture();
  29151. }
  29152. }
  29153. declare module BABYLON {
  29154. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  29155. /**
  29156. * Public members
  29157. */
  29158. originalPostProcess: Nullable<PostProcess>;
  29159. downSampleX4PostProcess: Nullable<PostProcess>;
  29160. brightPassPostProcess: Nullable<PostProcess>;
  29161. blurHPostProcesses: PostProcess[];
  29162. blurVPostProcesses: PostProcess[];
  29163. textureAdderPostProcess: Nullable<PostProcess>;
  29164. volumetricLightPostProcess: Nullable<PostProcess>;
  29165. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  29166. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  29167. volumetricLightMergePostProces: Nullable<PostProcess>;
  29168. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  29169. luminancePostProcess: Nullable<PostProcess>;
  29170. luminanceDownSamplePostProcesses: PostProcess[];
  29171. hdrPostProcess: Nullable<PostProcess>;
  29172. textureAdderFinalPostProcess: Nullable<PostProcess>;
  29173. lensFlareFinalPostProcess: Nullable<PostProcess>;
  29174. hdrFinalPostProcess: Nullable<PostProcess>;
  29175. lensFlarePostProcess: Nullable<PostProcess>;
  29176. lensFlareComposePostProcess: Nullable<PostProcess>;
  29177. motionBlurPostProcess: Nullable<PostProcess>;
  29178. depthOfFieldPostProcess: Nullable<PostProcess>;
  29179. brightThreshold: number;
  29180. blurWidth: number;
  29181. horizontalBlur: boolean;
  29182. exposure: number;
  29183. lensTexture: Nullable<Texture>;
  29184. volumetricLightCoefficient: number;
  29185. volumetricLightPower: number;
  29186. volumetricLightBlurScale: number;
  29187. sourceLight: Nullable<SpotLight | DirectionalLight>;
  29188. hdrMinimumLuminance: number;
  29189. hdrDecreaseRate: number;
  29190. hdrIncreaseRate: number;
  29191. lensColorTexture: Nullable<Texture>;
  29192. lensFlareStrength: number;
  29193. lensFlareGhostDispersal: number;
  29194. lensFlareHaloWidth: number;
  29195. lensFlareDistortionStrength: number;
  29196. lensStarTexture: Nullable<Texture>;
  29197. lensFlareDirtTexture: Nullable<Texture>;
  29198. depthOfFieldDistance: number;
  29199. depthOfFieldBlurWidth: number;
  29200. motionStrength: number;
  29201. animations: Animation[];
  29202. /**
  29203. * Private members
  29204. */
  29205. private _scene;
  29206. private _currentDepthOfFieldSource;
  29207. private _basePostProcess;
  29208. private _hdrCurrentLuminance;
  29209. private _floatTextureType;
  29210. private _ratio;
  29211. private _bloomEnabled;
  29212. private _depthOfFieldEnabled;
  29213. private _vlsEnabled;
  29214. private _lensFlareEnabled;
  29215. private _hdrEnabled;
  29216. private _motionBlurEnabled;
  29217. private _motionBlurSamples;
  29218. private _volumetricLightStepsCount;
  29219. BloomEnabled: boolean;
  29220. DepthOfFieldEnabled: boolean;
  29221. LensFlareEnabled: boolean;
  29222. HDREnabled: boolean;
  29223. VLSEnabled: boolean;
  29224. MotionBlurEnabled: boolean;
  29225. volumetricLightStepsCount: number;
  29226. motionBlurSamples: number;
  29227. /**
  29228. * @constructor
  29229. * @param {string} name - The rendering pipeline name
  29230. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  29231. * @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)
  29232. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  29233. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  29234. */
  29235. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  29236. private _buildPipeline();
  29237. private _createDownSampleX4PostProcess(scene, ratio);
  29238. private _createBrightPassPostProcess(scene, ratio);
  29239. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  29240. private _createTextureAdderPostProcess(scene, ratio);
  29241. private _createVolumetricLightPostProcess(scene, ratio);
  29242. private _createLuminancePostProcesses(scene, textureType);
  29243. private _createHdrPostProcess(scene, ratio);
  29244. private _createLensFlarePostProcess(scene, ratio);
  29245. private _createDepthOfFieldPostProcess(scene, ratio);
  29246. private _createMotionBlurPostProcess(scene, ratio);
  29247. private _getDepthTexture();
  29248. private _disposePostProcesses();
  29249. dispose(): void;
  29250. serialize(): any;
  29251. /**
  29252. * Static members
  29253. */
  29254. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  29255. static LuminanceSteps: number;
  29256. }
  29257. }