documentation.d.ts 3.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */
  110. _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * 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.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * 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).
  161. * 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.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @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.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Extracts text content from a DOM element hierarchy
  283. * @param element defines the root element
  284. * @returns a string
  285. */
  286. static GetDOMTextContent(element: HTMLElement): string;
  287. }
  288. }
  289. declare module BABYLON {
  290. /**
  291. * Logger used througouht the application to allow configuration of
  292. * the log level required for the messages.
  293. */
  294. export class Logger {
  295. /**
  296. * No log
  297. */
  298. static readonly NoneLogLevel: number;
  299. /**
  300. * Only message logs
  301. */
  302. static readonly MessageLogLevel: number;
  303. /**
  304. * Only warning logs
  305. */
  306. static readonly WarningLogLevel: number;
  307. /**
  308. * Only error logs
  309. */
  310. static readonly ErrorLogLevel: number;
  311. /**
  312. * All logs
  313. */
  314. static readonly AllLogLevel: number;
  315. private static _LogCache;
  316. /**
  317. * Gets a value indicating the number of loading errors
  318. * @ignorenaming
  319. */
  320. static errorsCount: number;
  321. /**
  322. * Callback called when a new log is added
  323. */
  324. static OnNewCacheEntry: (entry: string) => void;
  325. private static _AddLogEntry;
  326. private static _FormatMessage;
  327. private static _LogDisabled;
  328. private static _LogEnabled;
  329. private static _WarnDisabled;
  330. private static _WarnEnabled;
  331. private static _ErrorDisabled;
  332. private static _ErrorEnabled;
  333. /**
  334. * Log a message to the console
  335. */
  336. static Log: (message: string) => void;
  337. /**
  338. * Write a warning message to the console
  339. */
  340. static Warn: (message: string) => void;
  341. /**
  342. * Write an error message to the console
  343. */
  344. static Error: (message: string) => void;
  345. /**
  346. * Gets current log cache (list of logs)
  347. */
  348. static readonly LogCache: string;
  349. /**
  350. * Clears the log cache
  351. */
  352. static ClearLogCache(): void;
  353. /**
  354. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  355. */
  356. static LogLevels: number;
  357. }
  358. }
  359. declare module BABYLON {
  360. /** @hidden */
  361. export class _TypeStore {
  362. /** @hidden */
  363. static RegisteredTypes: {
  364. [key: string]: Object;
  365. };
  366. /** @hidden */
  367. static GetClass(fqdn: string): any;
  368. }
  369. }
  370. declare module BABYLON {
  371. /**
  372. * Class containing a set of static utilities functions for deep copy.
  373. */
  374. export class DeepCopier {
  375. /**
  376. * Tries to copy an object by duplicating every property
  377. * @param source defines the source object
  378. * @param destination defines the target object
  379. * @param doNotCopyList defines a list of properties to avoid
  380. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  381. */
  382. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  383. }
  384. }
  385. declare module BABYLON {
  386. /**
  387. * Class containing a set of static utilities functions for precision date
  388. */
  389. export class PrecisionDate {
  390. /**
  391. * Gets either window.performance.now() if supported or Date.now() else
  392. */
  393. static readonly Now: number;
  394. }
  395. }
  396. declare module BABYLON {
  397. /** @hidden */
  398. export class _DevTools {
  399. static WarnImport(name: string): string;
  400. }
  401. }
  402. declare module BABYLON {
  403. /**
  404. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  405. */
  406. export class WebRequest {
  407. private _xhr;
  408. /**
  409. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  410. * i.e. when loading files, where the server/service expects an Authorization header
  411. */
  412. static CustomRequestHeaders: {
  413. [key: string]: string;
  414. };
  415. /**
  416. * Add callback functions in this array to update all the requests before they get sent to the network
  417. */
  418. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  419. private _injectCustomRequestHeaders;
  420. /**
  421. * Gets or sets a function to be called when loading progress changes
  422. */
  423. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  424. /**
  425. * Returns client's state
  426. */
  427. readonly readyState: number;
  428. /**
  429. * Returns client's status
  430. */
  431. readonly status: number;
  432. /**
  433. * Returns client's status as a text
  434. */
  435. readonly statusText: string;
  436. /**
  437. * Returns client's response
  438. */
  439. readonly response: any;
  440. /**
  441. * Returns client's response url
  442. */
  443. readonly responseURL: string;
  444. /**
  445. * Returns client's response as text
  446. */
  447. readonly responseText: string;
  448. /**
  449. * Gets or sets the expected response type
  450. */
  451. responseType: XMLHttpRequestResponseType;
  452. /** @hidden */
  453. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  454. /** @hidden */
  455. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  456. /**
  457. * Cancels any network activity
  458. */
  459. abort(): void;
  460. /**
  461. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  462. * @param body defines an optional request body
  463. */
  464. send(body?: Document | BodyInit | null): void;
  465. /**
  466. * Sets the request method, request URL
  467. * @param method defines the method to use (GET, POST, etc..)
  468. * @param url defines the url to connect with
  469. */
  470. open(method: string, url: string): void;
  471. }
  472. }
  473. declare module BABYLON {
  474. /**
  475. * File request interface
  476. */
  477. export interface IFileRequest {
  478. /**
  479. * Raised when the request is complete (success or error).
  480. */
  481. onCompleteObservable: Observable<IFileRequest>;
  482. /**
  483. * Aborts the request for a file.
  484. */
  485. abort: () => void;
  486. }
  487. }
  488. declare module BABYLON {
  489. /**
  490. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  491. */
  492. export class PerformanceMonitor {
  493. private _enabled;
  494. private _rollingFrameTime;
  495. private _lastFrameTimeMs;
  496. /**
  497. * constructor
  498. * @param frameSampleSize The number of samples required to saturate the sliding window
  499. */
  500. constructor(frameSampleSize?: number);
  501. /**
  502. * Samples current frame
  503. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  504. */
  505. sampleFrame(timeMs?: number): void;
  506. /**
  507. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  508. */
  509. readonly averageFrameTime: number;
  510. /**
  511. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  512. */
  513. readonly averageFrameTimeVariance: number;
  514. /**
  515. * Returns the frame time of the most recent frame
  516. */
  517. readonly instantaneousFrameTime: number;
  518. /**
  519. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  520. */
  521. readonly averageFPS: number;
  522. /**
  523. * Returns the average framerate in frames per second using the most recent frame time
  524. */
  525. readonly instantaneousFPS: number;
  526. /**
  527. * Returns true if enough samples have been taken to completely fill the sliding window
  528. */
  529. readonly isSaturated: boolean;
  530. /**
  531. * Enables contributions to the sliding window sample set
  532. */
  533. enable(): void;
  534. /**
  535. * Disables contributions to the sliding window sample set
  536. * Samples will not be interpolated over the disabled period
  537. */
  538. disable(): void;
  539. /**
  540. * Returns true if sampling is enabled
  541. */
  542. readonly isEnabled: boolean;
  543. /**
  544. * Resets performance monitor
  545. */
  546. reset(): void;
  547. }
  548. /**
  549. * RollingAverage
  550. *
  551. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  552. */
  553. export class RollingAverage {
  554. /**
  555. * Current average
  556. */
  557. average: number;
  558. /**
  559. * Current variance
  560. */
  561. variance: number;
  562. protected _samples: Array<number>;
  563. protected _sampleCount: number;
  564. protected _pos: number;
  565. protected _m2: number;
  566. /**
  567. * constructor
  568. * @param length The number of samples required to saturate the sliding window
  569. */
  570. constructor(length: number);
  571. /**
  572. * Adds a sample to the sample set
  573. * @param v The sample value
  574. */
  575. add(v: number): void;
  576. /**
  577. * Returns previously added values or null if outside of history or outside the sliding window domain
  578. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  579. * @return Value previously recorded with add() or null if outside of range
  580. */
  581. history(i: number): number;
  582. /**
  583. * Returns true if enough samples have been taken to completely fill the sliding window
  584. * @return true if sample-set saturated
  585. */
  586. isSaturated(): boolean;
  587. /**
  588. * Resets the rolling average (equivalent to 0 samples taken so far)
  589. */
  590. reset(): void;
  591. /**
  592. * Wraps a value around the sample range boundaries
  593. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  594. * @return Wrapped position in sample range
  595. */
  596. protected _wrapPosition(i: number): number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /**
  601. * This class implement a typical dictionary using a string as key and the generic type T as value.
  602. * The underlying implementation relies on an associative array to ensure the best performances.
  603. * The value can be anything including 'null' but except 'undefined'
  604. */
  605. export class StringDictionary<T> {
  606. /**
  607. * This will clear this dictionary and copy the content from the 'source' one.
  608. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  609. * @param source the dictionary to take the content from and copy to this dictionary
  610. */
  611. copyFrom(source: StringDictionary<T>): void;
  612. /**
  613. * Get a value based from its key
  614. * @param key the given key to get the matching value from
  615. * @return the value if found, otherwise undefined is returned
  616. */
  617. get(key: string): T | undefined;
  618. /**
  619. * Get a value from its key or add it if it doesn't exist.
  620. * This method will ensure you that a given key/data will be present in the dictionary.
  621. * @param key the given key to get the matching value from
  622. * @param factory the factory that will create the value if the key is not present in the dictionary.
  623. * The factory will only be invoked if there's no data for the given key.
  624. * @return the value corresponding to the key.
  625. */
  626. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  627. /**
  628. * Get a value from its key if present in the dictionary otherwise add it
  629. * @param key the key to get the value from
  630. * @param val if there's no such key/value pair in the dictionary add it with this value
  631. * @return the value corresponding to the key
  632. */
  633. getOrAdd(key: string, val: T): T;
  634. /**
  635. * Check if there's a given key in the dictionary
  636. * @param key the key to check for
  637. * @return true if the key is present, false otherwise
  638. */
  639. contains(key: string): boolean;
  640. /**
  641. * Add a new key and its corresponding value
  642. * @param key the key to add
  643. * @param value the value corresponding to the key
  644. * @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
  645. */
  646. add(key: string, value: T): boolean;
  647. /**
  648. * Update a specific value associated to a key
  649. * @param key defines the key to use
  650. * @param value defines the value to store
  651. * @returns true if the value was updated (or false if the key was not found)
  652. */
  653. set(key: string, value: T): boolean;
  654. /**
  655. * Get the element of the given key and remove it from the dictionary
  656. * @param key defines the key to search
  657. * @returns the value associated with the key or null if not found
  658. */
  659. getAndRemove(key: string): Nullable<T>;
  660. /**
  661. * Remove a key/value from the dictionary.
  662. * @param key the key to remove
  663. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  664. */
  665. remove(key: string): boolean;
  666. /**
  667. * Clear the whole content of the dictionary
  668. */
  669. clear(): void;
  670. /**
  671. * Gets the current count
  672. */
  673. readonly count: number;
  674. /**
  675. * Execute a callback on each key/val of the dictionary.
  676. * Note that you can remove any element in this dictionary in the callback implementation
  677. * @param callback the callback to execute on a given key/value pair
  678. */
  679. forEach(callback: (key: string, val: T) => void): void;
  680. /**
  681. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  682. * If the callback returns null or undefined the method will iterate to the next key/value pair
  683. * Note that you can remove any element in this dictionary in the callback implementation
  684. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  685. * @returns the first item
  686. */
  687. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  688. private _count;
  689. private _data;
  690. }
  691. }
  692. declare module BABYLON {
  693. /**
  694. * Class used to store gfx data (like WebGLBuffer)
  695. */
  696. export class DataBuffer {
  697. /**
  698. * Gets or sets the number of objects referencing this buffer
  699. */
  700. references: number;
  701. /** Gets or sets the size of the underlying buffer */
  702. capacity: number;
  703. /**
  704. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  705. */
  706. is32Bits: boolean;
  707. /**
  708. * Gets the underlying buffer
  709. */
  710. readonly underlyingResource: any;
  711. }
  712. }
  713. declare module BABYLON {
  714. /**
  715. * Class used to store data that will be store in GPU memory
  716. */
  717. export class Buffer {
  718. private _engine;
  719. private _buffer;
  720. /** @hidden */
  721. _data: Nullable<DataArray>;
  722. private _updatable;
  723. private _instanced;
  724. /**
  725. * Gets the byte stride.
  726. */
  727. readonly byteStride: number;
  728. /**
  729. * Constructor
  730. * @param engine the engine
  731. * @param data the data to use for this buffer
  732. * @param updatable whether the data is updatable
  733. * @param stride the stride (optional)
  734. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  735. * @param instanced whether the buffer is instanced (optional)
  736. * @param useBytes set to true if the stride in in bytes (optional)
  737. */
  738. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  739. /**
  740. * Create a new VertexBuffer based on the current buffer
  741. * @param kind defines the vertex buffer kind (position, normal, etc.)
  742. * @param offset defines offset in the buffer (0 by default)
  743. * @param size defines the size in floats of attributes (position is 3 for instance)
  744. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  745. * @param instanced defines if the vertex buffer contains indexed data
  746. * @param useBytes defines if the offset and stride are in bytes
  747. * @returns the new vertex buffer
  748. */
  749. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  750. /**
  751. * Gets a boolean indicating if the Buffer is updatable?
  752. * @returns true if the buffer is updatable
  753. */
  754. isUpdatable(): boolean;
  755. /**
  756. * Gets current buffer's data
  757. * @returns a DataArray or null
  758. */
  759. getData(): Nullable<DataArray>;
  760. /**
  761. * Gets underlying native buffer
  762. * @returns underlying native buffer
  763. */
  764. getBuffer(): Nullable<DataBuffer>;
  765. /**
  766. * Gets the stride in float32 units (i.e. byte stride / 4).
  767. * May not be an integer if the byte stride is not divisible by 4.
  768. * DEPRECATED. Use byteStride instead.
  769. * @returns the stride in float32 units
  770. */
  771. getStrideSize(): number;
  772. /**
  773. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  774. * @param data defines the data to store
  775. */
  776. create(data?: Nullable<DataArray>): void;
  777. /** @hidden */
  778. _rebuild(): void;
  779. /**
  780. * Update current buffer data
  781. * @param data defines the data to store
  782. */
  783. update(data: DataArray): void;
  784. /**
  785. * Updates the data directly.
  786. * @param data the new data
  787. * @param offset the new offset
  788. * @param vertexCount the vertex count (optional)
  789. * @param useBytes set to true if the offset is in bytes
  790. */
  791. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  792. /**
  793. * Release all resources
  794. */
  795. dispose(): void;
  796. }
  797. /**
  798. * Specialized buffer used to store vertex data
  799. */
  800. export class VertexBuffer {
  801. /** @hidden */
  802. _buffer: Buffer;
  803. private _kind;
  804. private _size;
  805. private _ownsBuffer;
  806. private _instanced;
  807. private _instanceDivisor;
  808. /**
  809. * The byte type.
  810. */
  811. static readonly BYTE: number;
  812. /**
  813. * The unsigned byte type.
  814. */
  815. static readonly UNSIGNED_BYTE: number;
  816. /**
  817. * The short type.
  818. */
  819. static readonly SHORT: number;
  820. /**
  821. * The unsigned short type.
  822. */
  823. static readonly UNSIGNED_SHORT: number;
  824. /**
  825. * The integer type.
  826. */
  827. static readonly INT: number;
  828. /**
  829. * The unsigned integer type.
  830. */
  831. static readonly UNSIGNED_INT: number;
  832. /**
  833. * The float type.
  834. */
  835. static readonly FLOAT: number;
  836. /**
  837. * Gets or sets the instance divisor when in instanced mode
  838. */
  839. instanceDivisor: number;
  840. /**
  841. * Gets the byte stride.
  842. */
  843. readonly byteStride: number;
  844. /**
  845. * Gets the byte offset.
  846. */
  847. readonly byteOffset: number;
  848. /**
  849. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  850. */
  851. readonly normalized: boolean;
  852. /**
  853. * Gets the data type of each component in the array.
  854. */
  855. readonly type: number;
  856. /**
  857. * Constructor
  858. * @param engine the engine
  859. * @param data the data to use for this vertex buffer
  860. * @param kind the vertex buffer kind
  861. * @param updatable whether the data is updatable
  862. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  863. * @param stride the stride (optional)
  864. * @param instanced whether the buffer is instanced (optional)
  865. * @param offset the offset of the data (optional)
  866. * @param size the number of components (optional)
  867. * @param type the type of the component (optional)
  868. * @param normalized whether the data contains normalized data (optional)
  869. * @param useBytes set to true if stride and offset are in bytes (optional)
  870. */
  871. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  872. /** @hidden */
  873. _rebuild(): void;
  874. /**
  875. * Returns the kind of the VertexBuffer (string)
  876. * @returns a string
  877. */
  878. getKind(): string;
  879. /**
  880. * Gets a boolean indicating if the VertexBuffer is updatable?
  881. * @returns true if the buffer is updatable
  882. */
  883. isUpdatable(): boolean;
  884. /**
  885. * Gets current buffer's data
  886. * @returns a DataArray or null
  887. */
  888. getData(): Nullable<DataArray>;
  889. /**
  890. * Gets underlying native buffer
  891. * @returns underlying native buffer
  892. */
  893. getBuffer(): Nullable<DataBuffer>;
  894. /**
  895. * Gets the stride in float32 units (i.e. byte stride / 4).
  896. * May not be an integer if the byte stride is not divisible by 4.
  897. * DEPRECATED. Use byteStride instead.
  898. * @returns the stride in float32 units
  899. */
  900. getStrideSize(): number;
  901. /**
  902. * Returns the offset as a multiple of the type byte length.
  903. * DEPRECATED. Use byteOffset instead.
  904. * @returns the offset in bytes
  905. */
  906. getOffset(): number;
  907. /**
  908. * Returns the number of components per vertex attribute (integer)
  909. * @returns the size in float
  910. */
  911. getSize(): number;
  912. /**
  913. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  914. * @returns true if this buffer is instanced
  915. */
  916. getIsInstanced(): boolean;
  917. /**
  918. * Returns the instancing divisor, zero for non-instanced (integer).
  919. * @returns a number
  920. */
  921. getInstanceDivisor(): number;
  922. /**
  923. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  924. * @param data defines the data to store
  925. */
  926. create(data?: DataArray): void;
  927. /**
  928. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  929. * This function will create a new buffer if the current one is not updatable
  930. * @param data defines the data to store
  931. */
  932. update(data: DataArray): void;
  933. /**
  934. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  935. * Returns the directly updated WebGLBuffer.
  936. * @param data the new data
  937. * @param offset the new offset
  938. * @param useBytes set to true if the offset is in bytes
  939. */
  940. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  941. /**
  942. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  943. */
  944. dispose(): void;
  945. /**
  946. * Enumerates each value of this vertex buffer as numbers.
  947. * @param count the number of values to enumerate
  948. * @param callback the callback function called for each value
  949. */
  950. forEach(count: number, callback: (value: number, index: number) => void): void;
  951. /**
  952. * Positions
  953. */
  954. static readonly PositionKind: string;
  955. /**
  956. * Normals
  957. */
  958. static readonly NormalKind: string;
  959. /**
  960. * Tangents
  961. */
  962. static readonly TangentKind: string;
  963. /**
  964. * Texture coordinates
  965. */
  966. static readonly UVKind: string;
  967. /**
  968. * Texture coordinates 2
  969. */
  970. static readonly UV2Kind: string;
  971. /**
  972. * Texture coordinates 3
  973. */
  974. static readonly UV3Kind: string;
  975. /**
  976. * Texture coordinates 4
  977. */
  978. static readonly UV4Kind: string;
  979. /**
  980. * Texture coordinates 5
  981. */
  982. static readonly UV5Kind: string;
  983. /**
  984. * Texture coordinates 6
  985. */
  986. static readonly UV6Kind: string;
  987. /**
  988. * Colors
  989. */
  990. static readonly ColorKind: string;
  991. /**
  992. * Matrix indices (for bones)
  993. */
  994. static readonly MatricesIndicesKind: string;
  995. /**
  996. * Matrix weights (for bones)
  997. */
  998. static readonly MatricesWeightsKind: string;
  999. /**
  1000. * Additional matrix indices (for bones)
  1001. */
  1002. static readonly MatricesIndicesExtraKind: string;
  1003. /**
  1004. * Additional matrix weights (for bones)
  1005. */
  1006. static readonly MatricesWeightsExtraKind: string;
  1007. /**
  1008. * Deduces the stride given a kind.
  1009. * @param kind The kind string to deduce
  1010. * @returns The deduced stride
  1011. */
  1012. static DeduceStride(kind: string): number;
  1013. /**
  1014. * Gets the byte length of the given type.
  1015. * @param type the type
  1016. * @returns the number of bytes
  1017. */
  1018. static GetTypeByteLength(type: number): number;
  1019. /**
  1020. * Enumerates each value of the given parameters as numbers.
  1021. * @param data the data to enumerate
  1022. * @param byteOffset the byte offset of the data
  1023. * @param byteStride the byte stride of the data
  1024. * @param componentCount the number of components per element
  1025. * @param componentType the type of the component
  1026. * @param count the number of values to enumerate
  1027. * @param normalized whether the data is normalized
  1028. * @param callback the callback function called for each value
  1029. */
  1030. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1031. private static _GetFloatValue;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * Scalar computation library
  1037. */
  1038. export class Scalar {
  1039. /**
  1040. * Two pi constants convenient for computation.
  1041. */
  1042. static TwoPi: number;
  1043. /**
  1044. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1045. * @param a number
  1046. * @param b number
  1047. * @param epsilon (default = 1.401298E-45)
  1048. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1049. */
  1050. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1051. /**
  1052. * Returns a string : the upper case translation of the number i to hexadecimal.
  1053. * @param i number
  1054. * @returns the upper case translation of the number i to hexadecimal.
  1055. */
  1056. static ToHex(i: number): string;
  1057. /**
  1058. * Returns -1 if value is negative and +1 is value is positive.
  1059. * @param value the value
  1060. * @returns the value itself if it's equal to zero.
  1061. */
  1062. static Sign(value: number): number;
  1063. /**
  1064. * Returns the value itself if it's between min and max.
  1065. * Returns min if the value is lower than min.
  1066. * Returns max if the value is greater than max.
  1067. * @param value the value to clmap
  1068. * @param min the min value to clamp to (default: 0)
  1069. * @param max the max value to clamp to (default: 1)
  1070. * @returns the clamped value
  1071. */
  1072. static Clamp(value: number, min?: number, max?: number): number;
  1073. /**
  1074. * the log2 of value.
  1075. * @param value the value to compute log2 of
  1076. * @returns the log2 of value.
  1077. */
  1078. static Log2(value: number): number;
  1079. /**
  1080. * Loops the value, so that it is never larger than length and never smaller than 0.
  1081. *
  1082. * This is similar to the modulo operator but it works with floating point numbers.
  1083. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1084. * With t = 5 and length = 2.5, the result would be 0.0.
  1085. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1086. * @param value the value
  1087. * @param length the length
  1088. * @returns the looped value
  1089. */
  1090. static Repeat(value: number, length: number): number;
  1091. /**
  1092. * Normalize the value between 0.0 and 1.0 using min and max values
  1093. * @param value value to normalize
  1094. * @param min max to normalize between
  1095. * @param max min to normalize between
  1096. * @returns the normalized value
  1097. */
  1098. static Normalize(value: number, min: number, max: number): number;
  1099. /**
  1100. * Denormalize the value from 0.0 and 1.0 using min and max values
  1101. * @param normalized value to denormalize
  1102. * @param min max to denormalize between
  1103. * @param max min to denormalize between
  1104. * @returns the denormalized value
  1105. */
  1106. static Denormalize(normalized: number, min: number, max: number): number;
  1107. /**
  1108. * Calculates the shortest difference between two given angles given in degrees.
  1109. * @param current current angle in degrees
  1110. * @param target target angle in degrees
  1111. * @returns the delta
  1112. */
  1113. static DeltaAngle(current: number, target: number): number;
  1114. /**
  1115. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1116. * @param tx value
  1117. * @param length length
  1118. * @returns The returned value will move back and forth between 0 and length
  1119. */
  1120. static PingPong(tx: number, length: number): number;
  1121. /**
  1122. * Interpolates between min and max with smoothing at the limits.
  1123. *
  1124. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1125. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1126. * @param from from
  1127. * @param to to
  1128. * @param tx value
  1129. * @returns the smooth stepped value
  1130. */
  1131. static SmoothStep(from: number, to: number, tx: number): number;
  1132. /**
  1133. * Moves a value current towards target.
  1134. *
  1135. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1136. * Negative values of maxDelta pushes the value away from target.
  1137. * @param current current value
  1138. * @param target target value
  1139. * @param maxDelta max distance to move
  1140. * @returns resulting value
  1141. */
  1142. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1143. /**
  1144. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1145. *
  1146. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1147. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1148. * @param current current value
  1149. * @param target target value
  1150. * @param maxDelta max distance to move
  1151. * @returns resulting angle
  1152. */
  1153. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1154. /**
  1155. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1156. * @param start start value
  1157. * @param end target value
  1158. * @param amount amount to lerp between
  1159. * @returns the lerped value
  1160. */
  1161. static Lerp(start: number, end: number, amount: number): number;
  1162. /**
  1163. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1164. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1165. * @param start start value
  1166. * @param end target value
  1167. * @param amount amount to lerp between
  1168. * @returns the lerped value
  1169. */
  1170. static LerpAngle(start: number, end: number, amount: number): number;
  1171. /**
  1172. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1173. * @param a start value
  1174. * @param b target value
  1175. * @param value value between a and b
  1176. * @returns the inverseLerp value
  1177. */
  1178. static InverseLerp(a: number, b: number, value: number): number;
  1179. /**
  1180. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1181. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1182. * @param value1 spline value
  1183. * @param tangent1 spline value
  1184. * @param value2 spline value
  1185. * @param tangent2 spline value
  1186. * @param amount input value
  1187. * @returns hermite result
  1188. */
  1189. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1190. /**
  1191. * Returns a random float number between and min and max values
  1192. * @param min min value of random
  1193. * @param max max value of random
  1194. * @returns random value
  1195. */
  1196. static RandomRange(min: number, max: number): number;
  1197. /**
  1198. * This function returns percentage of a number in a given range.
  1199. *
  1200. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1201. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1202. * @param number to convert to percentage
  1203. * @param min min range
  1204. * @param max max range
  1205. * @returns the percentage
  1206. */
  1207. static RangeToPercent(number: number, min: number, max: number): number;
  1208. /**
  1209. * This function returns number that corresponds to the percentage in a given range.
  1210. *
  1211. * PercentToRange(0.34,0,100) will return 34.
  1212. * @param percent to convert to number
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the number
  1216. */
  1217. static PercentToRange(percent: number, min: number, max: number): number;
  1218. /**
  1219. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1220. * @param angle The angle to normalize in radian.
  1221. * @return The converted angle.
  1222. */
  1223. static NormalizeRadians(angle: number): number;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /**
  1228. * Constant used to convert a value to gamma space
  1229. * @ignorenaming
  1230. */
  1231. export const ToGammaSpace: number;
  1232. /**
  1233. * Constant used to convert a value to linear space
  1234. * @ignorenaming
  1235. */
  1236. export const ToLinearSpace = 2.2;
  1237. /**
  1238. * Constant used to define the minimal number value in Babylon.js
  1239. * @ignorenaming
  1240. */
  1241. let Epsilon: number;
  1242. }
  1243. declare module BABYLON {
  1244. /**
  1245. * Class used to represent a viewport on screen
  1246. */
  1247. export class Viewport {
  1248. /** viewport left coordinate */
  1249. x: number;
  1250. /** viewport top coordinate */
  1251. y: number;
  1252. /**viewport width */
  1253. width: number;
  1254. /** viewport height */
  1255. height: number;
  1256. /**
  1257. * Creates a Viewport object located at (x, y) and sized (width, height)
  1258. * @param x defines viewport left coordinate
  1259. * @param y defines viewport top coordinate
  1260. * @param width defines the viewport width
  1261. * @param height defines the viewport height
  1262. */
  1263. constructor(
  1264. /** viewport left coordinate */
  1265. x: number,
  1266. /** viewport top coordinate */
  1267. y: number,
  1268. /**viewport width */
  1269. width: number,
  1270. /** viewport height */
  1271. height: number);
  1272. /**
  1273. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1274. * @param renderWidth defines the rendering width
  1275. * @param renderHeight defines the rendering height
  1276. * @returns a new Viewport
  1277. */
  1278. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1279. /**
  1280. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1281. * @param renderWidth defines the rendering width
  1282. * @param renderHeight defines the rendering height
  1283. * @param ref defines the target viewport
  1284. * @returns the current viewport
  1285. */
  1286. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1287. /**
  1288. * Returns a new Viewport copied from the current one
  1289. * @returns a new Viewport
  1290. */
  1291. clone(): Viewport;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class containing a set of static utilities functions for arrays.
  1297. */
  1298. export class ArrayTools {
  1299. /**
  1300. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1301. * @param size the number of element to construct and put in the array
  1302. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1303. * @returns a new array filled with new objects
  1304. */
  1305. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * @hidden
  1311. */
  1312. export interface IColor4Like {
  1313. r: float;
  1314. g: float;
  1315. b: float;
  1316. a: float;
  1317. }
  1318. /**
  1319. * @hidden
  1320. */
  1321. export interface IColor3Like {
  1322. r: float;
  1323. g: float;
  1324. b: float;
  1325. }
  1326. /**
  1327. * @hidden
  1328. */
  1329. export interface IVector4Like {
  1330. x: float;
  1331. y: float;
  1332. z: float;
  1333. w: float;
  1334. }
  1335. /**
  1336. * @hidden
  1337. */
  1338. export interface IVector3Like {
  1339. x: float;
  1340. y: float;
  1341. z: float;
  1342. }
  1343. /**
  1344. * @hidden
  1345. */
  1346. export interface IVector2Like {
  1347. x: float;
  1348. y: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IMatrixLike {
  1354. toArray(): DeepImmutable<Float32Array>;
  1355. updateFlag: int;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IViewportLike {
  1361. x: float;
  1362. y: float;
  1363. width: float;
  1364. height: float;
  1365. }
  1366. /**
  1367. * @hidden
  1368. */
  1369. export interface IPlaneLike {
  1370. normal: IVector3Like;
  1371. d: float;
  1372. normalize(): void;
  1373. }
  1374. }
  1375. declare module BABYLON {
  1376. /**
  1377. * Class representing a vector containing 2 coordinates
  1378. */
  1379. export class Vector2 {
  1380. /** defines the first coordinate */
  1381. x: number;
  1382. /** defines the second coordinate */
  1383. y: number;
  1384. /**
  1385. * Creates a new Vector2 from the given x and y coordinates
  1386. * @param x defines the first coordinate
  1387. * @param y defines the second coordinate
  1388. */
  1389. constructor(
  1390. /** defines the first coordinate */
  1391. x?: number,
  1392. /** defines the second coordinate */
  1393. y?: number);
  1394. /**
  1395. * Gets a string with the Vector2 coordinates
  1396. * @returns a string with the Vector2 coordinates
  1397. */
  1398. toString(): string;
  1399. /**
  1400. * Gets class name
  1401. * @returns the string "Vector2"
  1402. */
  1403. getClassName(): string;
  1404. /**
  1405. * Gets current vector hash code
  1406. * @returns the Vector2 hash code as a number
  1407. */
  1408. getHashCode(): number;
  1409. /**
  1410. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1411. * @param array defines the source array
  1412. * @param index defines the offset in source array
  1413. * @returns the current Vector2
  1414. */
  1415. toArray(array: FloatArray, index?: number): Vector2;
  1416. /**
  1417. * Copy the current vector to an array
  1418. * @returns a new array with 2 elements: the Vector2 coordinates.
  1419. */
  1420. asArray(): number[];
  1421. /**
  1422. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1423. * @param source defines the source Vector2
  1424. * @returns the current updated Vector2
  1425. */
  1426. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1427. /**
  1428. * Sets the Vector2 coordinates with the given floats
  1429. * @param x defines the first coordinate
  1430. * @param y defines the second coordinate
  1431. * @returns the current updated Vector2
  1432. */
  1433. copyFromFloats(x: number, y: number): Vector2;
  1434. /**
  1435. * Sets the Vector2 coordinates with the given floats
  1436. * @param x defines the first coordinate
  1437. * @param y defines the second coordinate
  1438. * @returns the current updated Vector2
  1439. */
  1440. set(x: number, y: number): Vector2;
  1441. /**
  1442. * Add another vector with the current one
  1443. * @param otherVector defines the other vector
  1444. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1445. */
  1446. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1447. /**
  1448. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1449. * @param otherVector defines the other vector
  1450. * @param result defines the target vector
  1451. * @returns the unmodified current Vector2
  1452. */
  1453. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1454. /**
  1455. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1456. * @param otherVector defines the other vector
  1457. * @returns the current updated Vector2
  1458. */
  1459. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1460. /**
  1461. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1462. * @param otherVector defines the other vector
  1463. * @returns a new Vector2
  1464. */
  1465. addVector3(otherVector: Vector3): Vector2;
  1466. /**
  1467. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1468. * @param otherVector defines the other vector
  1469. * @returns a new Vector2
  1470. */
  1471. subtract(otherVector: Vector2): Vector2;
  1472. /**
  1473. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1474. * @param otherVector defines the other vector
  1475. * @param result defines the target vector
  1476. * @returns the unmodified current Vector2
  1477. */
  1478. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1479. /**
  1480. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1481. * @param otherVector defines the other vector
  1482. * @returns the current updated Vector2
  1483. */
  1484. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1485. /**
  1486. * Multiplies in place the current Vector2 coordinates by the given ones
  1487. * @param otherVector defines the other vector
  1488. * @returns the current updated Vector2
  1489. */
  1490. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1491. /**
  1492. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1493. * @param otherVector defines the other vector
  1494. * @returns a new Vector2
  1495. */
  1496. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1497. /**
  1498. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1499. * @param otherVector defines the other vector
  1500. * @param result defines the target vector
  1501. * @returns the unmodified current Vector2
  1502. */
  1503. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1504. /**
  1505. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1506. * @param x defines the first coordinate
  1507. * @param y defines the second coordinate
  1508. * @returns a new Vector2
  1509. */
  1510. multiplyByFloats(x: number, y: number): Vector2;
  1511. /**
  1512. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1513. * @param otherVector defines the other vector
  1514. * @returns a new Vector2
  1515. */
  1516. divide(otherVector: Vector2): Vector2;
  1517. /**
  1518. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1519. * @param otherVector defines the other vector
  1520. * @param result defines the target vector
  1521. * @returns the unmodified current Vector2
  1522. */
  1523. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1524. /**
  1525. * Divides the current Vector2 coordinates by the given ones
  1526. * @param otherVector defines the other vector
  1527. * @returns the current updated Vector2
  1528. */
  1529. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1530. /**
  1531. * Gets a new Vector2 with current Vector2 negated coordinates
  1532. * @returns a new Vector2
  1533. */
  1534. negate(): Vector2;
  1535. /**
  1536. * Multiply the Vector2 coordinates by scale
  1537. * @param scale defines the scaling factor
  1538. * @returns the current updated Vector2
  1539. */
  1540. scaleInPlace(scale: number): Vector2;
  1541. /**
  1542. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1543. * @param scale defines the scaling factor
  1544. * @returns a new Vector2
  1545. */
  1546. scale(scale: number): Vector2;
  1547. /**
  1548. * Scale the current Vector2 values by a factor to a given Vector2
  1549. * @param scale defines the scale factor
  1550. * @param result defines the Vector2 object where to store the result
  1551. * @returns the unmodified current Vector2
  1552. */
  1553. scaleToRef(scale: number, result: Vector2): Vector2;
  1554. /**
  1555. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1556. * @param scale defines the scale factor
  1557. * @param result defines the Vector2 object where to store the result
  1558. * @returns the unmodified current Vector2
  1559. */
  1560. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1561. /**
  1562. * Gets a boolean if two vectors are equals
  1563. * @param otherVector defines the other vector
  1564. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1565. */
  1566. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1567. /**
  1568. * Gets a boolean if two vectors are equals (using an epsilon value)
  1569. * @param otherVector defines the other vector
  1570. * @param epsilon defines the minimal distance to consider equality
  1571. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1572. */
  1573. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1574. /**
  1575. * Gets a new Vector2 from current Vector2 floored values
  1576. * @returns a new Vector2
  1577. */
  1578. floor(): Vector2;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. fract(): Vector2;
  1584. /**
  1585. * Gets the length of the vector
  1586. * @returns the vector length (float)
  1587. */
  1588. length(): number;
  1589. /**
  1590. * Gets the vector squared length
  1591. * @returns the vector squared length (float)
  1592. */
  1593. lengthSquared(): number;
  1594. /**
  1595. * Normalize the vector
  1596. * @returns the current updated Vector2
  1597. */
  1598. normalize(): Vector2;
  1599. /**
  1600. * Gets a new Vector2 copied from the Vector2
  1601. * @returns a new Vector2
  1602. */
  1603. clone(): Vector2;
  1604. /**
  1605. * Gets a new Vector2(0, 0)
  1606. * @returns a new Vector2
  1607. */
  1608. static Zero(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(1, 1)
  1611. * @returns a new Vector2
  1612. */
  1613. static One(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 set from the given index element of the given array
  1616. * @param array defines the data source
  1617. * @param offset defines the offset in the data source
  1618. * @returns a new Vector2
  1619. */
  1620. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1621. /**
  1622. * Sets "result" from the given index element of the given array
  1623. * @param array defines the data source
  1624. * @param offset defines the offset in the data source
  1625. * @param result defines the target vector
  1626. */
  1627. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1628. /**
  1629. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1630. * @param value1 defines 1st point of control
  1631. * @param value2 defines 2nd point of control
  1632. * @param value3 defines 3rd point of control
  1633. * @param value4 defines 4th point of control
  1634. * @param amount defines the interpolation factor
  1635. * @returns a new Vector2
  1636. */
  1637. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1638. /**
  1639. * 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".
  1640. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1641. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1642. * @param value defines the value to clamp
  1643. * @param min defines the lower limit
  1644. * @param max defines the upper limit
  1645. * @returns a new Vector2
  1646. */
  1647. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1648. /**
  1649. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1650. * @param value1 defines the 1st control point
  1651. * @param tangent1 defines the outgoing tangent
  1652. * @param value2 defines the 2nd control point
  1653. * @param tangent2 defines the incoming tangent
  1654. * @param amount defines the interpolation factor
  1655. * @returns a new Vector2
  1656. */
  1657. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1660. * @param start defines the start vector
  1661. * @param end defines the end vector
  1662. * @param amount defines the interpolation factor
  1663. * @returns a new Vector2
  1664. */
  1665. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1666. /**
  1667. * Gets the dot product of the vector "left" and the vector "right"
  1668. * @param left defines first vector
  1669. * @param right defines second vector
  1670. * @returns the dot product (float)
  1671. */
  1672. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1673. /**
  1674. * Returns a new Vector2 equal to the normalized given vector
  1675. * @param vector defines the vector to normalize
  1676. * @returns a new Vector2
  1677. */
  1678. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1679. /**
  1680. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1681. * @param left defines 1st vector
  1682. * @param right defines 2nd vector
  1683. * @returns a new Vector2
  1684. */
  1685. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1686. /**
  1687. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1688. * @param left defines 1st vector
  1689. * @param right defines 2nd vector
  1690. * @returns a new Vector2
  1691. */
  1692. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1693. /**
  1694. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1695. * @param vector defines the vector to transform
  1696. * @param transformation defines the matrix to apply
  1697. * @returns a new Vector2
  1698. */
  1699. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1700. /**
  1701. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1702. * @param vector defines the vector to transform
  1703. * @param transformation defines the matrix to apply
  1704. * @param result defines the target vector
  1705. */
  1706. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1707. /**
  1708. * Determines if a given vector is included in a triangle
  1709. * @param p defines the vector to test
  1710. * @param p0 defines 1st triangle point
  1711. * @param p1 defines 2nd triangle point
  1712. * @param p2 defines 3rd triangle point
  1713. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1714. */
  1715. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1716. /**
  1717. * Gets the distance between the vectors "value1" and "value2"
  1718. * @param value1 defines first vector
  1719. * @param value2 defines second vector
  1720. * @returns the distance between vectors
  1721. */
  1722. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1723. /**
  1724. * Returns the squared distance between the vectors "value1" and "value2"
  1725. * @param value1 defines first vector
  1726. * @param value2 defines second vector
  1727. * @returns the squared distance between vectors
  1728. */
  1729. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1730. /**
  1731. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1732. * @param value1 defines first vector
  1733. * @param value2 defines second vector
  1734. * @returns a new Vector2
  1735. */
  1736. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1737. /**
  1738. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1739. * @param p defines the middle point
  1740. * @param segA defines one point of the segment
  1741. * @param segB defines the other point of the segment
  1742. * @returns the shortest distance
  1743. */
  1744. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1745. }
  1746. /**
  1747. * Classed used to store (x,y,z) vector representation
  1748. * A Vector3 is the main object used in 3D geometry
  1749. * It can represent etiher the coordinates of a point the space, either a direction
  1750. * Reminder: js uses a left handed forward facing system
  1751. */
  1752. export class Vector3 {
  1753. /**
  1754. * Defines the first coordinates (on X axis)
  1755. */
  1756. x: number;
  1757. /**
  1758. * Defines the second coordinates (on Y axis)
  1759. */
  1760. y: number;
  1761. /**
  1762. * Defines the third coordinates (on Z axis)
  1763. */
  1764. z: number;
  1765. private static _UpReadOnly;
  1766. private static _ZeroReadOnly;
  1767. /**
  1768. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1769. * @param x defines the first coordinates (on X axis)
  1770. * @param y defines the second coordinates (on Y axis)
  1771. * @param z defines the third coordinates (on Z axis)
  1772. */
  1773. constructor(
  1774. /**
  1775. * Defines the first coordinates (on X axis)
  1776. */
  1777. x?: number,
  1778. /**
  1779. * Defines the second coordinates (on Y axis)
  1780. */
  1781. y?: number,
  1782. /**
  1783. * Defines the third coordinates (on Z axis)
  1784. */
  1785. z?: number);
  1786. /**
  1787. * Creates a string representation of the Vector3
  1788. * @returns a string with the Vector3 coordinates.
  1789. */
  1790. toString(): string;
  1791. /**
  1792. * Gets the class name
  1793. * @returns the string "Vector3"
  1794. */
  1795. getClassName(): string;
  1796. /**
  1797. * Creates the Vector3 hash code
  1798. * @returns a number which tends to be unique between Vector3 instances
  1799. */
  1800. getHashCode(): number;
  1801. /**
  1802. * Creates an array containing three elements : the coordinates of the Vector3
  1803. * @returns a new array of numbers
  1804. */
  1805. asArray(): number[];
  1806. /**
  1807. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1808. * @param array defines the destination array
  1809. * @param index defines the offset in the destination array
  1810. * @returns the current Vector3
  1811. */
  1812. toArray(array: FloatArray, index?: number): Vector3;
  1813. /**
  1814. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1815. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1816. */
  1817. toQuaternion(): Quaternion;
  1818. /**
  1819. * Adds the given vector to the current Vector3
  1820. * @param otherVector defines the second operand
  1821. * @returns the current updated Vector3
  1822. */
  1823. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1824. /**
  1825. * Adds the given coordinates to the current Vector3
  1826. * @param x defines the x coordinate of the operand
  1827. * @param y defines the y coordinate of the operand
  1828. * @param z defines the z coordinate of the operand
  1829. * @returns the current updated Vector3
  1830. */
  1831. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1832. /**
  1833. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1834. * @param otherVector defines the second operand
  1835. * @returns the resulting Vector3
  1836. */
  1837. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1838. /**
  1839. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1840. * @param otherVector defines the second operand
  1841. * @param result defines the Vector3 object where to store the result
  1842. * @returns the current Vector3
  1843. */
  1844. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1845. /**
  1846. * Subtract the given vector from the current Vector3
  1847. * @param otherVector defines the second operand
  1848. * @returns the current updated Vector3
  1849. */
  1850. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1851. /**
  1852. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1853. * @param otherVector defines the second operand
  1854. * @returns the resulting Vector3
  1855. */
  1856. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1857. /**
  1858. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1859. * @param otherVector defines the second operand
  1860. * @param result defines the Vector3 object where to store the result
  1861. * @returns the current Vector3
  1862. */
  1863. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1864. /**
  1865. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1866. * @param x defines the x coordinate of the operand
  1867. * @param y defines the y coordinate of the operand
  1868. * @param z defines the z coordinate of the operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1872. /**
  1873. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1874. * @param x defines the x coordinate of the operand
  1875. * @param y defines the y coordinate of the operand
  1876. * @param z defines the z coordinate of the operand
  1877. * @param result defines the Vector3 object where to store the result
  1878. * @returns the current Vector3
  1879. */
  1880. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1881. /**
  1882. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1883. * @returns a new Vector3
  1884. */
  1885. negate(): Vector3;
  1886. /**
  1887. * Multiplies the Vector3 coordinates by the float "scale"
  1888. * @param scale defines the multiplier factor
  1889. * @returns the current updated Vector3
  1890. */
  1891. scaleInPlace(scale: number): Vector3;
  1892. /**
  1893. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1894. * @param scale defines the multiplier factor
  1895. * @returns a new Vector3
  1896. */
  1897. scale(scale: number): Vector3;
  1898. /**
  1899. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1900. * @param scale defines the multiplier factor
  1901. * @param result defines the Vector3 object where to store the result
  1902. * @returns the current Vector3
  1903. */
  1904. scaleToRef(scale: number, result: Vector3): Vector3;
  1905. /**
  1906. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1907. * @param scale defines the scale factor
  1908. * @param result defines the Vector3 object where to store the result
  1909. * @returns the unmodified current Vector3
  1910. */
  1911. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1912. /**
  1913. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1914. * @param otherVector defines the second operand
  1915. * @returns true if both vectors are equals
  1916. */
  1917. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1918. /**
  1919. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1920. * @param otherVector defines the second operand
  1921. * @param epsilon defines the minimal distance to define values as equals
  1922. * @returns true if both vectors are distant less than epsilon
  1923. */
  1924. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1925. /**
  1926. * Returns true if the current Vector3 coordinates equals the given floats
  1927. * @param x defines the x coordinate of the operand
  1928. * @param y defines the y coordinate of the operand
  1929. * @param z defines the z coordinate of the operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equalsToFloats(x: number, y: number, z: number): boolean;
  1933. /**
  1934. * Multiplies the current Vector3 coordinates by the given ones
  1935. * @param otherVector defines the second operand
  1936. * @returns the current updated Vector3
  1937. */
  1938. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1939. /**
  1940. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1941. * @param otherVector defines the second operand
  1942. * @returns the new Vector3
  1943. */
  1944. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1945. /**
  1946. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1947. * @param otherVector defines the second operand
  1948. * @param result defines the Vector3 object where to store the result
  1949. * @returns the current Vector3
  1950. */
  1951. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1952. /**
  1953. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1954. * @param x defines the x coordinate of the operand
  1955. * @param y defines the y coordinate of the operand
  1956. * @param z defines the z coordinate of the operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1960. /**
  1961. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1962. * @param otherVector defines the second operand
  1963. * @returns the new Vector3
  1964. */
  1965. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1966. /**
  1967. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1968. * @param otherVector defines the second operand
  1969. * @param result defines the Vector3 object where to store the result
  1970. * @returns the current Vector3
  1971. */
  1972. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1973. /**
  1974. * Divides the current Vector3 coordinates by the given ones.
  1975. * @param otherVector defines the second operand
  1976. * @returns the current updated Vector3
  1977. */
  1978. divideInPlace(otherVector: Vector3): Vector3;
  1979. /**
  1980. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1981. * @param other defines the second operand
  1982. * @returns the current updated Vector3
  1983. */
  1984. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1985. /**
  1986. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1987. * @param other defines the second operand
  1988. * @returns the current updated Vector3
  1989. */
  1990. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1991. /**
  1992. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1993. * @param x defines the x coordinate of the operand
  1994. * @param y defines the y coordinate of the operand
  1995. * @param z defines the z coordinate of the operand
  1996. * @returns the current updated Vector3
  1997. */
  1998. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1999. /**
  2000. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2001. * @param x defines the x coordinate of the operand
  2002. * @param y defines the y coordinate of the operand
  2003. * @param z defines the z coordinate of the operand
  2004. * @returns the current updated Vector3
  2005. */
  2006. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2007. /**
  2008. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2009. * Check if is non uniform within a certain amount of decimal places to account for this
  2010. * @param epsilon the amount the values can differ
  2011. * @returns if the the vector is non uniform to a certain number of decimal places
  2012. */
  2013. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2014. /**
  2015. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2016. */
  2017. readonly isNonUniform: boolean;
  2018. /**
  2019. * Gets a new Vector3 from current Vector3 floored values
  2020. * @returns a new Vector3
  2021. */
  2022. floor(): Vector3;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. fract(): Vector3;
  2028. /**
  2029. * Gets the length of the Vector3
  2030. * @returns the length of the Vector3
  2031. */
  2032. length(): number;
  2033. /**
  2034. * Gets the squared length of the Vector3
  2035. * @returns squared length of the Vector3
  2036. */
  2037. lengthSquared(): number;
  2038. /**
  2039. * Normalize the current Vector3.
  2040. * Please note that this is an in place operation.
  2041. * @returns the current updated Vector3
  2042. */
  2043. normalize(): Vector3;
  2044. /**
  2045. * Reorders the x y z properties of the vector in place
  2046. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2047. * @returns the current updated vector
  2048. */
  2049. reorderInPlace(order: string): this;
  2050. /**
  2051. * Rotates the vector around 0,0,0 by a quaternion
  2052. * @param quaternion the rotation quaternion
  2053. * @param result vector to store the result
  2054. * @returns the resulting vector
  2055. */
  2056. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2057. /**
  2058. * Rotates a vector around a given point
  2059. * @param quaternion the rotation quaternion
  2060. * @param point the point to rotate around
  2061. * @param result vector to store the result
  2062. * @returns the resulting vector
  2063. */
  2064. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2065. /**
  2066. * Normalize the current Vector3 with the given input length.
  2067. * Please note that this is an in place operation.
  2068. * @param len the length of the vector
  2069. * @returns the current updated Vector3
  2070. */
  2071. normalizeFromLength(len: number): Vector3;
  2072. /**
  2073. * Normalize the current Vector3 to a new vector
  2074. * @returns the new Vector3
  2075. */
  2076. normalizeToNew(): Vector3;
  2077. /**
  2078. * Normalize the current Vector3 to the reference
  2079. * @param reference define the Vector3 to update
  2080. * @returns the updated Vector3
  2081. */
  2082. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2083. /**
  2084. * Creates a new Vector3 copied from the current Vector3
  2085. * @returns the new Vector3
  2086. */
  2087. clone(): Vector3;
  2088. /**
  2089. * Copies the given vector coordinates to the current Vector3 ones
  2090. * @param source defines the source Vector3
  2091. * @returns the current updated Vector3
  2092. */
  2093. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2094. /**
  2095. * Copies the given floats to the current Vector3 coordinates
  2096. * @param x defines the x coordinate of the operand
  2097. * @param y defines the y coordinate of the operand
  2098. * @param z defines the z coordinate of the operand
  2099. * @returns the current updated Vector3
  2100. */
  2101. copyFromFloats(x: number, y: number, z: number): Vector3;
  2102. /**
  2103. * Copies the given floats to the current Vector3 coordinates
  2104. * @param x defines the x coordinate of the operand
  2105. * @param y defines the y coordinate of the operand
  2106. * @param z defines the z coordinate of the operand
  2107. * @returns the current updated Vector3
  2108. */
  2109. set(x: number, y: number, z: number): Vector3;
  2110. /**
  2111. * Copies the given float to the current Vector3 coordinates
  2112. * @param v defines the x, y and z coordinates of the operand
  2113. * @returns the current updated Vector3
  2114. */
  2115. setAll(v: number): Vector3;
  2116. /**
  2117. * Get the clip factor between two vectors
  2118. * @param vector0 defines the first operand
  2119. * @param vector1 defines the second operand
  2120. * @param axis defines the axis to use
  2121. * @param size defines the size along the axis
  2122. * @returns the clip factor
  2123. */
  2124. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2125. /**
  2126. * Get angle between two vectors
  2127. * @param vector0 angle between vector0 and vector1
  2128. * @param vector1 angle between vector0 and vector1
  2129. * @param normal direction of the normal
  2130. * @return the angle between vector0 and vector1
  2131. */
  2132. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2133. /**
  2134. * Returns a new Vector3 set from the index "offset" of the given array
  2135. * @param array defines the source array
  2136. * @param offset defines the offset in the source array
  2137. * @returns the new Vector3
  2138. */
  2139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2140. /**
  2141. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2142. * This function is deprecated. Use FromArray instead
  2143. * @param array defines the source array
  2144. * @param offset defines the offset in the source array
  2145. * @returns the new Vector3
  2146. */
  2147. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2148. /**
  2149. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2150. * @param array defines the source array
  2151. * @param offset defines the offset in the source array
  2152. * @param result defines the Vector3 where to store the result
  2153. */
  2154. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2155. /**
  2156. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2157. * This function is deprecated. Use FromArrayToRef instead.
  2158. * @param array defines the source array
  2159. * @param offset defines the offset in the source array
  2160. * @param result defines the Vector3 where to store the result
  2161. */
  2162. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2163. /**
  2164. * Sets the given vector "result" with the given floats.
  2165. * @param x defines the x coordinate of the source
  2166. * @param y defines the y coordinate of the source
  2167. * @param z defines the z coordinate of the source
  2168. * @param result defines the Vector3 where to store the result
  2169. */
  2170. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2171. /**
  2172. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2173. * @returns a new empty Vector3
  2174. */
  2175. static Zero(): Vector3;
  2176. /**
  2177. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2178. * @returns a new unit Vector3
  2179. */
  2180. static One(): Vector3;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2183. * @returns a new up Vector3
  2184. */
  2185. static Up(): Vector3;
  2186. /**
  2187. * Gets a up Vector3 that must not be updated
  2188. */
  2189. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2190. /**
  2191. * Gets a zero Vector3 that must not be updated
  2192. */
  2193. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2194. /**
  2195. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2196. * @returns a new down Vector3
  2197. */
  2198. static Down(): Vector3;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2201. * @returns a new forward Vector3
  2202. */
  2203. static Forward(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2206. * @returns a new forward Vector3
  2207. */
  2208. static Backward(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2211. * @returns a new right Vector3
  2212. */
  2213. static Right(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2216. * @returns a new left Vector3
  2217. */
  2218. static Left(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2221. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2222. * @param vector defines the Vector3 to transform
  2223. * @param transformation defines the transformation matrix
  2224. * @returns the transformed Vector3
  2225. */
  2226. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2227. /**
  2228. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2229. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2230. * @param vector defines the Vector3 to transform
  2231. * @param transformation defines the transformation matrix
  2232. * @param result defines the Vector3 where to store the result
  2233. */
  2234. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2235. /**
  2236. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2237. * This method computes tranformed coordinates only, not transformed direction vectors
  2238. * @param x define the x coordinate of the source vector
  2239. * @param y define the y coordinate of the source vector
  2240. * @param z define the z coordinate of the source vector
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2247. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2248. * @param vector defines the Vector3 to transform
  2249. * @param transformation defines the transformation matrix
  2250. * @returns the new Vector3
  2251. */
  2252. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2253. /**
  2254. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2255. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2256. * @param vector defines the Vector3 to transform
  2257. * @param transformation defines the transformation matrix
  2258. * @param result defines the Vector3 where to store the result
  2259. */
  2260. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2261. /**
  2262. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2263. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2264. * @param x define the x coordinate of the source vector
  2265. * @param y define the y coordinate of the source vector
  2266. * @param z define the z coordinate of the source vector
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2273. * @param value1 defines the first control point
  2274. * @param value2 defines the second control point
  2275. * @param value3 defines the third control point
  2276. * @param value4 defines the fourth control point
  2277. * @param amount defines the amount on the spline to use
  2278. * @returns the new Vector3
  2279. */
  2280. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2281. /**
  2282. * 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"
  2283. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2284. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2285. * @param value defines the current value
  2286. * @param min defines the lower range value
  2287. * @param max defines the upper range value
  2288. * @returns the new Vector3
  2289. */
  2290. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2291. /**
  2292. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @param result defines the Vector3 where to store the result
  2299. */
  2300. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2301. /**
  2302. * Checks if a given vector is inside a specific range
  2303. * @param v defines the vector to test
  2304. * @param min defines the minimum range
  2305. * @param max defines the maximum range
  2306. */
  2307. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2308. /**
  2309. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2310. * @param value1 defines the first control point
  2311. * @param tangent1 defines the first tangent vector
  2312. * @param value2 defines the second control point
  2313. * @param tangent2 defines the second tangent vector
  2314. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2315. * @returns the new Vector3
  2316. */
  2317. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2320. * @param start defines the start value
  2321. * @param end defines the end value
  2322. * @param amount max defines amount between both (between 0 and 1)
  2323. * @returns the new Vector3
  2324. */
  2325. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2326. /**
  2327. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2328. * @param start defines the start value
  2329. * @param end defines the end value
  2330. * @param amount max defines amount between both (between 0 and 1)
  2331. * @param result defines the Vector3 where to store the result
  2332. */
  2333. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2334. /**
  2335. * Returns the dot product (float) between the vectors "left" and "right"
  2336. * @param left defines the left operand
  2337. * @param right defines the right operand
  2338. * @returns the dot product
  2339. */
  2340. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2341. /**
  2342. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2343. * The cross product is then orthogonal to both "left" and "right"
  2344. * @param left defines the left operand
  2345. * @param right defines the right operand
  2346. * @returns the cross product
  2347. */
  2348. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2349. /**
  2350. * Sets the given vector "result" with the cross product of "left" and "right"
  2351. * The cross product is then orthogonal to both "left" and "right"
  2352. * @param left defines the left operand
  2353. * @param right defines the right operand
  2354. * @param result defines the Vector3 where to store the result
  2355. */
  2356. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2357. /**
  2358. * Returns a new Vector3 as the normalization of the given vector
  2359. * @param vector defines the Vector3 to normalize
  2360. * @returns the new Vector3
  2361. */
  2362. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2363. /**
  2364. * Sets the given vector "result" with the normalization of the given first vector
  2365. * @param vector defines the Vector3 to normalize
  2366. * @param result defines the Vector3 where to store the result
  2367. */
  2368. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2369. /**
  2370. * Project a Vector3 onto screen space
  2371. * @param vector defines the Vector3 to project
  2372. * @param world defines the world matrix to use
  2373. * @param transform defines the transform (view x projection) matrix to use
  2374. * @param viewport defines the screen viewport to use
  2375. * @returns the new Vector3
  2376. */
  2377. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2378. /** @hidden */
  2379. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2380. /**
  2381. * Unproject from screen space to object space
  2382. * @param source defines the screen space Vector3 to use
  2383. * @param viewportWidth defines the current width of the viewport
  2384. * @param viewportHeight defines the current height of the viewport
  2385. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2386. * @param transform defines the transform (view x projection) matrix to use
  2387. * @returns the new Vector3
  2388. */
  2389. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param view defines the view matrix to use
  2397. * @param projection defines the projection matrix to use
  2398. * @returns the new Vector3
  2399. */
  2400. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2401. /**
  2402. * Unproject from screen space to object space
  2403. * @param source defines the screen space Vector3 to use
  2404. * @param viewportWidth defines the current width of the viewport
  2405. * @param viewportHeight defines the current height of the viewport
  2406. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2407. * @param view defines the view matrix to use
  2408. * @param projection defines the projection matrix to use
  2409. * @param result defines the Vector3 where to store the result
  2410. */
  2411. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2412. /**
  2413. * Unproject from screen space to object space
  2414. * @param sourceX defines the screen space x coordinate to use
  2415. * @param sourceY defines the screen space y coordinate to use
  2416. * @param sourceZ defines the screen space z coordinate to use
  2417. * @param viewportWidth defines the current width of the viewport
  2418. * @param viewportHeight defines the current height of the viewport
  2419. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2420. * @param view defines the view matrix to use
  2421. * @param projection defines the projection matrix to use
  2422. * @param result defines the Vector3 where to store the result
  2423. */
  2424. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2425. /**
  2426. * Gets the minimal coordinate values between two Vector3
  2427. * @param left defines the first operand
  2428. * @param right defines the second operand
  2429. * @returns the new Vector3
  2430. */
  2431. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2432. /**
  2433. * Gets the maximal coordinate values between two Vector3
  2434. * @param left defines the first operand
  2435. * @param right defines the second operand
  2436. * @returns the new Vector3
  2437. */
  2438. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2439. /**
  2440. * Returns the distance between the vectors "value1" and "value2"
  2441. * @param value1 defines the first operand
  2442. * @param value2 defines the second operand
  2443. * @returns the distance
  2444. */
  2445. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2446. /**
  2447. * Returns the squared distance between the vectors "value1" and "value2"
  2448. * @param value1 defines the first operand
  2449. * @param value2 defines the second operand
  2450. * @returns the squared distance
  2451. */
  2452. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2453. /**
  2454. * Returns a new Vector3 located at the center between "value1" and "value2"
  2455. * @param value1 defines the first operand
  2456. * @param value2 defines the second operand
  2457. * @returns the new Vector3
  2458. */
  2459. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2460. /**
  2461. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2462. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2463. * to something in order to rotate it from its local system to the given target system
  2464. * Note: axis1, axis2 and axis3 are normalized during this operation
  2465. * @param axis1 defines the first axis
  2466. * @param axis2 defines the second axis
  2467. * @param axis3 defines the third axis
  2468. * @returns a new Vector3
  2469. */
  2470. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2471. /**
  2472. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2473. * @param axis1 defines the first axis
  2474. * @param axis2 defines the second axis
  2475. * @param axis3 defines the third axis
  2476. * @param ref defines the Vector3 where to store the result
  2477. */
  2478. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2479. }
  2480. /**
  2481. * Vector4 class created for EulerAngle class conversion to Quaternion
  2482. */
  2483. export class Vector4 {
  2484. /** x value of the vector */
  2485. x: number;
  2486. /** y value of the vector */
  2487. y: number;
  2488. /** z value of the vector */
  2489. z: number;
  2490. /** w value of the vector */
  2491. w: number;
  2492. /**
  2493. * Creates a Vector4 object from the given floats.
  2494. * @param x x value of the vector
  2495. * @param y y value of the vector
  2496. * @param z z value of the vector
  2497. * @param w w value of the vector
  2498. */
  2499. constructor(
  2500. /** x value of the vector */
  2501. x: number,
  2502. /** y value of the vector */
  2503. y: number,
  2504. /** z value of the vector */
  2505. z: number,
  2506. /** w value of the vector */
  2507. w: number);
  2508. /**
  2509. * Returns the string with the Vector4 coordinates.
  2510. * @returns a string containing all the vector values
  2511. */
  2512. toString(): string;
  2513. /**
  2514. * Returns the string "Vector4".
  2515. * @returns "Vector4"
  2516. */
  2517. getClassName(): string;
  2518. /**
  2519. * Returns the Vector4 hash code.
  2520. * @returns a unique hash code
  2521. */
  2522. getHashCode(): number;
  2523. /**
  2524. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2525. * @returns the resulting array
  2526. */
  2527. asArray(): number[];
  2528. /**
  2529. * Populates the given array from the given index with the Vector4 coordinates.
  2530. * @param array array to populate
  2531. * @param index index of the array to start at (default: 0)
  2532. * @returns the Vector4.
  2533. */
  2534. toArray(array: FloatArray, index?: number): Vector4;
  2535. /**
  2536. * Adds the given vector to the current Vector4.
  2537. * @param otherVector the vector to add
  2538. * @returns the updated Vector4.
  2539. */
  2540. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2541. /**
  2542. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2543. * @param otherVector the vector to add
  2544. * @returns the resulting vector
  2545. */
  2546. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2547. /**
  2548. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2549. * @param otherVector the vector to add
  2550. * @param result the vector to store the result
  2551. * @returns the current Vector4.
  2552. */
  2553. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2554. /**
  2555. * Subtract in place the given vector from the current Vector4.
  2556. * @param otherVector the vector to subtract
  2557. * @returns the updated Vector4.
  2558. */
  2559. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2560. /**
  2561. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2562. * @param otherVector the vector to add
  2563. * @returns the new vector with the result
  2564. */
  2565. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2566. /**
  2567. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2568. * @param otherVector the vector to subtract
  2569. * @param result the vector to store the result
  2570. * @returns the current Vector4.
  2571. */
  2572. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2573. /**
  2574. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2575. */
  2576. /**
  2577. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2578. * @param x value to subtract
  2579. * @param y value to subtract
  2580. * @param z value to subtract
  2581. * @param w value to subtract
  2582. * @returns new vector containing the result
  2583. */
  2584. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2585. /**
  2586. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2587. * @param x value to subtract
  2588. * @param y value to subtract
  2589. * @param z value to subtract
  2590. * @param w value to subtract
  2591. * @param result the vector to store the result in
  2592. * @returns the current Vector4.
  2593. */
  2594. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2595. /**
  2596. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2597. * @returns a new vector with the negated values
  2598. */
  2599. negate(): Vector4;
  2600. /**
  2601. * Multiplies the current Vector4 coordinates by scale (float).
  2602. * @param scale the number to scale with
  2603. * @returns the updated Vector4.
  2604. */
  2605. scaleInPlace(scale: number): Vector4;
  2606. /**
  2607. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2608. * @param scale the number to scale with
  2609. * @returns a new vector with the result
  2610. */
  2611. scale(scale: number): Vector4;
  2612. /**
  2613. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2614. * @param scale the number to scale with
  2615. * @param result a vector to store the result in
  2616. * @returns the current Vector4.
  2617. */
  2618. scaleToRef(scale: number, result: Vector4): Vector4;
  2619. /**
  2620. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2621. * @param scale defines the scale factor
  2622. * @param result defines the Vector4 object where to store the result
  2623. * @returns the unmodified current Vector4
  2624. */
  2625. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2626. /**
  2627. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2628. * @param otherVector the vector to compare against
  2629. * @returns true if they are equal
  2630. */
  2631. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2632. /**
  2633. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2634. * @param otherVector vector to compare against
  2635. * @param epsilon (Default: very small number)
  2636. * @returns true if they are equal
  2637. */
  2638. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2639. /**
  2640. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2641. * @param x x value to compare against
  2642. * @param y y value to compare against
  2643. * @param z z value to compare against
  2644. * @param w w value to compare against
  2645. * @returns true if equal
  2646. */
  2647. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2648. /**
  2649. * Multiplies in place the current Vector4 by the given one.
  2650. * @param otherVector vector to multiple with
  2651. * @returns the updated Vector4.
  2652. */
  2653. multiplyInPlace(otherVector: Vector4): Vector4;
  2654. /**
  2655. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2656. * @param otherVector vector to multiple with
  2657. * @returns resulting new vector
  2658. */
  2659. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2660. /**
  2661. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2662. * @param otherVector vector to multiple with
  2663. * @param result vector to store the result
  2664. * @returns the current Vector4.
  2665. */
  2666. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2667. /**
  2668. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2669. * @param x x value multiply with
  2670. * @param y y value multiply with
  2671. * @param z z value multiply with
  2672. * @param w w value multiply with
  2673. * @returns resulting new vector
  2674. */
  2675. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2676. /**
  2677. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2678. * @param otherVector vector to devide with
  2679. * @returns resulting new vector
  2680. */
  2681. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2682. /**
  2683. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2684. * @param otherVector vector to devide with
  2685. * @param result vector to store the result
  2686. * @returns the current Vector4.
  2687. */
  2688. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2689. /**
  2690. * Divides the current Vector3 coordinates by the given ones.
  2691. * @param otherVector vector to devide with
  2692. * @returns the updated Vector3.
  2693. */
  2694. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2695. /**
  2696. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2697. * @param other defines the second operand
  2698. * @returns the current updated Vector4
  2699. */
  2700. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2701. /**
  2702. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector4
  2705. */
  2706. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2707. /**
  2708. * Gets a new Vector4 from current Vector4 floored values
  2709. * @returns a new Vector4
  2710. */
  2711. floor(): Vector4;
  2712. /**
  2713. * Gets a new Vector4 from current Vector3 floored values
  2714. * @returns a new Vector4
  2715. */
  2716. fract(): Vector4;
  2717. /**
  2718. * Returns the Vector4 length (float).
  2719. * @returns the length
  2720. */
  2721. length(): number;
  2722. /**
  2723. * Returns the Vector4 squared length (float).
  2724. * @returns the length squared
  2725. */
  2726. lengthSquared(): number;
  2727. /**
  2728. * Normalizes in place the Vector4.
  2729. * @returns the updated Vector4.
  2730. */
  2731. normalize(): Vector4;
  2732. /**
  2733. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2734. * @returns this converted to a new vector3
  2735. */
  2736. toVector3(): Vector3;
  2737. /**
  2738. * Returns a new Vector4 copied from the current one.
  2739. * @returns the new cloned vector
  2740. */
  2741. clone(): Vector4;
  2742. /**
  2743. * Updates the current Vector4 with the given one coordinates.
  2744. * @param source the source vector to copy from
  2745. * @returns the updated Vector4.
  2746. */
  2747. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2748. /**
  2749. * Updates the current Vector4 coordinates with the given floats.
  2750. * @param x float to copy from
  2751. * @param y float to copy from
  2752. * @param z float to copy from
  2753. * @param w float to copy from
  2754. * @returns the updated Vector4.
  2755. */
  2756. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2757. /**
  2758. * Updates the current Vector4 coordinates with the given floats.
  2759. * @param x float to set from
  2760. * @param y float to set from
  2761. * @param z float to set from
  2762. * @param w float to set from
  2763. * @returns the updated Vector4.
  2764. */
  2765. set(x: number, y: number, z: number, w: number): Vector4;
  2766. /**
  2767. * Copies the given float to the current Vector3 coordinates
  2768. * @param v defines the x, y, z and w coordinates of the operand
  2769. * @returns the current updated Vector3
  2770. */
  2771. setAll(v: number): Vector4;
  2772. /**
  2773. * Returns a new Vector4 set from the starting index of the given array.
  2774. * @param array the array to pull values from
  2775. * @param offset the offset into the array to start at
  2776. * @returns the new vector
  2777. */
  2778. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2779. /**
  2780. * Updates the given vector "result" from the starting index of the given array.
  2781. * @param array the array to pull values from
  2782. * @param offset the offset into the array to start at
  2783. * @param result the vector to store the result in
  2784. */
  2785. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2786. /**
  2787. * Updates the given vector "result" from the starting index of the given Float32Array.
  2788. * @param array the array to pull values from
  2789. * @param offset the offset into the array to start at
  2790. * @param result the vector to store the result in
  2791. */
  2792. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2793. /**
  2794. * Updates the given vector "result" coordinates from the given floats.
  2795. * @param x float to set from
  2796. * @param y float to set from
  2797. * @param z float to set from
  2798. * @param w float to set from
  2799. * @param result the vector to the floats in
  2800. */
  2801. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2802. /**
  2803. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2804. * @returns the new vector
  2805. */
  2806. static Zero(): Vector4;
  2807. /**
  2808. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2809. * @returns the new vector
  2810. */
  2811. static One(): Vector4;
  2812. /**
  2813. * Returns a new normalized Vector4 from the given one.
  2814. * @param vector the vector to normalize
  2815. * @returns the vector
  2816. */
  2817. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2818. /**
  2819. * Updates the given vector "result" from the normalization of the given one.
  2820. * @param vector the vector to normalize
  2821. * @param result the vector to store the result in
  2822. */
  2823. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2824. /**
  2825. * Returns a vector with the minimum values from the left and right vectors
  2826. * @param left left vector to minimize
  2827. * @param right right vector to minimize
  2828. * @returns a new vector with the minimum of the left and right vector values
  2829. */
  2830. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2831. /**
  2832. * Returns a vector with the maximum values from the left and right vectors
  2833. * @param left left vector to maximize
  2834. * @param right right vector to maximize
  2835. * @returns a new vector with the maximum of the left and right vector values
  2836. */
  2837. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2838. /**
  2839. * Returns the distance (float) between the vectors "value1" and "value2".
  2840. * @param value1 value to calulate the distance between
  2841. * @param value2 value to calulate the distance between
  2842. * @return the distance between the two vectors
  2843. */
  2844. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2845. /**
  2846. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2847. * @param value1 value to calulate the distance between
  2848. * @param value2 value to calulate the distance between
  2849. * @return the distance between the two vectors squared
  2850. */
  2851. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2852. /**
  2853. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2854. * @param value1 value to calulate the center between
  2855. * @param value2 value to calulate the center between
  2856. * @return the center between the two vectors
  2857. */
  2858. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2859. /**
  2860. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2861. * This methods computes transformed normalized direction vectors only.
  2862. * @param vector the vector to transform
  2863. * @param transformation the transformation matrix to apply
  2864. * @returns the new vector
  2865. */
  2866. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2867. /**
  2868. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2869. * This methods computes transformed normalized direction vectors only.
  2870. * @param vector the vector to transform
  2871. * @param transformation the transformation matrix to apply
  2872. * @param result the vector to store the result in
  2873. */
  2874. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2875. /**
  2876. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2877. * This methods computes transformed normalized direction vectors only.
  2878. * @param x value to transform
  2879. * @param y value to transform
  2880. * @param z value to transform
  2881. * @param w value to transform
  2882. * @param transformation the transformation matrix to apply
  2883. * @param result the vector to store the results in
  2884. */
  2885. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2886. /**
  2887. * Creates a new Vector4 from a Vector3
  2888. * @param source defines the source data
  2889. * @param w defines the 4th component (default is 0)
  2890. * @returns a new Vector4
  2891. */
  2892. static FromVector3(source: Vector3, w?: number): Vector4;
  2893. }
  2894. /**
  2895. * Class used to store quaternion data
  2896. * @see https://en.wikipedia.org/wiki/Quaternion
  2897. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2898. */
  2899. export class Quaternion {
  2900. /** defines the first component (0 by default) */
  2901. x: number;
  2902. /** defines the second component (0 by default) */
  2903. y: number;
  2904. /** defines the third component (0 by default) */
  2905. z: number;
  2906. /** defines the fourth component (1.0 by default) */
  2907. w: number;
  2908. /**
  2909. * Creates a new Quaternion from the given floats
  2910. * @param x defines the first component (0 by default)
  2911. * @param y defines the second component (0 by default)
  2912. * @param z defines the third component (0 by default)
  2913. * @param w defines the fourth component (1.0 by default)
  2914. */
  2915. constructor(
  2916. /** defines the first component (0 by default) */
  2917. x?: number,
  2918. /** defines the second component (0 by default) */
  2919. y?: number,
  2920. /** defines the third component (0 by default) */
  2921. z?: number,
  2922. /** defines the fourth component (1.0 by default) */
  2923. w?: number);
  2924. /**
  2925. * Gets a string representation for the current quaternion
  2926. * @returns a string with the Quaternion coordinates
  2927. */
  2928. toString(): string;
  2929. /**
  2930. * Gets the class name of the quaternion
  2931. * @returns the string "Quaternion"
  2932. */
  2933. getClassName(): string;
  2934. /**
  2935. * Gets a hash code for this quaternion
  2936. * @returns the quaternion hash code
  2937. */
  2938. getHashCode(): number;
  2939. /**
  2940. * Copy the quaternion to an array
  2941. * @returns a new array populated with 4 elements from the quaternion coordinates
  2942. */
  2943. asArray(): number[];
  2944. /**
  2945. * Check if two quaternions are equals
  2946. * @param otherQuaternion defines the second operand
  2947. * @return true if the current quaternion and the given one coordinates are strictly equals
  2948. */
  2949. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2950. /**
  2951. * Clone the current quaternion
  2952. * @returns a new quaternion copied from the current one
  2953. */
  2954. clone(): Quaternion;
  2955. /**
  2956. * Copy a quaternion to the current one
  2957. * @param other defines the other quaternion
  2958. * @returns the updated current quaternion
  2959. */
  2960. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2961. /**
  2962. * Updates the current quaternion with the given float coordinates
  2963. * @param x defines the x coordinate
  2964. * @param y defines the y coordinate
  2965. * @param z defines the z coordinate
  2966. * @param w defines the w coordinate
  2967. * @returns the updated current quaternion
  2968. */
  2969. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2970. /**
  2971. * Updates the current quaternion from the given float coordinates
  2972. * @param x defines the x coordinate
  2973. * @param y defines the y coordinate
  2974. * @param z defines the z coordinate
  2975. * @param w defines the w coordinate
  2976. * @returns the updated current quaternion
  2977. */
  2978. set(x: number, y: number, z: number, w: number): Quaternion;
  2979. /**
  2980. * Adds two quaternions
  2981. * @param other defines the second operand
  2982. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2983. */
  2984. add(other: DeepImmutable<Quaternion>): Quaternion;
  2985. /**
  2986. * Add a quaternion to the current one
  2987. * @param other defines the quaternion to add
  2988. * @returns the current quaternion
  2989. */
  2990. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2991. /**
  2992. * Subtract two quaternions
  2993. * @param other defines the second operand
  2994. * @returns a new quaternion as the subtraction result of the given one from the current one
  2995. */
  2996. subtract(other: Quaternion): Quaternion;
  2997. /**
  2998. * Multiplies the current quaternion by a scale factor
  2999. * @param value defines the scale factor
  3000. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3001. */
  3002. scale(value: number): Quaternion;
  3003. /**
  3004. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3005. * @param scale defines the scale factor
  3006. * @param result defines the Quaternion object where to store the result
  3007. * @returns the unmodified current quaternion
  3008. */
  3009. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3010. /**
  3011. * Multiplies in place the current quaternion by a scale factor
  3012. * @param value defines the scale factor
  3013. * @returns the current modified quaternion
  3014. */
  3015. scaleInPlace(value: number): Quaternion;
  3016. /**
  3017. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3018. * @param scale defines the scale factor
  3019. * @param result defines the Quaternion object where to store the result
  3020. * @returns the unmodified current quaternion
  3021. */
  3022. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3023. /**
  3024. * Multiplies two quaternions
  3025. * @param q1 defines the second operand
  3026. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3027. */
  3028. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3029. /**
  3030. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3031. * @param q1 defines the second operand
  3032. * @param result defines the target quaternion
  3033. * @returns the current quaternion
  3034. */
  3035. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3036. /**
  3037. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3038. * @param q1 defines the second operand
  3039. * @returns the currentupdated quaternion
  3040. */
  3041. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3042. /**
  3043. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3044. * @param ref defines the target quaternion
  3045. * @returns the current quaternion
  3046. */
  3047. conjugateToRef(ref: Quaternion): Quaternion;
  3048. /**
  3049. * Conjugates in place (1-q) the current quaternion
  3050. * @returns the current updated quaternion
  3051. */
  3052. conjugateInPlace(): Quaternion;
  3053. /**
  3054. * Conjugates in place (1-q) the current quaternion
  3055. * @returns a new quaternion
  3056. */
  3057. conjugate(): Quaternion;
  3058. /**
  3059. * Gets length of current quaternion
  3060. * @returns the quaternion length (float)
  3061. */
  3062. length(): number;
  3063. /**
  3064. * Normalize in place the current quaternion
  3065. * @returns the current updated quaternion
  3066. */
  3067. normalize(): Quaternion;
  3068. /**
  3069. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3070. * @param order is a reserved parameter and is ignore for now
  3071. * @returns a new Vector3 containing the Euler angles
  3072. */
  3073. toEulerAngles(order?: string): Vector3;
  3074. /**
  3075. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3076. * @param result defines the vector which will be filled with the Euler angles
  3077. * @param order is a reserved parameter and is ignore for now
  3078. * @returns the current unchanged quaternion
  3079. */
  3080. toEulerAnglesToRef(result: Vector3): Quaternion;
  3081. /**
  3082. * Updates the given rotation matrix with the current quaternion values
  3083. * @param result defines the target matrix
  3084. * @returns the current unchanged quaternion
  3085. */
  3086. toRotationMatrix(result: Matrix): Quaternion;
  3087. /**
  3088. * Updates the current quaternion from the given rotation matrix values
  3089. * @param matrix defines the source matrix
  3090. * @returns the current updated quaternion
  3091. */
  3092. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3093. /**
  3094. * Creates a new quaternion from a rotation matrix
  3095. * @param matrix defines the source matrix
  3096. * @returns a new quaternion created from the given rotation matrix values
  3097. */
  3098. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3099. /**
  3100. * Updates the given quaternion with the given rotation matrix values
  3101. * @param matrix defines the source matrix
  3102. * @param result defines the target quaternion
  3103. */
  3104. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3105. /**
  3106. * Returns the dot product (float) between the quaternions "left" and "right"
  3107. * @param left defines the left operand
  3108. * @param right defines the right operand
  3109. * @returns the dot product
  3110. */
  3111. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3112. /**
  3113. * Checks if the two quaternions are close to each other
  3114. * @param quat0 defines the first quaternion to check
  3115. * @param quat1 defines the second quaternion to check
  3116. * @returns true if the two quaternions are close to each other
  3117. */
  3118. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3119. /**
  3120. * Creates an empty quaternion
  3121. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3122. */
  3123. static Zero(): Quaternion;
  3124. /**
  3125. * Inverse a given quaternion
  3126. * @param q defines the source quaternion
  3127. * @returns a new quaternion as the inverted current quaternion
  3128. */
  3129. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3130. /**
  3131. * Inverse a given quaternion
  3132. * @param q defines the source quaternion
  3133. * @param result the quaternion the result will be stored in
  3134. * @returns the result quaternion
  3135. */
  3136. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3137. /**
  3138. * Creates an identity quaternion
  3139. * @returns the identity quaternion
  3140. */
  3141. static Identity(): Quaternion;
  3142. /**
  3143. * Gets a boolean indicating if the given quaternion is identity
  3144. * @param quaternion defines the quaternion to check
  3145. * @returns true if the quaternion is identity
  3146. */
  3147. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3148. /**
  3149. * Creates a quaternion from a rotation around an axis
  3150. * @param axis defines the axis to use
  3151. * @param angle defines the angle to use
  3152. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3153. */
  3154. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3155. /**
  3156. * Creates a rotation around an axis and stores it into the given quaternion
  3157. * @param axis defines the axis to use
  3158. * @param angle defines the angle to use
  3159. * @param result defines the target quaternion
  3160. * @returns the target quaternion
  3161. */
  3162. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3163. /**
  3164. * Creates a new quaternion from data stored into an array
  3165. * @param array defines the data source
  3166. * @param offset defines the offset in the source array where the data starts
  3167. * @returns a new quaternion
  3168. */
  3169. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3170. /**
  3171. * Create a quaternion from Euler rotation angles
  3172. * @param x Pitch
  3173. * @param y Yaw
  3174. * @param z Roll
  3175. * @returns the new Quaternion
  3176. */
  3177. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3178. /**
  3179. * Updates a quaternion from Euler rotation angles
  3180. * @param x Pitch
  3181. * @param y Yaw
  3182. * @param z Roll
  3183. * @param result the quaternion to store the result
  3184. * @returns the updated quaternion
  3185. */
  3186. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3187. /**
  3188. * Create a quaternion from Euler rotation vector
  3189. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3190. * @returns the new Quaternion
  3191. */
  3192. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3193. /**
  3194. * Updates a quaternion from Euler rotation vector
  3195. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3196. * @param result the quaternion to store the result
  3197. * @returns the updated quaternion
  3198. */
  3199. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3200. /**
  3201. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3202. * @param yaw defines the rotation around Y axis
  3203. * @param pitch defines the rotation around X axis
  3204. * @param roll defines the rotation around Z axis
  3205. * @returns the new quaternion
  3206. */
  3207. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3208. /**
  3209. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3210. * @param yaw defines the rotation around Y axis
  3211. * @param pitch defines the rotation around X axis
  3212. * @param roll defines the rotation around Z axis
  3213. * @param result defines the target quaternion
  3214. */
  3215. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3216. /**
  3217. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3218. * @param alpha defines the rotation around first axis
  3219. * @param beta defines the rotation around second axis
  3220. * @param gamma defines the rotation around third axis
  3221. * @returns the new quaternion
  3222. */
  3223. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3224. /**
  3225. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3226. * @param alpha defines the rotation around first axis
  3227. * @param beta defines the rotation around second axis
  3228. * @param gamma defines the rotation around third axis
  3229. * @param result defines the target quaternion
  3230. */
  3231. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3232. /**
  3233. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3234. * @param axis1 defines the first axis
  3235. * @param axis2 defines the second axis
  3236. * @param axis3 defines the third axis
  3237. * @returns the new quaternion
  3238. */
  3239. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3240. /**
  3241. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3242. * @param axis1 defines the first axis
  3243. * @param axis2 defines the second axis
  3244. * @param axis3 defines the third axis
  3245. * @param ref defines the target quaternion
  3246. */
  3247. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3248. /**
  3249. * Interpolates between two quaternions
  3250. * @param left defines first quaternion
  3251. * @param right defines second quaternion
  3252. * @param amount defines the gradient to use
  3253. * @returns the new interpolated quaternion
  3254. */
  3255. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3256. /**
  3257. * Interpolates between two quaternions and stores it into a target quaternion
  3258. * @param left defines first quaternion
  3259. * @param right defines second quaternion
  3260. * @param amount defines the gradient to use
  3261. * @param result defines the target quaternion
  3262. */
  3263. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3264. /**
  3265. * Interpolate between two quaternions using Hermite interpolation
  3266. * @param value1 defines first quaternion
  3267. * @param tangent1 defines the incoming tangent
  3268. * @param value2 defines second quaternion
  3269. * @param tangent2 defines the outgoing tangent
  3270. * @param amount defines the target quaternion
  3271. * @returns the new interpolated quaternion
  3272. */
  3273. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3274. }
  3275. /**
  3276. * Class used to store matrix data (4x4)
  3277. */
  3278. export class Matrix {
  3279. private static _updateFlagSeed;
  3280. private static _identityReadOnly;
  3281. private _isIdentity;
  3282. private _isIdentityDirty;
  3283. private _isIdentity3x2;
  3284. private _isIdentity3x2Dirty;
  3285. /**
  3286. * Gets the update flag of the matrix which is an unique number for the matrix.
  3287. * It will be incremented every time the matrix data change.
  3288. * You can use it to speed the comparison between two versions of the same matrix.
  3289. */
  3290. updateFlag: number;
  3291. private readonly _m;
  3292. /**
  3293. * Gets the internal data of the matrix
  3294. */
  3295. readonly m: DeepImmutable<Float32Array>;
  3296. /** @hidden */
  3297. _markAsUpdated(): void;
  3298. /** @hidden */
  3299. private _updateIdentityStatus;
  3300. /**
  3301. * Creates an empty matrix (filled with zeros)
  3302. */
  3303. constructor();
  3304. /**
  3305. * Check if the current matrix is identity
  3306. * @returns true is the matrix is the identity matrix
  3307. */
  3308. isIdentity(): boolean;
  3309. /**
  3310. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3311. * @returns true is the matrix is the identity matrix
  3312. */
  3313. isIdentityAs3x2(): boolean;
  3314. /**
  3315. * Gets the determinant of the matrix
  3316. * @returns the matrix determinant
  3317. */
  3318. determinant(): number;
  3319. /**
  3320. * Returns the matrix as a Float32Array
  3321. * @returns the matrix underlying array
  3322. */
  3323. toArray(): DeepImmutable<Float32Array>;
  3324. /**
  3325. * Returns the matrix as a Float32Array
  3326. * @returns the matrix underlying array.
  3327. */
  3328. asArray(): DeepImmutable<Float32Array>;
  3329. /**
  3330. * Inverts the current matrix in place
  3331. * @returns the current inverted matrix
  3332. */
  3333. invert(): Matrix;
  3334. /**
  3335. * Sets all the matrix elements to zero
  3336. * @returns the current matrix
  3337. */
  3338. reset(): Matrix;
  3339. /**
  3340. * Adds the current matrix with a second one
  3341. * @param other defines the matrix to add
  3342. * @returns a new matrix as the addition of the current matrix and the given one
  3343. */
  3344. add(other: DeepImmutable<Matrix>): Matrix;
  3345. /**
  3346. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3347. * @param other defines the matrix to add
  3348. * @param result defines the target matrix
  3349. * @returns the current matrix
  3350. */
  3351. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3352. /**
  3353. * Adds in place the given matrix to the current matrix
  3354. * @param other defines the second operand
  3355. * @returns the current updated matrix
  3356. */
  3357. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3358. /**
  3359. * Sets the given matrix to the current inverted Matrix
  3360. * @param other defines the target matrix
  3361. * @returns the unmodified current matrix
  3362. */
  3363. invertToRef(other: Matrix): Matrix;
  3364. /**
  3365. * add a value at the specified position in the current Matrix
  3366. * @param index the index of the value within the matrix. between 0 and 15.
  3367. * @param value the value to be added
  3368. * @returns the current updated matrix
  3369. */
  3370. addAtIndex(index: number, value: number): Matrix;
  3371. /**
  3372. * mutiply the specified position in the current Matrix by a value
  3373. * @param index the index of the value within the matrix. between 0 and 15.
  3374. * @param value the value to be added
  3375. * @returns the current updated matrix
  3376. */
  3377. multiplyAtIndex(index: number, value: number): Matrix;
  3378. /**
  3379. * Inserts the translation vector (using 3 floats) in the current matrix
  3380. * @param x defines the 1st component of the translation
  3381. * @param y defines the 2nd component of the translation
  3382. * @param z defines the 3rd component of the translation
  3383. * @returns the current updated matrix
  3384. */
  3385. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3386. /**
  3387. * Adds the translation vector (using 3 floats) in the current matrix
  3388. * @param x defines the 1st component of the translation
  3389. * @param y defines the 2nd component of the translation
  3390. * @param z defines the 3rd component of the translation
  3391. * @returns the current updated matrix
  3392. */
  3393. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3394. /**
  3395. * Inserts the translation vector in the current matrix
  3396. * @param vector3 defines the translation to insert
  3397. * @returns the current updated matrix
  3398. */
  3399. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3400. /**
  3401. * Gets the translation value of the current matrix
  3402. * @returns a new Vector3 as the extracted translation from the matrix
  3403. */
  3404. getTranslation(): Vector3;
  3405. /**
  3406. * Fill a Vector3 with the extracted translation from the matrix
  3407. * @param result defines the Vector3 where to store the translation
  3408. * @returns the current matrix
  3409. */
  3410. getTranslationToRef(result: Vector3): Matrix;
  3411. /**
  3412. * Remove rotation and scaling part from the matrix
  3413. * @returns the updated matrix
  3414. */
  3415. removeRotationAndScaling(): Matrix;
  3416. /**
  3417. * Multiply two matrices
  3418. * @param other defines the second operand
  3419. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3420. */
  3421. multiply(other: DeepImmutable<Matrix>): Matrix;
  3422. /**
  3423. * Copy the current matrix from the given one
  3424. * @param other defines the source matrix
  3425. * @returns the current updated matrix
  3426. */
  3427. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3428. /**
  3429. * Populates the given array from the starting index with the current matrix values
  3430. * @param array defines the target array
  3431. * @param offset defines the offset in the target array where to start storing values
  3432. * @returns the current matrix
  3433. */
  3434. copyToArray(array: Float32Array, offset?: number): Matrix;
  3435. /**
  3436. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3437. * @param other defines the second operand
  3438. * @param result defines the matrix where to store the multiplication
  3439. * @returns the current matrix
  3440. */
  3441. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3442. /**
  3443. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3444. * @param other defines the second operand
  3445. * @param result defines the array where to store the multiplication
  3446. * @param offset defines the offset in the target array where to start storing values
  3447. * @returns the current matrix
  3448. */
  3449. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3450. /**
  3451. * Check equality between this matrix and a second one
  3452. * @param value defines the second matrix to compare
  3453. * @returns true is the current matrix and the given one values are strictly equal
  3454. */
  3455. equals(value: DeepImmutable<Matrix>): boolean;
  3456. /**
  3457. * Clone the current matrix
  3458. * @returns a new matrix from the current matrix
  3459. */
  3460. clone(): Matrix;
  3461. /**
  3462. * Returns the name of the current matrix class
  3463. * @returns the string "Matrix"
  3464. */
  3465. getClassName(): string;
  3466. /**
  3467. * Gets the hash code of the current matrix
  3468. * @returns the hash code
  3469. */
  3470. getHashCode(): number;
  3471. /**
  3472. * Decomposes the current Matrix into a translation, rotation and scaling components
  3473. * @param scale defines the scale vector3 given as a reference to update
  3474. * @param rotation defines the rotation quaternion given as a reference to update
  3475. * @param translation defines the translation vector3 given as a reference to update
  3476. * @returns true if operation was successful
  3477. */
  3478. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3479. /**
  3480. * Gets specific row of the matrix
  3481. * @param index defines the number of the row to get
  3482. * @returns the index-th row of the current matrix as a new Vector4
  3483. */
  3484. getRow(index: number): Nullable<Vector4>;
  3485. /**
  3486. * Sets the index-th row of the current matrix to the vector4 values
  3487. * @param index defines the number of the row to set
  3488. * @param row defines the target vector4
  3489. * @returns the updated current matrix
  3490. */
  3491. setRow(index: number, row: Vector4): Matrix;
  3492. /**
  3493. * Compute the transpose of the matrix
  3494. * @returns the new transposed matrix
  3495. */
  3496. transpose(): Matrix;
  3497. /**
  3498. * Compute the transpose of the matrix and store it in a given matrix
  3499. * @param result defines the target matrix
  3500. * @returns the current matrix
  3501. */
  3502. transposeToRef(result: Matrix): Matrix;
  3503. /**
  3504. * Sets the index-th row of the current matrix with the given 4 x float values
  3505. * @param index defines the row index
  3506. * @param x defines the x component to set
  3507. * @param y defines the y component to set
  3508. * @param z defines the z component to set
  3509. * @param w defines the w component to set
  3510. * @returns the updated current matrix
  3511. */
  3512. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3513. /**
  3514. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3515. * @param scale defines the scale factor
  3516. * @returns a new matrix
  3517. */
  3518. scale(scale: number): Matrix;
  3519. /**
  3520. * Scale the current matrix values by a factor to a given result matrix
  3521. * @param scale defines the scale factor
  3522. * @param result defines the matrix to store the result
  3523. * @returns the current matrix
  3524. */
  3525. scaleToRef(scale: number, result: Matrix): Matrix;
  3526. /**
  3527. * Scale the current matrix values by a factor and add the result to a given matrix
  3528. * @param scale defines the scale factor
  3529. * @param result defines the Matrix to store the result
  3530. * @returns the current matrix
  3531. */
  3532. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3533. /**
  3534. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3535. * @param ref matrix to store the result
  3536. */
  3537. toNormalMatrix(ref: Matrix): void;
  3538. /**
  3539. * Gets only rotation part of the current matrix
  3540. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3541. */
  3542. getRotationMatrix(): Matrix;
  3543. /**
  3544. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3545. * @param result defines the target matrix to store data to
  3546. * @returns the current matrix
  3547. */
  3548. getRotationMatrixToRef(result: Matrix): Matrix;
  3549. /**
  3550. * Toggles model matrix from being right handed to left handed in place and vice versa
  3551. */
  3552. toggleModelMatrixHandInPlace(): void;
  3553. /**
  3554. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3555. */
  3556. toggleProjectionMatrixHandInPlace(): void;
  3557. /**
  3558. * Creates a matrix from an array
  3559. * @param array defines the source array
  3560. * @param offset defines an offset in the source array
  3561. * @returns a new Matrix set from the starting index of the given array
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3564. /**
  3565. * Copy the content of an array into a given matrix
  3566. * @param array defines the source array
  3567. * @param offset defines an offset in the source array
  3568. * @param result defines the target matrix
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3571. /**
  3572. * Stores an array into a matrix after having multiplied each component by a given factor
  3573. * @param array defines the source array
  3574. * @param offset defines the offset in the source array
  3575. * @param scale defines the scaling factor
  3576. * @param result defines the target matrix
  3577. */
  3578. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3579. /**
  3580. * Gets an identity matrix that must not be updated
  3581. */
  3582. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3583. /**
  3584. * Stores a list of values (16) inside a given matrix
  3585. * @param initialM11 defines 1st value of 1st row
  3586. * @param initialM12 defines 2nd value of 1st row
  3587. * @param initialM13 defines 3rd value of 1st row
  3588. * @param initialM14 defines 4th value of 1st row
  3589. * @param initialM21 defines 1st value of 2nd row
  3590. * @param initialM22 defines 2nd value of 2nd row
  3591. * @param initialM23 defines 3rd value of 2nd row
  3592. * @param initialM24 defines 4th value of 2nd row
  3593. * @param initialM31 defines 1st value of 3rd row
  3594. * @param initialM32 defines 2nd value of 3rd row
  3595. * @param initialM33 defines 3rd value of 3rd row
  3596. * @param initialM34 defines 4th value of 3rd row
  3597. * @param initialM41 defines 1st value of 4th row
  3598. * @param initialM42 defines 2nd value of 4th row
  3599. * @param initialM43 defines 3rd value of 4th row
  3600. * @param initialM44 defines 4th value of 4th row
  3601. * @param result defines the target matrix
  3602. */
  3603. 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;
  3604. /**
  3605. * Creates new matrix from a list of values (16)
  3606. * @param initialM11 defines 1st value of 1st row
  3607. * @param initialM12 defines 2nd value of 1st row
  3608. * @param initialM13 defines 3rd value of 1st row
  3609. * @param initialM14 defines 4th value of 1st row
  3610. * @param initialM21 defines 1st value of 2nd row
  3611. * @param initialM22 defines 2nd value of 2nd row
  3612. * @param initialM23 defines 3rd value of 2nd row
  3613. * @param initialM24 defines 4th value of 2nd row
  3614. * @param initialM31 defines 1st value of 3rd row
  3615. * @param initialM32 defines 2nd value of 3rd row
  3616. * @param initialM33 defines 3rd value of 3rd row
  3617. * @param initialM34 defines 4th value of 3rd row
  3618. * @param initialM41 defines 1st value of 4th row
  3619. * @param initialM42 defines 2nd value of 4th row
  3620. * @param initialM43 defines 3rd value of 4th row
  3621. * @param initialM44 defines 4th value of 4th row
  3622. * @returns the new matrix
  3623. */
  3624. 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;
  3625. /**
  3626. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3627. * @param scale defines the scale vector3
  3628. * @param rotation defines the rotation quaternion
  3629. * @param translation defines the translation vector3
  3630. * @returns a new matrix
  3631. */
  3632. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3633. /**
  3634. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3635. * @param scale defines the scale vector3
  3636. * @param rotation defines the rotation quaternion
  3637. * @param translation defines the translation vector3
  3638. * @param result defines the target matrix
  3639. */
  3640. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3641. /**
  3642. * Creates a new identity matrix
  3643. * @returns a new identity matrix
  3644. */
  3645. static Identity(): Matrix;
  3646. /**
  3647. * Creates a new identity matrix and stores the result in a given matrix
  3648. * @param result defines the target matrix
  3649. */
  3650. static IdentityToRef(result: Matrix): void;
  3651. /**
  3652. * Creates a new zero matrix
  3653. * @returns a new zero matrix
  3654. */
  3655. static Zero(): Matrix;
  3656. /**
  3657. * Creates a new rotation matrix for "angle" radians around the X axis
  3658. * @param angle defines the angle (in radians) to use
  3659. * @return the new matrix
  3660. */
  3661. static RotationX(angle: number): Matrix;
  3662. /**
  3663. * Creates a new matrix as the invert of a given matrix
  3664. * @param source defines the source matrix
  3665. * @returns the new matrix
  3666. */
  3667. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3668. /**
  3669. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3670. * @param angle defines the angle (in radians) to use
  3671. * @param result defines the target matrix
  3672. */
  3673. static RotationXToRef(angle: number, result: Matrix): void;
  3674. /**
  3675. * Creates a new rotation matrix for "angle" radians around the Y axis
  3676. * @param angle defines the angle (in radians) to use
  3677. * @return the new matrix
  3678. */
  3679. static RotationY(angle: number): Matrix;
  3680. /**
  3681. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3682. * @param angle defines the angle (in radians) to use
  3683. * @param result defines the target matrix
  3684. */
  3685. static RotationYToRef(angle: number, result: Matrix): void;
  3686. /**
  3687. * Creates a new rotation matrix for "angle" radians around the Z axis
  3688. * @param angle defines the angle (in radians) to use
  3689. * @return the new matrix
  3690. */
  3691. static RotationZ(angle: number): Matrix;
  3692. /**
  3693. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3694. * @param angle defines the angle (in radians) to use
  3695. * @param result defines the target matrix
  3696. */
  3697. static RotationZToRef(angle: number, result: Matrix): void;
  3698. /**
  3699. * Creates a new rotation matrix for "angle" radians around the given axis
  3700. * @param axis defines the axis to use
  3701. * @param angle defines the angle (in radians) to use
  3702. * @return the new matrix
  3703. */
  3704. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3705. /**
  3706. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3707. * @param axis defines the axis to use
  3708. * @param angle defines the angle (in radians) to use
  3709. * @param result defines the target matrix
  3710. */
  3711. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3712. /**
  3713. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3714. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3715. * @param from defines the vector to align
  3716. * @param to defines the vector to align to
  3717. * @param result defines the target matrix
  3718. */
  3719. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3720. /**
  3721. * Creates a rotation matrix
  3722. * @param yaw defines the yaw angle in radians (Y axis)
  3723. * @param pitch defines the pitch angle in radians (X axis)
  3724. * @param roll defines the roll angle in radians (X axis)
  3725. * @returns the new rotation matrix
  3726. */
  3727. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3728. /**
  3729. * Creates a rotation matrix and stores it in a given matrix
  3730. * @param yaw defines the yaw angle in radians (Y axis)
  3731. * @param pitch defines the pitch angle in radians (X axis)
  3732. * @param roll defines the roll angle in radians (X axis)
  3733. * @param result defines the target matrix
  3734. */
  3735. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3736. /**
  3737. * Creates a scaling matrix
  3738. * @param x defines the scale factor on X axis
  3739. * @param y defines the scale factor on Y axis
  3740. * @param z defines the scale factor on Z axis
  3741. * @returns the new matrix
  3742. */
  3743. static Scaling(x: number, y: number, z: number): Matrix;
  3744. /**
  3745. * Creates a scaling matrix and stores it in a given matrix
  3746. * @param x defines the scale factor on X axis
  3747. * @param y defines the scale factor on Y axis
  3748. * @param z defines the scale factor on Z axis
  3749. * @param result defines the target matrix
  3750. */
  3751. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3752. /**
  3753. * Creates a translation matrix
  3754. * @param x defines the translation on X axis
  3755. * @param y defines the translation on Y axis
  3756. * @param z defines the translationon Z axis
  3757. * @returns the new matrix
  3758. */
  3759. static Translation(x: number, y: number, z: number): Matrix;
  3760. /**
  3761. * Creates a translation matrix and stores it in a given matrix
  3762. * @param x defines the translation on X axis
  3763. * @param y defines the translation on Y axis
  3764. * @param z defines the translationon Z axis
  3765. * @param result defines the target matrix
  3766. */
  3767. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3768. /**
  3769. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3770. * @param startValue defines the start value
  3771. * @param endValue defines the end value
  3772. * @param gradient defines the gradient factor
  3773. * @returns the new matrix
  3774. */
  3775. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3776. /**
  3777. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3778. * @param startValue defines the start value
  3779. * @param endValue defines the end value
  3780. * @param gradient defines the gradient factor
  3781. * @param result defines the Matrix object where to store data
  3782. */
  3783. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3784. /**
  3785. * Builds a new matrix whose values are computed by:
  3786. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3787. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3788. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3789. * @param startValue defines the first matrix
  3790. * @param endValue defines the second matrix
  3791. * @param gradient defines the gradient between the two matrices
  3792. * @returns the new matrix
  3793. */
  3794. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3795. /**
  3796. * Update a matrix to values which are computed by:
  3797. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3798. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3799. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3800. * @param startValue defines the first matrix
  3801. * @param endValue defines the second matrix
  3802. * @param gradient defines the gradient between the two matrices
  3803. * @param result defines the target matrix
  3804. */
  3805. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3806. /**
  3807. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3808. * This function works in left handed mode
  3809. * @param eye defines the final position of the entity
  3810. * @param target defines where the entity should look at
  3811. * @param up defines the up vector for the entity
  3812. * @returns the new matrix
  3813. */
  3814. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3815. /**
  3816. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3817. * This function works in left handed mode
  3818. * @param eye defines the final position of the entity
  3819. * @param target defines where the entity should look at
  3820. * @param up defines the up vector for the entity
  3821. * @param result defines the target matrix
  3822. */
  3823. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3824. /**
  3825. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3826. * This function works in right handed mode
  3827. * @param eye defines the final position of the entity
  3828. * @param target defines where the entity should look at
  3829. * @param up defines the up vector for the entity
  3830. * @returns the new matrix
  3831. */
  3832. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3833. /**
  3834. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3835. * This function works in right handed mode
  3836. * @param eye defines the final position of the entity
  3837. * @param target defines where the entity should look at
  3838. * @param up defines the up vector for the entity
  3839. * @param result defines the target matrix
  3840. */
  3841. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3842. /**
  3843. * Create a left-handed orthographic projection matrix
  3844. * @param width defines the viewport width
  3845. * @param height defines the viewport height
  3846. * @param znear defines the near clip plane
  3847. * @param zfar defines the far clip plane
  3848. * @returns a new matrix as a left-handed orthographic projection matrix
  3849. */
  3850. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3851. /**
  3852. * Store a left-handed orthographic projection to a given matrix
  3853. * @param width defines the viewport width
  3854. * @param height defines the viewport height
  3855. * @param znear defines the near clip plane
  3856. * @param zfar defines the far clip plane
  3857. * @param result defines the target matrix
  3858. */
  3859. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3860. /**
  3861. * Create a left-handed orthographic projection matrix
  3862. * @param left defines the viewport left coordinate
  3863. * @param right defines the viewport right coordinate
  3864. * @param bottom defines the viewport bottom coordinate
  3865. * @param top defines the viewport top coordinate
  3866. * @param znear defines the near clip plane
  3867. * @param zfar defines the far clip plane
  3868. * @returns a new matrix as a left-handed orthographic projection matrix
  3869. */
  3870. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3871. /**
  3872. * Stores a left-handed orthographic projection into a given matrix
  3873. * @param left defines the viewport left coordinate
  3874. * @param right defines the viewport right coordinate
  3875. * @param bottom defines the viewport bottom coordinate
  3876. * @param top defines the viewport top coordinate
  3877. * @param znear defines the near clip plane
  3878. * @param zfar defines the far clip plane
  3879. * @param result defines the target matrix
  3880. */
  3881. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3882. /**
  3883. * Creates a right-handed orthographic projection matrix
  3884. * @param left defines the viewport left coordinate
  3885. * @param right defines the viewport right coordinate
  3886. * @param bottom defines the viewport bottom coordinate
  3887. * @param top defines the viewport top coordinate
  3888. * @param znear defines the near clip plane
  3889. * @param zfar defines the far clip plane
  3890. * @returns a new matrix as a right-handed orthographic projection matrix
  3891. */
  3892. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3893. /**
  3894. * Stores a right-handed orthographic projection into a given matrix
  3895. * @param left defines the viewport left coordinate
  3896. * @param right defines the viewport right coordinate
  3897. * @param bottom defines the viewport bottom coordinate
  3898. * @param top defines the viewport top coordinate
  3899. * @param znear defines the near clip plane
  3900. * @param zfar defines the far clip plane
  3901. * @param result defines the target matrix
  3902. */
  3903. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3904. /**
  3905. * Creates a left-handed perspective projection matrix
  3906. * @param width defines the viewport width
  3907. * @param height defines the viewport height
  3908. * @param znear defines the near clip plane
  3909. * @param zfar defines the far clip plane
  3910. * @returns a new matrix as a left-handed perspective projection matrix
  3911. */
  3912. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3913. /**
  3914. * Creates a left-handed perspective projection matrix
  3915. * @param fov defines the horizontal field of view
  3916. * @param aspect defines the aspect ratio
  3917. * @param znear defines the near clip plane
  3918. * @param zfar defines the far clip plane
  3919. * @returns a new matrix as a left-handed perspective projection matrix
  3920. */
  3921. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3922. /**
  3923. * Stores a left-handed perspective projection into a given matrix
  3924. * @param fov defines the horizontal field of view
  3925. * @param aspect defines the aspect ratio
  3926. * @param znear defines the near clip plane
  3927. * @param zfar defines the far clip plane
  3928. * @param result defines the target matrix
  3929. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3930. */
  3931. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3932. /**
  3933. * Creates a right-handed perspective projection matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @returns a new matrix as a right-handed perspective projection matrix
  3939. */
  3940. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3941. /**
  3942. * Stores a right-handed perspective projection into a given matrix
  3943. * @param fov defines the horizontal field of view
  3944. * @param aspect defines the aspect ratio
  3945. * @param znear defines the near clip plane
  3946. * @param zfar defines the far clip plane
  3947. * @param result defines the target matrix
  3948. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3949. */
  3950. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3951. /**
  3952. * Stores a perspective projection for WebVR info a given matrix
  3953. * @param fov defines the field of view
  3954. * @param znear defines the near clip plane
  3955. * @param zfar defines the far clip plane
  3956. * @param result defines the target matrix
  3957. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3958. */
  3959. static PerspectiveFovWebVRToRef(fov: {
  3960. upDegrees: number;
  3961. downDegrees: number;
  3962. leftDegrees: number;
  3963. rightDegrees: number;
  3964. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3965. /**
  3966. * Computes a complete transformation matrix
  3967. * @param viewport defines the viewport to use
  3968. * @param world defines the world matrix
  3969. * @param view defines the view matrix
  3970. * @param projection defines the projection matrix
  3971. * @param zmin defines the near clip plane
  3972. * @param zmax defines the far clip plane
  3973. * @returns the transformation matrix
  3974. */
  3975. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3976. /**
  3977. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3978. * @param matrix defines the matrix to use
  3979. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3980. */
  3981. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3982. /**
  3983. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3984. * @param matrix defines the matrix to use
  3985. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3986. */
  3987. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3988. /**
  3989. * Compute the transpose of a given matrix
  3990. * @param matrix defines the matrix to transpose
  3991. * @returns the new matrix
  3992. */
  3993. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3994. /**
  3995. * Compute the transpose of a matrix and store it in a target matrix
  3996. * @param matrix defines the matrix to transpose
  3997. * @param result defines the target matrix
  3998. */
  3999. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4000. /**
  4001. * Computes a reflection matrix from a plane
  4002. * @param plane defines the reflection plane
  4003. * @returns a new matrix
  4004. */
  4005. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4006. /**
  4007. * Computes a reflection matrix from a plane
  4008. * @param plane defines the reflection plane
  4009. * @param result defines the target matrix
  4010. */
  4011. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4012. /**
  4013. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4014. * @param xaxis defines the value of the 1st axis
  4015. * @param yaxis defines the value of the 2nd axis
  4016. * @param zaxis defines the value of the 3rd axis
  4017. * @param result defines the target matrix
  4018. */
  4019. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4020. /**
  4021. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4022. * @param quat defines the quaternion to use
  4023. * @param result defines the target matrix
  4024. */
  4025. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4026. }
  4027. /**
  4028. * @hidden
  4029. */
  4030. export class TmpVectors {
  4031. static Vector2: Vector2[];
  4032. static Vector3: Vector3[];
  4033. static Vector4: Vector4[];
  4034. static Quaternion: Quaternion[];
  4035. static Matrix: Matrix[];
  4036. }
  4037. }
  4038. declare module BABYLON {
  4039. /** Defines the cross module used constants to avoid circular dependncies */
  4040. export class Constants {
  4041. /** Defines that alpha blending is disabled */
  4042. static readonly ALPHA_DISABLE: number;
  4043. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4044. static readonly ALPHA_ADD: number;
  4045. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4046. static readonly ALPHA_COMBINE: number;
  4047. /** Defines that alpha blending to DEST - SRC * DEST */
  4048. static readonly ALPHA_SUBTRACT: number;
  4049. /** Defines that alpha blending to SRC * DEST */
  4050. static readonly ALPHA_MULTIPLY: number;
  4051. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4052. static readonly ALPHA_MAXIMIZED: number;
  4053. /** Defines that alpha blending to SRC + DEST */
  4054. static readonly ALPHA_ONEONE: number;
  4055. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_PREMULTIPLIED: number;
  4057. /**
  4058. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4059. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4060. */
  4061. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4062. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4063. static readonly ALPHA_INTERPOLATE: number;
  4064. /**
  4065. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4066. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4067. */
  4068. static readonly ALPHA_SCREENMODE: number;
  4069. /** Defines that the ressource is not delayed*/
  4070. static readonly DELAYLOADSTATE_NONE: number;
  4071. /** Defines that the ressource was successfully delay loaded */
  4072. static readonly DELAYLOADSTATE_LOADED: number;
  4073. /** Defines that the ressource is currently delay loading */
  4074. static readonly DELAYLOADSTATE_LOADING: number;
  4075. /** Defines that the ressource is delayed and has not started loading */
  4076. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4077. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4078. static readonly NEVER: number;
  4079. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4080. static readonly ALWAYS: number;
  4081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4082. static readonly LESS: number;
  4083. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4084. static readonly EQUAL: number;
  4085. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4086. static readonly LEQUAL: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4088. static readonly GREATER: number;
  4089. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4090. static readonly GEQUAL: number;
  4091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4092. static readonly NOTEQUAL: number;
  4093. /** Passed to stencilOperation to specify that stencil value must be kept */
  4094. static readonly KEEP: number;
  4095. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4096. static readonly REPLACE: number;
  4097. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4098. static readonly INCR: number;
  4099. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4100. static readonly DECR: number;
  4101. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4102. static readonly INVERT: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4104. static readonly INCR_WRAP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4106. static readonly DECR_WRAP: number;
  4107. /** Texture is not repeating outside of 0..1 UVs */
  4108. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4109. /** Texture is repeating outside of 0..1 UVs */
  4110. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4111. /** Texture is repeating and mirrored */
  4112. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4113. /** ALPHA */
  4114. static readonly TEXTUREFORMAT_ALPHA: number;
  4115. /** LUMINANCE */
  4116. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4117. /** LUMINANCE_ALPHA */
  4118. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4119. /** RGB */
  4120. static readonly TEXTUREFORMAT_RGB: number;
  4121. /** RGBA */
  4122. static readonly TEXTUREFORMAT_RGBA: number;
  4123. /** RED */
  4124. static readonly TEXTUREFORMAT_RED: number;
  4125. /** RED (2nd reference) */
  4126. static readonly TEXTUREFORMAT_R: number;
  4127. /** RG */
  4128. static readonly TEXTUREFORMAT_RG: number;
  4129. /** RED_INTEGER */
  4130. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4131. /** RED_INTEGER (2nd reference) */
  4132. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4133. /** RG_INTEGER */
  4134. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4135. /** RGB_INTEGER */
  4136. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4137. /** RGBA_INTEGER */
  4138. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4139. /** UNSIGNED_BYTE */
  4140. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4141. /** UNSIGNED_BYTE (2nd reference) */
  4142. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4143. /** FLOAT */
  4144. static readonly TEXTURETYPE_FLOAT: number;
  4145. /** HALF_FLOAT */
  4146. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4147. /** BYTE */
  4148. static readonly TEXTURETYPE_BYTE: number;
  4149. /** SHORT */
  4150. static readonly TEXTURETYPE_SHORT: number;
  4151. /** UNSIGNED_SHORT */
  4152. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4153. /** INT */
  4154. static readonly TEXTURETYPE_INT: number;
  4155. /** UNSIGNED_INT */
  4156. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4157. /** UNSIGNED_SHORT_4_4_4_4 */
  4158. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4159. /** UNSIGNED_SHORT_5_5_5_1 */
  4160. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4161. /** UNSIGNED_SHORT_5_6_5 */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4163. /** UNSIGNED_INT_2_10_10_10_REV */
  4164. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4165. /** UNSIGNED_INT_24_8 */
  4166. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4167. /** UNSIGNED_INT_10F_11F_11F_REV */
  4168. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4169. /** UNSIGNED_INT_5_9_9_9_REV */
  4170. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4171. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4172. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4173. /** nearest is mag = nearest and min = nearest and mip = linear */
  4174. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4175. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4176. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4177. /** Trilinear is mag = linear and min = linear and mip = linear */
  4178. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4179. /** nearest is mag = nearest and min = nearest and mip = linear */
  4180. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4181. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4182. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4183. /** Trilinear is mag = linear and min = linear and mip = linear */
  4184. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4185. /** mag = nearest and min = nearest and mip = nearest */
  4186. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4187. /** mag = nearest and min = linear and mip = nearest */
  4188. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4189. /** mag = nearest and min = linear and mip = linear */
  4190. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4191. /** mag = nearest and min = linear and mip = none */
  4192. static readonly TEXTURE_NEAREST_LINEAR: number;
  4193. /** mag = nearest and min = nearest and mip = none */
  4194. static readonly TEXTURE_NEAREST_NEAREST: number;
  4195. /** mag = linear and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4197. /** mag = linear and min = nearest and mip = linear */
  4198. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4199. /** mag = linear and min = linear and mip = none */
  4200. static readonly TEXTURE_LINEAR_LINEAR: number;
  4201. /** mag = linear and min = nearest and mip = none */
  4202. static readonly TEXTURE_LINEAR_NEAREST: number;
  4203. /** Explicit coordinates mode */
  4204. static readonly TEXTURE_EXPLICIT_MODE: number;
  4205. /** Spherical coordinates mode */
  4206. static readonly TEXTURE_SPHERICAL_MODE: number;
  4207. /** Planar coordinates mode */
  4208. static readonly TEXTURE_PLANAR_MODE: number;
  4209. /** Cubic coordinates mode */
  4210. static readonly TEXTURE_CUBIC_MODE: number;
  4211. /** Projection coordinates mode */
  4212. static readonly TEXTURE_PROJECTION_MODE: number;
  4213. /** Skybox coordinates mode */
  4214. static readonly TEXTURE_SKYBOX_MODE: number;
  4215. /** Inverse Cubic coordinates mode */
  4216. static readonly TEXTURE_INVCUBIC_MODE: number;
  4217. /** Equirectangular coordinates mode */
  4218. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4219. /** Equirectangular Fixed coordinates mode */
  4220. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4221. /** Equirectangular Fixed Mirrored coordinates mode */
  4222. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4223. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4224. static readonly SCALEMODE_FLOOR: number;
  4225. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4226. static readonly SCALEMODE_NEAREST: number;
  4227. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4228. static readonly SCALEMODE_CEILING: number;
  4229. /**
  4230. * The dirty texture flag value
  4231. */
  4232. static readonly MATERIAL_TextureDirtyFlag: number;
  4233. /**
  4234. * The dirty light flag value
  4235. */
  4236. static readonly MATERIAL_LightDirtyFlag: number;
  4237. /**
  4238. * The dirty fresnel flag value
  4239. */
  4240. static readonly MATERIAL_FresnelDirtyFlag: number;
  4241. /**
  4242. * The dirty attribute flag value
  4243. */
  4244. static readonly MATERIAL_AttributesDirtyFlag: number;
  4245. /**
  4246. * The dirty misc flag value
  4247. */
  4248. static readonly MATERIAL_MiscDirtyFlag: number;
  4249. /**
  4250. * The all dirty flag value
  4251. */
  4252. static readonly MATERIAL_AllDirtyFlag: number;
  4253. /**
  4254. * Returns the triangle fill mode
  4255. */
  4256. static readonly MATERIAL_TriangleFillMode: number;
  4257. /**
  4258. * Returns the wireframe mode
  4259. */
  4260. static readonly MATERIAL_WireFrameFillMode: number;
  4261. /**
  4262. * Returns the point fill mode
  4263. */
  4264. static readonly MATERIAL_PointFillMode: number;
  4265. /**
  4266. * Returns the point list draw mode
  4267. */
  4268. static readonly MATERIAL_PointListDrawMode: number;
  4269. /**
  4270. * Returns the line list draw mode
  4271. */
  4272. static readonly MATERIAL_LineListDrawMode: number;
  4273. /**
  4274. * Returns the line loop draw mode
  4275. */
  4276. static readonly MATERIAL_LineLoopDrawMode: number;
  4277. /**
  4278. * Returns the line strip draw mode
  4279. */
  4280. static readonly MATERIAL_LineStripDrawMode: number;
  4281. /**
  4282. * Returns the triangle strip draw mode
  4283. */
  4284. static readonly MATERIAL_TriangleStripDrawMode: number;
  4285. /**
  4286. * Returns the triangle fan draw mode
  4287. */
  4288. static readonly MATERIAL_TriangleFanDrawMode: number;
  4289. /**
  4290. * Stores the clock-wise side orientation
  4291. */
  4292. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4293. /**
  4294. * Stores the counter clock-wise side orientation
  4295. */
  4296. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4297. /**
  4298. * Nothing
  4299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4300. */
  4301. static readonly ACTION_NothingTrigger: number;
  4302. /**
  4303. * On pick
  4304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4305. */
  4306. static readonly ACTION_OnPickTrigger: number;
  4307. /**
  4308. * On left pick
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_OnLeftPickTrigger: number;
  4312. /**
  4313. * On right pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnRightPickTrigger: number;
  4317. /**
  4318. * On center pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnCenterPickTrigger: number;
  4322. /**
  4323. * On pick down
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnPickDownTrigger: number;
  4327. /**
  4328. * On double pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnDoublePickTrigger: number;
  4332. /**
  4333. * On pick up
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickUpTrigger: number;
  4337. /**
  4338. * On pick out.
  4339. * This trigger will only be raised if you also declared a OnPickDown
  4340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4341. */
  4342. static readonly ACTION_OnPickOutTrigger: number;
  4343. /**
  4344. * On long press
  4345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4346. */
  4347. static readonly ACTION_OnLongPressTrigger: number;
  4348. /**
  4349. * On pointer over
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPointerOverTrigger: number;
  4353. /**
  4354. * On pointer out
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPointerOutTrigger: number;
  4358. /**
  4359. * On every frame
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnEveryFrameTrigger: number;
  4363. /**
  4364. * On intersection enter
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4368. /**
  4369. * On intersection exit
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnIntersectionExitTrigger: number;
  4373. /**
  4374. * On key down
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnKeyDownTrigger: number;
  4378. /**
  4379. * On key up
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnKeyUpTrigger: number;
  4383. /**
  4384. * Billboard mode will only apply to Y axis
  4385. */
  4386. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4387. /**
  4388. * Billboard mode will apply to all axes
  4389. */
  4390. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4391. /**
  4392. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4393. */
  4394. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4395. /**
  4396. * Gets or sets base Assets URL
  4397. */
  4398. static PARTICLES_BaseAssetsUrl: string;
  4399. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4400. * Test order :
  4401. * Is the bounding sphere outside the frustum ?
  4402. * If not, are the bounding box vertices outside the frustum ?
  4403. * It not, then the cullable object is in the frustum.
  4404. */
  4405. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4406. /** Culling strategy : Bounding Sphere Only.
  4407. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4408. * It's also less accurate than the standard because some not visible objects can still be selected.
  4409. * Test : is the bounding sphere outside the frustum ?
  4410. * If not, then the cullable object is in the frustum.
  4411. */
  4412. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4413. /** Culling strategy : Optimistic Inclusion.
  4414. * This in an inclusion test first, then the standard exclusion test.
  4415. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4416. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4417. * Anyway, it's as accurate as the standard strategy.
  4418. * Test :
  4419. * Is the cullable object bounding sphere center in the frustum ?
  4420. * If not, apply the default culling strategy.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4423. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4424. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4425. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4426. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4427. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4433. /**
  4434. * No logging while loading
  4435. */
  4436. static readonly SCENELOADER_NO_LOGGING: number;
  4437. /**
  4438. * Minimal logging while loading
  4439. */
  4440. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4441. /**
  4442. * Summary logging while loading
  4443. */
  4444. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4445. /**
  4446. * Detailled logging while loading
  4447. */
  4448. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4449. }
  4450. }
  4451. declare module BABYLON {
  4452. /**
  4453. * Class used to store and describe the pipeline context associated with an effect
  4454. */
  4455. export interface IPipelineContext {
  4456. /**
  4457. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4458. */
  4459. isAsync: boolean;
  4460. /**
  4461. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4462. */
  4463. isReady: boolean;
  4464. /** @hidden */
  4465. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4466. }
  4467. }
  4468. declare module BABYLON {
  4469. /** @hidden */
  4470. export interface IShaderProcessor {
  4471. attributeProcessor?: (attribute: string) => string;
  4472. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4473. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4474. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4475. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4476. lineProcessor?: (line: string, isFragment: boolean) => string;
  4477. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4478. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4479. }
  4480. }
  4481. declare module BABYLON {
  4482. /** @hidden */
  4483. export interface ProcessingOptions {
  4484. defines: string[];
  4485. indexParameters: any;
  4486. isFragment: boolean;
  4487. shouldUseHighPrecisionShader: boolean;
  4488. supportsUniformBuffers: boolean;
  4489. shadersRepository: string;
  4490. includesShadersStore: {
  4491. [key: string]: string;
  4492. };
  4493. processor?: IShaderProcessor;
  4494. version: string;
  4495. platformName: string;
  4496. lookForClosingBracketForUniformBuffer?: boolean;
  4497. }
  4498. }
  4499. declare module BABYLON {
  4500. /**
  4501. * Helper to manipulate strings
  4502. */
  4503. export class StringTools {
  4504. /**
  4505. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4506. * @param str Source string
  4507. * @param suffix Suffix to search for in the source string
  4508. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4509. */
  4510. static EndsWith(str: string, suffix: string): boolean;
  4511. /**
  4512. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4513. * @param str Source string
  4514. * @param suffix Suffix to search for in the source string
  4515. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4516. */
  4517. static StartsWith(str: string, suffix: string): boolean;
  4518. }
  4519. }
  4520. declare module BABYLON {
  4521. /** @hidden */
  4522. export class ShaderCodeNode {
  4523. line: string;
  4524. children: ShaderCodeNode[];
  4525. additionalDefineKey?: string;
  4526. additionalDefineValue?: string;
  4527. isValid(preprocessors: {
  4528. [key: string]: string;
  4529. }): boolean;
  4530. process(preprocessors: {
  4531. [key: string]: string;
  4532. }, options: ProcessingOptions): string;
  4533. }
  4534. }
  4535. declare module BABYLON {
  4536. /** @hidden */
  4537. export class ShaderCodeCursor {
  4538. private _lines;
  4539. lineIndex: number;
  4540. readonly currentLine: string;
  4541. readonly canRead: boolean;
  4542. lines: string[];
  4543. }
  4544. }
  4545. declare module BABYLON {
  4546. /** @hidden */
  4547. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4548. process(preprocessors: {
  4549. [key: string]: string;
  4550. }, options: ProcessingOptions): string;
  4551. }
  4552. }
  4553. declare module BABYLON {
  4554. /** @hidden */
  4555. export class ShaderDefineExpression {
  4556. isTrue(preprocessors: {
  4557. [key: string]: string;
  4558. }): boolean;
  4559. }
  4560. }
  4561. declare module BABYLON {
  4562. /** @hidden */
  4563. export class ShaderCodeTestNode extends ShaderCodeNode {
  4564. testExpression: ShaderDefineExpression;
  4565. isValid(preprocessors: {
  4566. [key: string]: string;
  4567. }): boolean;
  4568. }
  4569. }
  4570. declare module BABYLON {
  4571. /** @hidden */
  4572. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4573. define: string;
  4574. not: boolean;
  4575. constructor(define: string, not?: boolean);
  4576. isTrue(preprocessors: {
  4577. [key: string]: string;
  4578. }): boolean;
  4579. }
  4580. }
  4581. declare module BABYLON {
  4582. /** @hidden */
  4583. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4584. leftOperand: ShaderDefineExpression;
  4585. rightOperand: ShaderDefineExpression;
  4586. isTrue(preprocessors: {
  4587. [key: string]: string;
  4588. }): boolean;
  4589. }
  4590. }
  4591. declare module BABYLON {
  4592. /** @hidden */
  4593. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4594. leftOperand: ShaderDefineExpression;
  4595. rightOperand: ShaderDefineExpression;
  4596. isTrue(preprocessors: {
  4597. [key: string]: string;
  4598. }): boolean;
  4599. }
  4600. }
  4601. declare module BABYLON {
  4602. /** @hidden */
  4603. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4604. define: string;
  4605. operand: string;
  4606. testValue: string;
  4607. constructor(define: string, operand: string, testValue: string);
  4608. isTrue(preprocessors: {
  4609. [key: string]: string;
  4610. }): boolean;
  4611. }
  4612. }
  4613. declare module BABYLON {
  4614. /**
  4615. * @ignore
  4616. * Application error to support additional information when loading a file
  4617. */
  4618. export class LoadFileError extends Error {
  4619. /** defines the optional web request */
  4620. request?: WebRequest | undefined;
  4621. private static _setPrototypeOf;
  4622. /**
  4623. * Creates a new LoadFileError
  4624. * @param message defines the message of the error
  4625. * @param request defines the optional web request
  4626. */
  4627. constructor(message: string,
  4628. /** defines the optional web request */
  4629. request?: WebRequest | undefined);
  4630. }
  4631. }
  4632. declare module BABYLON {
  4633. /**
  4634. * Class used to enable access to offline support
  4635. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4636. */
  4637. export interface IOfflineProvider {
  4638. /**
  4639. * Gets a boolean indicating if scene must be saved in the database
  4640. */
  4641. enableSceneOffline: boolean;
  4642. /**
  4643. * Gets a boolean indicating if textures must be saved in the database
  4644. */
  4645. enableTexturesOffline: boolean;
  4646. /**
  4647. * Open the offline support and make it available
  4648. * @param successCallback defines the callback to call on success
  4649. * @param errorCallback defines the callback to call on error
  4650. */
  4651. open(successCallback: () => void, errorCallback: () => void): void;
  4652. /**
  4653. * Loads an image from the offline support
  4654. * @param url defines the url to load from
  4655. * @param image defines the target DOM image
  4656. */
  4657. loadImage(url: string, image: HTMLImageElement): void;
  4658. /**
  4659. * Loads a file from offline support
  4660. * @param url defines the URL to load from
  4661. * @param sceneLoaded defines a callback to call on success
  4662. * @param progressCallBack defines a callback to call when progress changed
  4663. * @param errorCallback defines a callback to call on error
  4664. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4665. */
  4666. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4667. }
  4668. }
  4669. declare module BABYLON {
  4670. /**
  4671. * Class used to help managing file picking and drag'n'drop
  4672. * File Storage
  4673. */
  4674. export class FilesInputStore {
  4675. /**
  4676. * List of files ready to be loaded
  4677. */
  4678. static FilesToLoad: {
  4679. [key: string]: File;
  4680. };
  4681. }
  4682. }
  4683. declare module BABYLON {
  4684. /**
  4685. * Class used to define a retry strategy when error happens while loading assets
  4686. */
  4687. export class RetryStrategy {
  4688. /**
  4689. * Function used to defines an exponential back off strategy
  4690. * @param maxRetries defines the maximum number of retries (3 by default)
  4691. * @param baseInterval defines the interval between retries
  4692. * @returns the strategy function to use
  4693. */
  4694. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4695. }
  4696. }
  4697. declare module BABYLON {
  4698. /**
  4699. * @hidden
  4700. */
  4701. export class FileTools {
  4702. /**
  4703. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4704. */
  4705. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4706. /**
  4707. * Gets or sets the base URL to use to load assets
  4708. */
  4709. static BaseUrl: string;
  4710. /**
  4711. * Default behaviour for cors in the application.
  4712. * It can be a string if the expected behavior is identical in the entire app.
  4713. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4714. */
  4715. static CorsBehavior: string | ((url: string | string[]) => string);
  4716. /**
  4717. * Gets or sets a function used to pre-process url before using them to load assets
  4718. */
  4719. static PreprocessUrl: (url: string) => string;
  4720. /**
  4721. * Removes unwanted characters from an url
  4722. * @param url defines the url to clean
  4723. * @returns the cleaned url
  4724. */
  4725. private static _CleanUrl;
  4726. /**
  4727. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4728. * @param url define the url we are trying
  4729. * @param element define the dom element where to configure the cors policy
  4730. */
  4731. static SetCorsBehavior(url: string | string[], element: {
  4732. crossOrigin: string | null;
  4733. }): void;
  4734. /**
  4735. * Loads an image as an HTMLImageElement.
  4736. * @param input url string, ArrayBuffer, or Blob to load
  4737. * @param onLoad callback called when the image successfully loads
  4738. * @param onError callback called when the image fails to load
  4739. * @param offlineProvider offline provider for caching
  4740. * @returns the HTMLImageElement of the loaded image
  4741. */
  4742. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4743. /**
  4744. * Loads a file
  4745. * @param fileToLoad defines the file to load
  4746. * @param callback defines the callback to call when data is loaded
  4747. * @param progressCallBack defines the callback to call during loading process
  4748. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4749. * @returns a file request object
  4750. */
  4751. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4752. /**
  4753. * Loads a file
  4754. * @param url url string, ArrayBuffer, or Blob to load
  4755. * @param onSuccess callback called when the file successfully loads
  4756. * @param onProgress callback called while file is loading (if the server supports this mode)
  4757. * @param offlineProvider defines the offline provider for caching
  4758. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4759. * @param onError callback called when the file fails to load
  4760. * @returns a file request object
  4761. */
  4762. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  4763. /**
  4764. * Checks if the loaded document was accessed via `file:`-Protocol.
  4765. * @returns boolean
  4766. */
  4767. static IsFileURL(): boolean;
  4768. }
  4769. }
  4770. declare module BABYLON {
  4771. /** @hidden */
  4772. export class ShaderProcessor {
  4773. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4774. private static _ProcessPrecision;
  4775. private static _ExtractOperation;
  4776. private static _BuildSubExpression;
  4777. private static _BuildExpression;
  4778. private static _MoveCursorWithinIf;
  4779. private static _MoveCursor;
  4780. private static _EvaluatePreProcessors;
  4781. private static _PreparePreProcessors;
  4782. private static _ProcessShaderConversion;
  4783. private static _ProcessIncludes;
  4784. }
  4785. }
  4786. declare module BABYLON {
  4787. /**
  4788. * Class used to hold a RBG color
  4789. */
  4790. export class Color3 {
  4791. /**
  4792. * Defines the red component (between 0 and 1, default is 0)
  4793. */
  4794. r: number;
  4795. /**
  4796. * Defines the green component (between 0 and 1, default is 0)
  4797. */
  4798. g: number;
  4799. /**
  4800. * Defines the blue component (between 0 and 1, default is 0)
  4801. */
  4802. b: number;
  4803. /**
  4804. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4805. * @param r defines the red component (between 0 and 1, default is 0)
  4806. * @param g defines the green component (between 0 and 1, default is 0)
  4807. * @param b defines the blue component (between 0 and 1, default is 0)
  4808. */
  4809. constructor(
  4810. /**
  4811. * Defines the red component (between 0 and 1, default is 0)
  4812. */
  4813. r?: number,
  4814. /**
  4815. * Defines the green component (between 0 and 1, default is 0)
  4816. */
  4817. g?: number,
  4818. /**
  4819. * Defines the blue component (between 0 and 1, default is 0)
  4820. */
  4821. b?: number);
  4822. /**
  4823. * Creates a string with the Color3 current values
  4824. * @returns the string representation of the Color3 object
  4825. */
  4826. toString(): string;
  4827. /**
  4828. * Returns the string "Color3"
  4829. * @returns "Color3"
  4830. */
  4831. getClassName(): string;
  4832. /**
  4833. * Compute the Color3 hash code
  4834. * @returns an unique number that can be used to hash Color3 objects
  4835. */
  4836. getHashCode(): number;
  4837. /**
  4838. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4839. * @param array defines the array where to store the r,g,b components
  4840. * @param index defines an optional index in the target array to define where to start storing values
  4841. * @returns the current Color3 object
  4842. */
  4843. toArray(array: FloatArray, index?: number): Color3;
  4844. /**
  4845. * Returns a new Color4 object from the current Color3 and the given alpha
  4846. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4847. * @returns a new Color4 object
  4848. */
  4849. toColor4(alpha?: number): Color4;
  4850. /**
  4851. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4852. * @returns the new array
  4853. */
  4854. asArray(): number[];
  4855. /**
  4856. * Returns the luminance value
  4857. * @returns a float value
  4858. */
  4859. toLuminance(): number;
  4860. /**
  4861. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4862. * @param otherColor defines the second operand
  4863. * @returns the new Color3 object
  4864. */
  4865. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4866. /**
  4867. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4868. * @param otherColor defines the second operand
  4869. * @param result defines the Color3 object where to store the result
  4870. * @returns the current Color3
  4871. */
  4872. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4873. /**
  4874. * Determines equality between Color3 objects
  4875. * @param otherColor defines the second operand
  4876. * @returns true if the rgb values are equal to the given ones
  4877. */
  4878. equals(otherColor: DeepImmutable<Color3>): boolean;
  4879. /**
  4880. * Determines equality between the current Color3 object and a set of r,b,g values
  4881. * @param r defines the red component to check
  4882. * @param g defines the green component to check
  4883. * @param b defines the blue component to check
  4884. * @returns true if the rgb values are equal to the given ones
  4885. */
  4886. equalsFloats(r: number, g: number, b: number): boolean;
  4887. /**
  4888. * Multiplies in place each rgb value by scale
  4889. * @param scale defines the scaling factor
  4890. * @returns the updated Color3
  4891. */
  4892. scale(scale: number): Color3;
  4893. /**
  4894. * Multiplies the rgb values by scale and stores the result into "result"
  4895. * @param scale defines the scaling factor
  4896. * @param result defines the Color3 object where to store the result
  4897. * @returns the unmodified current Color3
  4898. */
  4899. scaleToRef(scale: number, result: Color3): Color3;
  4900. /**
  4901. * Scale the current Color3 values by a factor and add the result to a given Color3
  4902. * @param scale defines the scale factor
  4903. * @param result defines color to store the result into
  4904. * @returns the unmodified current Color3
  4905. */
  4906. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4907. /**
  4908. * Clamps the rgb values by the min and max values and stores the result into "result"
  4909. * @param min defines minimum clamping value (default is 0)
  4910. * @param max defines maximum clamping value (default is 1)
  4911. * @param result defines color to store the result into
  4912. * @returns the original Color3
  4913. */
  4914. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4915. /**
  4916. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4917. * @param otherColor defines the second operand
  4918. * @returns the new Color3
  4919. */
  4920. add(otherColor: DeepImmutable<Color3>): Color3;
  4921. /**
  4922. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4923. * @param otherColor defines the second operand
  4924. * @param result defines Color3 object to store the result into
  4925. * @returns the unmodified current Color3
  4926. */
  4927. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4928. /**
  4929. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4930. * @param otherColor defines the second operand
  4931. * @returns the new Color3
  4932. */
  4933. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4934. /**
  4935. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4936. * @param otherColor defines the second operand
  4937. * @param result defines Color3 object to store the result into
  4938. * @returns the unmodified current Color3
  4939. */
  4940. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4941. /**
  4942. * Copy the current object
  4943. * @returns a new Color3 copied the current one
  4944. */
  4945. clone(): Color3;
  4946. /**
  4947. * Copies the rgb values from the source in the current Color3
  4948. * @param source defines the source Color3 object
  4949. * @returns the updated Color3 object
  4950. */
  4951. copyFrom(source: DeepImmutable<Color3>): Color3;
  4952. /**
  4953. * Updates the Color3 rgb values from the given floats
  4954. * @param r defines the red component to read from
  4955. * @param g defines the green component to read from
  4956. * @param b defines the blue component to read from
  4957. * @returns the current Color3 object
  4958. */
  4959. copyFromFloats(r: number, g: number, b: number): Color3;
  4960. /**
  4961. * Updates the Color3 rgb values from the given floats
  4962. * @param r defines the red component to read from
  4963. * @param g defines the green component to read from
  4964. * @param b defines the blue component to read from
  4965. * @returns the current Color3 object
  4966. */
  4967. set(r: number, g: number, b: number): Color3;
  4968. /**
  4969. * Compute the Color3 hexadecimal code as a string
  4970. * @returns a string containing the hexadecimal representation of the Color3 object
  4971. */
  4972. toHexString(): string;
  4973. /**
  4974. * Computes a new Color3 converted from the current one to linear space
  4975. * @returns a new Color3 object
  4976. */
  4977. toLinearSpace(): Color3;
  4978. /**
  4979. * Converts current color in rgb space to HSV values
  4980. * @returns a new color3 representing the HSV values
  4981. */
  4982. toHSV(): Color3;
  4983. /**
  4984. * Converts current color in rgb space to HSV values
  4985. * @param result defines the Color3 where to store the HSV values
  4986. */
  4987. toHSVToRef(result: Color3): void;
  4988. /**
  4989. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4990. * @param convertedColor defines the Color3 object where to store the linear space version
  4991. * @returns the unmodified Color3
  4992. */
  4993. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4994. /**
  4995. * Computes a new Color3 converted from the current one to gamma space
  4996. * @returns a new Color3 object
  4997. */
  4998. toGammaSpace(): Color3;
  4999. /**
  5000. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5001. * @param convertedColor defines the Color3 object where to store the gamma space version
  5002. * @returns the unmodified Color3
  5003. */
  5004. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5005. private static _BlackReadOnly;
  5006. /**
  5007. * Convert Hue, saturation and value to a Color3 (RGB)
  5008. * @param hue defines the hue
  5009. * @param saturation defines the saturation
  5010. * @param value defines the value
  5011. * @param result defines the Color3 where to store the RGB values
  5012. */
  5013. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5014. /**
  5015. * Creates a new Color3 from the string containing valid hexadecimal values
  5016. * @param hex defines a string containing valid hexadecimal values
  5017. * @returns a new Color3 object
  5018. */
  5019. static FromHexString(hex: string): Color3;
  5020. /**
  5021. * Creates a new Color3 from the starting index of the given array
  5022. * @param array defines the source array
  5023. * @param offset defines an offset in the source array
  5024. * @returns a new Color3 object
  5025. */
  5026. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5027. /**
  5028. * Creates a new Color3 from integer values (< 256)
  5029. * @param r defines the red component to read from (value between 0 and 255)
  5030. * @param g defines the green component to read from (value between 0 and 255)
  5031. * @param b defines the blue component to read from (value between 0 and 255)
  5032. * @returns a new Color3 object
  5033. */
  5034. static FromInts(r: number, g: number, b: number): Color3;
  5035. /**
  5036. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5037. * @param start defines the start Color3 value
  5038. * @param end defines the end Color3 value
  5039. * @param amount defines the gradient value between start and end
  5040. * @returns a new Color3 object
  5041. */
  5042. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5043. /**
  5044. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5045. * @param left defines the start value
  5046. * @param right defines the end value
  5047. * @param amount defines the gradient factor
  5048. * @param result defines the Color3 object where to store the result
  5049. */
  5050. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5051. /**
  5052. * Returns a Color3 value containing a red color
  5053. * @returns a new Color3 object
  5054. */
  5055. static Red(): Color3;
  5056. /**
  5057. * Returns a Color3 value containing a green color
  5058. * @returns a new Color3 object
  5059. */
  5060. static Green(): Color3;
  5061. /**
  5062. * Returns a Color3 value containing a blue color
  5063. * @returns a new Color3 object
  5064. */
  5065. static Blue(): Color3;
  5066. /**
  5067. * Returns a Color3 value containing a black color
  5068. * @returns a new Color3 object
  5069. */
  5070. static Black(): Color3;
  5071. /**
  5072. * Gets a Color3 value containing a black color that must not be updated
  5073. */
  5074. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5075. /**
  5076. * Returns a Color3 value containing a white color
  5077. * @returns a new Color3 object
  5078. */
  5079. static White(): Color3;
  5080. /**
  5081. * Returns a Color3 value containing a purple color
  5082. * @returns a new Color3 object
  5083. */
  5084. static Purple(): Color3;
  5085. /**
  5086. * Returns a Color3 value containing a magenta color
  5087. * @returns a new Color3 object
  5088. */
  5089. static Magenta(): Color3;
  5090. /**
  5091. * Returns a Color3 value containing a yellow color
  5092. * @returns a new Color3 object
  5093. */
  5094. static Yellow(): Color3;
  5095. /**
  5096. * Returns a Color3 value containing a gray color
  5097. * @returns a new Color3 object
  5098. */
  5099. static Gray(): Color3;
  5100. /**
  5101. * Returns a Color3 value containing a teal color
  5102. * @returns a new Color3 object
  5103. */
  5104. static Teal(): Color3;
  5105. /**
  5106. * Returns a Color3 value containing a random color
  5107. * @returns a new Color3 object
  5108. */
  5109. static Random(): Color3;
  5110. }
  5111. /**
  5112. * Class used to hold a RBGA color
  5113. */
  5114. export class Color4 {
  5115. /**
  5116. * Defines the red component (between 0 and 1, default is 0)
  5117. */
  5118. r: number;
  5119. /**
  5120. * Defines the green component (between 0 and 1, default is 0)
  5121. */
  5122. g: number;
  5123. /**
  5124. * Defines the blue component (between 0 and 1, default is 0)
  5125. */
  5126. b: number;
  5127. /**
  5128. * Defines the alpha component (between 0 and 1, default is 1)
  5129. */
  5130. a: number;
  5131. /**
  5132. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5133. * @param r defines the red component (between 0 and 1, default is 0)
  5134. * @param g defines the green component (between 0 and 1, default is 0)
  5135. * @param b defines the blue component (between 0 and 1, default is 0)
  5136. * @param a defines the alpha component (between 0 and 1, default is 1)
  5137. */
  5138. constructor(
  5139. /**
  5140. * Defines the red component (between 0 and 1, default is 0)
  5141. */
  5142. r?: number,
  5143. /**
  5144. * Defines the green component (between 0 and 1, default is 0)
  5145. */
  5146. g?: number,
  5147. /**
  5148. * Defines the blue component (between 0 and 1, default is 0)
  5149. */
  5150. b?: number,
  5151. /**
  5152. * Defines the alpha component (between 0 and 1, default is 1)
  5153. */
  5154. a?: number);
  5155. /**
  5156. * Adds in place the given Color4 values to the current Color4 object
  5157. * @param right defines the second operand
  5158. * @returns the current updated Color4 object
  5159. */
  5160. addInPlace(right: DeepImmutable<Color4>): Color4;
  5161. /**
  5162. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5163. * @returns the new array
  5164. */
  5165. asArray(): number[];
  5166. /**
  5167. * Stores from the starting index in the given array the Color4 successive values
  5168. * @param array defines the array where to store the r,g,b components
  5169. * @param index defines an optional index in the target array to define where to start storing values
  5170. * @returns the current Color4 object
  5171. */
  5172. toArray(array: number[], index?: number): Color4;
  5173. /**
  5174. * Determines equality between Color4 objects
  5175. * @param otherColor defines the second operand
  5176. * @returns true if the rgba values are equal to the given ones
  5177. */
  5178. equals(otherColor: DeepImmutable<Color4>): boolean;
  5179. /**
  5180. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5181. * @param right defines the second operand
  5182. * @returns a new Color4 object
  5183. */
  5184. add(right: DeepImmutable<Color4>): Color4;
  5185. /**
  5186. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5187. * @param right defines the second operand
  5188. * @returns a new Color4 object
  5189. */
  5190. subtract(right: DeepImmutable<Color4>): Color4;
  5191. /**
  5192. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5193. * @param right defines the second operand
  5194. * @param result defines the Color4 object where to store the result
  5195. * @returns the current Color4 object
  5196. */
  5197. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5198. /**
  5199. * Creates a new Color4 with the current Color4 values multiplied by scale
  5200. * @param scale defines the scaling factor to apply
  5201. * @returns a new Color4 object
  5202. */
  5203. scale(scale: number): Color4;
  5204. /**
  5205. * Multiplies the current Color4 values by scale and stores the result in "result"
  5206. * @param scale defines the scaling factor to apply
  5207. * @param result defines the Color4 object where to store the result
  5208. * @returns the current unmodified Color4
  5209. */
  5210. scaleToRef(scale: number, result: Color4): Color4;
  5211. /**
  5212. * Scale the current Color4 values by a factor and add the result to a given Color4
  5213. * @param scale defines the scale factor
  5214. * @param result defines the Color4 object where to store the result
  5215. * @returns the unmodified current Color4
  5216. */
  5217. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5218. /**
  5219. * Clamps the rgb values by the min and max values and stores the result into "result"
  5220. * @param min defines minimum clamping value (default is 0)
  5221. * @param max defines maximum clamping value (default is 1)
  5222. * @param result defines color to store the result into.
  5223. * @returns the cuurent Color4
  5224. */
  5225. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5226. /**
  5227. * Multipy an Color4 value by another and return a new Color4 object
  5228. * @param color defines the Color4 value to multiply by
  5229. * @returns a new Color4 object
  5230. */
  5231. multiply(color: Color4): Color4;
  5232. /**
  5233. * Multipy a Color4 value by another and push the result in a reference value
  5234. * @param color defines the Color4 value to multiply by
  5235. * @param result defines the Color4 to fill the result in
  5236. * @returns the result Color4
  5237. */
  5238. multiplyToRef(color: Color4, result: Color4): Color4;
  5239. /**
  5240. * Creates a string with the Color4 current values
  5241. * @returns the string representation of the Color4 object
  5242. */
  5243. toString(): string;
  5244. /**
  5245. * Returns the string "Color4"
  5246. * @returns "Color4"
  5247. */
  5248. getClassName(): string;
  5249. /**
  5250. * Compute the Color4 hash code
  5251. * @returns an unique number that can be used to hash Color4 objects
  5252. */
  5253. getHashCode(): number;
  5254. /**
  5255. * Creates a new Color4 copied from the current one
  5256. * @returns a new Color4 object
  5257. */
  5258. clone(): Color4;
  5259. /**
  5260. * Copies the given Color4 values into the current one
  5261. * @param source defines the source Color4 object
  5262. * @returns the current updated Color4 object
  5263. */
  5264. copyFrom(source: Color4): Color4;
  5265. /**
  5266. * Copies the given float values into the current one
  5267. * @param r defines the red component to read from
  5268. * @param g defines the green component to read from
  5269. * @param b defines the blue component to read from
  5270. * @param a defines the alpha component to read from
  5271. * @returns the current updated Color4 object
  5272. */
  5273. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5274. /**
  5275. * Copies the given float values into the current one
  5276. * @param r defines the red component to read from
  5277. * @param g defines the green component to read from
  5278. * @param b defines the blue component to read from
  5279. * @param a defines the alpha component to read from
  5280. * @returns the current updated Color4 object
  5281. */
  5282. set(r: number, g: number, b: number, a: number): Color4;
  5283. /**
  5284. * Compute the Color4 hexadecimal code as a string
  5285. * @returns a string containing the hexadecimal representation of the Color4 object
  5286. */
  5287. toHexString(): string;
  5288. /**
  5289. * Computes a new Color4 converted from the current one to linear space
  5290. * @returns a new Color4 object
  5291. */
  5292. toLinearSpace(): Color4;
  5293. /**
  5294. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5295. * @param convertedColor defines the Color4 object where to store the linear space version
  5296. * @returns the unmodified Color4
  5297. */
  5298. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5299. /**
  5300. * Computes a new Color4 converted from the current one to gamma space
  5301. * @returns a new Color4 object
  5302. */
  5303. toGammaSpace(): Color4;
  5304. /**
  5305. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5306. * @param convertedColor defines the Color4 object where to store the gamma space version
  5307. * @returns the unmodified Color4
  5308. */
  5309. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5310. /**
  5311. * Creates a new Color4 from the string containing valid hexadecimal values
  5312. * @param hex defines a string containing valid hexadecimal values
  5313. * @returns a new Color4 object
  5314. */
  5315. static FromHexString(hex: string): Color4;
  5316. /**
  5317. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5318. * @param left defines the start value
  5319. * @param right defines the end value
  5320. * @param amount defines the gradient factor
  5321. * @returns a new Color4 object
  5322. */
  5323. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5324. /**
  5325. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5326. * @param left defines the start value
  5327. * @param right defines the end value
  5328. * @param amount defines the gradient factor
  5329. * @param result defines the Color4 object where to store data
  5330. */
  5331. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5332. /**
  5333. * Creates a new Color4 from a Color3 and an alpha value
  5334. * @param color3 defines the source Color3 to read from
  5335. * @param alpha defines the alpha component (1.0 by default)
  5336. * @returns a new Color4 object
  5337. */
  5338. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5339. /**
  5340. * Creates a new Color4 from the starting index element of the given array
  5341. * @param array defines the source array to read from
  5342. * @param offset defines the offset in the source array
  5343. * @returns a new Color4 object
  5344. */
  5345. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5346. /**
  5347. * Creates a new Color3 from integer values (< 256)
  5348. * @param r defines the red component to read from (value between 0 and 255)
  5349. * @param g defines the green component to read from (value between 0 and 255)
  5350. * @param b defines the blue component to read from (value between 0 and 255)
  5351. * @param a defines the alpha component to read from (value between 0 and 255)
  5352. * @returns a new Color3 object
  5353. */
  5354. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5355. /**
  5356. * Check the content of a given array and convert it to an array containing RGBA data
  5357. * If the original array was already containing count * 4 values then it is returned directly
  5358. * @param colors defines the array to check
  5359. * @param count defines the number of RGBA data to expect
  5360. * @returns an array containing count * 4 values (RGBA)
  5361. */
  5362. static CheckColors4(colors: number[], count: number): number[];
  5363. }
  5364. /**
  5365. * @hidden
  5366. */
  5367. export class TmpColors {
  5368. static Color3: Color3[];
  5369. static Color4: Color4[];
  5370. }
  5371. }
  5372. declare module BABYLON {
  5373. /**
  5374. * Class representing spherical harmonics coefficients to the 3rd degree
  5375. */
  5376. export class SphericalHarmonics {
  5377. /**
  5378. * Defines whether or not the harmonics have been prescaled for rendering.
  5379. */
  5380. preScaled: boolean;
  5381. /**
  5382. * The l0,0 coefficients of the spherical harmonics
  5383. */
  5384. l00: Vector3;
  5385. /**
  5386. * The l1,-1 coefficients of the spherical harmonics
  5387. */
  5388. l1_1: Vector3;
  5389. /**
  5390. * The l1,0 coefficients of the spherical harmonics
  5391. */
  5392. l10: Vector3;
  5393. /**
  5394. * The l1,1 coefficients of the spherical harmonics
  5395. */
  5396. l11: Vector3;
  5397. /**
  5398. * The l2,-2 coefficients of the spherical harmonics
  5399. */
  5400. l2_2: Vector3;
  5401. /**
  5402. * The l2,-1 coefficients of the spherical harmonics
  5403. */
  5404. l2_1: Vector3;
  5405. /**
  5406. * The l2,0 coefficients of the spherical harmonics
  5407. */
  5408. l20: Vector3;
  5409. /**
  5410. * The l2,1 coefficients of the spherical harmonics
  5411. */
  5412. l21: Vector3;
  5413. /**
  5414. * The l2,2 coefficients of the spherical harmonics
  5415. */
  5416. l22: Vector3;
  5417. /**
  5418. * Adds a light to the spherical harmonics
  5419. * @param direction the direction of the light
  5420. * @param color the color of the light
  5421. * @param deltaSolidAngle the delta solid angle of the light
  5422. */
  5423. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5424. /**
  5425. * Scales the spherical harmonics by the given amount
  5426. * @param scale the amount to scale
  5427. */
  5428. scaleInPlace(scale: number): void;
  5429. /**
  5430. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5431. *
  5432. * ```
  5433. * E_lm = A_l * L_lm
  5434. * ```
  5435. *
  5436. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5437. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5438. * the scaling factors are given in equation 9.
  5439. */
  5440. convertIncidentRadianceToIrradiance(): void;
  5441. /**
  5442. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5443. *
  5444. * ```
  5445. * L = (1/pi) * E * rho
  5446. * ```
  5447. *
  5448. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5449. */
  5450. convertIrradianceToLambertianRadiance(): void;
  5451. /**
  5452. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5453. * required operations at run time.
  5454. *
  5455. * This is simply done by scaling back the SH with Ylm constants parameter.
  5456. * The trigonometric part being applied by the shader at run time.
  5457. */
  5458. preScaleForRendering(): void;
  5459. /**
  5460. * Constructs a spherical harmonics from an array.
  5461. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5462. * @returns the spherical harmonics
  5463. */
  5464. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5465. /**
  5466. * Gets the spherical harmonics from polynomial
  5467. * @param polynomial the spherical polynomial
  5468. * @returns the spherical harmonics
  5469. */
  5470. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5471. }
  5472. /**
  5473. * Class representing spherical polynomial coefficients to the 3rd degree
  5474. */
  5475. export class SphericalPolynomial {
  5476. private _harmonics;
  5477. /**
  5478. * The spherical harmonics used to create the polynomials.
  5479. */
  5480. readonly preScaledHarmonics: SphericalHarmonics;
  5481. /**
  5482. * The x coefficients of the spherical polynomial
  5483. */
  5484. x: Vector3;
  5485. /**
  5486. * The y coefficients of the spherical polynomial
  5487. */
  5488. y: Vector3;
  5489. /**
  5490. * The z coefficients of the spherical polynomial
  5491. */
  5492. z: Vector3;
  5493. /**
  5494. * The xx coefficients of the spherical polynomial
  5495. */
  5496. xx: Vector3;
  5497. /**
  5498. * The yy coefficients of the spherical polynomial
  5499. */
  5500. yy: Vector3;
  5501. /**
  5502. * The zz coefficients of the spherical polynomial
  5503. */
  5504. zz: Vector3;
  5505. /**
  5506. * The xy coefficients of the spherical polynomial
  5507. */
  5508. xy: Vector3;
  5509. /**
  5510. * The yz coefficients of the spherical polynomial
  5511. */
  5512. yz: Vector3;
  5513. /**
  5514. * The zx coefficients of the spherical polynomial
  5515. */
  5516. zx: Vector3;
  5517. /**
  5518. * Adds an ambient color to the spherical polynomial
  5519. * @param color the color to add
  5520. */
  5521. addAmbient(color: Color3): void;
  5522. /**
  5523. * Scales the spherical polynomial by the given amount
  5524. * @param scale the amount to scale
  5525. */
  5526. scaleInPlace(scale: number): void;
  5527. /**
  5528. * Gets the spherical polynomial from harmonics
  5529. * @param harmonics the spherical harmonics
  5530. * @returns the spherical polynomial
  5531. */
  5532. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5533. /**
  5534. * Constructs a spherical polynomial from an array.
  5535. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5536. * @returns the spherical polynomial
  5537. */
  5538. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5539. }
  5540. }
  5541. declare module BABYLON {
  5542. /**
  5543. * Define options used to create a render target texture
  5544. */
  5545. export class RenderTargetCreationOptions {
  5546. /**
  5547. * Specifies is mipmaps must be generated
  5548. */
  5549. generateMipMaps?: boolean;
  5550. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5551. generateDepthBuffer?: boolean;
  5552. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5553. generateStencilBuffer?: boolean;
  5554. /** Defines texture type (int by default) */
  5555. type?: number;
  5556. /** Defines sampling mode (trilinear by default) */
  5557. samplingMode?: number;
  5558. /** Defines format (RGBA by default) */
  5559. format?: number;
  5560. }
  5561. }
  5562. declare module BABYLON {
  5563. /**
  5564. * @hidden
  5565. **/
  5566. export class _AlphaState {
  5567. private _isAlphaBlendDirty;
  5568. private _isBlendFunctionParametersDirty;
  5569. private _isBlendEquationParametersDirty;
  5570. private _isBlendConstantsDirty;
  5571. private _alphaBlend;
  5572. private _blendFunctionParameters;
  5573. private _blendEquationParameters;
  5574. private _blendConstants;
  5575. /**
  5576. * Initializes the state.
  5577. */
  5578. constructor();
  5579. readonly isDirty: boolean;
  5580. alphaBlend: boolean;
  5581. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5582. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5583. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5584. reset(): void;
  5585. apply(gl: WebGLRenderingContext): void;
  5586. }
  5587. }
  5588. declare module BABYLON {
  5589. /**
  5590. * @hidden
  5591. **/
  5592. export class _DepthCullingState {
  5593. private _isDepthTestDirty;
  5594. private _isDepthMaskDirty;
  5595. private _isDepthFuncDirty;
  5596. private _isCullFaceDirty;
  5597. private _isCullDirty;
  5598. private _isZOffsetDirty;
  5599. private _isFrontFaceDirty;
  5600. private _depthTest;
  5601. private _depthMask;
  5602. private _depthFunc;
  5603. private _cull;
  5604. private _cullFace;
  5605. private _zOffset;
  5606. private _frontFace;
  5607. /**
  5608. * Initializes the state.
  5609. */
  5610. constructor();
  5611. readonly isDirty: boolean;
  5612. zOffset: number;
  5613. cullFace: Nullable<number>;
  5614. cull: Nullable<boolean>;
  5615. depthFunc: Nullable<number>;
  5616. depthMask: boolean;
  5617. depthTest: boolean;
  5618. frontFace: Nullable<number>;
  5619. reset(): void;
  5620. apply(gl: WebGLRenderingContext): void;
  5621. }
  5622. }
  5623. declare module BABYLON {
  5624. /**
  5625. * @hidden
  5626. **/
  5627. export class _StencilState {
  5628. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  5629. static readonly ALWAYS: number;
  5630. /** Passed to stencilOperation to specify that stencil value must be kept */
  5631. static readonly KEEP: number;
  5632. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5633. static readonly REPLACE: number;
  5634. private _isStencilTestDirty;
  5635. private _isStencilMaskDirty;
  5636. private _isStencilFuncDirty;
  5637. private _isStencilOpDirty;
  5638. private _stencilTest;
  5639. private _stencilMask;
  5640. private _stencilFunc;
  5641. private _stencilFuncRef;
  5642. private _stencilFuncMask;
  5643. private _stencilOpStencilFail;
  5644. private _stencilOpDepthFail;
  5645. private _stencilOpStencilDepthPass;
  5646. readonly isDirty: boolean;
  5647. stencilFunc: number;
  5648. stencilFuncRef: number;
  5649. stencilFuncMask: number;
  5650. stencilOpStencilFail: number;
  5651. stencilOpDepthFail: number;
  5652. stencilOpStencilDepthPass: number;
  5653. stencilMask: number;
  5654. stencilTest: boolean;
  5655. constructor();
  5656. reset(): void;
  5657. apply(gl: WebGLRenderingContext): void;
  5658. }
  5659. }
  5660. declare module BABYLON {
  5661. /**
  5662. * @hidden
  5663. **/
  5664. export class _TimeToken {
  5665. _startTimeQuery: Nullable<WebGLQuery>;
  5666. _endTimeQuery: Nullable<WebGLQuery>;
  5667. _timeElapsedQuery: Nullable<WebGLQuery>;
  5668. _timeElapsedQueryEnded: boolean;
  5669. }
  5670. }
  5671. declare module BABYLON {
  5672. /**
  5673. * Class used to evalaute queries containing `and` and `or` operators
  5674. */
  5675. export class AndOrNotEvaluator {
  5676. /**
  5677. * Evaluate a query
  5678. * @param query defines the query to evaluate
  5679. * @param evaluateCallback defines the callback used to filter result
  5680. * @returns true if the query matches
  5681. */
  5682. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5683. private static _HandleParenthesisContent;
  5684. private static _SimplifyNegation;
  5685. }
  5686. }
  5687. declare module BABYLON {
  5688. /**
  5689. * Class used to store custom tags
  5690. */
  5691. export class Tags {
  5692. /**
  5693. * Adds support for tags on the given object
  5694. * @param obj defines the object to use
  5695. */
  5696. static EnableFor(obj: any): void;
  5697. /**
  5698. * Removes tags support
  5699. * @param obj defines the object to use
  5700. */
  5701. static DisableFor(obj: any): void;
  5702. /**
  5703. * Gets a boolean indicating if the given object has tags
  5704. * @param obj defines the object to use
  5705. * @returns a boolean
  5706. */
  5707. static HasTags(obj: any): boolean;
  5708. /**
  5709. * Gets the tags available on a given object
  5710. * @param obj defines the object to use
  5711. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5712. * @returns the tags
  5713. */
  5714. static GetTags(obj: any, asString?: boolean): any;
  5715. /**
  5716. * Adds tags to an object
  5717. * @param obj defines the object to use
  5718. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5719. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5720. */
  5721. static AddTagsTo(obj: any, tagsString: string): void;
  5722. /**
  5723. * @hidden
  5724. */
  5725. static _AddTagTo(obj: any, tag: string): void;
  5726. /**
  5727. * Removes specific tags from a specific object
  5728. * @param obj defines the object to use
  5729. * @param tagsString defines the tags to remove
  5730. */
  5731. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5732. /**
  5733. * @hidden
  5734. */
  5735. static _RemoveTagFrom(obj: any, tag: string): void;
  5736. /**
  5737. * Defines if tags hosted on an object match a given query
  5738. * @param obj defines the object to use
  5739. * @param tagsQuery defines the tag query
  5740. * @returns a boolean
  5741. */
  5742. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5743. }
  5744. }
  5745. declare module BABYLON {
  5746. /**
  5747. * Defines potential orientation for back face culling
  5748. */
  5749. export enum Orientation {
  5750. /**
  5751. * Clockwise
  5752. */
  5753. CW = 0,
  5754. /** Counter clockwise */
  5755. CCW = 1
  5756. }
  5757. /** Class used to represent a Bezier curve */
  5758. export class BezierCurve {
  5759. /**
  5760. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5761. * @param t defines the time
  5762. * @param x1 defines the left coordinate on X axis
  5763. * @param y1 defines the left coordinate on Y axis
  5764. * @param x2 defines the right coordinate on X axis
  5765. * @param y2 defines the right coordinate on Y axis
  5766. * @returns the interpolated value
  5767. */
  5768. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5769. }
  5770. /**
  5771. * Defines angle representation
  5772. */
  5773. export class Angle {
  5774. private _radians;
  5775. /**
  5776. * Creates an Angle object of "radians" radians (float).
  5777. * @param radians the angle in radians
  5778. */
  5779. constructor(radians: number);
  5780. /**
  5781. * Get value in degrees
  5782. * @returns the Angle value in degrees (float)
  5783. */
  5784. degrees(): number;
  5785. /**
  5786. * Get value in radians
  5787. * @returns the Angle value in radians (float)
  5788. */
  5789. radians(): number;
  5790. /**
  5791. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5792. * @param a defines first vector
  5793. * @param b defines second vector
  5794. * @returns a new Angle
  5795. */
  5796. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5797. /**
  5798. * Gets a new Angle object from the given float in radians
  5799. * @param radians defines the angle value in radians
  5800. * @returns a new Angle
  5801. */
  5802. static FromRadians(radians: number): Angle;
  5803. /**
  5804. * Gets a new Angle object from the given float in degrees
  5805. * @param degrees defines the angle value in degrees
  5806. * @returns a new Angle
  5807. */
  5808. static FromDegrees(degrees: number): Angle;
  5809. }
  5810. /**
  5811. * This represents an arc in a 2d space.
  5812. */
  5813. export class Arc2 {
  5814. /** Defines the start point of the arc */
  5815. startPoint: Vector2;
  5816. /** Defines the mid point of the arc */
  5817. midPoint: Vector2;
  5818. /** Defines the end point of the arc */
  5819. endPoint: Vector2;
  5820. /**
  5821. * Defines the center point of the arc.
  5822. */
  5823. centerPoint: Vector2;
  5824. /**
  5825. * Defines the radius of the arc.
  5826. */
  5827. radius: number;
  5828. /**
  5829. * Defines the angle of the arc (from mid point to end point).
  5830. */
  5831. angle: Angle;
  5832. /**
  5833. * Defines the start angle of the arc (from start point to middle point).
  5834. */
  5835. startAngle: Angle;
  5836. /**
  5837. * Defines the orientation of the arc (clock wise/counter clock wise).
  5838. */
  5839. orientation: Orientation;
  5840. /**
  5841. * Creates an Arc object from the three given points : start, middle and end.
  5842. * @param startPoint Defines the start point of the arc
  5843. * @param midPoint Defines the midlle point of the arc
  5844. * @param endPoint Defines the end point of the arc
  5845. */
  5846. constructor(
  5847. /** Defines the start point of the arc */
  5848. startPoint: Vector2,
  5849. /** Defines the mid point of the arc */
  5850. midPoint: Vector2,
  5851. /** Defines the end point of the arc */
  5852. endPoint: Vector2);
  5853. }
  5854. /**
  5855. * Represents a 2D path made up of multiple 2D points
  5856. */
  5857. export class Path2 {
  5858. private _points;
  5859. private _length;
  5860. /**
  5861. * If the path start and end point are the same
  5862. */
  5863. closed: boolean;
  5864. /**
  5865. * Creates a Path2 object from the starting 2D coordinates x and y.
  5866. * @param x the starting points x value
  5867. * @param y the starting points y value
  5868. */
  5869. constructor(x: number, y: number);
  5870. /**
  5871. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5872. * @param x the added points x value
  5873. * @param y the added points y value
  5874. * @returns the updated Path2.
  5875. */
  5876. addLineTo(x: number, y: number): Path2;
  5877. /**
  5878. * 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.
  5879. * @param midX middle point x value
  5880. * @param midY middle point y value
  5881. * @param endX end point x value
  5882. * @param endY end point y value
  5883. * @param numberOfSegments (default: 36)
  5884. * @returns the updated Path2.
  5885. */
  5886. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5887. /**
  5888. * Closes the Path2.
  5889. * @returns the Path2.
  5890. */
  5891. close(): Path2;
  5892. /**
  5893. * Gets the sum of the distance between each sequential point in the path
  5894. * @returns the Path2 total length (float).
  5895. */
  5896. length(): number;
  5897. /**
  5898. * Gets the points which construct the path
  5899. * @returns the Path2 internal array of points.
  5900. */
  5901. getPoints(): Vector2[];
  5902. /**
  5903. * Retreives the point at the distance aways from the starting point
  5904. * @param normalizedLengthPosition the length along the path to retreive the point from
  5905. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5906. */
  5907. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5908. /**
  5909. * Creates a new path starting from an x and y position
  5910. * @param x starting x value
  5911. * @param y starting y value
  5912. * @returns a new Path2 starting at the coordinates (x, y).
  5913. */
  5914. static StartingAt(x: number, y: number): Path2;
  5915. }
  5916. /**
  5917. * Represents a 3D path made up of multiple 3D points
  5918. */
  5919. export class Path3D {
  5920. /**
  5921. * an array of Vector3, the curve axis of the Path3D
  5922. */
  5923. path: Vector3[];
  5924. private _curve;
  5925. private _distances;
  5926. private _tangents;
  5927. private _normals;
  5928. private _binormals;
  5929. private _raw;
  5930. /**
  5931. * new Path3D(path, normal, raw)
  5932. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5933. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5934. * @param path an array of Vector3, the curve axis of the Path3D
  5935. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5936. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5937. */
  5938. constructor(
  5939. /**
  5940. * an array of Vector3, the curve axis of the Path3D
  5941. */
  5942. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5943. /**
  5944. * Returns the Path3D array of successive Vector3 designing its curve.
  5945. * @returns the Path3D array of successive Vector3 designing its curve.
  5946. */
  5947. getCurve(): Vector3[];
  5948. /**
  5949. * Returns an array populated with tangent vectors on each Path3D curve point.
  5950. * @returns an array populated with tangent vectors on each Path3D curve point.
  5951. */
  5952. getTangents(): Vector3[];
  5953. /**
  5954. * Returns an array populated with normal vectors on each Path3D curve point.
  5955. * @returns an array populated with normal vectors on each Path3D curve point.
  5956. */
  5957. getNormals(): Vector3[];
  5958. /**
  5959. * Returns an array populated with binormal vectors on each Path3D curve point.
  5960. * @returns an array populated with binormal vectors on each Path3D curve point.
  5961. */
  5962. getBinormals(): Vector3[];
  5963. /**
  5964. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5965. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5966. */
  5967. getDistances(): number[];
  5968. /**
  5969. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5970. * @param path path which all values are copied into the curves points
  5971. * @param firstNormal which should be projected onto the curve
  5972. * @returns the same object updated.
  5973. */
  5974. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5975. private _compute;
  5976. private _getFirstNonNullVector;
  5977. private _getLastNonNullVector;
  5978. private _normalVector;
  5979. }
  5980. /**
  5981. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5982. * A Curve3 is designed from a series of successive Vector3.
  5983. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5984. */
  5985. export class Curve3 {
  5986. private _points;
  5987. private _length;
  5988. /**
  5989. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5990. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5991. * @param v1 (Vector3) the control point
  5992. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5993. * @param nbPoints (integer) the wanted number of points in the curve
  5994. * @returns the created Curve3
  5995. */
  5996. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5997. /**
  5998. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5999. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6000. * @param v1 (Vector3) the first control point
  6001. * @param v2 (Vector3) the second control point
  6002. * @param v3 (Vector3) the end point of the Cubic Bezier
  6003. * @param nbPoints (integer) the wanted number of points in the curve
  6004. * @returns the created Curve3
  6005. */
  6006. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6007. /**
  6008. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6009. * @param p1 (Vector3) the origin point of the Hermite Spline
  6010. * @param t1 (Vector3) the tangent vector at the origin point
  6011. * @param p2 (Vector3) the end point of the Hermite Spline
  6012. * @param t2 (Vector3) the tangent vector at the end point
  6013. * @param nbPoints (integer) the wanted number of points in the curve
  6014. * @returns the created Curve3
  6015. */
  6016. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6017. /**
  6018. * Returns a Curve3 object along a CatmullRom Spline curve :
  6019. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6020. * @param nbPoints (integer) the wanted number of points between each curve control points
  6021. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6022. * @returns the created Curve3
  6023. */
  6024. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6025. /**
  6026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6027. * A Curve3 is designed from a series of successive Vector3.
  6028. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6029. * @param points points which make up the curve
  6030. */
  6031. constructor(points: Vector3[]);
  6032. /**
  6033. * @returns the Curve3 stored array of successive Vector3
  6034. */
  6035. getPoints(): Vector3[];
  6036. /**
  6037. * @returns the computed length (float) of the curve.
  6038. */
  6039. length(): number;
  6040. /**
  6041. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6042. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6043. * curveA and curveB keep unchanged.
  6044. * @param curve the curve to continue from this curve
  6045. * @returns the newly constructed curve
  6046. */
  6047. continue(curve: DeepImmutable<Curve3>): Curve3;
  6048. private _computeLength;
  6049. }
  6050. }
  6051. declare module BABYLON {
  6052. /**
  6053. * This represents the main contract an easing function should follow.
  6054. * Easing functions are used throughout the animation system.
  6055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6056. */
  6057. export interface IEasingFunction {
  6058. /**
  6059. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6060. * of the easing function.
  6061. * The link below provides some of the most common examples of easing functions.
  6062. * @see https://easings.net/
  6063. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6064. * @returns the corresponding value on the curve defined by the easing function
  6065. */
  6066. ease(gradient: number): number;
  6067. }
  6068. /**
  6069. * Base class used for every default easing function.
  6070. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6071. */
  6072. export class EasingFunction implements IEasingFunction {
  6073. /**
  6074. * Interpolation follows the mathematical formula associated with the easing function.
  6075. */
  6076. static readonly EASINGMODE_EASEIN: number;
  6077. /**
  6078. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6079. */
  6080. static readonly EASINGMODE_EASEOUT: number;
  6081. /**
  6082. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6083. */
  6084. static readonly EASINGMODE_EASEINOUT: number;
  6085. private _easingMode;
  6086. /**
  6087. * Sets the easing mode of the current function.
  6088. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6089. */
  6090. setEasingMode(easingMode: number): void;
  6091. /**
  6092. * Gets the current easing mode.
  6093. * @returns the easing mode
  6094. */
  6095. getEasingMode(): number;
  6096. /**
  6097. * @hidden
  6098. */
  6099. easeInCore(gradient: number): number;
  6100. /**
  6101. * Given an input gradient between 0 and 1, this returns the corresponding value
  6102. * of the easing function.
  6103. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6104. * @returns the corresponding value on the curve defined by the easing function
  6105. */
  6106. ease(gradient: number): number;
  6107. }
  6108. /**
  6109. * Easing function with a circle shape (see link below).
  6110. * @see https://easings.net/#easeInCirc
  6111. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6112. */
  6113. export class CircleEase extends EasingFunction implements IEasingFunction {
  6114. /** @hidden */
  6115. easeInCore(gradient: number): number;
  6116. }
  6117. /**
  6118. * Easing function with a ease back shape (see link below).
  6119. * @see https://easings.net/#easeInBack
  6120. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6121. */
  6122. export class BackEase extends EasingFunction implements IEasingFunction {
  6123. /** Defines the amplitude of the function */
  6124. amplitude: number;
  6125. /**
  6126. * Instantiates a back ease easing
  6127. * @see https://easings.net/#easeInBack
  6128. * @param amplitude Defines the amplitude of the function
  6129. */
  6130. constructor(
  6131. /** Defines the amplitude of the function */
  6132. amplitude?: number);
  6133. /** @hidden */
  6134. easeInCore(gradient: number): number;
  6135. }
  6136. /**
  6137. * Easing function with a bouncing shape (see link below).
  6138. * @see https://easings.net/#easeInBounce
  6139. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6140. */
  6141. export class BounceEase extends EasingFunction implements IEasingFunction {
  6142. /** Defines the number of bounces */
  6143. bounces: number;
  6144. /** Defines the amplitude of the bounce */
  6145. bounciness: number;
  6146. /**
  6147. * Instantiates a bounce easing
  6148. * @see https://easings.net/#easeInBounce
  6149. * @param bounces Defines the number of bounces
  6150. * @param bounciness Defines the amplitude of the bounce
  6151. */
  6152. constructor(
  6153. /** Defines the number of bounces */
  6154. bounces?: number,
  6155. /** Defines the amplitude of the bounce */
  6156. bounciness?: number);
  6157. /** @hidden */
  6158. easeInCore(gradient: number): number;
  6159. }
  6160. /**
  6161. * Easing function with a power of 3 shape (see link below).
  6162. * @see https://easings.net/#easeInCubic
  6163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6164. */
  6165. export class CubicEase extends EasingFunction implements IEasingFunction {
  6166. /** @hidden */
  6167. easeInCore(gradient: number): number;
  6168. }
  6169. /**
  6170. * Easing function with an elastic shape (see link below).
  6171. * @see https://easings.net/#easeInElastic
  6172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6173. */
  6174. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6175. /** Defines the number of oscillations*/
  6176. oscillations: number;
  6177. /** Defines the amplitude of the oscillations*/
  6178. springiness: number;
  6179. /**
  6180. * Instantiates an elastic easing function
  6181. * @see https://easings.net/#easeInElastic
  6182. * @param oscillations Defines the number of oscillations
  6183. * @param springiness Defines the amplitude of the oscillations
  6184. */
  6185. constructor(
  6186. /** Defines the number of oscillations*/
  6187. oscillations?: number,
  6188. /** Defines the amplitude of the oscillations*/
  6189. springiness?: number);
  6190. /** @hidden */
  6191. easeInCore(gradient: number): number;
  6192. }
  6193. /**
  6194. * Easing function with an exponential shape (see link below).
  6195. * @see https://easings.net/#easeInExpo
  6196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6197. */
  6198. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6199. /** Defines the exponent of the function */
  6200. exponent: number;
  6201. /**
  6202. * Instantiates an exponential easing function
  6203. * @see https://easings.net/#easeInExpo
  6204. * @param exponent Defines the exponent of the function
  6205. */
  6206. constructor(
  6207. /** Defines the exponent of the function */
  6208. exponent?: number);
  6209. /** @hidden */
  6210. easeInCore(gradient: number): number;
  6211. }
  6212. /**
  6213. * Easing function with a power shape (see link below).
  6214. * @see https://easings.net/#easeInQuad
  6215. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6216. */
  6217. export class PowerEase extends EasingFunction implements IEasingFunction {
  6218. /** Defines the power of the function */
  6219. power: number;
  6220. /**
  6221. * Instantiates an power base easing function
  6222. * @see https://easings.net/#easeInQuad
  6223. * @param power Defines the power of the function
  6224. */
  6225. constructor(
  6226. /** Defines the power of the function */
  6227. power?: number);
  6228. /** @hidden */
  6229. easeInCore(gradient: number): number;
  6230. }
  6231. /**
  6232. * Easing function with a power of 2 shape (see link below).
  6233. * @see https://easings.net/#easeInQuad
  6234. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6235. */
  6236. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6237. /** @hidden */
  6238. easeInCore(gradient: number): number;
  6239. }
  6240. /**
  6241. * Easing function with a power of 4 shape (see link below).
  6242. * @see https://easings.net/#easeInQuart
  6243. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6244. */
  6245. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6246. /** @hidden */
  6247. easeInCore(gradient: number): number;
  6248. }
  6249. /**
  6250. * Easing function with a power of 5 shape (see link below).
  6251. * @see https://easings.net/#easeInQuint
  6252. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6253. */
  6254. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6255. /** @hidden */
  6256. easeInCore(gradient: number): number;
  6257. }
  6258. /**
  6259. * Easing function with a sin shape (see link below).
  6260. * @see https://easings.net/#easeInSine
  6261. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6262. */
  6263. export class SineEase extends EasingFunction implements IEasingFunction {
  6264. /** @hidden */
  6265. easeInCore(gradient: number): number;
  6266. }
  6267. /**
  6268. * Easing function with a bezier shape (see link below).
  6269. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6270. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6271. */
  6272. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6273. /** Defines the x component of the start tangent in the bezier curve */
  6274. x1: number;
  6275. /** Defines the y component of the start tangent in the bezier curve */
  6276. y1: number;
  6277. /** Defines the x component of the end tangent in the bezier curve */
  6278. x2: number;
  6279. /** Defines the y component of the end tangent in the bezier curve */
  6280. y2: number;
  6281. /**
  6282. * Instantiates a bezier function
  6283. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6284. * @param x1 Defines the x component of the start tangent in the bezier curve
  6285. * @param y1 Defines the y component of the start tangent in the bezier curve
  6286. * @param x2 Defines the x component of the end tangent in the bezier curve
  6287. * @param y2 Defines the y component of the end tangent in the bezier curve
  6288. */
  6289. constructor(
  6290. /** Defines the x component of the start tangent in the bezier curve */
  6291. x1?: number,
  6292. /** Defines the y component of the start tangent in the bezier curve */
  6293. y1?: number,
  6294. /** Defines the x component of the end tangent in the bezier curve */
  6295. x2?: number,
  6296. /** Defines the y component of the end tangent in the bezier curve */
  6297. y2?: number);
  6298. /** @hidden */
  6299. easeInCore(gradient: number): number;
  6300. }
  6301. }
  6302. declare module BABYLON {
  6303. /**
  6304. * Defines an interface which represents an animation key frame
  6305. */
  6306. export interface IAnimationKey {
  6307. /**
  6308. * Frame of the key frame
  6309. */
  6310. frame: number;
  6311. /**
  6312. * Value at the specifies key frame
  6313. */
  6314. value: any;
  6315. /**
  6316. * The input tangent for the cubic hermite spline
  6317. */
  6318. inTangent?: any;
  6319. /**
  6320. * The output tangent for the cubic hermite spline
  6321. */
  6322. outTangent?: any;
  6323. /**
  6324. * The animation interpolation type
  6325. */
  6326. interpolation?: AnimationKeyInterpolation;
  6327. }
  6328. /**
  6329. * Enum for the animation key frame interpolation type
  6330. */
  6331. export enum AnimationKeyInterpolation {
  6332. /**
  6333. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6334. */
  6335. STEP = 1
  6336. }
  6337. }
  6338. declare module BABYLON {
  6339. /**
  6340. * Represents the range of an animation
  6341. */
  6342. export class AnimationRange {
  6343. /**The name of the animation range**/
  6344. name: string;
  6345. /**The starting frame of the animation */
  6346. from: number;
  6347. /**The ending frame of the animation*/
  6348. to: number;
  6349. /**
  6350. * Initializes the range of an animation
  6351. * @param name The name of the animation range
  6352. * @param from The starting frame of the animation
  6353. * @param to The ending frame of the animation
  6354. */
  6355. constructor(
  6356. /**The name of the animation range**/
  6357. name: string,
  6358. /**The starting frame of the animation */
  6359. from: number,
  6360. /**The ending frame of the animation*/
  6361. to: number);
  6362. /**
  6363. * Makes a copy of the animation range
  6364. * @returns A copy of the animation range
  6365. */
  6366. clone(): AnimationRange;
  6367. }
  6368. }
  6369. declare module BABYLON {
  6370. /**
  6371. * Composed of a frame, and an action function
  6372. */
  6373. export class AnimationEvent {
  6374. /** The frame for which the event is triggered **/
  6375. frame: number;
  6376. /** The event to perform when triggered **/
  6377. action: (currentFrame: number) => void;
  6378. /** Specifies if the event should be triggered only once**/
  6379. onlyOnce?: boolean | undefined;
  6380. /**
  6381. * Specifies if the animation event is done
  6382. */
  6383. isDone: boolean;
  6384. /**
  6385. * Initializes the animation event
  6386. * @param frame The frame for which the event is triggered
  6387. * @param action The event to perform when triggered
  6388. * @param onlyOnce Specifies if the event should be triggered only once
  6389. */
  6390. constructor(
  6391. /** The frame for which the event is triggered **/
  6392. frame: number,
  6393. /** The event to perform when triggered **/
  6394. action: (currentFrame: number) => void,
  6395. /** Specifies if the event should be triggered only once**/
  6396. onlyOnce?: boolean | undefined);
  6397. /** @hidden */
  6398. _clone(): AnimationEvent;
  6399. }
  6400. }
  6401. declare module BABYLON {
  6402. /**
  6403. * Interface used to define a behavior
  6404. */
  6405. export interface Behavior<T> {
  6406. /** gets or sets behavior's name */
  6407. name: string;
  6408. /**
  6409. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6410. */
  6411. init(): void;
  6412. /**
  6413. * Called when the behavior is attached to a target
  6414. * @param target defines the target where the behavior is attached to
  6415. */
  6416. attach(target: T): void;
  6417. /**
  6418. * Called when the behavior is detached from its target
  6419. */
  6420. detach(): void;
  6421. }
  6422. /**
  6423. * Interface implemented by classes supporting behaviors
  6424. */
  6425. export interface IBehaviorAware<T> {
  6426. /**
  6427. * Attach a behavior
  6428. * @param behavior defines the behavior to attach
  6429. * @returns the current host
  6430. */
  6431. addBehavior(behavior: Behavior<T>): T;
  6432. /**
  6433. * Remove a behavior from the current object
  6434. * @param behavior defines the behavior to detach
  6435. * @returns the current host
  6436. */
  6437. removeBehavior(behavior: Behavior<T>): T;
  6438. /**
  6439. * Gets a behavior using its name to search
  6440. * @param name defines the name to search
  6441. * @returns the behavior or null if not found
  6442. */
  6443. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6444. }
  6445. }
  6446. declare module BABYLON {
  6447. /**
  6448. * Defines an array and its length.
  6449. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6450. */
  6451. export interface ISmartArrayLike<T> {
  6452. /**
  6453. * The data of the array.
  6454. */
  6455. data: Array<T>;
  6456. /**
  6457. * The active length of the array.
  6458. */
  6459. length: number;
  6460. }
  6461. /**
  6462. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6463. */
  6464. export class SmartArray<T> implements ISmartArrayLike<T> {
  6465. /**
  6466. * The full set of data from the array.
  6467. */
  6468. data: Array<T>;
  6469. /**
  6470. * The active length of the array.
  6471. */
  6472. length: number;
  6473. protected _id: number;
  6474. /**
  6475. * Instantiates a Smart Array.
  6476. * @param capacity defines the default capacity of the array.
  6477. */
  6478. constructor(capacity: number);
  6479. /**
  6480. * Pushes a value at the end of the active data.
  6481. * @param value defines the object to push in the array.
  6482. */
  6483. push(value: T): void;
  6484. /**
  6485. * Iterates over the active data and apply the lambda to them.
  6486. * @param func defines the action to apply on each value.
  6487. */
  6488. forEach(func: (content: T) => void): void;
  6489. /**
  6490. * Sorts the full sets of data.
  6491. * @param compareFn defines the comparison function to apply.
  6492. */
  6493. sort(compareFn: (a: T, b: T) => number): void;
  6494. /**
  6495. * Resets the active data to an empty array.
  6496. */
  6497. reset(): void;
  6498. /**
  6499. * Releases all the data from the array as well as the array.
  6500. */
  6501. dispose(): void;
  6502. /**
  6503. * Concats the active data with a given array.
  6504. * @param array defines the data to concatenate with.
  6505. */
  6506. concat(array: any): void;
  6507. /**
  6508. * Returns the position of a value in the active data.
  6509. * @param value defines the value to find the index for
  6510. * @returns the index if found in the active data otherwise -1
  6511. */
  6512. indexOf(value: T): number;
  6513. /**
  6514. * Returns whether an element is part of the active data.
  6515. * @param value defines the value to look for
  6516. * @returns true if found in the active data otherwise false
  6517. */
  6518. contains(value: T): boolean;
  6519. private static _GlobalId;
  6520. }
  6521. /**
  6522. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6523. * The data in this array can only be present once
  6524. */
  6525. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6526. private _duplicateId;
  6527. /**
  6528. * Pushes a value at the end of the active data.
  6529. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6530. * @param value defines the object to push in the array.
  6531. */
  6532. push(value: T): void;
  6533. /**
  6534. * Pushes a value at the end of the active data.
  6535. * If the data is already present, it won t be added again
  6536. * @param value defines the object to push in the array.
  6537. * @returns true if added false if it was already present
  6538. */
  6539. pushNoDuplicate(value: T): boolean;
  6540. /**
  6541. * Resets the active data to an empty array.
  6542. */
  6543. reset(): void;
  6544. /**
  6545. * Concats the active data with a given array.
  6546. * This ensures no dupplicate will be present in the result.
  6547. * @param array defines the data to concatenate with.
  6548. */
  6549. concatWithNoDuplicate(array: any): void;
  6550. }
  6551. }
  6552. declare module BABYLON {
  6553. /**
  6554. * @ignore
  6555. * This is a list of all the different input types that are available in the application.
  6556. * Fo instance: ArcRotateCameraGamepadInput...
  6557. */
  6558. export var CameraInputTypes: {};
  6559. /**
  6560. * This is the contract to implement in order to create a new input class.
  6561. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6562. */
  6563. export interface ICameraInput<TCamera extends Camera> {
  6564. /**
  6565. * Defines the camera the input is attached to.
  6566. */
  6567. camera: Nullable<TCamera>;
  6568. /**
  6569. * Gets the class name of the current intput.
  6570. * @returns the class name
  6571. */
  6572. getClassName(): string;
  6573. /**
  6574. * Get the friendly name associated with the input class.
  6575. * @returns the input friendly name
  6576. */
  6577. getSimpleName(): string;
  6578. /**
  6579. * Attach the input controls to a specific dom element to get the input from.
  6580. * @param element Defines the element the controls should be listened from
  6581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6582. */
  6583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6584. /**
  6585. * Detach the current controls from the specified dom element.
  6586. * @param element Defines the element to stop listening the inputs from
  6587. */
  6588. detachControl(element: Nullable<HTMLElement>): void;
  6589. /**
  6590. * Update the current camera state depending on the inputs that have been used this frame.
  6591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6592. */
  6593. checkInputs?: () => void;
  6594. }
  6595. /**
  6596. * Represents a map of input types to input instance or input index to input instance.
  6597. */
  6598. export interface CameraInputsMap<TCamera extends Camera> {
  6599. /**
  6600. * Accessor to the input by input type.
  6601. */
  6602. [name: string]: ICameraInput<TCamera>;
  6603. /**
  6604. * Accessor to the input by input index.
  6605. */
  6606. [idx: number]: ICameraInput<TCamera>;
  6607. }
  6608. /**
  6609. * This represents the input manager used within a camera.
  6610. * It helps dealing with all the different kind of input attached to a camera.
  6611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6612. */
  6613. export class CameraInputsManager<TCamera extends Camera> {
  6614. /**
  6615. * Defines the list of inputs attahed to the camera.
  6616. */
  6617. attached: CameraInputsMap<TCamera>;
  6618. /**
  6619. * Defines the dom element the camera is collecting inputs from.
  6620. * This is null if the controls have not been attached.
  6621. */
  6622. attachedElement: Nullable<HTMLElement>;
  6623. /**
  6624. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6625. */
  6626. noPreventDefault: boolean;
  6627. /**
  6628. * Defined the camera the input manager belongs to.
  6629. */
  6630. camera: TCamera;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs: () => void;
  6636. /**
  6637. * Instantiate a new Camera Input Manager.
  6638. * @param camera Defines the camera the input manager blongs to
  6639. */
  6640. constructor(camera: TCamera);
  6641. /**
  6642. * Add an input method to a camera
  6643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6644. * @param input camera input method
  6645. */
  6646. add(input: ICameraInput<TCamera>): void;
  6647. /**
  6648. * Remove a specific input method from a camera
  6649. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6650. * @param inputToRemove camera input method
  6651. */
  6652. remove(inputToRemove: ICameraInput<TCamera>): void;
  6653. /**
  6654. * Remove a specific input type from a camera
  6655. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6656. * @param inputType the type of the input to remove
  6657. */
  6658. removeByType(inputType: string): void;
  6659. private _addCheckInputs;
  6660. /**
  6661. * Attach the input controls to the currently attached dom element to listen the events from.
  6662. * @param input Defines the input to attach
  6663. */
  6664. attachInput(input: ICameraInput<TCamera>): void;
  6665. /**
  6666. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6667. * @param element Defines the dom element to collect the events from
  6668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6669. */
  6670. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6671. /**
  6672. * Detach the current manager inputs controls from a specific dom element.
  6673. * @param element Defines the dom element to collect the events from
  6674. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6675. */
  6676. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6677. /**
  6678. * Rebuild the dynamic inputCheck function from the current list of
  6679. * defined inputs in the manager.
  6680. */
  6681. rebuildInputCheck(): void;
  6682. /**
  6683. * Remove all attached input methods from a camera
  6684. */
  6685. clear(): void;
  6686. /**
  6687. * Serialize the current input manager attached to a camera.
  6688. * This ensures than once parsed,
  6689. * the input associated to the camera will be identical to the current ones
  6690. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6691. */
  6692. serialize(serializedCamera: any): void;
  6693. /**
  6694. * Parses an input manager serialized JSON to restore the previous list of inputs
  6695. * and states associated to a camera.
  6696. * @param parsedCamera Defines the JSON to parse
  6697. */
  6698. parse(parsedCamera: any): void;
  6699. }
  6700. }
  6701. declare module BABYLON {
  6702. /**
  6703. * @hidden
  6704. */
  6705. export class IntersectionInfo {
  6706. bu: Nullable<number>;
  6707. bv: Nullable<number>;
  6708. distance: number;
  6709. faceId: number;
  6710. subMeshId: number;
  6711. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6712. }
  6713. }
  6714. declare module BABYLON {
  6715. /**
  6716. * Represens a plane by the equation ax + by + cz + d = 0
  6717. */
  6718. export class Plane {
  6719. private static _TmpMatrix;
  6720. /**
  6721. * Normal of the plane (a,b,c)
  6722. */
  6723. normal: Vector3;
  6724. /**
  6725. * d component of the plane
  6726. */
  6727. d: number;
  6728. /**
  6729. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6730. * @param a a component of the plane
  6731. * @param b b component of the plane
  6732. * @param c c component of the plane
  6733. * @param d d component of the plane
  6734. */
  6735. constructor(a: number, b: number, c: number, d: number);
  6736. /**
  6737. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6738. */
  6739. asArray(): number[];
  6740. /**
  6741. * @returns a new plane copied from the current Plane.
  6742. */
  6743. clone(): Plane;
  6744. /**
  6745. * @returns the string "Plane".
  6746. */
  6747. getClassName(): string;
  6748. /**
  6749. * @returns the Plane hash code.
  6750. */
  6751. getHashCode(): number;
  6752. /**
  6753. * Normalize the current Plane in place.
  6754. * @returns the updated Plane.
  6755. */
  6756. normalize(): Plane;
  6757. /**
  6758. * Applies a transformation the plane and returns the result
  6759. * @param transformation the transformation matrix to be applied to the plane
  6760. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6761. */
  6762. transform(transformation: DeepImmutable<Matrix>): Plane;
  6763. /**
  6764. * Calcualtte the dot product between the point and the plane normal
  6765. * @param point point to calculate the dot product with
  6766. * @returns the dot product (float) of the point coordinates and the plane normal.
  6767. */
  6768. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6769. /**
  6770. * Updates the current Plane from the plane defined by the three given points.
  6771. * @param point1 one of the points used to contruct the plane
  6772. * @param point2 one of the points used to contruct the plane
  6773. * @param point3 one of the points used to contruct the plane
  6774. * @returns the updated Plane.
  6775. */
  6776. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6777. /**
  6778. * Checks if the plane is facing a given direction
  6779. * @param direction the direction to check if the plane is facing
  6780. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6781. * @returns True is the vector "direction" is the same side than the plane normal.
  6782. */
  6783. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6784. /**
  6785. * Calculates the distance to a point
  6786. * @param point point to calculate distance to
  6787. * @returns the signed distance (float) from the given point to the Plane.
  6788. */
  6789. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6790. /**
  6791. * Creates a plane from an array
  6792. * @param array the array to create a plane from
  6793. * @returns a new Plane from the given array.
  6794. */
  6795. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6796. /**
  6797. * Creates a plane from three points
  6798. * @param point1 point used to create the plane
  6799. * @param point2 point used to create the plane
  6800. * @param point3 point used to create the plane
  6801. * @returns a new Plane defined by the three given points.
  6802. */
  6803. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6804. /**
  6805. * Creates a plane from an origin point and a normal
  6806. * @param origin origin of the plane to be constructed
  6807. * @param normal normal of the plane to be constructed
  6808. * @returns a new Plane the normal vector to this plane at the given origin point.
  6809. * Note : the vector "normal" is updated because normalized.
  6810. */
  6811. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6812. /**
  6813. * Calculates the distance from a plane and a point
  6814. * @param origin origin of the plane to be constructed
  6815. * @param normal normal of the plane to be constructed
  6816. * @param point point to calculate distance to
  6817. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6818. */
  6819. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6820. }
  6821. }
  6822. declare module BABYLON {
  6823. /**
  6824. * Class used to store bounding sphere information
  6825. */
  6826. export class BoundingSphere {
  6827. /**
  6828. * Gets the center of the bounding sphere in local space
  6829. */
  6830. readonly center: Vector3;
  6831. /**
  6832. * Radius of the bounding sphere in local space
  6833. */
  6834. radius: number;
  6835. /**
  6836. * Gets the center of the bounding sphere in world space
  6837. */
  6838. readonly centerWorld: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in world space
  6841. */
  6842. radiusWorld: number;
  6843. /**
  6844. * Gets the minimum vector in local space
  6845. */
  6846. readonly minimum: Vector3;
  6847. /**
  6848. * Gets the maximum vector in local space
  6849. */
  6850. readonly maximum: Vector3;
  6851. private _worldMatrix;
  6852. private static readonly TmpVector3;
  6853. /**
  6854. * Creates a new bounding sphere
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding sphere by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingSphere;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding sphere is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding sphere center is in between the frustum planes.
  6888. * Used for optimistic fast inclusion.
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @returns true if the sphere center is in between the frustum planes
  6891. */
  6892. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if a point is inside the bounding sphere
  6895. * @param point defines the point to test
  6896. * @returns true if the point is inside the bounding sphere
  6897. */
  6898. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6899. /**
  6900. * Checks if two sphere intersct
  6901. * @param sphere0 sphere 0
  6902. * @param sphere1 sphere 1
  6903. * @returns true if the speres intersect
  6904. */
  6905. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6906. }
  6907. }
  6908. declare module BABYLON {
  6909. /**
  6910. * Class used to store bounding box information
  6911. */
  6912. export class BoundingBox implements ICullable {
  6913. /**
  6914. * Gets the 8 vectors representing the bounding box in local space
  6915. */
  6916. readonly vectors: Vector3[];
  6917. /**
  6918. * Gets the center of the bounding box in local space
  6919. */
  6920. readonly center: Vector3;
  6921. /**
  6922. * Gets the center of the bounding box in world space
  6923. */
  6924. readonly centerWorld: Vector3;
  6925. /**
  6926. * Gets the extend size in local space
  6927. */
  6928. readonly extendSize: Vector3;
  6929. /**
  6930. * Gets the extend size in world space
  6931. */
  6932. readonly extendSizeWorld: Vector3;
  6933. /**
  6934. * Gets the OBB (object bounding box) directions
  6935. */
  6936. readonly directions: Vector3[];
  6937. /**
  6938. * Gets the 8 vectors representing the bounding box in world space
  6939. */
  6940. readonly vectorsWorld: Vector3[];
  6941. /**
  6942. * Gets the minimum vector in world space
  6943. */
  6944. readonly minimumWorld: Vector3;
  6945. /**
  6946. * Gets the maximum vector in world space
  6947. */
  6948. readonly maximumWorld: Vector3;
  6949. /**
  6950. * Gets the minimum vector in local space
  6951. */
  6952. readonly minimum: Vector3;
  6953. /**
  6954. * Gets the maximum vector in local space
  6955. */
  6956. readonly maximum: Vector3;
  6957. private _worldMatrix;
  6958. private static readonly TmpVector3;
  6959. /**
  6960. * @hidden
  6961. */
  6962. _tag: number;
  6963. /**
  6964. * Creates a new bounding box
  6965. * @param min defines the minimum vector (in local space)
  6966. * @param max defines the maximum vector (in local space)
  6967. * @param worldMatrix defines the new world matrix
  6968. */
  6969. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6970. /**
  6971. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6972. * @param min defines the new minimum vector (in local space)
  6973. * @param max defines the new maximum vector (in local space)
  6974. * @param worldMatrix defines the new world matrix
  6975. */
  6976. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6977. /**
  6978. * Scale the current bounding box by applying a scale factor
  6979. * @param factor defines the scale factor to apply
  6980. * @returns the current bounding box
  6981. */
  6982. scale(factor: number): BoundingBox;
  6983. /**
  6984. * Gets the world matrix of the bounding box
  6985. * @returns a matrix
  6986. */
  6987. getWorldMatrix(): DeepImmutable<Matrix>;
  6988. /** @hidden */
  6989. _update(world: DeepImmutable<Matrix>): void;
  6990. /**
  6991. * Tests if the bounding box is intersecting the frustum planes
  6992. * @param frustumPlanes defines the frustum planes to test
  6993. * @returns true if there is an intersection
  6994. */
  6995. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6996. /**
  6997. * Tests if the bounding box is entirely inside the frustum planes
  6998. * @param frustumPlanes defines the frustum planes to test
  6999. * @returns true if there is an inclusion
  7000. */
  7001. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /**
  7003. * Tests if a point is inside the bounding box
  7004. * @param point defines the point to test
  7005. * @returns true if the point is inside the bounding box
  7006. */
  7007. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7008. /**
  7009. * Tests if the bounding box intersects with a bounding sphere
  7010. * @param sphere defines the sphere to test
  7011. * @returns true if there is an intersection
  7012. */
  7013. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7014. /**
  7015. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7016. * @param min defines the min vector to use
  7017. * @param max defines the max vector to use
  7018. * @returns true if there is an intersection
  7019. */
  7020. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7021. /**
  7022. * Tests if two bounding boxes are intersections
  7023. * @param box0 defines the first box to test
  7024. * @param box1 defines the second box to test
  7025. * @returns true if there is an intersection
  7026. */
  7027. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7028. /**
  7029. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7030. * @param minPoint defines the minimum vector of the bounding box
  7031. * @param maxPoint defines the maximum vector of the bounding box
  7032. * @param sphereCenter defines the sphere center
  7033. * @param sphereRadius defines the sphere radius
  7034. * @returns true if there is an intersection
  7035. */
  7036. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7037. /**
  7038. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7039. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7040. * @param frustumPlanes defines the frustum planes to test
  7041. * @return true if there is an inclusion
  7042. */
  7043. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7044. /**
  7045. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7046. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7047. * @param frustumPlanes defines the frustum planes to test
  7048. * @return true if there is an intersection
  7049. */
  7050. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7051. }
  7052. }
  7053. declare module BABYLON {
  7054. /** @hidden */
  7055. export class Collider {
  7056. /** Define if a collision was found */
  7057. collisionFound: boolean;
  7058. /**
  7059. * Define last intersection point in local space
  7060. */
  7061. intersectionPoint: Vector3;
  7062. /**
  7063. * Define last collided mesh
  7064. */
  7065. collidedMesh: Nullable<AbstractMesh>;
  7066. private _collisionPoint;
  7067. private _planeIntersectionPoint;
  7068. private _tempVector;
  7069. private _tempVector2;
  7070. private _tempVector3;
  7071. private _tempVector4;
  7072. private _edge;
  7073. private _baseToVertex;
  7074. private _destinationPoint;
  7075. private _slidePlaneNormal;
  7076. private _displacementVector;
  7077. /** @hidden */
  7078. _radius: Vector3;
  7079. /** @hidden */
  7080. _retry: number;
  7081. private _velocity;
  7082. private _basePoint;
  7083. private _epsilon;
  7084. /** @hidden */
  7085. _velocityWorldLength: number;
  7086. /** @hidden */
  7087. _basePointWorld: Vector3;
  7088. private _velocityWorld;
  7089. private _normalizedVelocity;
  7090. /** @hidden */
  7091. _initialVelocity: Vector3;
  7092. /** @hidden */
  7093. _initialPosition: Vector3;
  7094. private _nearestDistance;
  7095. private _collisionMask;
  7096. collisionMask: number;
  7097. /**
  7098. * Gets the plane normal used to compute the sliding response (in local space)
  7099. */
  7100. readonly slidePlaneNormal: Vector3;
  7101. /** @hidden */
  7102. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7103. /** @hidden */
  7104. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7105. /** @hidden */
  7106. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7107. /** @hidden */
  7108. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7109. /** @hidden */
  7110. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7111. /** @hidden */
  7112. _getResponse(pos: Vector3, vel: Vector3): void;
  7113. }
  7114. }
  7115. declare module BABYLON {
  7116. /**
  7117. * Interface for cullable objects
  7118. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7119. */
  7120. export interface ICullable {
  7121. /**
  7122. * Checks if the object or part of the object is in the frustum
  7123. * @param frustumPlanes Camera near/planes
  7124. * @returns true if the object is in frustum otherwise false
  7125. */
  7126. isInFrustum(frustumPlanes: Plane[]): boolean;
  7127. /**
  7128. * Checks if a cullable object (mesh...) is in the camera frustum
  7129. * Unlike isInFrustum this cheks the full bounding box
  7130. * @param frustumPlanes Camera near/planes
  7131. * @returns true if the object is in frustum otherwise false
  7132. */
  7133. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7134. }
  7135. /**
  7136. * Info for a bounding data of a mesh
  7137. */
  7138. export class BoundingInfo implements ICullable {
  7139. /**
  7140. * Bounding box for the mesh
  7141. */
  7142. readonly boundingBox: BoundingBox;
  7143. /**
  7144. * Bounding sphere for the mesh
  7145. */
  7146. readonly boundingSphere: BoundingSphere;
  7147. private _isLocked;
  7148. private static readonly TmpVector3;
  7149. /**
  7150. * Constructs bounding info
  7151. * @param minimum min vector of the bounding box/sphere
  7152. * @param maximum max vector of the bounding box/sphere
  7153. * @param worldMatrix defines the new world matrix
  7154. */
  7155. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7156. /**
  7157. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7158. * @param min defines the new minimum vector (in local space)
  7159. * @param max defines the new maximum vector (in local space)
  7160. * @param worldMatrix defines the new world matrix
  7161. */
  7162. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7163. /**
  7164. * min vector of the bounding box/sphere
  7165. */
  7166. readonly minimum: Vector3;
  7167. /**
  7168. * max vector of the bounding box/sphere
  7169. */
  7170. readonly maximum: Vector3;
  7171. /**
  7172. * If the info is locked and won't be updated to avoid perf overhead
  7173. */
  7174. isLocked: boolean;
  7175. /**
  7176. * Updates the bounding sphere and box
  7177. * @param world world matrix to be used to update
  7178. */
  7179. update(world: DeepImmutable<Matrix>): void;
  7180. /**
  7181. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7182. * @param center New center of the bounding info
  7183. * @param extend New extend of the bounding info
  7184. * @returns the current bounding info
  7185. */
  7186. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7187. /**
  7188. * Scale the current bounding info by applying a scale factor
  7189. * @param factor defines the scale factor to apply
  7190. * @returns the current bounding info
  7191. */
  7192. scale(factor: number): BoundingInfo;
  7193. /**
  7194. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7195. * @param frustumPlanes defines the frustum to test
  7196. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7197. * @returns true if the bounding info is in the frustum planes
  7198. */
  7199. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7200. /**
  7201. * Gets the world distance between the min and max points of the bounding box
  7202. */
  7203. readonly diagonalLength: number;
  7204. /**
  7205. * Checks if a cullable object (mesh...) is in the camera frustum
  7206. * Unlike isInFrustum this cheks the full bounding box
  7207. * @param frustumPlanes Camera near/planes
  7208. * @returns true if the object is in frustum otherwise false
  7209. */
  7210. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7211. /** @hidden */
  7212. _checkCollision(collider: Collider): boolean;
  7213. /**
  7214. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7215. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7216. * @param point the point to check intersection with
  7217. * @returns if the point intersects
  7218. */
  7219. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7220. /**
  7221. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7222. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7223. * @param boundingInfo the bounding info to check intersection with
  7224. * @param precise if the intersection should be done using OBB
  7225. * @returns if the bounding info intersects
  7226. */
  7227. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7228. }
  7229. }
  7230. declare module BABYLON {
  7231. /**
  7232. * Extracts minimum and maximum values from a list of indexed positions
  7233. * @param positions defines the positions to use
  7234. * @param indices defines the indices to the positions
  7235. * @param indexStart defines the start index
  7236. * @param indexCount defines the end index
  7237. * @param bias defines bias value to add to the result
  7238. * @return minimum and maximum values
  7239. */
  7240. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7241. minimum: Vector3;
  7242. maximum: Vector3;
  7243. };
  7244. /**
  7245. * Extracts minimum and maximum values from a list of positions
  7246. * @param positions defines the positions to use
  7247. * @param start defines the start index in the positions array
  7248. * @param count defines the number of positions to handle
  7249. * @param bias defines bias value to add to the result
  7250. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7251. * @return minimum and maximum values
  7252. */
  7253. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7254. minimum: Vector3;
  7255. maximum: Vector3;
  7256. };
  7257. }
  7258. declare module BABYLON {
  7259. /**
  7260. * Enum that determines the text-wrapping mode to use.
  7261. */
  7262. export enum InspectableType {
  7263. /**
  7264. * Checkbox for booleans
  7265. */
  7266. Checkbox = 0,
  7267. /**
  7268. * Sliders for numbers
  7269. */
  7270. Slider = 1,
  7271. /**
  7272. * Vector3
  7273. */
  7274. Vector3 = 2,
  7275. /**
  7276. * Quaternions
  7277. */
  7278. Quaternion = 3,
  7279. /**
  7280. * Color3
  7281. */
  7282. Color3 = 4,
  7283. /**
  7284. * String
  7285. */
  7286. String = 5
  7287. }
  7288. /**
  7289. * Interface used to define custom inspectable properties.
  7290. * This interface is used by the inspector to display custom property grids
  7291. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7292. */
  7293. export interface IInspectable {
  7294. /**
  7295. * Gets the label to display
  7296. */
  7297. label: string;
  7298. /**
  7299. * Gets the name of the property to edit
  7300. */
  7301. propertyName: string;
  7302. /**
  7303. * Gets the type of the editor to use
  7304. */
  7305. type: InspectableType;
  7306. /**
  7307. * Gets the minimum value of the property when using in "slider" mode
  7308. */
  7309. min?: number;
  7310. /**
  7311. * Gets the maximum value of the property when using in "slider" mode
  7312. */
  7313. max?: number;
  7314. /**
  7315. * Gets the setp to use when using in "slider" mode
  7316. */
  7317. step?: number;
  7318. }
  7319. }
  7320. declare module BABYLON {
  7321. /**
  7322. * Class used to provide helper for timing
  7323. */
  7324. export class TimingTools {
  7325. /**
  7326. * Polyfill for setImmediate
  7327. * @param action defines the action to execute after the current execution block
  7328. */
  7329. static SetImmediate(action: () => void): void;
  7330. }
  7331. }
  7332. declare module BABYLON {
  7333. /**
  7334. * Class used to enable instatition of objects by class name
  7335. */
  7336. export class InstantiationTools {
  7337. /**
  7338. * Use this object to register external classes like custom textures or material
  7339. * to allow the laoders to instantiate them
  7340. */
  7341. static RegisteredExternalClasses: {
  7342. [key: string]: Object;
  7343. };
  7344. /**
  7345. * Tries to instantiate a new object from a given class name
  7346. * @param className defines the class name to instantiate
  7347. * @returns the new object or null if the system was not able to do the instantiation
  7348. */
  7349. static Instantiate(className: string): any;
  7350. }
  7351. }
  7352. declare module BABYLON {
  7353. /**
  7354. * This represents the required contract to create a new type of texture loader.
  7355. */
  7356. export interface IInternalTextureLoader {
  7357. /**
  7358. * Defines wether the loader supports cascade loading the different faces.
  7359. */
  7360. supportCascades: boolean;
  7361. /**
  7362. * This returns if the loader support the current file information.
  7363. * @param extension defines the file extension of the file being loaded
  7364. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7365. * @param fallback defines the fallback internal texture if any
  7366. * @param isBase64 defines whether the texture is encoded as a base64
  7367. * @param isBuffer defines whether the texture data are stored as a buffer
  7368. * @returns true if the loader can load the specified file
  7369. */
  7370. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7371. /**
  7372. * Transform the url before loading if required.
  7373. * @param rootUrl the url of the texture
  7374. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7375. * @returns the transformed texture
  7376. */
  7377. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7378. /**
  7379. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7380. * @param rootUrl the url of the texture
  7381. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7382. * @returns the fallback texture
  7383. */
  7384. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7385. /**
  7386. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7387. * @param data contains the texture data
  7388. * @param texture defines the BabylonJS internal texture
  7389. * @param createPolynomials will be true if polynomials have been requested
  7390. * @param onLoad defines the callback to trigger once the texture is ready
  7391. * @param onError defines the callback to trigger in case of error
  7392. */
  7393. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7394. /**
  7395. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7396. * @param data contains the texture data
  7397. * @param texture defines the BabylonJS internal texture
  7398. * @param callback defines the method to call once ready to upload
  7399. */
  7400. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7401. }
  7402. }
  7403. declare module BABYLON {
  7404. interface Engine {
  7405. /**
  7406. * Creates a depth stencil cube texture.
  7407. * This is only available in WebGL 2.
  7408. * @param size The size of face edge in the cube texture.
  7409. * @param options The options defining the cube texture.
  7410. * @returns The cube texture
  7411. */
  7412. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7413. /**
  7414. * Creates a cube texture
  7415. * @param rootUrl defines the url where the files to load is located
  7416. * @param scene defines the current scene
  7417. * @param files defines the list of files to load (1 per face)
  7418. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7419. * @param onLoad defines an optional callback raised when the texture is loaded
  7420. * @param onError defines an optional callback raised if there is an issue to load the texture
  7421. * @param format defines the format of the data
  7422. * @param forcedExtension defines the extension to use to pick the right loader
  7423. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7424. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7425. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7426. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7427. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7428. * @returns the cube texture as an InternalTexture
  7429. */
  7430. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7431. /**
  7432. * Creates a cube texture
  7433. * @param rootUrl defines the url where the files to load is located
  7434. * @param scene defines the current scene
  7435. * @param files defines the list of files to load (1 per face)
  7436. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7437. * @param onLoad defines an optional callback raised when the texture is loaded
  7438. * @param onError defines an optional callback raised if there is an issue to load the texture
  7439. * @param format defines the format of the data
  7440. * @param forcedExtension defines the extension to use to pick the right loader
  7441. * @returns the cube texture as an InternalTexture
  7442. */
  7443. 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 | undefined, forcedExtension: any): InternalTexture;
  7444. /**
  7445. * Creates a cube texture
  7446. * @param rootUrl defines the url where the files to load is located
  7447. * @param scene defines the current scene
  7448. * @param files defines the list of files to load (1 per face)
  7449. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7450. * @param onLoad defines an optional callback raised when the texture is loaded
  7451. * @param onError defines an optional callback raised if there is an issue to load the texture
  7452. * @param format defines the format of the data
  7453. * @param forcedExtension defines the extension to use to pick the right loader
  7454. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7455. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7456. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7457. * @returns the cube texture as an InternalTexture
  7458. */
  7459. 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 | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7460. /** @hidden */
  7461. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7462. /** @hidden */
  7463. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7464. /** @hidden */
  7465. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7466. /** @hidden */
  7467. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7468. }
  7469. }
  7470. declare module BABYLON {
  7471. /**
  7472. * Class for creating a cube texture
  7473. */
  7474. export class CubeTexture extends BaseTexture {
  7475. private _delayedOnLoad;
  7476. /**
  7477. * The url of the texture
  7478. */
  7479. url: string;
  7480. /**
  7481. * Gets or sets the center of the bounding box associated with the cube texture.
  7482. * It must define where the camera used to render the texture was set
  7483. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7484. */
  7485. boundingBoxPosition: Vector3;
  7486. private _boundingBoxSize;
  7487. /**
  7488. * Gets or sets the size of the bounding box associated with the cube texture
  7489. * When defined, the cubemap will switch to local mode
  7490. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7491. * @example https://www.babylonjs-playground.com/#RNASML
  7492. */
  7493. /**
  7494. * Returns the bounding box size
  7495. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7496. */
  7497. boundingBoxSize: Vector3;
  7498. protected _rotationY: number;
  7499. /**
  7500. * Sets texture matrix rotation angle around Y axis in radians.
  7501. */
  7502. /**
  7503. * Gets texture matrix rotation angle around Y axis radians.
  7504. */
  7505. rotationY: number;
  7506. /**
  7507. * Are mip maps generated for this texture or not.
  7508. */
  7509. readonly noMipmap: boolean;
  7510. private _noMipmap;
  7511. private _files;
  7512. private _extensions;
  7513. private _textureMatrix;
  7514. private _format;
  7515. private _createPolynomials;
  7516. /** @hidden */
  7517. _prefiltered: boolean;
  7518. /**
  7519. * Creates a cube texture from an array of image urls
  7520. * @param files defines an array of image urls
  7521. * @param scene defines the hosting scene
  7522. * @param noMipmap specifies if mip maps are not used
  7523. * @returns a cube texture
  7524. */
  7525. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7526. /**
  7527. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7528. * @param url defines the url of the prefiltered texture
  7529. * @param scene defines the scene the texture is attached to
  7530. * @param forcedExtension defines the extension of the file if different from the url
  7531. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7532. * @return the prefiltered texture
  7533. */
  7534. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7535. /**
  7536. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7537. * as prefiltered data.
  7538. * @param rootUrl defines the url of the texture or the root name of the six images
  7539. * @param scene defines the scene the texture is attached to
  7540. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7541. * @param noMipmap defines if mipmaps should be created or not
  7542. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7543. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7544. * @param onError defines a callback triggered in case of error during load
  7545. * @param format defines the internal format to use for the texture once loaded
  7546. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7547. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7548. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7549. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7550. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7551. * @return the cube texture
  7552. */
  7553. 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, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7554. /**
  7555. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7556. */
  7557. readonly isPrefiltered: boolean;
  7558. /**
  7559. * Get the current class name of the texture useful for serialization or dynamic coding.
  7560. * @returns "CubeTexture"
  7561. */
  7562. getClassName(): string;
  7563. /**
  7564. * Update the url (and optional buffer) of this texture if url was null during construction.
  7565. * @param url the url of the texture
  7566. * @param forcedExtension defines the extension to use
  7567. * @param onLoad callback called when the texture is loaded (defaults to null)
  7568. */
  7569. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7570. /**
  7571. * Delays loading of the cube texture
  7572. * @param forcedExtension defines the extension to use
  7573. */
  7574. delayLoad(forcedExtension?: string): void;
  7575. /**
  7576. * Returns the reflection texture matrix
  7577. * @returns the reflection texture matrix
  7578. */
  7579. getReflectionTextureMatrix(): Matrix;
  7580. /**
  7581. * Sets the reflection texture matrix
  7582. * @param value Reflection texture matrix
  7583. */
  7584. setReflectionTextureMatrix(value: Matrix): void;
  7585. /**
  7586. * Parses text to create a cube texture
  7587. * @param parsedTexture define the serialized text to read from
  7588. * @param scene defines the hosting scene
  7589. * @param rootUrl defines the root url of the cube texture
  7590. * @returns a cube texture
  7591. */
  7592. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7593. /**
  7594. * Makes a clone, or deep copy, of the cube texture
  7595. * @returns a new cube texture
  7596. */
  7597. clone(): CubeTexture;
  7598. }
  7599. }
  7600. declare module BABYLON {
  7601. /**
  7602. * Manages the defines for the Material
  7603. */
  7604. export class MaterialDefines {
  7605. /** @hidden */
  7606. protected _keys: string[];
  7607. private _isDirty;
  7608. /** @hidden */
  7609. _renderId: number;
  7610. /** @hidden */
  7611. _areLightsDirty: boolean;
  7612. /** @hidden */
  7613. _areAttributesDirty: boolean;
  7614. /** @hidden */
  7615. _areTexturesDirty: boolean;
  7616. /** @hidden */
  7617. _areFresnelDirty: boolean;
  7618. /** @hidden */
  7619. _areMiscDirty: boolean;
  7620. /** @hidden */
  7621. _areImageProcessingDirty: boolean;
  7622. /** @hidden */
  7623. _normals: boolean;
  7624. /** @hidden */
  7625. _uvs: boolean;
  7626. /** @hidden */
  7627. _needNormals: boolean;
  7628. /** @hidden */
  7629. _needUVs: boolean;
  7630. [id: string]: any;
  7631. /**
  7632. * Specifies if the material needs to be re-calculated
  7633. */
  7634. readonly isDirty: boolean;
  7635. /**
  7636. * Marks the material to indicate that it has been re-calculated
  7637. */
  7638. markAsProcessed(): void;
  7639. /**
  7640. * Marks the material to indicate that it needs to be re-calculated
  7641. */
  7642. markAsUnprocessed(): void;
  7643. /**
  7644. * Marks the material to indicate all of its defines need to be re-calculated
  7645. */
  7646. markAllAsDirty(): void;
  7647. /**
  7648. * Marks the material to indicate that image processing needs to be re-calculated
  7649. */
  7650. markAsImageProcessingDirty(): void;
  7651. /**
  7652. * Marks the material to indicate the lights need to be re-calculated
  7653. */
  7654. markAsLightDirty(): void;
  7655. /**
  7656. * Marks the attribute state as changed
  7657. */
  7658. markAsAttributesDirty(): void;
  7659. /**
  7660. * Marks the texture state as changed
  7661. */
  7662. markAsTexturesDirty(): void;
  7663. /**
  7664. * Marks the fresnel state as changed
  7665. */
  7666. markAsFresnelDirty(): void;
  7667. /**
  7668. * Marks the misc state as changed
  7669. */
  7670. markAsMiscDirty(): void;
  7671. /**
  7672. * Rebuilds the material defines
  7673. */
  7674. rebuild(): void;
  7675. /**
  7676. * Specifies if two material defines are equal
  7677. * @param other - A material define instance to compare to
  7678. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7679. */
  7680. isEqual(other: MaterialDefines): boolean;
  7681. /**
  7682. * Clones this instance's defines to another instance
  7683. * @param other - material defines to clone values to
  7684. */
  7685. cloneTo(other: MaterialDefines): void;
  7686. /**
  7687. * Resets the material define values
  7688. */
  7689. reset(): void;
  7690. /**
  7691. * Converts the material define values to a string
  7692. * @returns - String of material define information
  7693. */
  7694. toString(): string;
  7695. }
  7696. }
  7697. declare module BABYLON {
  7698. /**
  7699. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7700. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7701. * 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;
  7702. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7703. */
  7704. export class ColorCurves {
  7705. private _dirty;
  7706. private _tempColor;
  7707. private _globalCurve;
  7708. private _highlightsCurve;
  7709. private _midtonesCurve;
  7710. private _shadowsCurve;
  7711. private _positiveCurve;
  7712. private _negativeCurve;
  7713. private _globalHue;
  7714. private _globalDensity;
  7715. private _globalSaturation;
  7716. private _globalExposure;
  7717. /**
  7718. * Gets the global Hue value.
  7719. * 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).
  7720. */
  7721. /**
  7722. * Sets the global Hue value.
  7723. * 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).
  7724. */
  7725. globalHue: number;
  7726. /**
  7727. * Gets the global Density value.
  7728. * 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.
  7729. * Values less than zero provide a filter of opposite hue.
  7730. */
  7731. /**
  7732. * Sets the global Density value.
  7733. * 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.
  7734. * Values less than zero provide a filter of opposite hue.
  7735. */
  7736. globalDensity: number;
  7737. /**
  7738. * Gets the global Saturation value.
  7739. * 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.
  7740. */
  7741. /**
  7742. * Sets the global Saturation value.
  7743. * 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.
  7744. */
  7745. globalSaturation: number;
  7746. /**
  7747. * Gets the global Exposure value.
  7748. * 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.
  7749. */
  7750. /**
  7751. * Sets the global Exposure value.
  7752. * 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.
  7753. */
  7754. globalExposure: number;
  7755. private _highlightsHue;
  7756. private _highlightsDensity;
  7757. private _highlightsSaturation;
  7758. private _highlightsExposure;
  7759. /**
  7760. * Gets the highlights Hue value.
  7761. * 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).
  7762. */
  7763. /**
  7764. * Sets the highlights Hue value.
  7765. * 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).
  7766. */
  7767. highlightsHue: number;
  7768. /**
  7769. * Gets the highlights Density value.
  7770. * 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.
  7771. * Values less than zero provide a filter of opposite hue.
  7772. */
  7773. /**
  7774. * Sets the highlights Density value.
  7775. * 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.
  7776. * Values less than zero provide a filter of opposite hue.
  7777. */
  7778. highlightsDensity: number;
  7779. /**
  7780. * Gets the highlights Saturation value.
  7781. * 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.
  7782. */
  7783. /**
  7784. * Sets the highlights Saturation value.
  7785. * 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.
  7786. */
  7787. highlightsSaturation: number;
  7788. /**
  7789. * Gets the highlights Exposure value.
  7790. * 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.
  7791. */
  7792. /**
  7793. * Sets the highlights Exposure value.
  7794. * 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.
  7795. */
  7796. highlightsExposure: number;
  7797. private _midtonesHue;
  7798. private _midtonesDensity;
  7799. private _midtonesSaturation;
  7800. private _midtonesExposure;
  7801. /**
  7802. * Gets the midtones Hue value.
  7803. * 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).
  7804. */
  7805. /**
  7806. * Sets the midtones Hue value.
  7807. * 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).
  7808. */
  7809. midtonesHue: number;
  7810. /**
  7811. * Gets the midtones Density value.
  7812. * 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.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. /**
  7816. * Sets the midtones Density value.
  7817. * 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.
  7818. * Values less than zero provide a filter of opposite hue.
  7819. */
  7820. midtonesDensity: number;
  7821. /**
  7822. * Gets the midtones Saturation value.
  7823. * 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.
  7824. */
  7825. /**
  7826. * Sets the midtones Saturation value.
  7827. * 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.
  7828. */
  7829. midtonesSaturation: number;
  7830. /**
  7831. * Gets the midtones Exposure value.
  7832. * 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.
  7833. */
  7834. /**
  7835. * Sets the midtones Exposure value.
  7836. * 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.
  7837. */
  7838. midtonesExposure: number;
  7839. private _shadowsHue;
  7840. private _shadowsDensity;
  7841. private _shadowsSaturation;
  7842. private _shadowsExposure;
  7843. /**
  7844. * Gets the shadows Hue value.
  7845. * 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).
  7846. */
  7847. /**
  7848. * Sets the shadows Hue value.
  7849. * 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).
  7850. */
  7851. shadowsHue: number;
  7852. /**
  7853. * Gets the shadows Density value.
  7854. * 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.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. /**
  7858. * Sets the shadows Density value.
  7859. * 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.
  7860. * Values less than zero provide a filter of opposite hue.
  7861. */
  7862. shadowsDensity: number;
  7863. /**
  7864. * Gets the shadows Saturation value.
  7865. * 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.
  7866. */
  7867. /**
  7868. * Sets the shadows Saturation value.
  7869. * 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.
  7870. */
  7871. shadowsSaturation: number;
  7872. /**
  7873. * Gets the shadows Exposure value.
  7874. * 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.
  7875. */
  7876. /**
  7877. * Sets the shadows Exposure value.
  7878. * 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.
  7879. */
  7880. shadowsExposure: number;
  7881. /**
  7882. * Returns the class name
  7883. * @returns The class name
  7884. */
  7885. getClassName(): string;
  7886. /**
  7887. * Binds the color curves to the shader.
  7888. * @param colorCurves The color curve to bind
  7889. * @param effect The effect to bind to
  7890. * @param positiveUniform The positive uniform shader parameter
  7891. * @param neutralUniform The neutral uniform shader parameter
  7892. * @param negativeUniform The negative uniform shader parameter
  7893. */
  7894. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7895. /**
  7896. * Prepare the list of uniforms associated with the ColorCurves effects.
  7897. * @param uniformsList The list of uniforms used in the effect
  7898. */
  7899. static PrepareUniforms(uniformsList: string[]): void;
  7900. /**
  7901. * Returns color grading data based on a hue, density, saturation and exposure value.
  7902. * @param filterHue The hue of the color filter.
  7903. * @param filterDensity The density of the color filter.
  7904. * @param saturation The saturation.
  7905. * @param exposure The exposure.
  7906. * @param result The result data container.
  7907. */
  7908. private getColorGradingDataToRef;
  7909. /**
  7910. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7911. * @param value The input slider value in range [-100,100].
  7912. * @returns Adjusted value.
  7913. */
  7914. private static applyColorGradingSliderNonlinear;
  7915. /**
  7916. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7917. * @param hue The hue (H) input.
  7918. * @param saturation The saturation (S) input.
  7919. * @param brightness The brightness (B) input.
  7920. * @result An RGBA color represented as Vector4.
  7921. */
  7922. private static fromHSBToRef;
  7923. /**
  7924. * Returns a value clamped between min and max
  7925. * @param value The value to clamp
  7926. * @param min The minimum of value
  7927. * @param max The maximum of value
  7928. * @returns The clamped value.
  7929. */
  7930. private static clamp;
  7931. /**
  7932. * Clones the current color curve instance.
  7933. * @return The cloned curves
  7934. */
  7935. clone(): ColorCurves;
  7936. /**
  7937. * Serializes the current color curve instance to a json representation.
  7938. * @return a JSON representation
  7939. */
  7940. serialize(): any;
  7941. /**
  7942. * Parses the color curve from a json representation.
  7943. * @param source the JSON source to parse
  7944. * @return The parsed curves
  7945. */
  7946. static Parse(source: any): ColorCurves;
  7947. }
  7948. }
  7949. declare module BABYLON {
  7950. /**
  7951. * Interface to follow in your material defines to integrate easily the
  7952. * Image proccessing functions.
  7953. * @hidden
  7954. */
  7955. export interface IImageProcessingConfigurationDefines {
  7956. IMAGEPROCESSING: boolean;
  7957. VIGNETTE: boolean;
  7958. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7959. VIGNETTEBLENDMODEOPAQUE: boolean;
  7960. TONEMAPPING: boolean;
  7961. TONEMAPPING_ACES: boolean;
  7962. CONTRAST: boolean;
  7963. EXPOSURE: boolean;
  7964. COLORCURVES: boolean;
  7965. COLORGRADING: boolean;
  7966. COLORGRADING3D: boolean;
  7967. SAMPLER3DGREENDEPTH: boolean;
  7968. SAMPLER3DBGRMAP: boolean;
  7969. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7970. }
  7971. /**
  7972. * @hidden
  7973. */
  7974. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7975. IMAGEPROCESSING: boolean;
  7976. VIGNETTE: boolean;
  7977. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7978. VIGNETTEBLENDMODEOPAQUE: boolean;
  7979. TONEMAPPING: boolean;
  7980. TONEMAPPING_ACES: boolean;
  7981. CONTRAST: boolean;
  7982. COLORCURVES: boolean;
  7983. COLORGRADING: boolean;
  7984. COLORGRADING3D: boolean;
  7985. SAMPLER3DGREENDEPTH: boolean;
  7986. SAMPLER3DBGRMAP: boolean;
  7987. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7988. EXPOSURE: boolean;
  7989. constructor();
  7990. }
  7991. /**
  7992. * This groups together the common properties used for image processing either in direct forward pass
  7993. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7994. * or not.
  7995. */
  7996. export class ImageProcessingConfiguration {
  7997. /**
  7998. * Default tone mapping applied in BabylonJS.
  7999. */
  8000. static readonly TONEMAPPING_STANDARD: number;
  8001. /**
  8002. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8003. * to other engines rendering to increase portability.
  8004. */
  8005. static readonly TONEMAPPING_ACES: number;
  8006. /**
  8007. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8008. */
  8009. colorCurves: Nullable<ColorCurves>;
  8010. private _colorCurvesEnabled;
  8011. /**
  8012. * Gets wether the color curves effect is enabled.
  8013. */
  8014. /**
  8015. * Sets wether the color curves effect is enabled.
  8016. */
  8017. colorCurvesEnabled: boolean;
  8018. private _colorGradingTexture;
  8019. /**
  8020. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8021. */
  8022. /**
  8023. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8024. */
  8025. colorGradingTexture: Nullable<BaseTexture>;
  8026. private _colorGradingEnabled;
  8027. /**
  8028. * Gets wether the color grading effect is enabled.
  8029. */
  8030. /**
  8031. * Sets wether the color grading effect is enabled.
  8032. */
  8033. colorGradingEnabled: boolean;
  8034. private _colorGradingWithGreenDepth;
  8035. /**
  8036. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8037. */
  8038. /**
  8039. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8040. */
  8041. colorGradingWithGreenDepth: boolean;
  8042. private _colorGradingBGR;
  8043. /**
  8044. * Gets wether the color grading texture contains BGR values.
  8045. */
  8046. /**
  8047. * Sets wether the color grading texture contains BGR values.
  8048. */
  8049. colorGradingBGR: boolean;
  8050. /** @hidden */
  8051. _exposure: number;
  8052. /**
  8053. * Gets the Exposure used in the effect.
  8054. */
  8055. /**
  8056. * Sets the Exposure used in the effect.
  8057. */
  8058. exposure: number;
  8059. private _toneMappingEnabled;
  8060. /**
  8061. * Gets wether the tone mapping effect is enabled.
  8062. */
  8063. /**
  8064. * Sets wether the tone mapping effect is enabled.
  8065. */
  8066. toneMappingEnabled: boolean;
  8067. private _toneMappingType;
  8068. /**
  8069. * Gets the type of tone mapping effect.
  8070. */
  8071. /**
  8072. * Sets the type of tone mapping effect used in BabylonJS.
  8073. */
  8074. toneMappingType: number;
  8075. protected _contrast: number;
  8076. /**
  8077. * Gets the contrast used in the effect.
  8078. */
  8079. /**
  8080. * Sets the contrast used in the effect.
  8081. */
  8082. contrast: number;
  8083. /**
  8084. * Vignette stretch size.
  8085. */
  8086. vignetteStretch: number;
  8087. /**
  8088. * Vignette centre X Offset.
  8089. */
  8090. vignetteCentreX: number;
  8091. /**
  8092. * Vignette centre Y Offset.
  8093. */
  8094. vignetteCentreY: number;
  8095. /**
  8096. * Vignette weight or intensity of the vignette effect.
  8097. */
  8098. vignetteWeight: number;
  8099. /**
  8100. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8101. * if vignetteEnabled is set to true.
  8102. */
  8103. vignetteColor: Color4;
  8104. /**
  8105. * Camera field of view used by the Vignette effect.
  8106. */
  8107. vignetteCameraFov: number;
  8108. private _vignetteBlendMode;
  8109. /**
  8110. * Gets the vignette blend mode allowing different kind of effect.
  8111. */
  8112. /**
  8113. * Sets the vignette blend mode allowing different kind of effect.
  8114. */
  8115. vignetteBlendMode: number;
  8116. private _vignetteEnabled;
  8117. /**
  8118. * Gets wether the vignette effect is enabled.
  8119. */
  8120. /**
  8121. * Sets wether the vignette effect is enabled.
  8122. */
  8123. vignetteEnabled: boolean;
  8124. private _applyByPostProcess;
  8125. /**
  8126. * Gets wether the image processing is applied through a post process or not.
  8127. */
  8128. /**
  8129. * Sets wether the image processing is applied through a post process or not.
  8130. */
  8131. applyByPostProcess: boolean;
  8132. private _isEnabled;
  8133. /**
  8134. * Gets wether the image processing is enabled or not.
  8135. */
  8136. /**
  8137. * Sets wether the image processing is enabled or not.
  8138. */
  8139. isEnabled: boolean;
  8140. /**
  8141. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8142. */
  8143. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8144. /**
  8145. * Method called each time the image processing information changes requires to recompile the effect.
  8146. */
  8147. protected _updateParameters(): void;
  8148. /**
  8149. * Gets the current class name.
  8150. * @return "ImageProcessingConfiguration"
  8151. */
  8152. getClassName(): string;
  8153. /**
  8154. * Prepare the list of uniforms associated with the Image Processing effects.
  8155. * @param uniforms The list of uniforms used in the effect
  8156. * @param defines the list of defines currently in use
  8157. */
  8158. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8159. /**
  8160. * Prepare the list of samplers associated with the Image Processing effects.
  8161. * @param samplersList The list of uniforms used in the effect
  8162. * @param defines the list of defines currently in use
  8163. */
  8164. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8165. /**
  8166. * Prepare the list of defines associated to the shader.
  8167. * @param defines the list of defines to complete
  8168. * @param forPostProcess Define if we are currently in post process mode or not
  8169. */
  8170. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8171. /**
  8172. * Returns true if all the image processing information are ready.
  8173. * @returns True if ready, otherwise, false
  8174. */
  8175. isReady(): boolean;
  8176. /**
  8177. * Binds the image processing to the shader.
  8178. * @param effect The effect to bind to
  8179. * @param aspectRatio Define the current aspect ratio of the effect
  8180. */
  8181. bind(effect: Effect, aspectRatio?: number): void;
  8182. /**
  8183. * Clones the current image processing instance.
  8184. * @return The cloned image processing
  8185. */
  8186. clone(): ImageProcessingConfiguration;
  8187. /**
  8188. * Serializes the current image processing instance to a json representation.
  8189. * @return a JSON representation
  8190. */
  8191. serialize(): any;
  8192. /**
  8193. * Parses the image processing from a json representation.
  8194. * @param source the JSON source to parse
  8195. * @return The parsed image processing
  8196. */
  8197. static Parse(source: any): ImageProcessingConfiguration;
  8198. private static _VIGNETTEMODE_MULTIPLY;
  8199. private static _VIGNETTEMODE_OPAQUE;
  8200. /**
  8201. * Used to apply the vignette as a mix with the pixel color.
  8202. */
  8203. static readonly VIGNETTEMODE_MULTIPLY: number;
  8204. /**
  8205. * Used to apply the vignette as a replacement of the pixel color.
  8206. */
  8207. static readonly VIGNETTEMODE_OPAQUE: number;
  8208. }
  8209. }
  8210. declare module BABYLON {
  8211. /** @hidden */
  8212. export var postprocessVertexShader: {
  8213. name: string;
  8214. shader: string;
  8215. };
  8216. }
  8217. declare module BABYLON {
  8218. /** Defines supported spaces */
  8219. export enum Space {
  8220. /** Local (object) space */
  8221. LOCAL = 0,
  8222. /** World space */
  8223. WORLD = 1,
  8224. /** Bone space */
  8225. BONE = 2
  8226. }
  8227. /** Defines the 3 main axes */
  8228. export class Axis {
  8229. /** X axis */
  8230. static X: Vector3;
  8231. /** Y axis */
  8232. static Y: Vector3;
  8233. /** Z axis */
  8234. static Z: Vector3;
  8235. }
  8236. }
  8237. declare module BABYLON {
  8238. /**
  8239. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8240. * This is the base of the follow, arc rotate cameras and Free camera
  8241. * @see http://doc.babylonjs.com/features/cameras
  8242. */
  8243. export class TargetCamera extends Camera {
  8244. private static _RigCamTransformMatrix;
  8245. private static _TargetTransformMatrix;
  8246. private static _TargetFocalPoint;
  8247. /**
  8248. * Define the current direction the camera is moving to
  8249. */
  8250. cameraDirection: Vector3;
  8251. /**
  8252. * Define the current rotation the camera is rotating to
  8253. */
  8254. cameraRotation: Vector2;
  8255. /**
  8256. * When set, the up vector of the camera will be updated by the rotation of the camera
  8257. */
  8258. updateUpVectorFromRotation: boolean;
  8259. private _tmpQuaternion;
  8260. /**
  8261. * Define the current rotation of the camera
  8262. */
  8263. rotation: Vector3;
  8264. /**
  8265. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8266. */
  8267. rotationQuaternion: Quaternion;
  8268. /**
  8269. * Define the current speed of the camera
  8270. */
  8271. speed: number;
  8272. /**
  8273. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8274. * around all axis.
  8275. */
  8276. noRotationConstraint: boolean;
  8277. /**
  8278. * Define the current target of the camera as an object or a position.
  8279. */
  8280. lockedTarget: any;
  8281. /** @hidden */
  8282. _currentTarget: Vector3;
  8283. /** @hidden */
  8284. _initialFocalDistance: number;
  8285. /** @hidden */
  8286. _viewMatrix: Matrix;
  8287. /** @hidden */
  8288. _camMatrix: Matrix;
  8289. /** @hidden */
  8290. _cameraTransformMatrix: Matrix;
  8291. /** @hidden */
  8292. _cameraRotationMatrix: Matrix;
  8293. /** @hidden */
  8294. _referencePoint: Vector3;
  8295. /** @hidden */
  8296. _transformedReferencePoint: Vector3;
  8297. protected _globalCurrentTarget: Vector3;
  8298. protected _globalCurrentUpVector: Vector3;
  8299. /** @hidden */
  8300. _reset: () => void;
  8301. private _defaultUp;
  8302. /**
  8303. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8304. * This is the base of the follow, arc rotate cameras and Free camera
  8305. * @see http://doc.babylonjs.com/features/cameras
  8306. * @param name Defines the name of the camera in the scene
  8307. * @param position Defines the start position of the camera in the scene
  8308. * @param scene Defines the scene the camera belongs to
  8309. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8310. */
  8311. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8312. /**
  8313. * Gets the position in front of the camera at a given distance.
  8314. * @param distance The distance from the camera we want the position to be
  8315. * @returns the position
  8316. */
  8317. getFrontPosition(distance: number): Vector3;
  8318. /** @hidden */
  8319. _getLockedTargetPosition(): Nullable<Vector3>;
  8320. private _storedPosition;
  8321. private _storedRotation;
  8322. private _storedRotationQuaternion;
  8323. /**
  8324. * Store current camera state of the camera (fov, position, rotation, etc..)
  8325. * @returns the camera
  8326. */
  8327. storeState(): Camera;
  8328. /**
  8329. * Restored camera state. You must call storeState() first
  8330. * @returns whether it was successful or not
  8331. * @hidden
  8332. */
  8333. _restoreStateValues(): boolean;
  8334. /** @hidden */
  8335. _initCache(): void;
  8336. /** @hidden */
  8337. _updateCache(ignoreParentClass?: boolean): void;
  8338. /** @hidden */
  8339. _isSynchronizedViewMatrix(): boolean;
  8340. /** @hidden */
  8341. _computeLocalCameraSpeed(): number;
  8342. /**
  8343. * Defines the target the camera should look at.
  8344. * @param target Defines the new target as a Vector or a mesh
  8345. */
  8346. setTarget(target: Vector3): void;
  8347. /**
  8348. * Return the current target position of the camera. This value is expressed in local space.
  8349. * @returns the target position
  8350. */
  8351. getTarget(): Vector3;
  8352. /** @hidden */
  8353. _decideIfNeedsToMove(): boolean;
  8354. /** @hidden */
  8355. _updatePosition(): void;
  8356. /** @hidden */
  8357. _checkInputs(): void;
  8358. protected _updateCameraRotationMatrix(): void;
  8359. /**
  8360. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8361. * @returns the current camera
  8362. */
  8363. private _rotateUpVectorWithCameraRotationMatrix;
  8364. private _cachedRotationZ;
  8365. private _cachedQuaternionRotationZ;
  8366. /** @hidden */
  8367. _getViewMatrix(): Matrix;
  8368. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8369. /**
  8370. * @hidden
  8371. */
  8372. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8373. /**
  8374. * @hidden
  8375. */
  8376. _updateRigCameras(): void;
  8377. private _getRigCamPositionAndTarget;
  8378. /**
  8379. * Gets the current object class name.
  8380. * @return the class name
  8381. */
  8382. getClassName(): string;
  8383. }
  8384. }
  8385. declare module BABYLON {
  8386. /**
  8387. * Gather the list of keyboard event types as constants.
  8388. */
  8389. export class KeyboardEventTypes {
  8390. /**
  8391. * The keydown event is fired when a key becomes active (pressed).
  8392. */
  8393. static readonly KEYDOWN: number;
  8394. /**
  8395. * The keyup event is fired when a key has been released.
  8396. */
  8397. static readonly KEYUP: number;
  8398. }
  8399. /**
  8400. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8401. */
  8402. export class KeyboardInfo {
  8403. /**
  8404. * Defines the type of event (KeyboardEventTypes)
  8405. */
  8406. type: number;
  8407. /**
  8408. * Defines the related dom event
  8409. */
  8410. event: KeyboardEvent;
  8411. /**
  8412. * Instantiates a new keyboard info.
  8413. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8414. * @param type Defines the type of event (KeyboardEventTypes)
  8415. * @param event Defines the related dom event
  8416. */
  8417. constructor(
  8418. /**
  8419. * Defines the type of event (KeyboardEventTypes)
  8420. */
  8421. type: number,
  8422. /**
  8423. * Defines the related dom event
  8424. */
  8425. event: KeyboardEvent);
  8426. }
  8427. /**
  8428. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8429. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8430. */
  8431. export class KeyboardInfoPre extends KeyboardInfo {
  8432. /**
  8433. * Defines the type of event (KeyboardEventTypes)
  8434. */
  8435. type: number;
  8436. /**
  8437. * Defines the related dom event
  8438. */
  8439. event: KeyboardEvent;
  8440. /**
  8441. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8442. */
  8443. skipOnPointerObservable: boolean;
  8444. /**
  8445. * Instantiates a new keyboard pre info.
  8446. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8447. * @param type Defines the type of event (KeyboardEventTypes)
  8448. * @param event Defines the related dom event
  8449. */
  8450. constructor(
  8451. /**
  8452. * Defines the type of event (KeyboardEventTypes)
  8453. */
  8454. type: number,
  8455. /**
  8456. * Defines the related dom event
  8457. */
  8458. event: KeyboardEvent);
  8459. }
  8460. }
  8461. declare module BABYLON {
  8462. /**
  8463. * Manage the keyboard inputs to control the movement of a free camera.
  8464. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8465. */
  8466. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8467. /**
  8468. * Defines the camera the input is attached to.
  8469. */
  8470. camera: FreeCamera;
  8471. /**
  8472. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8473. */
  8474. keysUp: number[];
  8475. /**
  8476. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8477. */
  8478. keysDown: number[];
  8479. /**
  8480. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8481. */
  8482. keysLeft: number[];
  8483. /**
  8484. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8485. */
  8486. keysRight: number[];
  8487. private _keys;
  8488. private _onCanvasBlurObserver;
  8489. private _onKeyboardObserver;
  8490. private _engine;
  8491. private _scene;
  8492. /**
  8493. * Attach the input controls to a specific dom element to get the input from.
  8494. * @param element Defines the element the controls should be listened from
  8495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8496. */
  8497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8498. /**
  8499. * Detach the current controls from the specified dom element.
  8500. * @param element Defines the element to stop listening the inputs from
  8501. */
  8502. detachControl(element: Nullable<HTMLElement>): void;
  8503. /**
  8504. * Update the current camera state depending on the inputs that have been used this frame.
  8505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8506. */
  8507. checkInputs(): void;
  8508. /**
  8509. * Gets the class name of the current intput.
  8510. * @returns the class name
  8511. */
  8512. getClassName(): string;
  8513. /** @hidden */
  8514. _onLostFocus(): void;
  8515. /**
  8516. * Get the friendly name associated with the input class.
  8517. * @returns the input friendly name
  8518. */
  8519. getSimpleName(): string;
  8520. }
  8521. }
  8522. declare module BABYLON {
  8523. /**
  8524. * Interface describing all the common properties and methods a shadow light needs to implement.
  8525. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8526. * as well as binding the different shadow properties to the effects.
  8527. */
  8528. export interface IShadowLight extends Light {
  8529. /**
  8530. * The light id in the scene (used in scene.findLighById for instance)
  8531. */
  8532. id: string;
  8533. /**
  8534. * The position the shdow will be casted from.
  8535. */
  8536. position: Vector3;
  8537. /**
  8538. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8539. */
  8540. direction: Vector3;
  8541. /**
  8542. * The transformed position. Position of the light in world space taking parenting in account.
  8543. */
  8544. transformedPosition: Vector3;
  8545. /**
  8546. * The transformed direction. Direction of the light in world space taking parenting in account.
  8547. */
  8548. transformedDirection: Vector3;
  8549. /**
  8550. * The friendly name of the light in the scene.
  8551. */
  8552. name: string;
  8553. /**
  8554. * Defines the shadow projection clipping minimum z value.
  8555. */
  8556. shadowMinZ: number;
  8557. /**
  8558. * Defines the shadow projection clipping maximum z value.
  8559. */
  8560. shadowMaxZ: number;
  8561. /**
  8562. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8563. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8564. */
  8565. computeTransformedInformation(): boolean;
  8566. /**
  8567. * Gets the scene the light belongs to.
  8568. * @returns The scene
  8569. */
  8570. getScene(): Scene;
  8571. /**
  8572. * Callback defining a custom Projection Matrix Builder.
  8573. * This can be used to override the default projection matrix computation.
  8574. */
  8575. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8576. /**
  8577. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8578. * @param matrix The materix to updated with the projection information
  8579. * @param viewMatrix The transform matrix of the light
  8580. * @param renderList The list of mesh to render in the map
  8581. * @returns The current light
  8582. */
  8583. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8584. /**
  8585. * Gets the current depth scale used in ESM.
  8586. * @returns The scale
  8587. */
  8588. getDepthScale(): number;
  8589. /**
  8590. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8591. * @returns true if a cube texture needs to be use
  8592. */
  8593. needCube(): boolean;
  8594. /**
  8595. * Detects if the projection matrix requires to be recomputed this frame.
  8596. * @returns true if it requires to be recomputed otherwise, false.
  8597. */
  8598. needProjectionMatrixCompute(): boolean;
  8599. /**
  8600. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8601. */
  8602. forceProjectionMatrixCompute(): void;
  8603. /**
  8604. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8605. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8606. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8607. */
  8608. getShadowDirection(faceIndex?: number): Vector3;
  8609. /**
  8610. * Gets the minZ used for shadow according to both the scene and the light.
  8611. * @param activeCamera The camera we are returning the min for
  8612. * @returns the depth min z
  8613. */
  8614. getDepthMinZ(activeCamera: Camera): number;
  8615. /**
  8616. * Gets the maxZ used for shadow according to both the scene and the light.
  8617. * @param activeCamera The camera we are returning the max for
  8618. * @returns the depth max z
  8619. */
  8620. getDepthMaxZ(activeCamera: Camera): number;
  8621. }
  8622. /**
  8623. * Base implementation IShadowLight
  8624. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8625. */
  8626. export abstract class ShadowLight extends Light implements IShadowLight {
  8627. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8628. protected _position: Vector3;
  8629. protected _setPosition(value: Vector3): void;
  8630. /**
  8631. * Sets the position the shadow will be casted from. Also use as the light position for both
  8632. * point and spot lights.
  8633. */
  8634. /**
  8635. * Sets the position the shadow will be casted from. Also use as the light position for both
  8636. * point and spot lights.
  8637. */
  8638. position: Vector3;
  8639. protected _direction: Vector3;
  8640. protected _setDirection(value: Vector3): void;
  8641. /**
  8642. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8643. * Also use as the light direction on spot and directional lights.
  8644. */
  8645. /**
  8646. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8647. * Also use as the light direction on spot and directional lights.
  8648. */
  8649. direction: Vector3;
  8650. private _shadowMinZ;
  8651. /**
  8652. * Gets the shadow projection clipping minimum z value.
  8653. */
  8654. /**
  8655. * Sets the shadow projection clipping minimum z value.
  8656. */
  8657. shadowMinZ: number;
  8658. private _shadowMaxZ;
  8659. /**
  8660. * Sets the shadow projection clipping maximum z value.
  8661. */
  8662. /**
  8663. * Gets the shadow projection clipping maximum z value.
  8664. */
  8665. shadowMaxZ: number;
  8666. /**
  8667. * Callback defining a custom Projection Matrix Builder.
  8668. * This can be used to override the default projection matrix computation.
  8669. */
  8670. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8671. /**
  8672. * The transformed position. Position of the light in world space taking parenting in account.
  8673. */
  8674. transformedPosition: Vector3;
  8675. /**
  8676. * The transformed direction. Direction of the light in world space taking parenting in account.
  8677. */
  8678. transformedDirection: Vector3;
  8679. private _needProjectionMatrixCompute;
  8680. /**
  8681. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8682. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8683. */
  8684. computeTransformedInformation(): boolean;
  8685. /**
  8686. * Return the depth scale used for the shadow map.
  8687. * @returns the depth scale.
  8688. */
  8689. getDepthScale(): number;
  8690. /**
  8691. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8692. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8693. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8694. */
  8695. getShadowDirection(faceIndex?: number): Vector3;
  8696. /**
  8697. * Returns the ShadowLight absolute position in the World.
  8698. * @returns the position vector in world space
  8699. */
  8700. getAbsolutePosition(): Vector3;
  8701. /**
  8702. * Sets the ShadowLight direction toward the passed target.
  8703. * @param target The point to target in local space
  8704. * @returns the updated ShadowLight direction
  8705. */
  8706. setDirectionToTarget(target: Vector3): Vector3;
  8707. /**
  8708. * Returns the light rotation in euler definition.
  8709. * @returns the x y z rotation in local space.
  8710. */
  8711. getRotation(): Vector3;
  8712. /**
  8713. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8714. * @returns true if a cube texture needs to be use
  8715. */
  8716. needCube(): boolean;
  8717. /**
  8718. * Detects if the projection matrix requires to be recomputed this frame.
  8719. * @returns true if it requires to be recomputed otherwise, false.
  8720. */
  8721. needProjectionMatrixCompute(): boolean;
  8722. /**
  8723. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8724. */
  8725. forceProjectionMatrixCompute(): void;
  8726. /** @hidden */
  8727. _initCache(): void;
  8728. /** @hidden */
  8729. _isSynchronized(): boolean;
  8730. /**
  8731. * Computes the world matrix of the node
  8732. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8733. * @returns the world matrix
  8734. */
  8735. computeWorldMatrix(force?: boolean): Matrix;
  8736. /**
  8737. * Gets the minZ used for shadow according to both the scene and the light.
  8738. * @param activeCamera The camera we are returning the min for
  8739. * @returns the depth min z
  8740. */
  8741. getDepthMinZ(activeCamera: Camera): number;
  8742. /**
  8743. * Gets the maxZ used for shadow according to both the scene and the light.
  8744. * @param activeCamera The camera we are returning the max for
  8745. * @returns the depth max z
  8746. */
  8747. getDepthMaxZ(activeCamera: Camera): number;
  8748. /**
  8749. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8750. * @param matrix The materix to updated with the projection information
  8751. * @param viewMatrix The transform matrix of the light
  8752. * @param renderList The list of mesh to render in the map
  8753. * @returns The current light
  8754. */
  8755. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8756. }
  8757. }
  8758. declare module BABYLON {
  8759. /**
  8760. * "Static Class" containing the most commonly used helper while dealing with material for
  8761. * rendering purpose.
  8762. *
  8763. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8764. *
  8765. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8766. */
  8767. export class MaterialHelper {
  8768. /**
  8769. * Bind the current view position to an effect.
  8770. * @param effect The effect to be bound
  8771. * @param scene The scene the eyes position is used from
  8772. */
  8773. static BindEyePosition(effect: Effect, scene: Scene): void;
  8774. /**
  8775. * Helps preparing the defines values about the UVs in used in the effect.
  8776. * UVs are shared as much as we can accross channels in the shaders.
  8777. * @param texture The texture we are preparing the UVs for
  8778. * @param defines The defines to update
  8779. * @param key The channel key "diffuse", "specular"... used in the shader
  8780. */
  8781. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8782. /**
  8783. * Binds a texture matrix value to its corrsponding uniform
  8784. * @param texture The texture to bind the matrix for
  8785. * @param uniformBuffer The uniform buffer receivin the data
  8786. * @param key The channel key "diffuse", "specular"... used in the shader
  8787. */
  8788. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8789. /**
  8790. * Gets the current status of the fog (should it be enabled?)
  8791. * @param mesh defines the mesh to evaluate for fog support
  8792. * @param scene defines the hosting scene
  8793. * @returns true if fog must be enabled
  8794. */
  8795. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8796. /**
  8797. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8798. * @param mesh defines the current mesh
  8799. * @param scene defines the current scene
  8800. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8801. * @param pointsCloud defines if point cloud rendering has to be turned on
  8802. * @param fogEnabled defines if fog has to be turned on
  8803. * @param alphaTest defines if alpha testing has to be turned on
  8804. * @param defines defines the current list of defines
  8805. */
  8806. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8807. /**
  8808. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8809. * @param scene defines the current scene
  8810. * @param engine defines the current engine
  8811. * @param defines specifies the list of active defines
  8812. * @param useInstances defines if instances have to be turned on
  8813. * @param useClipPlane defines if clip plane have to be turned on
  8814. */
  8815. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8816. /**
  8817. * Prepares the defines for bones
  8818. * @param mesh The mesh containing the geometry data we will draw
  8819. * @param defines The defines to update
  8820. */
  8821. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8822. /**
  8823. * Prepares the defines for morph targets
  8824. * @param mesh The mesh containing the geometry data we will draw
  8825. * @param defines The defines to update
  8826. */
  8827. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8828. /**
  8829. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8830. * @param mesh The mesh containing the geometry data we will draw
  8831. * @param defines The defines to update
  8832. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8833. * @param useBones Precise whether bones should be used or not (override mesh info)
  8834. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8835. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8836. * @returns false if defines are considered not dirty and have not been checked
  8837. */
  8838. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8839. /**
  8840. * Prepares the defines related to multiview
  8841. * @param scene The scene we are intending to draw
  8842. * @param defines The defines to update
  8843. */
  8844. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8845. /**
  8846. * Prepares the defines related to the light information passed in parameter
  8847. * @param scene The scene we are intending to draw
  8848. * @param mesh The mesh the effect is compiling for
  8849. * @param light The light the effect is compiling for
  8850. * @param lightIndex The index of the light
  8851. * @param defines The defines to update
  8852. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8853. * @param state Defines the current state regarding what is needed (normals, etc...)
  8854. */
  8855. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8856. needNormals: boolean;
  8857. needRebuild: boolean;
  8858. shadowEnabled: boolean;
  8859. specularEnabled: boolean;
  8860. lightmapMode: boolean;
  8861. }): void;
  8862. /**
  8863. * Prepares the defines related to the light information passed in parameter
  8864. * @param scene The scene we are intending to draw
  8865. * @param mesh The mesh the effect is compiling for
  8866. * @param defines The defines to update
  8867. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8868. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8869. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8870. * @returns true if normals will be required for the rest of the effect
  8871. */
  8872. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8873. /**
  8874. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8875. * @param lightIndex defines the light index
  8876. * @param uniformsList The uniform list
  8877. * @param samplersList The sampler list
  8878. * @param projectedLightTexture defines if projected texture must be used
  8879. * @param uniformBuffersList defines an optional list of uniform buffers
  8880. */
  8881. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8882. /**
  8883. * Prepares the uniforms and samplers list to be used in the effect
  8884. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8885. * @param samplersList The sampler list
  8886. * @param defines The defines helping in the list generation
  8887. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8888. */
  8889. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8890. /**
  8891. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8892. * @param defines The defines to update while falling back
  8893. * @param fallbacks The authorized effect fallbacks
  8894. * @param maxSimultaneousLights The maximum number of lights allowed
  8895. * @param rank the current rank of the Effect
  8896. * @returns The newly affected rank
  8897. */
  8898. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8899. private static _TmpMorphInfluencers;
  8900. /**
  8901. * Prepares the list of attributes required for morph targets according to the effect defines.
  8902. * @param attribs The current list of supported attribs
  8903. * @param mesh The mesh to prepare the morph targets attributes for
  8904. * @param influencers The number of influencers
  8905. */
  8906. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8907. /**
  8908. * Prepares the list of attributes required for morph targets according to the effect defines.
  8909. * @param attribs The current list of supported attribs
  8910. * @param mesh The mesh to prepare the morph targets attributes for
  8911. * @param defines The current Defines of the effect
  8912. */
  8913. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8914. /**
  8915. * Prepares the list of attributes required for bones according to the effect defines.
  8916. * @param attribs The current list of supported attribs
  8917. * @param mesh The mesh to prepare the bones attributes for
  8918. * @param defines The current Defines of the effect
  8919. * @param fallbacks The current efffect fallback strategy
  8920. */
  8921. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8922. /**
  8923. * Check and prepare the list of attributes required for instances according to the effect defines.
  8924. * @param attribs The current list of supported attribs
  8925. * @param defines The current MaterialDefines of the effect
  8926. */
  8927. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8928. /**
  8929. * Add the list of attributes required for instances to the attribs array.
  8930. * @param attribs The current list of supported attribs
  8931. */
  8932. static PushAttributesForInstances(attribs: string[]): void;
  8933. /**
  8934. * Binds the light shadow information to the effect for the given mesh.
  8935. * @param light The light containing the generator
  8936. * @param scene The scene the lights belongs to
  8937. * @param mesh The mesh we are binding the information to render
  8938. * @param lightIndex The light index in the effect used to render the mesh
  8939. * @param effect The effect we are binding the data to
  8940. */
  8941. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8942. /**
  8943. * Binds the light information to the effect.
  8944. * @param light The light containing the generator
  8945. * @param effect The effect we are binding the data to
  8946. * @param lightIndex The light index in the effect used to render
  8947. */
  8948. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8949. /**
  8950. * Binds the lights information from the scene to the effect for the given mesh.
  8951. * @param light Light to bind
  8952. * @param lightIndex Light index
  8953. * @param scene The scene where the light belongs to
  8954. * @param mesh The mesh we are binding the information to render
  8955. * @param effect The effect we are binding the data to
  8956. * @param useSpecular Defines if specular is supported
  8957. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8958. */
  8959. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  8960. /**
  8961. * Binds the lights information from the scene to the effect for the given mesh.
  8962. * @param scene The scene the lights belongs to
  8963. * @param mesh The mesh we are binding the information to render
  8964. * @param effect The effect we are binding the data to
  8965. * @param defines The generated defines for the effect
  8966. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8967. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8968. */
  8969. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  8970. private static _tempFogColor;
  8971. /**
  8972. * Binds the fog information from the scene to the effect for the given mesh.
  8973. * @param scene The scene the lights belongs to
  8974. * @param mesh The mesh we are binding the information to render
  8975. * @param effect The effect we are binding the data to
  8976. * @param linearSpace Defines if the fog effect is applied in linear space
  8977. */
  8978. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8979. /**
  8980. * Binds the bones information from the mesh to the effect.
  8981. * @param mesh The mesh we are binding the information to render
  8982. * @param effect The effect we are binding the data to
  8983. */
  8984. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8985. /**
  8986. * Binds the morph targets information from the mesh to the effect.
  8987. * @param abstractMesh The mesh we are binding the information to render
  8988. * @param effect The effect we are binding the data to
  8989. */
  8990. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8991. /**
  8992. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8993. * @param defines The generated defines used in the effect
  8994. * @param effect The effect we are binding the data to
  8995. * @param scene The scene we are willing to render with logarithmic scale for
  8996. */
  8997. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8998. /**
  8999. * Binds the clip plane information from the scene to the effect.
  9000. * @param scene The scene the clip plane information are extracted from
  9001. * @param effect The effect we are binding the data to
  9002. */
  9003. static BindClipPlane(effect: Effect, scene: Scene): void;
  9004. }
  9005. }
  9006. declare module BABYLON {
  9007. /** @hidden */
  9008. export var packingFunctions: {
  9009. name: string;
  9010. shader: string;
  9011. };
  9012. }
  9013. declare module BABYLON {
  9014. /** @hidden */
  9015. export var shadowMapPixelShader: {
  9016. name: string;
  9017. shader: string;
  9018. };
  9019. }
  9020. declare module BABYLON {
  9021. /** @hidden */
  9022. export var bonesDeclaration: {
  9023. name: string;
  9024. shader: string;
  9025. };
  9026. }
  9027. declare module BABYLON {
  9028. /** @hidden */
  9029. export var morphTargetsVertexGlobalDeclaration: {
  9030. name: string;
  9031. shader: string;
  9032. };
  9033. }
  9034. declare module BABYLON {
  9035. /** @hidden */
  9036. export var morphTargetsVertexDeclaration: {
  9037. name: string;
  9038. shader: string;
  9039. };
  9040. }
  9041. declare module BABYLON {
  9042. /** @hidden */
  9043. export var instancesDeclaration: {
  9044. name: string;
  9045. shader: string;
  9046. };
  9047. }
  9048. declare module BABYLON {
  9049. /** @hidden */
  9050. export var helperFunctions: {
  9051. name: string;
  9052. shader: string;
  9053. };
  9054. }
  9055. declare module BABYLON {
  9056. /** @hidden */
  9057. export var morphTargetsVertex: {
  9058. name: string;
  9059. shader: string;
  9060. };
  9061. }
  9062. declare module BABYLON {
  9063. /** @hidden */
  9064. export var instancesVertex: {
  9065. name: string;
  9066. shader: string;
  9067. };
  9068. }
  9069. declare module BABYLON {
  9070. /** @hidden */
  9071. export var bonesVertex: {
  9072. name: string;
  9073. shader: string;
  9074. };
  9075. }
  9076. declare module BABYLON {
  9077. /** @hidden */
  9078. export var shadowMapVertexShader: {
  9079. name: string;
  9080. shader: string;
  9081. };
  9082. }
  9083. declare module BABYLON {
  9084. /** @hidden */
  9085. export var depthBoxBlurPixelShader: {
  9086. name: string;
  9087. shader: string;
  9088. };
  9089. }
  9090. declare module BABYLON {
  9091. /**
  9092. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9093. */
  9094. export interface ICustomShaderOptions {
  9095. /**
  9096. * Gets or sets the custom shader name to use
  9097. */
  9098. shaderName: string;
  9099. /**
  9100. * The list of attribute names used in the shader
  9101. */
  9102. attributes?: string[];
  9103. /**
  9104. * The list of unifrom names used in the shader
  9105. */
  9106. uniforms?: string[];
  9107. /**
  9108. * The list of sampler names used in the shader
  9109. */
  9110. samplers?: string[];
  9111. /**
  9112. * The list of defines used in the shader
  9113. */
  9114. defines?: string[];
  9115. }
  9116. /**
  9117. * Interface to implement to create a shadow generator compatible with BJS.
  9118. */
  9119. export interface IShadowGenerator {
  9120. /**
  9121. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9122. * @returns The render target texture if present otherwise, null
  9123. */
  9124. getShadowMap(): Nullable<RenderTargetTexture>;
  9125. /**
  9126. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9127. * @returns The render target texture if the shadow map is present otherwise, null
  9128. */
  9129. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9130. /**
  9131. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9132. * @param subMesh The submesh we want to render in the shadow map
  9133. * @param useInstances Defines wether will draw in the map using instances
  9134. * @returns true if ready otherwise, false
  9135. */
  9136. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9137. /**
  9138. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9139. * @param defines Defines of the material we want to update
  9140. * @param lightIndex Index of the light in the enabled light list of the material
  9141. */
  9142. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9143. /**
  9144. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9145. * defined in the generator but impacting the effect).
  9146. * It implies the unifroms available on the materials are the standard BJS ones.
  9147. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9148. * @param effect The effect we are binfing the information for
  9149. */
  9150. bindShadowLight(lightIndex: string, effect: Effect): void;
  9151. /**
  9152. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9153. * (eq to shadow prjection matrix * light transform matrix)
  9154. * @returns The transform matrix used to create the shadow map
  9155. */
  9156. getTransformMatrix(): Matrix;
  9157. /**
  9158. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9159. * Cube and 2D textures for instance.
  9160. */
  9161. recreateShadowMap(): void;
  9162. /**
  9163. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9164. * @param onCompiled Callback triggered at the and of the effects compilation
  9165. * @param options Sets of optional options forcing the compilation with different modes
  9166. */
  9167. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9168. useInstances: boolean;
  9169. }>): void;
  9170. /**
  9171. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9172. * @param options Sets of optional options forcing the compilation with different modes
  9173. * @returns A promise that resolves when the compilation completes
  9174. */
  9175. forceCompilationAsync(options?: Partial<{
  9176. useInstances: boolean;
  9177. }>): Promise<void>;
  9178. /**
  9179. * Serializes the shadow generator setup to a json object.
  9180. * @returns The serialized JSON object
  9181. */
  9182. serialize(): any;
  9183. /**
  9184. * Disposes the Shadow map and related Textures and effects.
  9185. */
  9186. dispose(): void;
  9187. }
  9188. /**
  9189. * Default implementation IShadowGenerator.
  9190. * This is the main object responsible of generating shadows in the framework.
  9191. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9192. */
  9193. export class ShadowGenerator implements IShadowGenerator {
  9194. /**
  9195. * Shadow generator mode None: no filtering applied.
  9196. */
  9197. static readonly FILTER_NONE: number;
  9198. /**
  9199. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9200. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9201. */
  9202. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9203. /**
  9204. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9205. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9206. */
  9207. static readonly FILTER_POISSONSAMPLING: number;
  9208. /**
  9209. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9210. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9211. */
  9212. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9213. /**
  9214. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9215. * edge artifacts on steep falloff.
  9216. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9217. */
  9218. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9219. /**
  9220. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9221. * edge artifacts on steep falloff.
  9222. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9223. */
  9224. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9225. /**
  9226. * Shadow generator mode PCF: Percentage Closer Filtering
  9227. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9228. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9229. */
  9230. static readonly FILTER_PCF: number;
  9231. /**
  9232. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9233. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9234. * Contact Hardening
  9235. */
  9236. static readonly FILTER_PCSS: number;
  9237. /**
  9238. * Reserved for PCF and PCSS
  9239. * Highest Quality.
  9240. *
  9241. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9242. *
  9243. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9244. */
  9245. static readonly QUALITY_HIGH: number;
  9246. /**
  9247. * Reserved for PCF and PCSS
  9248. * Good tradeoff for quality/perf cross devices
  9249. *
  9250. * Execute PCF on a 3*3 kernel.
  9251. *
  9252. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9253. */
  9254. static readonly QUALITY_MEDIUM: number;
  9255. /**
  9256. * Reserved for PCF and PCSS
  9257. * The lowest quality but the fastest.
  9258. *
  9259. * Execute PCF on a 1*1 kernel.
  9260. *
  9261. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9262. */
  9263. static readonly QUALITY_LOW: number;
  9264. /** Gets or sets the custom shader name to use */
  9265. customShaderOptions: ICustomShaderOptions;
  9266. /**
  9267. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9268. */
  9269. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9270. /**
  9271. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9272. */
  9273. onAfterShadowMapRenderObservable: Observable<Effect>;
  9274. /**
  9275. * Observable triggered before a mesh is rendered in the shadow map.
  9276. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9277. */
  9278. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9279. /**
  9280. * Observable triggered after a mesh is rendered in the shadow map.
  9281. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9282. */
  9283. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9284. private _bias;
  9285. /**
  9286. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9287. */
  9288. /**
  9289. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9290. */
  9291. bias: number;
  9292. private _normalBias;
  9293. /**
  9294. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9295. */
  9296. /**
  9297. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9298. */
  9299. normalBias: number;
  9300. private _blurBoxOffset;
  9301. /**
  9302. * Gets the blur box offset: offset applied during the blur pass.
  9303. * Only useful if useKernelBlur = false
  9304. */
  9305. /**
  9306. * Sets the blur box offset: offset applied during the blur pass.
  9307. * Only useful if useKernelBlur = false
  9308. */
  9309. blurBoxOffset: number;
  9310. private _blurScale;
  9311. /**
  9312. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9313. * 2 means half of the size.
  9314. */
  9315. /**
  9316. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9317. * 2 means half of the size.
  9318. */
  9319. blurScale: number;
  9320. private _blurKernel;
  9321. /**
  9322. * Gets the blur kernel: kernel size of the blur pass.
  9323. * Only useful if useKernelBlur = true
  9324. */
  9325. /**
  9326. * Sets the blur kernel: kernel size of the blur pass.
  9327. * Only useful if useKernelBlur = true
  9328. */
  9329. blurKernel: number;
  9330. private _useKernelBlur;
  9331. /**
  9332. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9333. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9334. */
  9335. /**
  9336. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9337. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9338. */
  9339. useKernelBlur: boolean;
  9340. private _depthScale;
  9341. /**
  9342. * Gets the depth scale used in ESM mode.
  9343. */
  9344. /**
  9345. * Sets the depth scale used in ESM mode.
  9346. * This can override the scale stored on the light.
  9347. */
  9348. depthScale: number;
  9349. private _filter;
  9350. /**
  9351. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9352. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9353. */
  9354. /**
  9355. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9356. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9357. */
  9358. filter: number;
  9359. /**
  9360. * Gets if the current filter is set to Poisson Sampling.
  9361. */
  9362. /**
  9363. * Sets the current filter to Poisson Sampling.
  9364. */
  9365. usePoissonSampling: boolean;
  9366. /**
  9367. * Gets if the current filter is set to ESM.
  9368. */
  9369. /**
  9370. * Sets the current filter is to ESM.
  9371. */
  9372. useExponentialShadowMap: boolean;
  9373. /**
  9374. * Gets if the current filter is set to filtered ESM.
  9375. */
  9376. /**
  9377. * Gets if the current filter is set to filtered ESM.
  9378. */
  9379. useBlurExponentialShadowMap: boolean;
  9380. /**
  9381. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9382. * exponential to prevent steep falloff artifacts).
  9383. */
  9384. /**
  9385. * Sets the current filter to "close ESM" (using the inverse of the
  9386. * exponential to prevent steep falloff artifacts).
  9387. */
  9388. useCloseExponentialShadowMap: boolean;
  9389. /**
  9390. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9391. * exponential to prevent steep falloff artifacts).
  9392. */
  9393. /**
  9394. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9395. * exponential to prevent steep falloff artifacts).
  9396. */
  9397. useBlurCloseExponentialShadowMap: boolean;
  9398. /**
  9399. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9400. */
  9401. /**
  9402. * Sets the current filter to "PCF" (percentage closer filtering).
  9403. */
  9404. usePercentageCloserFiltering: boolean;
  9405. private _filteringQuality;
  9406. /**
  9407. * Gets the PCF or PCSS Quality.
  9408. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9409. */
  9410. /**
  9411. * Sets the PCF or PCSS Quality.
  9412. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9413. */
  9414. filteringQuality: number;
  9415. /**
  9416. * Gets if the current filter is set to "PCSS" (contact hardening).
  9417. */
  9418. /**
  9419. * Sets the current filter to "PCSS" (contact hardening).
  9420. */
  9421. useContactHardeningShadow: boolean;
  9422. private _contactHardeningLightSizeUVRatio;
  9423. /**
  9424. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9425. * Using a ratio helps keeping shape stability independently of the map size.
  9426. *
  9427. * It does not account for the light projection as it was having too much
  9428. * instability during the light setup or during light position changes.
  9429. *
  9430. * Only valid if useContactHardeningShadow is true.
  9431. */
  9432. /**
  9433. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9434. * Using a ratio helps keeping shape stability independently of the map size.
  9435. *
  9436. * It does not account for the light projection as it was having too much
  9437. * instability during the light setup or during light position changes.
  9438. *
  9439. * Only valid if useContactHardeningShadow is true.
  9440. */
  9441. contactHardeningLightSizeUVRatio: number;
  9442. private _darkness;
  9443. /** Gets or sets the actual darkness of a shadow */
  9444. darkness: number;
  9445. /**
  9446. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9447. * 0 means strongest and 1 would means no shadow.
  9448. * @returns the darkness.
  9449. */
  9450. getDarkness(): number;
  9451. /**
  9452. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9453. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9454. * @returns the shadow generator allowing fluent coding.
  9455. */
  9456. setDarkness(darkness: number): ShadowGenerator;
  9457. private _transparencyShadow;
  9458. /** Gets or sets the ability to have transparent shadow */
  9459. transparencyShadow: boolean;
  9460. /**
  9461. * Sets the ability to have transparent shadow (boolean).
  9462. * @param transparent True if transparent else False
  9463. * @returns the shadow generator allowing fluent coding
  9464. */
  9465. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9466. private _shadowMap;
  9467. private _shadowMap2;
  9468. /**
  9469. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9470. * @returns The render target texture if present otherwise, null
  9471. */
  9472. getShadowMap(): Nullable<RenderTargetTexture>;
  9473. /**
  9474. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9475. * @returns The render target texture if the shadow map is present otherwise, null
  9476. */
  9477. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9478. /**
  9479. * Gets the class name of that object
  9480. * @returns "ShadowGenerator"
  9481. */
  9482. getClassName(): string;
  9483. /**
  9484. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9485. * @param mesh Mesh to add
  9486. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9487. * @returns the Shadow Generator itself
  9488. */
  9489. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9490. /**
  9491. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9492. * @param mesh Mesh to remove
  9493. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9494. * @returns the Shadow Generator itself
  9495. */
  9496. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9497. /**
  9498. * Controls the extent to which the shadows fade out at the edge of the frustum
  9499. * Used only by directionals and spots
  9500. */
  9501. frustumEdgeFalloff: number;
  9502. private _light;
  9503. /**
  9504. * Returns the associated light object.
  9505. * @returns the light generating the shadow
  9506. */
  9507. getLight(): IShadowLight;
  9508. /**
  9509. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9510. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9511. * It might on the other hand introduce peter panning.
  9512. */
  9513. forceBackFacesOnly: boolean;
  9514. private _scene;
  9515. private _lightDirection;
  9516. private _effect;
  9517. private _viewMatrix;
  9518. private _projectionMatrix;
  9519. private _transformMatrix;
  9520. private _cachedPosition;
  9521. private _cachedDirection;
  9522. private _cachedDefines;
  9523. private _currentRenderID;
  9524. private _boxBlurPostprocess;
  9525. private _kernelBlurXPostprocess;
  9526. private _kernelBlurYPostprocess;
  9527. private _blurPostProcesses;
  9528. private _mapSize;
  9529. private _currentFaceIndex;
  9530. private _currentFaceIndexCache;
  9531. private _textureType;
  9532. private _defaultTextureMatrix;
  9533. /** @hidden */
  9534. static _SceneComponentInitialization: (scene: Scene) => void;
  9535. /**
  9536. * Creates a ShadowGenerator object.
  9537. * A ShadowGenerator is the required tool to use the shadows.
  9538. * Each light casting shadows needs to use its own ShadowGenerator.
  9539. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9540. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9541. * @param light The light object generating the shadows.
  9542. * @param usefulFloatFirst 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.
  9543. */
  9544. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9545. private _initializeGenerator;
  9546. private _initializeShadowMap;
  9547. private _initializeBlurRTTAndPostProcesses;
  9548. private _renderForShadowMap;
  9549. private _renderSubMeshForShadowMap;
  9550. private _applyFilterValues;
  9551. /**
  9552. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9553. * @param onCompiled Callback triggered at the and of the effects compilation
  9554. * @param options Sets of optional options forcing the compilation with different modes
  9555. */
  9556. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9557. useInstances: boolean;
  9558. }>): void;
  9559. /**
  9560. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9561. * @param options Sets of optional options forcing the compilation with different modes
  9562. * @returns A promise that resolves when the compilation completes
  9563. */
  9564. forceCompilationAsync(options?: Partial<{
  9565. useInstances: boolean;
  9566. }>): Promise<void>;
  9567. /**
  9568. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9569. * @param subMesh The submesh we want to render in the shadow map
  9570. * @param useInstances Defines wether will draw in the map using instances
  9571. * @returns true if ready otherwise, false
  9572. */
  9573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9574. /**
  9575. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9576. * @param defines Defines of the material we want to update
  9577. * @param lightIndex Index of the light in the enabled light list of the material
  9578. */
  9579. prepareDefines(defines: any, lightIndex: number): void;
  9580. /**
  9581. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9582. * defined in the generator but impacting the effect).
  9583. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9584. * @param effect The effect we are binfing the information for
  9585. */
  9586. bindShadowLight(lightIndex: string, effect: Effect): void;
  9587. /**
  9588. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9589. * (eq to shadow prjection matrix * light transform matrix)
  9590. * @returns The transform matrix used to create the shadow map
  9591. */
  9592. getTransformMatrix(): Matrix;
  9593. /**
  9594. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9595. * Cube and 2D textures for instance.
  9596. */
  9597. recreateShadowMap(): void;
  9598. private _disposeBlurPostProcesses;
  9599. private _disposeRTTandPostProcesses;
  9600. /**
  9601. * Disposes the ShadowGenerator.
  9602. * Returns nothing.
  9603. */
  9604. dispose(): void;
  9605. /**
  9606. * Serializes the shadow generator setup to a json object.
  9607. * @returns The serialized JSON object
  9608. */
  9609. serialize(): any;
  9610. /**
  9611. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9612. * @param parsedShadowGenerator The JSON object to parse
  9613. * @param scene The scene to create the shadow map for
  9614. * @returns The parsed shadow generator
  9615. */
  9616. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9617. }
  9618. }
  9619. declare module BABYLON {
  9620. /**
  9621. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9622. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9623. * 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.
  9624. */
  9625. export abstract class Light extends Node {
  9626. /**
  9627. * Falloff Default: light is falling off following the material specification:
  9628. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9629. */
  9630. static readonly FALLOFF_DEFAULT: number;
  9631. /**
  9632. * Falloff Physical: light is falling off following the inverse squared distance law.
  9633. */
  9634. static readonly FALLOFF_PHYSICAL: number;
  9635. /**
  9636. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9637. * to enhance interoperability with other engines.
  9638. */
  9639. static readonly FALLOFF_GLTF: number;
  9640. /**
  9641. * Falloff Standard: light is falling off like in the standard material
  9642. * to enhance interoperability with other materials.
  9643. */
  9644. static readonly FALLOFF_STANDARD: number;
  9645. /**
  9646. * If every light affecting the material is in this lightmapMode,
  9647. * material.lightmapTexture adds or multiplies
  9648. * (depends on material.useLightmapAsShadowmap)
  9649. * after every other light calculations.
  9650. */
  9651. static readonly LIGHTMAP_DEFAULT: number;
  9652. /**
  9653. * material.lightmapTexture as only diffuse lighting from this light
  9654. * adds only specular lighting from this light
  9655. * adds dynamic shadows
  9656. */
  9657. static readonly LIGHTMAP_SPECULAR: number;
  9658. /**
  9659. * material.lightmapTexture as only lighting
  9660. * no light calculation from this light
  9661. * only adds dynamic shadows from this light
  9662. */
  9663. static readonly LIGHTMAP_SHADOWSONLY: number;
  9664. /**
  9665. * Each light type uses the default quantity according to its type:
  9666. * point/spot lights use luminous intensity
  9667. * directional lights use illuminance
  9668. */
  9669. static readonly INTENSITYMODE_AUTOMATIC: number;
  9670. /**
  9671. * lumen (lm)
  9672. */
  9673. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9674. /**
  9675. * candela (lm/sr)
  9676. */
  9677. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9678. /**
  9679. * lux (lm/m^2)
  9680. */
  9681. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9682. /**
  9683. * nit (cd/m^2)
  9684. */
  9685. static readonly INTENSITYMODE_LUMINANCE: number;
  9686. /**
  9687. * Light type const id of the point light.
  9688. */
  9689. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9690. /**
  9691. * Light type const id of the directional light.
  9692. */
  9693. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9694. /**
  9695. * Light type const id of the spot light.
  9696. */
  9697. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9698. /**
  9699. * Light type const id of the hemispheric light.
  9700. */
  9701. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9702. /**
  9703. * Diffuse gives the basic color to an object.
  9704. */
  9705. diffuse: Color3;
  9706. /**
  9707. * Specular produces a highlight color on an object.
  9708. * Note: This is note affecting PBR materials.
  9709. */
  9710. specular: Color3;
  9711. /**
  9712. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9713. * falling off base on range or angle.
  9714. * This can be set to any values in Light.FALLOFF_x.
  9715. *
  9716. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9717. * other types of materials.
  9718. */
  9719. falloffType: number;
  9720. /**
  9721. * Strength of the light.
  9722. * Note: By default it is define in the framework own unit.
  9723. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9724. */
  9725. intensity: number;
  9726. private _range;
  9727. protected _inverseSquaredRange: number;
  9728. /**
  9729. * Defines how far from the source the light is impacting in scene units.
  9730. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9731. */
  9732. /**
  9733. * Defines how far from the source the light is impacting in scene units.
  9734. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9735. */
  9736. range: number;
  9737. /**
  9738. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9739. * of light.
  9740. */
  9741. private _photometricScale;
  9742. private _intensityMode;
  9743. /**
  9744. * Gets the photometric scale used to interpret the intensity.
  9745. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9746. */
  9747. /**
  9748. * Sets the photometric scale used to interpret the intensity.
  9749. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9750. */
  9751. intensityMode: number;
  9752. private _radius;
  9753. /**
  9754. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9755. */
  9756. /**
  9757. * sets the light radius used by PBR Materials to simulate soft area lights.
  9758. */
  9759. radius: number;
  9760. private _renderPriority;
  9761. /**
  9762. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9763. * exceeding the number allowed of the materials.
  9764. */
  9765. renderPriority: number;
  9766. private _shadowEnabled;
  9767. /**
  9768. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9769. * the current shadow generator.
  9770. */
  9771. /**
  9772. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9773. * the current shadow generator.
  9774. */
  9775. shadowEnabled: boolean;
  9776. private _includedOnlyMeshes;
  9777. /**
  9778. * Gets the only meshes impacted by this light.
  9779. */
  9780. /**
  9781. * Sets the only meshes impacted by this light.
  9782. */
  9783. includedOnlyMeshes: AbstractMesh[];
  9784. private _excludedMeshes;
  9785. /**
  9786. * Gets the meshes not impacted by this light.
  9787. */
  9788. /**
  9789. * Sets the meshes not impacted by this light.
  9790. */
  9791. excludedMeshes: AbstractMesh[];
  9792. private _excludeWithLayerMask;
  9793. /**
  9794. * Gets the layer id use to find what meshes are not impacted by the light.
  9795. * Inactive if 0
  9796. */
  9797. /**
  9798. * Sets the layer id use to find what meshes are not impacted by the light.
  9799. * Inactive if 0
  9800. */
  9801. excludeWithLayerMask: number;
  9802. private _includeOnlyWithLayerMask;
  9803. /**
  9804. * Gets the layer id use to find what meshes are impacted by the light.
  9805. * Inactive if 0
  9806. */
  9807. /**
  9808. * Sets the layer id use to find what meshes are impacted by the light.
  9809. * Inactive if 0
  9810. */
  9811. includeOnlyWithLayerMask: number;
  9812. private _lightmapMode;
  9813. /**
  9814. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9815. */
  9816. /**
  9817. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9818. */
  9819. lightmapMode: number;
  9820. /**
  9821. * Shadow generator associted to the light.
  9822. * @hidden Internal use only.
  9823. */
  9824. _shadowGenerator: Nullable<IShadowGenerator>;
  9825. /**
  9826. * @hidden Internal use only.
  9827. */
  9828. _excludedMeshesIds: string[];
  9829. /**
  9830. * @hidden Internal use only.
  9831. */
  9832. _includedOnlyMeshesIds: string[];
  9833. /**
  9834. * The current light unifom buffer.
  9835. * @hidden Internal use only.
  9836. */
  9837. _uniformBuffer: UniformBuffer;
  9838. /**
  9839. * Creates a Light object in the scene.
  9840. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9841. * @param name The firendly name of the light
  9842. * @param scene The scene the light belongs too
  9843. */
  9844. constructor(name: string, scene: Scene);
  9845. protected abstract _buildUniformLayout(): void;
  9846. /**
  9847. * Sets the passed Effect "effect" with the Light information.
  9848. * @param effect The effect to update
  9849. * @param lightIndex The index of the light in the effect to update
  9850. * @returns The light
  9851. */
  9852. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9853. /**
  9854. * Returns the string "Light".
  9855. * @returns the class name
  9856. */
  9857. getClassName(): string;
  9858. /** @hidden */
  9859. readonly _isLight: boolean;
  9860. /**
  9861. * Converts the light information to a readable string for debug purpose.
  9862. * @param fullDetails Supports for multiple levels of logging within scene loading
  9863. * @returns the human readable light info
  9864. */
  9865. toString(fullDetails?: boolean): string;
  9866. /** @hidden */
  9867. protected _syncParentEnabledState(): void;
  9868. /**
  9869. * Set the enabled state of this node.
  9870. * @param value - the new enabled state
  9871. */
  9872. setEnabled(value: boolean): void;
  9873. /**
  9874. * Returns the Light associated shadow generator if any.
  9875. * @return the associated shadow generator.
  9876. */
  9877. getShadowGenerator(): Nullable<IShadowGenerator>;
  9878. /**
  9879. * Returns a Vector3, the absolute light position in the World.
  9880. * @returns the world space position of the light
  9881. */
  9882. getAbsolutePosition(): Vector3;
  9883. /**
  9884. * Specifies if the light will affect the passed mesh.
  9885. * @param mesh The mesh to test against the light
  9886. * @return true the mesh is affected otherwise, false.
  9887. */
  9888. canAffectMesh(mesh: AbstractMesh): boolean;
  9889. /**
  9890. * Sort function to order lights for rendering.
  9891. * @param a First Light object to compare to second.
  9892. * @param b Second Light object to compare first.
  9893. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9894. */
  9895. static CompareLightsPriority(a: Light, b: Light): number;
  9896. /**
  9897. * Releases resources associated with this node.
  9898. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9899. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9900. */
  9901. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9902. /**
  9903. * Returns the light type ID (integer).
  9904. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9905. */
  9906. getTypeID(): number;
  9907. /**
  9908. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9909. * @returns the scaled intensity in intensity mode unit
  9910. */
  9911. getScaledIntensity(): number;
  9912. /**
  9913. * Returns a new Light object, named "name", from the current one.
  9914. * @param name The name of the cloned light
  9915. * @returns the new created light
  9916. */
  9917. clone(name: string): Nullable<Light>;
  9918. /**
  9919. * Serializes the current light into a Serialization object.
  9920. * @returns the serialized object.
  9921. */
  9922. serialize(): any;
  9923. /**
  9924. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9925. * This new light is named "name" and added to the passed scene.
  9926. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9927. * @param name The friendly name of the light
  9928. * @param scene The scene the new light will belong to
  9929. * @returns the constructor function
  9930. */
  9931. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9932. /**
  9933. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9934. * @param parsedLight The JSON representation of the light
  9935. * @param scene The scene to create the parsed light in
  9936. * @returns the created light after parsing
  9937. */
  9938. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9939. private _hookArrayForExcluded;
  9940. private _hookArrayForIncludedOnly;
  9941. private _resyncMeshes;
  9942. /**
  9943. * Forces the meshes to update their light related information in their rendering used effects
  9944. * @hidden Internal Use Only
  9945. */
  9946. _markMeshesAsLightDirty(): void;
  9947. /**
  9948. * Recomputes the cached photometric scale if needed.
  9949. */
  9950. private _computePhotometricScale;
  9951. /**
  9952. * Returns the Photometric Scale according to the light type and intensity mode.
  9953. */
  9954. private _getPhotometricScale;
  9955. /**
  9956. * Reorder the light in the scene according to their defined priority.
  9957. * @hidden Internal Use Only
  9958. */
  9959. _reorderLightsInScene(): void;
  9960. /**
  9961. * Prepares the list of defines specific to the light type.
  9962. * @param defines the list of defines
  9963. * @param lightIndex defines the index of the light for the effect
  9964. */
  9965. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9966. }
  9967. }
  9968. declare module BABYLON {
  9969. /**
  9970. * Interface used to define Action
  9971. */
  9972. export interface IAction {
  9973. /**
  9974. * Trigger for the action
  9975. */
  9976. trigger: number;
  9977. /** Options of the trigger */
  9978. triggerOptions: any;
  9979. /**
  9980. * Gets the trigger parameters
  9981. * @returns the trigger parameters
  9982. */
  9983. getTriggerParameter(): any;
  9984. /**
  9985. * Internal only - executes current action event
  9986. * @hidden
  9987. */
  9988. _executeCurrent(evt?: ActionEvent): void;
  9989. /**
  9990. * Serialize placeholder for child classes
  9991. * @param parent of child
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. /**
  9996. * Internal only
  9997. * @hidden
  9998. */
  9999. _prepare(): void;
  10000. /**
  10001. * Internal only - manager for action
  10002. * @hidden
  10003. */
  10004. _actionManager: AbstractActionManager;
  10005. /**
  10006. * Adds action to chain of actions, may be a DoNothingAction
  10007. * @param action defines the next action to execute
  10008. * @returns The action passed in
  10009. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10010. */
  10011. then(action: IAction): IAction;
  10012. }
  10013. /**
  10014. * The action to be carried out following a trigger
  10015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10016. */
  10017. export class Action implements IAction {
  10018. /** the trigger, with or without parameters, for the action */
  10019. triggerOptions: any;
  10020. /**
  10021. * Trigger for the action
  10022. */
  10023. trigger: number;
  10024. /**
  10025. * Internal only - manager for action
  10026. * @hidden
  10027. */
  10028. _actionManager: ActionManager;
  10029. private _nextActiveAction;
  10030. private _child;
  10031. private _condition?;
  10032. private _triggerParameter;
  10033. /**
  10034. * An event triggered prior to action being executed.
  10035. */
  10036. onBeforeExecuteObservable: Observable<Action>;
  10037. /**
  10038. * Creates a new Action
  10039. * @param triggerOptions the trigger, with or without parameters, for the action
  10040. * @param condition an optional determinant of action
  10041. */
  10042. constructor(
  10043. /** the trigger, with or without parameters, for the action */
  10044. triggerOptions: any, condition?: Condition);
  10045. /**
  10046. * Internal only
  10047. * @hidden
  10048. */
  10049. _prepare(): void;
  10050. /**
  10051. * Gets the trigger parameters
  10052. * @returns the trigger parameters
  10053. */
  10054. getTriggerParameter(): any;
  10055. /**
  10056. * Internal only - executes current action event
  10057. * @hidden
  10058. */
  10059. _executeCurrent(evt?: ActionEvent): void;
  10060. /**
  10061. * Execute placeholder for child classes
  10062. * @param evt optional action event
  10063. */
  10064. execute(evt?: ActionEvent): void;
  10065. /**
  10066. * Skips to next active action
  10067. */
  10068. skipToNextActiveAction(): void;
  10069. /**
  10070. * Adds action to chain of actions, may be a DoNothingAction
  10071. * @param action defines the next action to execute
  10072. * @returns The action passed in
  10073. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10074. */
  10075. then(action: Action): Action;
  10076. /**
  10077. * Internal only
  10078. * @hidden
  10079. */
  10080. _getProperty(propertyPath: string): string;
  10081. /**
  10082. * Internal only
  10083. * @hidden
  10084. */
  10085. _getEffectiveTarget(target: any, propertyPath: string): any;
  10086. /**
  10087. * Serialize placeholder for child classes
  10088. * @param parent of child
  10089. * @returns the serialized object
  10090. */
  10091. serialize(parent: any): any;
  10092. /**
  10093. * Internal only called by serialize
  10094. * @hidden
  10095. */
  10096. protected _serialize(serializedAction: any, parent?: any): any;
  10097. /**
  10098. * Internal only
  10099. * @hidden
  10100. */
  10101. static _SerializeValueAsString: (value: any) => string;
  10102. /**
  10103. * Internal only
  10104. * @hidden
  10105. */
  10106. static _GetTargetProperty: (target: Node | Scene) => {
  10107. name: string;
  10108. targetType: string;
  10109. value: string;
  10110. };
  10111. }
  10112. }
  10113. declare module BABYLON {
  10114. /**
  10115. * A Condition applied to an Action
  10116. */
  10117. export class Condition {
  10118. /**
  10119. * Internal only - manager for action
  10120. * @hidden
  10121. */
  10122. _actionManager: ActionManager;
  10123. /**
  10124. * Internal only
  10125. * @hidden
  10126. */
  10127. _evaluationId: number;
  10128. /**
  10129. * Internal only
  10130. * @hidden
  10131. */
  10132. _currentResult: boolean;
  10133. /**
  10134. * Creates a new Condition
  10135. * @param actionManager the manager of the action the condition is applied to
  10136. */
  10137. constructor(actionManager: ActionManager);
  10138. /**
  10139. * Check if the current condition is valid
  10140. * @returns a boolean
  10141. */
  10142. isValid(): boolean;
  10143. /**
  10144. * Internal only
  10145. * @hidden
  10146. */
  10147. _getProperty(propertyPath: string): string;
  10148. /**
  10149. * Internal only
  10150. * @hidden
  10151. */
  10152. _getEffectiveTarget(target: any, propertyPath: string): any;
  10153. /**
  10154. * Serialize placeholder for child classes
  10155. * @returns the serialized object
  10156. */
  10157. serialize(): any;
  10158. /**
  10159. * Internal only
  10160. * @hidden
  10161. */
  10162. protected _serialize(serializedCondition: any): any;
  10163. }
  10164. /**
  10165. * Defines specific conditional operators as extensions of Condition
  10166. */
  10167. export class ValueCondition extends Condition {
  10168. /** path to specify the property of the target the conditional operator uses */
  10169. propertyPath: string;
  10170. /** the value compared by the conditional operator against the current value of the property */
  10171. value: any;
  10172. /** the conditional operator, default ValueCondition.IsEqual */
  10173. operator: number;
  10174. /**
  10175. * Internal only
  10176. * @hidden
  10177. */
  10178. private static _IsEqual;
  10179. /**
  10180. * Internal only
  10181. * @hidden
  10182. */
  10183. private static _IsDifferent;
  10184. /**
  10185. * Internal only
  10186. * @hidden
  10187. */
  10188. private static _IsGreater;
  10189. /**
  10190. * Internal only
  10191. * @hidden
  10192. */
  10193. private static _IsLesser;
  10194. /**
  10195. * returns the number for IsEqual
  10196. */
  10197. static readonly IsEqual: number;
  10198. /**
  10199. * Returns the number for IsDifferent
  10200. */
  10201. static readonly IsDifferent: number;
  10202. /**
  10203. * Returns the number for IsGreater
  10204. */
  10205. static readonly IsGreater: number;
  10206. /**
  10207. * Returns the number for IsLesser
  10208. */
  10209. static readonly IsLesser: number;
  10210. /**
  10211. * Internal only The action manager for the condition
  10212. * @hidden
  10213. */
  10214. _actionManager: ActionManager;
  10215. /**
  10216. * Internal only
  10217. * @hidden
  10218. */
  10219. private _target;
  10220. /**
  10221. * Internal only
  10222. * @hidden
  10223. */
  10224. private _effectiveTarget;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */
  10229. private _property;
  10230. /**
  10231. * Creates a new ValueCondition
  10232. * @param actionManager manager for the action the condition applies to
  10233. * @param target for the action
  10234. * @param propertyPath path to specify the property of the target the conditional operator uses
  10235. * @param value the value compared by the conditional operator against the current value of the property
  10236. * @param operator the conditional operator, default ValueCondition.IsEqual
  10237. */
  10238. constructor(actionManager: ActionManager, target: any,
  10239. /** path to specify the property of the target the conditional operator uses */
  10240. propertyPath: string,
  10241. /** the value compared by the conditional operator against the current value of the property */
  10242. value: any,
  10243. /** the conditional operator, default ValueCondition.IsEqual */
  10244. operator?: number);
  10245. /**
  10246. * Compares the given value with the property value for the specified conditional operator
  10247. * @returns the result of the comparison
  10248. */
  10249. isValid(): boolean;
  10250. /**
  10251. * Serialize the ValueCondition into a JSON compatible object
  10252. * @returns serialization object
  10253. */
  10254. serialize(): any;
  10255. /**
  10256. * Gets the name of the conditional operator for the ValueCondition
  10257. * @param operator the conditional operator
  10258. * @returns the name
  10259. */
  10260. static GetOperatorName(operator: number): string;
  10261. }
  10262. /**
  10263. * Defines a predicate condition as an extension of Condition
  10264. */
  10265. export class PredicateCondition extends Condition {
  10266. /** defines the predicate function used to validate the condition */
  10267. predicate: () => boolean;
  10268. /**
  10269. * Internal only - manager for action
  10270. * @hidden
  10271. */
  10272. _actionManager: ActionManager;
  10273. /**
  10274. * Creates a new PredicateCondition
  10275. * @param actionManager manager for the action the condition applies to
  10276. * @param predicate defines the predicate function used to validate the condition
  10277. */
  10278. constructor(actionManager: ActionManager,
  10279. /** defines the predicate function used to validate the condition */
  10280. predicate: () => boolean);
  10281. /**
  10282. * @returns the validity of the predicate condition
  10283. */
  10284. isValid(): boolean;
  10285. }
  10286. /**
  10287. * Defines a state condition as an extension of Condition
  10288. */
  10289. export class StateCondition extends Condition {
  10290. /** Value to compare with target state */
  10291. value: string;
  10292. /**
  10293. * Internal only - manager for action
  10294. * @hidden
  10295. */
  10296. _actionManager: ActionManager;
  10297. /**
  10298. * Internal only
  10299. * @hidden
  10300. */
  10301. private _target;
  10302. /**
  10303. * Creates a new StateCondition
  10304. * @param actionManager manager for the action the condition applies to
  10305. * @param target of the condition
  10306. * @param value to compare with target state
  10307. */
  10308. constructor(actionManager: ActionManager, target: any,
  10309. /** Value to compare with target state */
  10310. value: string);
  10311. /**
  10312. * Gets a boolean indicating if the current condition is met
  10313. * @returns the validity of the state
  10314. */
  10315. isValid(): boolean;
  10316. /**
  10317. * Serialize the StateCondition into a JSON compatible object
  10318. * @returns serialization object
  10319. */
  10320. serialize(): any;
  10321. }
  10322. }
  10323. declare module BABYLON {
  10324. /**
  10325. * This defines an action responsible to toggle a boolean once triggered.
  10326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10327. */
  10328. export class SwitchBooleanAction extends Action {
  10329. /**
  10330. * The path to the boolean property in the target object
  10331. */
  10332. propertyPath: string;
  10333. private _target;
  10334. private _effectiveTarget;
  10335. private _property;
  10336. /**
  10337. * Instantiate the action
  10338. * @param triggerOptions defines the trigger options
  10339. * @param target defines the object containing the boolean
  10340. * @param propertyPath defines the path to the boolean property in the target object
  10341. * @param condition defines the trigger related conditions
  10342. */
  10343. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10344. /** @hidden */
  10345. _prepare(): void;
  10346. /**
  10347. * Execute the action toggle the boolean value.
  10348. */
  10349. execute(): void;
  10350. /**
  10351. * Serializes the actions and its related information.
  10352. * @param parent defines the object to serialize in
  10353. * @returns the serialized object
  10354. */
  10355. serialize(parent: any): any;
  10356. }
  10357. /**
  10358. * This defines an action responsible to set a the state field of the target
  10359. * to a desired value once triggered.
  10360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10361. */
  10362. export class SetStateAction extends Action {
  10363. /**
  10364. * The value to store in the state field.
  10365. */
  10366. value: string;
  10367. private _target;
  10368. /**
  10369. * Instantiate the action
  10370. * @param triggerOptions defines the trigger options
  10371. * @param target defines the object containing the state property
  10372. * @param value defines the value to store in the state field
  10373. * @param condition defines the trigger related conditions
  10374. */
  10375. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10376. /**
  10377. * Execute the action and store the value on the target state property.
  10378. */
  10379. execute(): void;
  10380. /**
  10381. * Serializes the actions and its related information.
  10382. * @param parent defines the object to serialize in
  10383. * @returns the serialized object
  10384. */
  10385. serialize(parent: any): any;
  10386. }
  10387. /**
  10388. * This defines an action responsible to set a property of the target
  10389. * to a desired value once triggered.
  10390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10391. */
  10392. export class SetValueAction extends Action {
  10393. /**
  10394. * The path of the property to set in the target.
  10395. */
  10396. propertyPath: string;
  10397. /**
  10398. * The value to set in the property
  10399. */
  10400. value: any;
  10401. private _target;
  10402. private _effectiveTarget;
  10403. private _property;
  10404. /**
  10405. * Instantiate the action
  10406. * @param triggerOptions defines the trigger options
  10407. * @param target defines the object containing the property
  10408. * @param propertyPath defines the path of the property to set in the target
  10409. * @param value defines the value to set in the property
  10410. * @param condition defines the trigger related conditions
  10411. */
  10412. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10413. /** @hidden */
  10414. _prepare(): void;
  10415. /**
  10416. * Execute the action and set the targetted property to the desired value.
  10417. */
  10418. execute(): void;
  10419. /**
  10420. * Serializes the actions and its related information.
  10421. * @param parent defines the object to serialize in
  10422. * @returns the serialized object
  10423. */
  10424. serialize(parent: any): any;
  10425. }
  10426. /**
  10427. * This defines an action responsible to increment the target value
  10428. * to a desired value once triggered.
  10429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10430. */
  10431. export class IncrementValueAction extends Action {
  10432. /**
  10433. * The path of the property to increment in the target.
  10434. */
  10435. propertyPath: string;
  10436. /**
  10437. * The value we should increment the property by.
  10438. */
  10439. value: any;
  10440. private _target;
  10441. private _effectiveTarget;
  10442. private _property;
  10443. /**
  10444. * Instantiate the action
  10445. * @param triggerOptions defines the trigger options
  10446. * @param target defines the object containing the property
  10447. * @param propertyPath defines the path of the property to increment in the target
  10448. * @param value defines the value value we should increment the property by
  10449. * @param condition defines the trigger related conditions
  10450. */
  10451. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10452. /** @hidden */
  10453. _prepare(): void;
  10454. /**
  10455. * Execute the action and increment the target of the value amount.
  10456. */
  10457. execute(): void;
  10458. /**
  10459. * Serializes the actions and its related information.
  10460. * @param parent defines the object to serialize in
  10461. * @returns the serialized object
  10462. */
  10463. serialize(parent: any): any;
  10464. }
  10465. /**
  10466. * This defines an action responsible to start an animation once triggered.
  10467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10468. */
  10469. export class PlayAnimationAction extends Action {
  10470. /**
  10471. * Where the animation should start (animation frame)
  10472. */
  10473. from: number;
  10474. /**
  10475. * Where the animation should stop (animation frame)
  10476. */
  10477. to: number;
  10478. /**
  10479. * Define if the animation should loop or stop after the first play.
  10480. */
  10481. loop?: boolean;
  10482. private _target;
  10483. /**
  10484. * Instantiate the action
  10485. * @param triggerOptions defines the trigger options
  10486. * @param target defines the target animation or animation name
  10487. * @param from defines from where the animation should start (animation frame)
  10488. * @param end defines where the animation should stop (animation frame)
  10489. * @param loop defines if the animation should loop or stop after the first play
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action and play the animation.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to stop an animation once triggered.
  10508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10509. */
  10510. export class StopAnimationAction extends Action {
  10511. private _target;
  10512. /**
  10513. * Instantiate the action
  10514. * @param triggerOptions defines the trigger options
  10515. * @param target defines the target animation or animation name
  10516. * @param condition defines the trigger related conditions
  10517. */
  10518. constructor(triggerOptions: any, target: any, condition?: Condition);
  10519. /** @hidden */
  10520. _prepare(): void;
  10521. /**
  10522. * Execute the action and stop the animation.
  10523. */
  10524. execute(): void;
  10525. /**
  10526. * Serializes the actions and its related information.
  10527. * @param parent defines the object to serialize in
  10528. * @returns the serialized object
  10529. */
  10530. serialize(parent: any): any;
  10531. }
  10532. /**
  10533. * This defines an action responsible that does nothing once triggered.
  10534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10535. */
  10536. export class DoNothingAction extends Action {
  10537. /**
  10538. * Instantiate the action
  10539. * @param triggerOptions defines the trigger options
  10540. * @param condition defines the trigger related conditions
  10541. */
  10542. constructor(triggerOptions?: any, condition?: Condition);
  10543. /**
  10544. * Execute the action and do nothing.
  10545. */
  10546. execute(): void;
  10547. /**
  10548. * Serializes the actions and its related information.
  10549. * @param parent defines the object to serialize in
  10550. * @returns the serialized object
  10551. */
  10552. serialize(parent: any): any;
  10553. }
  10554. /**
  10555. * This defines an action responsible to trigger several actions once triggered.
  10556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10557. */
  10558. export class CombineAction extends Action {
  10559. /**
  10560. * The list of aggregated animations to run.
  10561. */
  10562. children: Action[];
  10563. /**
  10564. * Instantiate the action
  10565. * @param triggerOptions defines the trigger options
  10566. * @param children defines the list of aggregated animations to run
  10567. * @param condition defines the trigger related conditions
  10568. */
  10569. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10570. /** @hidden */
  10571. _prepare(): void;
  10572. /**
  10573. * Execute the action and executes all the aggregated actions.
  10574. */
  10575. execute(evt: ActionEvent): void;
  10576. /**
  10577. * Serializes the actions and its related information.
  10578. * @param parent defines the object to serialize in
  10579. * @returns the serialized object
  10580. */
  10581. serialize(parent: any): any;
  10582. }
  10583. /**
  10584. * This defines an action responsible to run code (external event) once triggered.
  10585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10586. */
  10587. export class ExecuteCodeAction extends Action {
  10588. /**
  10589. * The callback function to run.
  10590. */
  10591. func: (evt: ActionEvent) => void;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param func defines the callback function to run
  10596. * @param condition defines the trigger related conditions
  10597. */
  10598. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10599. /**
  10600. * Execute the action and run the attached code.
  10601. */
  10602. execute(evt: ActionEvent): void;
  10603. }
  10604. /**
  10605. * This defines an action responsible to set the parent property of the target once triggered.
  10606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10607. */
  10608. export class SetParentAction extends Action {
  10609. private _parent;
  10610. private _target;
  10611. /**
  10612. * Instantiate the action
  10613. * @param triggerOptions defines the trigger options
  10614. * @param target defines the target containing the parent property
  10615. * @param parent defines from where the animation should start (animation frame)
  10616. * @param condition defines the trigger related conditions
  10617. */
  10618. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10619. /** @hidden */
  10620. _prepare(): void;
  10621. /**
  10622. * Execute the action and set the parent property.
  10623. */
  10624. execute(): void;
  10625. /**
  10626. * Serializes the actions and its related information.
  10627. * @param parent defines the object to serialize in
  10628. * @returns the serialized object
  10629. */
  10630. serialize(parent: any): any;
  10631. }
  10632. }
  10633. declare module BABYLON {
  10634. /**
  10635. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10636. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10638. */
  10639. export class ActionManager extends AbstractActionManager {
  10640. /**
  10641. * Nothing
  10642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10643. */
  10644. static readonly NothingTrigger: number;
  10645. /**
  10646. * On pick
  10647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10648. */
  10649. static readonly OnPickTrigger: number;
  10650. /**
  10651. * On left pick
  10652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10653. */
  10654. static readonly OnLeftPickTrigger: number;
  10655. /**
  10656. * On right pick
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10658. */
  10659. static readonly OnRightPickTrigger: number;
  10660. /**
  10661. * On center pick
  10662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10663. */
  10664. static readonly OnCenterPickTrigger: number;
  10665. /**
  10666. * On pick down
  10667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10668. */
  10669. static readonly OnPickDownTrigger: number;
  10670. /**
  10671. * On double pick
  10672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10673. */
  10674. static readonly OnDoublePickTrigger: number;
  10675. /**
  10676. * On pick up
  10677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10678. */
  10679. static readonly OnPickUpTrigger: number;
  10680. /**
  10681. * On pick out.
  10682. * This trigger will only be raised if you also declared a OnPickDown
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10684. */
  10685. static readonly OnPickOutTrigger: number;
  10686. /**
  10687. * On long press
  10688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10689. */
  10690. static readonly OnLongPressTrigger: number;
  10691. /**
  10692. * On pointer over
  10693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10694. */
  10695. static readonly OnPointerOverTrigger: number;
  10696. /**
  10697. * On pointer out
  10698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10699. */
  10700. static readonly OnPointerOutTrigger: number;
  10701. /**
  10702. * On every frame
  10703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10704. */
  10705. static readonly OnEveryFrameTrigger: number;
  10706. /**
  10707. * On intersection enter
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10709. */
  10710. static readonly OnIntersectionEnterTrigger: number;
  10711. /**
  10712. * On intersection exit
  10713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10714. */
  10715. static readonly OnIntersectionExitTrigger: number;
  10716. /**
  10717. * On key down
  10718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10719. */
  10720. static readonly OnKeyDownTrigger: number;
  10721. /**
  10722. * On key up
  10723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10724. */
  10725. static readonly OnKeyUpTrigger: number;
  10726. private _scene;
  10727. /**
  10728. * Creates a new action manager
  10729. * @param scene defines the hosting scene
  10730. */
  10731. constructor(scene: Scene);
  10732. /**
  10733. * Releases all associated resources
  10734. */
  10735. dispose(): void;
  10736. /**
  10737. * Gets hosting scene
  10738. * @returns the hosting scene
  10739. */
  10740. getScene(): Scene;
  10741. /**
  10742. * Does this action manager handles actions of any of the given triggers
  10743. * @param triggers defines the triggers to be tested
  10744. * @return a boolean indicating whether one (or more) of the triggers is handled
  10745. */
  10746. hasSpecificTriggers(triggers: number[]): boolean;
  10747. /**
  10748. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10749. * speed.
  10750. * @param triggerA defines the trigger to be tested
  10751. * @param triggerB defines the trigger to be tested
  10752. * @return a boolean indicating whether one (or more) of the triggers is handled
  10753. */
  10754. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10755. /**
  10756. * Does this action manager handles actions of a given trigger
  10757. * @param trigger defines the trigger to be tested
  10758. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10759. * @return whether the trigger is handled
  10760. */
  10761. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10762. /**
  10763. * Does this action manager has pointer triggers
  10764. */
  10765. readonly hasPointerTriggers: boolean;
  10766. /**
  10767. * Does this action manager has pick triggers
  10768. */
  10769. readonly hasPickTriggers: boolean;
  10770. /**
  10771. * Registers an action to this action manager
  10772. * @param action defines the action to be registered
  10773. * @return the action amended (prepared) after registration
  10774. */
  10775. registerAction(action: IAction): Nullable<IAction>;
  10776. /**
  10777. * Unregisters an action to this action manager
  10778. * @param action defines the action to be unregistered
  10779. * @return a boolean indicating whether the action has been unregistered
  10780. */
  10781. unregisterAction(action: IAction): Boolean;
  10782. /**
  10783. * Process a specific trigger
  10784. * @param trigger defines the trigger to process
  10785. * @param evt defines the event details to be processed
  10786. */
  10787. processTrigger(trigger: number, evt?: IActionEvent): void;
  10788. /** @hidden */
  10789. _getEffectiveTarget(target: any, propertyPath: string): any;
  10790. /** @hidden */
  10791. _getProperty(propertyPath: string): string;
  10792. /**
  10793. * Serialize this manager to a JSON object
  10794. * @param name defines the property name to store this manager
  10795. * @returns a JSON representation of this manager
  10796. */
  10797. serialize(name: string): any;
  10798. /**
  10799. * Creates a new ActionManager from a JSON data
  10800. * @param parsedActions defines the JSON data to read from
  10801. * @param object defines the hosting mesh
  10802. * @param scene defines the hosting scene
  10803. */
  10804. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10805. /**
  10806. * Get a trigger name by index
  10807. * @param trigger defines the trigger index
  10808. * @returns a trigger name
  10809. */
  10810. static GetTriggerName(trigger: number): string;
  10811. }
  10812. }
  10813. declare module BABYLON {
  10814. /**
  10815. * Class representing a ray with position and direction
  10816. */
  10817. export class Ray {
  10818. /** origin point */
  10819. origin: Vector3;
  10820. /** direction */
  10821. direction: Vector3;
  10822. /** length of the ray */
  10823. length: number;
  10824. private static readonly TmpVector3;
  10825. private _tmpRay;
  10826. /**
  10827. * Creates a new ray
  10828. * @param origin origin point
  10829. * @param direction direction
  10830. * @param length length of the ray
  10831. */
  10832. constructor(
  10833. /** origin point */
  10834. origin: Vector3,
  10835. /** direction */
  10836. direction: Vector3,
  10837. /** length of the ray */
  10838. length?: number);
  10839. /**
  10840. * Checks if the ray intersects a box
  10841. * @param minimum bound of the box
  10842. * @param maximum bound of the box
  10843. * @param intersectionTreshold extra extend to be added to the box in all direction
  10844. * @returns if the box was hit
  10845. */
  10846. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10847. /**
  10848. * Checks if the ray intersects a box
  10849. * @param box the bounding box to check
  10850. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10851. * @returns if the box was hit
  10852. */
  10853. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10854. /**
  10855. * If the ray hits a sphere
  10856. * @param sphere the bounding sphere to check
  10857. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10858. * @returns true if it hits the sphere
  10859. */
  10860. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10861. /**
  10862. * If the ray hits a triange
  10863. * @param vertex0 triangle vertex
  10864. * @param vertex1 triangle vertex
  10865. * @param vertex2 triangle vertex
  10866. * @returns intersection information if hit
  10867. */
  10868. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10869. /**
  10870. * Checks if ray intersects a plane
  10871. * @param plane the plane to check
  10872. * @returns the distance away it was hit
  10873. */
  10874. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10875. /**
  10876. * Calculate the intercept of a ray on a given axis
  10877. * @param axis to check 'x' | 'y' | 'z'
  10878. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10879. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10880. */
  10881. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10882. /**
  10883. * Checks if ray intersects a mesh
  10884. * @param mesh the mesh to check
  10885. * @param fastCheck if only the bounding box should checked
  10886. * @returns picking info of the intersecton
  10887. */
  10888. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10889. /**
  10890. * Checks if ray intersects a mesh
  10891. * @param meshes the meshes to check
  10892. * @param fastCheck if only the bounding box should checked
  10893. * @param results array to store result in
  10894. * @returns Array of picking infos
  10895. */
  10896. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10897. private _comparePickingInfo;
  10898. private static smallnum;
  10899. private static rayl;
  10900. /**
  10901. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10902. * @param sega the first point of the segment to test the intersection against
  10903. * @param segb the second point of the segment to test the intersection against
  10904. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10905. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10906. */
  10907. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10908. /**
  10909. * Update the ray from viewport position
  10910. * @param x position
  10911. * @param y y position
  10912. * @param viewportWidth viewport width
  10913. * @param viewportHeight viewport height
  10914. * @param world world matrix
  10915. * @param view view matrix
  10916. * @param projection projection matrix
  10917. * @returns this ray updated
  10918. */
  10919. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10920. /**
  10921. * Creates a ray with origin and direction of 0,0,0
  10922. * @returns the new ray
  10923. */
  10924. static Zero(): Ray;
  10925. /**
  10926. * Creates a new ray from screen space and viewport
  10927. * @param x position
  10928. * @param y y position
  10929. * @param viewportWidth viewport width
  10930. * @param viewportHeight viewport height
  10931. * @param world world matrix
  10932. * @param view view matrix
  10933. * @param projection projection matrix
  10934. * @returns new ray
  10935. */
  10936. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10937. /**
  10938. * 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
  10939. * transformed to the given world matrix.
  10940. * @param origin The origin point
  10941. * @param end The end point
  10942. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10943. * @returns the new ray
  10944. */
  10945. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10946. /**
  10947. * Transforms a ray by a matrix
  10948. * @param ray ray to transform
  10949. * @param matrix matrix to apply
  10950. * @returns the resulting new ray
  10951. */
  10952. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10953. /**
  10954. * Transforms a ray by a matrix
  10955. * @param ray ray to transform
  10956. * @param matrix matrix to apply
  10957. * @param result ray to store result in
  10958. */
  10959. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10960. /**
  10961. * Unproject a ray from screen space to object space
  10962. * @param sourceX defines the screen space x coordinate to use
  10963. * @param sourceY defines the screen space y coordinate to use
  10964. * @param viewportWidth defines the current width of the viewport
  10965. * @param viewportHeight defines the current height of the viewport
  10966. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10967. * @param view defines the view matrix to use
  10968. * @param projection defines the projection matrix to use
  10969. */
  10970. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10971. }
  10972. /**
  10973. * Type used to define predicate used to select faces when a mesh intersection is detected
  10974. */
  10975. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10976. interface Scene {
  10977. /** @hidden */
  10978. _tempPickingRay: Nullable<Ray>;
  10979. /** @hidden */
  10980. _cachedRayForTransform: Ray;
  10981. /** @hidden */
  10982. _pickWithRayInverseMatrix: Matrix;
  10983. /** @hidden */
  10984. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10985. /** @hidden */
  10986. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10987. }
  10988. }
  10989. declare module BABYLON {
  10990. /**
  10991. * Groups all the scene component constants in one place to ease maintenance.
  10992. * @hidden
  10993. */
  10994. export class SceneComponentConstants {
  10995. static readonly NAME_EFFECTLAYER: string;
  10996. static readonly NAME_LAYER: string;
  10997. static readonly NAME_LENSFLARESYSTEM: string;
  10998. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10999. static readonly NAME_PARTICLESYSTEM: string;
  11000. static readonly NAME_GAMEPAD: string;
  11001. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11002. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11003. static readonly NAME_DEPTHRENDERER: string;
  11004. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11005. static readonly NAME_SPRITE: string;
  11006. static readonly NAME_OUTLINERENDERER: string;
  11007. static readonly NAME_PROCEDURALTEXTURE: string;
  11008. static readonly NAME_SHADOWGENERATOR: string;
  11009. static readonly NAME_OCTREE: string;
  11010. static readonly NAME_PHYSICSENGINE: string;
  11011. static readonly NAME_AUDIO: string;
  11012. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11013. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11014. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11015. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11016. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11017. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11018. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11019. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11020. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11021. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11022. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11023. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11024. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11025. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11026. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11027. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11028. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11029. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11030. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11031. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11032. static readonly STEP_AFTERRENDER_AUDIO: number;
  11033. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11034. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11035. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11036. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11037. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11038. static readonly STEP_POINTERMOVE_SPRITE: number;
  11039. static readonly STEP_POINTERDOWN_SPRITE: number;
  11040. static readonly STEP_POINTERUP_SPRITE: number;
  11041. }
  11042. /**
  11043. * This represents a scene component.
  11044. *
  11045. * This is used to decouple the dependency the scene is having on the different workloads like
  11046. * layers, post processes...
  11047. */
  11048. export interface ISceneComponent {
  11049. /**
  11050. * The name of the component. Each component must have a unique name.
  11051. */
  11052. name: string;
  11053. /**
  11054. * The scene the component belongs to.
  11055. */
  11056. scene: Scene;
  11057. /**
  11058. * Register the component to one instance of a scene.
  11059. */
  11060. register(): void;
  11061. /**
  11062. * Rebuilds the elements related to this component in case of
  11063. * context lost for instance.
  11064. */
  11065. rebuild(): void;
  11066. /**
  11067. * Disposes the component and the associated ressources.
  11068. */
  11069. dispose(): void;
  11070. }
  11071. /**
  11072. * This represents a SERIALIZABLE scene component.
  11073. *
  11074. * This extends Scene Component to add Serialization methods on top.
  11075. */
  11076. export interface ISceneSerializableComponent extends ISceneComponent {
  11077. /**
  11078. * Adds all the elements from the container to the scene
  11079. * @param container the container holding the elements
  11080. */
  11081. addFromContainer(container: AbstractScene): void;
  11082. /**
  11083. * Removes all the elements in the container from the scene
  11084. * @param container contains the elements to remove
  11085. * @param dispose if the removed element should be disposed (default: false)
  11086. */
  11087. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11088. /**
  11089. * Serializes the component data to the specified json object
  11090. * @param serializationObject The object to serialize to
  11091. */
  11092. serialize(serializationObject: any): void;
  11093. }
  11094. /**
  11095. * Strong typing of a Mesh related stage step action
  11096. */
  11097. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11098. /**
  11099. * Strong typing of a Evaluate Sub Mesh related stage step action
  11100. */
  11101. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11102. /**
  11103. * Strong typing of a Active Mesh related stage step action
  11104. */
  11105. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11106. /**
  11107. * Strong typing of a Camera related stage step action
  11108. */
  11109. export type CameraStageAction = (camera: Camera) => void;
  11110. /**
  11111. * Strong typing of a Camera Frame buffer related stage step action
  11112. */
  11113. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11114. /**
  11115. * Strong typing of a Render Target related stage step action
  11116. */
  11117. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11118. /**
  11119. * Strong typing of a RenderingGroup related stage step action
  11120. */
  11121. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11122. /**
  11123. * Strong typing of a Mesh Render related stage step action
  11124. */
  11125. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11126. /**
  11127. * Strong typing of a simple stage step action
  11128. */
  11129. export type SimpleStageAction = () => void;
  11130. /**
  11131. * Strong typing of a render target action.
  11132. */
  11133. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11134. /**
  11135. * Strong typing of a pointer move action.
  11136. */
  11137. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11138. /**
  11139. * Strong typing of a pointer up/down action.
  11140. */
  11141. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11142. /**
  11143. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11144. * @hidden
  11145. */
  11146. export class Stage<T extends Function> extends Array<{
  11147. index: number;
  11148. component: ISceneComponent;
  11149. action: T;
  11150. }> {
  11151. /**
  11152. * Hide ctor from the rest of the world.
  11153. * @param items The items to add.
  11154. */
  11155. private constructor();
  11156. /**
  11157. * Creates a new Stage.
  11158. * @returns A new instance of a Stage
  11159. */
  11160. static Create<T extends Function>(): Stage<T>;
  11161. /**
  11162. * Registers a step in an ordered way in the targeted stage.
  11163. * @param index Defines the position to register the step in
  11164. * @param component Defines the component attached to the step
  11165. * @param action Defines the action to launch during the step
  11166. */
  11167. registerStep(index: number, component: ISceneComponent, action: T): void;
  11168. /**
  11169. * Clears all the steps from the stage.
  11170. */
  11171. clear(): void;
  11172. }
  11173. }
  11174. declare module BABYLON {
  11175. interface Scene {
  11176. /** @hidden */
  11177. _pointerOverSprite: Nullable<Sprite>;
  11178. /** @hidden */
  11179. _pickedDownSprite: Nullable<Sprite>;
  11180. /** @hidden */
  11181. _tempSpritePickingRay: Nullable<Ray>;
  11182. /**
  11183. * All of the sprite managers added to this scene
  11184. * @see http://doc.babylonjs.com/babylon101/sprites
  11185. */
  11186. spriteManagers: Array<ISpriteManager>;
  11187. /**
  11188. * An event triggered when sprites rendering is about to start
  11189. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11190. */
  11191. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11192. /**
  11193. * An event triggered when sprites rendering is done
  11194. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11195. */
  11196. onAfterSpritesRenderingObservable: Observable<Scene>;
  11197. /** @hidden */
  11198. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11199. /** Launch a ray to try to pick a sprite in the scene
  11200. * @param x position on screen
  11201. * @param y position on screen
  11202. * @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
  11203. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11204. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11205. * @returns a PickingInfo
  11206. */
  11207. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11208. /** Use the given ray to pick a sprite in the scene
  11209. * @param ray The ray (in world space) to use to pick meshes
  11210. * @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
  11211. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11212. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11213. * @returns a PickingInfo
  11214. */
  11215. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11216. /** @hidden */
  11217. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11218. /** Launch a ray to try to pick sprites in the scene
  11219. * @param x position on screen
  11220. * @param y position on screen
  11221. * @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
  11222. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11223. * @returns a PickingInfo array
  11224. */
  11225. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11226. /** Use the given ray to pick sprites in the scene
  11227. * @param ray The ray (in world space) to use to pick meshes
  11228. * @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
  11229. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11230. * @returns a PickingInfo array
  11231. */
  11232. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11233. /**
  11234. * Force the sprite under the pointer
  11235. * @param sprite defines the sprite to use
  11236. */
  11237. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11238. /**
  11239. * Gets the sprite under the pointer
  11240. * @returns a Sprite or null if no sprite is under the pointer
  11241. */
  11242. getPointerOverSprite(): Nullable<Sprite>;
  11243. }
  11244. /**
  11245. * Defines the sprite scene component responsible to manage sprites
  11246. * in a given scene.
  11247. */
  11248. export class SpriteSceneComponent implements ISceneComponent {
  11249. /**
  11250. * The component name helpfull to identify the component in the list of scene components.
  11251. */
  11252. readonly name: string;
  11253. /**
  11254. * The scene the component belongs to.
  11255. */
  11256. scene: Scene;
  11257. /** @hidden */
  11258. private _spritePredicate;
  11259. /**
  11260. * Creates a new instance of the component for the given scene
  11261. * @param scene Defines the scene to register the component in
  11262. */
  11263. constructor(scene: Scene);
  11264. /**
  11265. * Registers the component in a given scene
  11266. */
  11267. register(): void;
  11268. /**
  11269. * Rebuilds the elements related to this component in case of
  11270. * context lost for instance.
  11271. */
  11272. rebuild(): void;
  11273. /**
  11274. * Disposes the component and the associated ressources.
  11275. */
  11276. dispose(): void;
  11277. private _pickSpriteButKeepRay;
  11278. private _pointerMove;
  11279. private _pointerDown;
  11280. private _pointerUp;
  11281. }
  11282. }
  11283. declare module BABYLON {
  11284. /** @hidden */
  11285. export var fogFragmentDeclaration: {
  11286. name: string;
  11287. shader: string;
  11288. };
  11289. }
  11290. declare module BABYLON {
  11291. /** @hidden */
  11292. export var fogFragment: {
  11293. name: string;
  11294. shader: string;
  11295. };
  11296. }
  11297. declare module BABYLON {
  11298. /** @hidden */
  11299. export var spritesPixelShader: {
  11300. name: string;
  11301. shader: string;
  11302. };
  11303. }
  11304. declare module BABYLON {
  11305. /** @hidden */
  11306. export var fogVertexDeclaration: {
  11307. name: string;
  11308. shader: string;
  11309. };
  11310. }
  11311. declare module BABYLON {
  11312. /** @hidden */
  11313. export var spritesVertexShader: {
  11314. name: string;
  11315. shader: string;
  11316. };
  11317. }
  11318. declare module BABYLON {
  11319. /**
  11320. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11321. */
  11322. export interface ISpriteManager extends IDisposable {
  11323. /**
  11324. * Restricts the camera to viewing objects with the same layerMask.
  11325. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11326. */
  11327. layerMask: number;
  11328. /**
  11329. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11330. */
  11331. isPickable: boolean;
  11332. /**
  11333. * Specifies the rendering group id for this mesh (0 by default)
  11334. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11335. */
  11336. renderingGroupId: number;
  11337. /**
  11338. * Defines the list of sprites managed by the manager.
  11339. */
  11340. sprites: Array<Sprite>;
  11341. /**
  11342. * Tests the intersection of a sprite with a specific ray.
  11343. * @param ray The ray we are sending to test the collision
  11344. * @param camera The camera space we are sending rays in
  11345. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11346. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11347. * @returns picking info or null.
  11348. */
  11349. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11350. /**
  11351. * Intersects the sprites with a ray
  11352. * @param ray defines the ray to intersect with
  11353. * @param camera defines the current active camera
  11354. * @param predicate defines a predicate used to select candidate sprites
  11355. * @returns null if no hit or a PickingInfo array
  11356. */
  11357. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11358. /**
  11359. * Renders the list of sprites on screen.
  11360. */
  11361. render(): void;
  11362. }
  11363. /**
  11364. * Class used to manage multiple sprites on the same spritesheet
  11365. * @see http://doc.babylonjs.com/babylon101/sprites
  11366. */
  11367. export class SpriteManager implements ISpriteManager {
  11368. /** defines the manager's name */
  11369. name: string;
  11370. /** Gets the list of sprites */
  11371. sprites: Sprite[];
  11372. /** Gets or sets the rendering group id (0 by default) */
  11373. renderingGroupId: number;
  11374. /** Gets or sets camera layer mask */
  11375. layerMask: number;
  11376. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11377. fogEnabled: boolean;
  11378. /** Gets or sets a boolean indicating if the sprites are pickable */
  11379. isPickable: boolean;
  11380. /** Defines the default width of a cell in the spritesheet */
  11381. cellWidth: number;
  11382. /** Defines the default height of a cell in the spritesheet */
  11383. cellHeight: number;
  11384. /** Associative array from JSON sprite data file */
  11385. private _cellData;
  11386. /** Array of sprite names from JSON sprite data file */
  11387. private _spriteMap;
  11388. /** True when packed cell data from JSON file is ready*/
  11389. private _packedAndReady;
  11390. /**
  11391. * An event triggered when the manager is disposed.
  11392. */
  11393. onDisposeObservable: Observable<SpriteManager>;
  11394. private _onDisposeObserver;
  11395. /**
  11396. * Callback called when the manager is disposed
  11397. */
  11398. onDispose: () => void;
  11399. private _capacity;
  11400. private _fromPacked;
  11401. private _spriteTexture;
  11402. private _epsilon;
  11403. private _scene;
  11404. private _vertexData;
  11405. private _buffer;
  11406. private _vertexBuffers;
  11407. private _indexBuffer;
  11408. private _effectBase;
  11409. private _effectFog;
  11410. /**
  11411. * Gets or sets the spritesheet texture
  11412. */
  11413. texture: Texture;
  11414. /**
  11415. * Creates a new sprite manager
  11416. * @param name defines the manager's name
  11417. * @param imgUrl defines the sprite sheet url
  11418. * @param capacity defines the maximum allowed number of sprites
  11419. * @param cellSize defines the size of a sprite cell
  11420. * @param scene defines the hosting scene
  11421. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11422. * @param samplingMode defines the smapling mode to use with spritesheet
  11423. * @param fromPacked set to false; do not alter
  11424. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11425. */
  11426. constructor(
  11427. /** defines the manager's name */
  11428. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11429. private _makePacked;
  11430. private _appendSpriteVertex;
  11431. /**
  11432. * Intersects the sprites with a ray
  11433. * @param ray defines the ray to intersect with
  11434. * @param camera defines the current active camera
  11435. * @param predicate defines a predicate used to select candidate sprites
  11436. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11437. * @returns null if no hit or a PickingInfo
  11438. */
  11439. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11440. /**
  11441. * Intersects the sprites with a ray
  11442. * @param ray defines the ray to intersect with
  11443. * @param camera defines the current active camera
  11444. * @param predicate defines a predicate used to select candidate sprites
  11445. * @returns null if no hit or a PickingInfo array
  11446. */
  11447. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11448. /**
  11449. * Render all child sprites
  11450. */
  11451. render(): void;
  11452. /**
  11453. * Release associated resources
  11454. */
  11455. dispose(): void;
  11456. }
  11457. }
  11458. declare module BABYLON {
  11459. /**
  11460. * Class used to represent a sprite
  11461. * @see http://doc.babylonjs.com/babylon101/sprites
  11462. */
  11463. export class Sprite {
  11464. /** defines the name */
  11465. name: string;
  11466. /** Gets or sets the current world position */
  11467. position: Vector3;
  11468. /** Gets or sets the main color */
  11469. color: Color4;
  11470. /** Gets or sets the width */
  11471. width: number;
  11472. /** Gets or sets the height */
  11473. height: number;
  11474. /** Gets or sets rotation angle */
  11475. angle: number;
  11476. /** Gets or sets the cell index in the sprite sheet */
  11477. cellIndex: number;
  11478. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11479. cellRef: string;
  11480. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11481. invertU: number;
  11482. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11483. invertV: number;
  11484. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11485. disposeWhenFinishedAnimating: boolean;
  11486. /** Gets the list of attached animations */
  11487. animations: Animation[];
  11488. /** Gets or sets a boolean indicating if the sprite can be picked */
  11489. isPickable: boolean;
  11490. /**
  11491. * Gets or sets the associated action manager
  11492. */
  11493. actionManager: Nullable<ActionManager>;
  11494. private _animationStarted;
  11495. private _loopAnimation;
  11496. private _fromIndex;
  11497. private _toIndex;
  11498. private _delay;
  11499. private _direction;
  11500. private _manager;
  11501. private _time;
  11502. private _onAnimationEnd;
  11503. /**
  11504. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11505. */
  11506. isVisible: boolean;
  11507. /**
  11508. * Gets or sets the sprite size
  11509. */
  11510. size: number;
  11511. /**
  11512. * Creates a new Sprite
  11513. * @param name defines the name
  11514. * @param manager defines the manager
  11515. */
  11516. constructor(
  11517. /** defines the name */
  11518. name: string, manager: ISpriteManager);
  11519. /**
  11520. * Starts an animation
  11521. * @param from defines the initial key
  11522. * @param to defines the end key
  11523. * @param loop defines if the animation must loop
  11524. * @param delay defines the start delay (in ms)
  11525. * @param onAnimationEnd defines a callback to call when animation ends
  11526. */
  11527. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11528. /** Stops current animation (if any) */
  11529. stopAnimation(): void;
  11530. /** @hidden */
  11531. _animate(deltaTime: number): void;
  11532. /** Release associated resources */
  11533. dispose(): void;
  11534. }
  11535. }
  11536. declare module BABYLON {
  11537. /**
  11538. * Information about the result of picking within a scene
  11539. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11540. */
  11541. export class PickingInfo {
  11542. /** @hidden */
  11543. _pickingUnavailable: boolean;
  11544. /**
  11545. * If the pick collided with an object
  11546. */
  11547. hit: boolean;
  11548. /**
  11549. * Distance away where the pick collided
  11550. */
  11551. distance: number;
  11552. /**
  11553. * The location of pick collision
  11554. */
  11555. pickedPoint: Nullable<Vector3>;
  11556. /**
  11557. * The mesh corresponding the the pick collision
  11558. */
  11559. pickedMesh: Nullable<AbstractMesh>;
  11560. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11561. bu: number;
  11562. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11563. bv: number;
  11564. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11565. faceId: number;
  11566. /** Id of the the submesh that was picked */
  11567. subMeshId: number;
  11568. /** If a sprite was picked, this will be the sprite the pick collided with */
  11569. pickedSprite: Nullable<Sprite>;
  11570. /**
  11571. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11572. */
  11573. originMesh: Nullable<AbstractMesh>;
  11574. /**
  11575. * The ray that was used to perform the picking.
  11576. */
  11577. ray: Nullable<Ray>;
  11578. /**
  11579. * Gets the normal correspodning to the face the pick collided with
  11580. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11581. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11582. * @returns The normal correspodning to the face the pick collided with
  11583. */
  11584. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11585. /**
  11586. * Gets the texture coordinates of where the pick occured
  11587. * @returns the vector containing the coordnates of the texture
  11588. */
  11589. getTextureCoordinates(): Nullable<Vector2>;
  11590. }
  11591. }
  11592. declare module BABYLON {
  11593. /**
  11594. * Gather the list of pointer event types as constants.
  11595. */
  11596. export class PointerEventTypes {
  11597. /**
  11598. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11599. */
  11600. static readonly POINTERDOWN: number;
  11601. /**
  11602. * The pointerup event is fired when a pointer is no longer active.
  11603. */
  11604. static readonly POINTERUP: number;
  11605. /**
  11606. * The pointermove event is fired when a pointer changes coordinates.
  11607. */
  11608. static readonly POINTERMOVE: number;
  11609. /**
  11610. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11611. */
  11612. static readonly POINTERWHEEL: number;
  11613. /**
  11614. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11615. */
  11616. static readonly POINTERPICK: number;
  11617. /**
  11618. * The pointertap event is fired when a the object has been touched and released without drag.
  11619. */
  11620. static readonly POINTERTAP: number;
  11621. /**
  11622. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11623. */
  11624. static readonly POINTERDOUBLETAP: number;
  11625. }
  11626. /**
  11627. * Base class of pointer info types.
  11628. */
  11629. export class PointerInfoBase {
  11630. /**
  11631. * Defines the type of event (PointerEventTypes)
  11632. */
  11633. type: number;
  11634. /**
  11635. * Defines the related dom event
  11636. */
  11637. event: PointerEvent | MouseWheelEvent;
  11638. /**
  11639. * Instantiates the base class of pointers info.
  11640. * @param type Defines the type of event (PointerEventTypes)
  11641. * @param event Defines the related dom event
  11642. */
  11643. constructor(
  11644. /**
  11645. * Defines the type of event (PointerEventTypes)
  11646. */
  11647. type: number,
  11648. /**
  11649. * Defines the related dom event
  11650. */
  11651. event: PointerEvent | MouseWheelEvent);
  11652. }
  11653. /**
  11654. * This class is used to store pointer related info for the onPrePointerObservable event.
  11655. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11656. */
  11657. export class PointerInfoPre extends PointerInfoBase {
  11658. /**
  11659. * Ray from a pointer if availible (eg. 6dof controller)
  11660. */
  11661. ray: Nullable<Ray>;
  11662. /**
  11663. * Defines the local position of the pointer on the canvas.
  11664. */
  11665. localPosition: Vector2;
  11666. /**
  11667. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11668. */
  11669. skipOnPointerObservable: boolean;
  11670. /**
  11671. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11672. * @param type Defines the type of event (PointerEventTypes)
  11673. * @param event Defines the related dom event
  11674. * @param localX Defines the local x coordinates of the pointer when the event occured
  11675. * @param localY Defines the local y coordinates of the pointer when the event occured
  11676. */
  11677. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11678. }
  11679. /**
  11680. * This type contains all the data related to a pointer event in Babylon.js.
  11681. * 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.
  11682. */
  11683. export class PointerInfo extends PointerInfoBase {
  11684. /**
  11685. * Defines the picking info associated to the info (if any)\
  11686. */
  11687. pickInfo: Nullable<PickingInfo>;
  11688. /**
  11689. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11690. * @param type Defines the type of event (PointerEventTypes)
  11691. * @param event Defines the related dom event
  11692. * @param pickInfo Defines the picking info associated to the info (if any)\
  11693. */
  11694. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11695. /**
  11696. * Defines the picking info associated to the info (if any)\
  11697. */
  11698. pickInfo: Nullable<PickingInfo>);
  11699. }
  11700. /**
  11701. * Data relating to a touch event on the screen.
  11702. */
  11703. export interface PointerTouch {
  11704. /**
  11705. * X coordinate of touch.
  11706. */
  11707. x: number;
  11708. /**
  11709. * Y coordinate of touch.
  11710. */
  11711. y: number;
  11712. /**
  11713. * Id of touch. Unique for each finger.
  11714. */
  11715. pointerId: number;
  11716. /**
  11717. * Event type passed from DOM.
  11718. */
  11719. type: any;
  11720. }
  11721. }
  11722. declare module BABYLON {
  11723. /**
  11724. * Manage the mouse inputs to control the movement of a free camera.
  11725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11726. */
  11727. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11728. /**
  11729. * Define if touch is enabled in the mouse input
  11730. */
  11731. touchEnabled: boolean;
  11732. /**
  11733. * Defines the camera the input is attached to.
  11734. */
  11735. camera: FreeCamera;
  11736. /**
  11737. * Defines the buttons associated with the input to handle camera move.
  11738. */
  11739. buttons: number[];
  11740. /**
  11741. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11742. */
  11743. angularSensibility: number;
  11744. private _pointerInput;
  11745. private _onMouseMove;
  11746. private _observer;
  11747. private previousPosition;
  11748. /**
  11749. * Observable for when a pointer move event occurs containing the move offset
  11750. */
  11751. onPointerMovedObservable: Observable<{
  11752. offsetX: number;
  11753. offsetY: number;
  11754. }>;
  11755. /**
  11756. * @hidden
  11757. * If the camera should be rotated automatically based on pointer movement
  11758. */
  11759. _allowCameraRotation: boolean;
  11760. /**
  11761. * Manage the mouse inputs to control the movement of a free camera.
  11762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11763. * @param touchEnabled Defines if touch is enabled or not
  11764. */
  11765. constructor(
  11766. /**
  11767. * Define if touch is enabled in the mouse input
  11768. */
  11769. touchEnabled?: boolean);
  11770. /**
  11771. * Attach the input controls to a specific dom element to get the input from.
  11772. * @param element Defines the element the controls should be listened from
  11773. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11774. */
  11775. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11776. /**
  11777. * Called on JS contextmenu event.
  11778. * Override this method to provide functionality.
  11779. */
  11780. protected onContextMenu(evt: PointerEvent): void;
  11781. /**
  11782. * Detach the current controls from the specified dom element.
  11783. * @param element Defines the element to stop listening the inputs from
  11784. */
  11785. detachControl(element: Nullable<HTMLElement>): void;
  11786. /**
  11787. * Gets the class name of the current intput.
  11788. * @returns the class name
  11789. */
  11790. getClassName(): string;
  11791. /**
  11792. * Get the friendly name associated with the input class.
  11793. * @returns the input friendly name
  11794. */
  11795. getSimpleName(): string;
  11796. }
  11797. }
  11798. declare module BABYLON {
  11799. /**
  11800. * Manage the touch inputs to control the movement of a free camera.
  11801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11802. */
  11803. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11804. /**
  11805. * Defines the camera the input is attached to.
  11806. */
  11807. camera: FreeCamera;
  11808. /**
  11809. * Defines the touch sensibility for rotation.
  11810. * The higher the faster.
  11811. */
  11812. touchAngularSensibility: number;
  11813. /**
  11814. * Defines the touch sensibility for move.
  11815. * The higher the faster.
  11816. */
  11817. touchMoveSensibility: number;
  11818. private _offsetX;
  11819. private _offsetY;
  11820. private _pointerPressed;
  11821. private _pointerInput;
  11822. private _observer;
  11823. private _onLostFocus;
  11824. /**
  11825. * Attach the input controls to a specific dom element to get the input from.
  11826. * @param element Defines the element the controls should be listened from
  11827. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11828. */
  11829. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11830. /**
  11831. * Detach the current controls from the specified dom element.
  11832. * @param element Defines the element to stop listening the inputs from
  11833. */
  11834. detachControl(element: Nullable<HTMLElement>): void;
  11835. /**
  11836. * Update the current camera state depending on the inputs that have been used this frame.
  11837. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11838. */
  11839. checkInputs(): void;
  11840. /**
  11841. * Gets the class name of the current intput.
  11842. * @returns the class name
  11843. */
  11844. getClassName(): string;
  11845. /**
  11846. * Get the friendly name associated with the input class.
  11847. * @returns the input friendly name
  11848. */
  11849. getSimpleName(): string;
  11850. }
  11851. }
  11852. declare module BABYLON {
  11853. /**
  11854. * Default Inputs manager for the FreeCamera.
  11855. * It groups all the default supported inputs for ease of use.
  11856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11857. */
  11858. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11859. /**
  11860. * @hidden
  11861. */
  11862. _mouseInput: Nullable<FreeCameraMouseInput>;
  11863. /**
  11864. * Instantiates a new FreeCameraInputsManager.
  11865. * @param camera Defines the camera the inputs belong to
  11866. */
  11867. constructor(camera: FreeCamera);
  11868. /**
  11869. * Add keyboard input support to the input manager.
  11870. * @returns the current input manager
  11871. */
  11872. addKeyboard(): FreeCameraInputsManager;
  11873. /**
  11874. * Add mouse input support to the input manager.
  11875. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11876. * @returns the current input manager
  11877. */
  11878. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11879. /**
  11880. * Removes the mouse input support from the manager
  11881. * @returns the current input manager
  11882. */
  11883. removeMouse(): FreeCameraInputsManager;
  11884. /**
  11885. * Add touch input support to the input manager.
  11886. * @returns the current input manager
  11887. */
  11888. addTouch(): FreeCameraInputsManager;
  11889. /**
  11890. * Remove all attached input methods from a camera
  11891. */
  11892. clear(): void;
  11893. }
  11894. }
  11895. declare module BABYLON {
  11896. /**
  11897. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11898. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11899. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11900. */
  11901. export class FreeCamera extends TargetCamera {
  11902. /**
  11903. * Define the collision ellipsoid of the camera.
  11904. * This is helpful to simulate a camera body like the player body around the camera
  11905. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11906. */
  11907. ellipsoid: Vector3;
  11908. /**
  11909. * Define an offset for the position of the ellipsoid around the camera.
  11910. * This can be helpful to determine the center of the body near the gravity center of the body
  11911. * instead of its head.
  11912. */
  11913. ellipsoidOffset: Vector3;
  11914. /**
  11915. * Enable or disable collisions of the camera with the rest of the scene objects.
  11916. */
  11917. checkCollisions: boolean;
  11918. /**
  11919. * Enable or disable gravity on the camera.
  11920. */
  11921. applyGravity: boolean;
  11922. /**
  11923. * Define the input manager associated to the camera.
  11924. */
  11925. inputs: FreeCameraInputsManager;
  11926. /**
  11927. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11928. * Higher values reduce sensitivity.
  11929. */
  11930. /**
  11931. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11932. * Higher values reduce sensitivity.
  11933. */
  11934. angularSensibility: number;
  11935. /**
  11936. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11937. */
  11938. keysUp: number[];
  11939. /**
  11940. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11941. */
  11942. keysDown: number[];
  11943. /**
  11944. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11945. */
  11946. keysLeft: number[];
  11947. /**
  11948. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11949. */
  11950. keysRight: number[];
  11951. /**
  11952. * Event raised when the camera collide with a mesh in the scene.
  11953. */
  11954. onCollide: (collidedMesh: AbstractMesh) => void;
  11955. private _collider;
  11956. private _needMoveForGravity;
  11957. private _oldPosition;
  11958. private _diffPosition;
  11959. private _newPosition;
  11960. /** @hidden */
  11961. _localDirection: Vector3;
  11962. /** @hidden */
  11963. _transformedDirection: Vector3;
  11964. /**
  11965. * Instantiates a Free Camera.
  11966. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11967. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11968. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11969. * @param name Define the name of the camera in the scene
  11970. * @param position Define the start position of the camera in the scene
  11971. * @param scene Define the scene the camera belongs to
  11972. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11973. */
  11974. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11975. /**
  11976. * Attached controls to the current camera.
  11977. * @param element Defines the element the controls should be listened from
  11978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11979. */
  11980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11981. /**
  11982. * Detach the current controls from the camera.
  11983. * The camera will stop reacting to inputs.
  11984. * @param element Defines the element to stop listening the inputs from
  11985. */
  11986. detachControl(element: HTMLElement): void;
  11987. private _collisionMask;
  11988. /**
  11989. * Define a collision mask to limit the list of object the camera can collide with
  11990. */
  11991. collisionMask: number;
  11992. /** @hidden */
  11993. _collideWithWorld(displacement: Vector3): void;
  11994. private _onCollisionPositionChange;
  11995. /** @hidden */
  11996. _checkInputs(): void;
  11997. /** @hidden */
  11998. _decideIfNeedsToMove(): boolean;
  11999. /** @hidden */
  12000. _updatePosition(): void;
  12001. /**
  12002. * Destroy the camera and release the current resources hold by it.
  12003. */
  12004. dispose(): void;
  12005. /**
  12006. * Gets the current object class name.
  12007. * @return the class name
  12008. */
  12009. getClassName(): string;
  12010. }
  12011. }
  12012. declare module BABYLON {
  12013. /**
  12014. * Represents a gamepad control stick position
  12015. */
  12016. export class StickValues {
  12017. /**
  12018. * The x component of the control stick
  12019. */
  12020. x: number;
  12021. /**
  12022. * The y component of the control stick
  12023. */
  12024. y: number;
  12025. /**
  12026. * Initializes the gamepad x and y control stick values
  12027. * @param x The x component of the gamepad control stick value
  12028. * @param y The y component of the gamepad control stick value
  12029. */
  12030. constructor(
  12031. /**
  12032. * The x component of the control stick
  12033. */
  12034. x: number,
  12035. /**
  12036. * The y component of the control stick
  12037. */
  12038. y: number);
  12039. }
  12040. /**
  12041. * An interface which manages callbacks for gamepad button changes
  12042. */
  12043. export interface GamepadButtonChanges {
  12044. /**
  12045. * Called when a gamepad has been changed
  12046. */
  12047. changed: boolean;
  12048. /**
  12049. * Called when a gamepad press event has been triggered
  12050. */
  12051. pressChanged: boolean;
  12052. /**
  12053. * Called when a touch event has been triggered
  12054. */
  12055. touchChanged: boolean;
  12056. /**
  12057. * Called when a value has changed
  12058. */
  12059. valueChanged: boolean;
  12060. }
  12061. /**
  12062. * Represents a gamepad
  12063. */
  12064. export class Gamepad {
  12065. /**
  12066. * The id of the gamepad
  12067. */
  12068. id: string;
  12069. /**
  12070. * The index of the gamepad
  12071. */
  12072. index: number;
  12073. /**
  12074. * The browser gamepad
  12075. */
  12076. browserGamepad: any;
  12077. /**
  12078. * Specifies what type of gamepad this represents
  12079. */
  12080. type: number;
  12081. private _leftStick;
  12082. private _rightStick;
  12083. /** @hidden */
  12084. _isConnected: boolean;
  12085. private _leftStickAxisX;
  12086. private _leftStickAxisY;
  12087. private _rightStickAxisX;
  12088. private _rightStickAxisY;
  12089. /**
  12090. * Triggered when the left control stick has been changed
  12091. */
  12092. private _onleftstickchanged;
  12093. /**
  12094. * Triggered when the right control stick has been changed
  12095. */
  12096. private _onrightstickchanged;
  12097. /**
  12098. * Represents a gamepad controller
  12099. */
  12100. static GAMEPAD: number;
  12101. /**
  12102. * Represents a generic controller
  12103. */
  12104. static GENERIC: number;
  12105. /**
  12106. * Represents an XBox controller
  12107. */
  12108. static XBOX: number;
  12109. /**
  12110. * Represents a pose-enabled controller
  12111. */
  12112. static POSE_ENABLED: number;
  12113. /**
  12114. * Represents an Dual Shock controller
  12115. */
  12116. static DUALSHOCK: number;
  12117. /**
  12118. * Specifies whether the left control stick should be Y-inverted
  12119. */
  12120. protected _invertLeftStickY: boolean;
  12121. /**
  12122. * Specifies if the gamepad has been connected
  12123. */
  12124. readonly isConnected: boolean;
  12125. /**
  12126. * Initializes the gamepad
  12127. * @param id The id of the gamepad
  12128. * @param index The index of the gamepad
  12129. * @param browserGamepad The browser gamepad
  12130. * @param leftStickX The x component of the left joystick
  12131. * @param leftStickY The y component of the left joystick
  12132. * @param rightStickX The x component of the right joystick
  12133. * @param rightStickY The y component of the right joystick
  12134. */
  12135. constructor(
  12136. /**
  12137. * The id of the gamepad
  12138. */
  12139. id: string,
  12140. /**
  12141. * The index of the gamepad
  12142. */
  12143. index: number,
  12144. /**
  12145. * The browser gamepad
  12146. */
  12147. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12148. /**
  12149. * Callback triggered when the left joystick has changed
  12150. * @param callback
  12151. */
  12152. onleftstickchanged(callback: (values: StickValues) => void): void;
  12153. /**
  12154. * Callback triggered when the right joystick has changed
  12155. * @param callback
  12156. */
  12157. onrightstickchanged(callback: (values: StickValues) => void): void;
  12158. /**
  12159. * Gets the left joystick
  12160. */
  12161. /**
  12162. * Sets the left joystick values
  12163. */
  12164. leftStick: StickValues;
  12165. /**
  12166. * Gets the right joystick
  12167. */
  12168. /**
  12169. * Sets the right joystick value
  12170. */
  12171. rightStick: StickValues;
  12172. /**
  12173. * Updates the gamepad joystick positions
  12174. */
  12175. update(): void;
  12176. /**
  12177. * Disposes the gamepad
  12178. */
  12179. dispose(): void;
  12180. }
  12181. /**
  12182. * Represents a generic gamepad
  12183. */
  12184. export class GenericPad extends Gamepad {
  12185. private _buttons;
  12186. private _onbuttondown;
  12187. private _onbuttonup;
  12188. /**
  12189. * Observable triggered when a button has been pressed
  12190. */
  12191. onButtonDownObservable: Observable<number>;
  12192. /**
  12193. * Observable triggered when a button has been released
  12194. */
  12195. onButtonUpObservable: Observable<number>;
  12196. /**
  12197. * Callback triggered when a button has been pressed
  12198. * @param callback Called when a button has been pressed
  12199. */
  12200. onbuttondown(callback: (buttonPressed: number) => void): void;
  12201. /**
  12202. * Callback triggered when a button has been released
  12203. * @param callback Called when a button has been released
  12204. */
  12205. onbuttonup(callback: (buttonReleased: number) => void): void;
  12206. /**
  12207. * Initializes the generic gamepad
  12208. * @param id The id of the generic gamepad
  12209. * @param index The index of the generic gamepad
  12210. * @param browserGamepad The browser gamepad
  12211. */
  12212. constructor(id: string, index: number, browserGamepad: any);
  12213. private _setButtonValue;
  12214. /**
  12215. * Updates the generic gamepad
  12216. */
  12217. update(): void;
  12218. /**
  12219. * Disposes the generic gamepad
  12220. */
  12221. dispose(): void;
  12222. }
  12223. }
  12224. declare module BABYLON {
  12225. interface Engine {
  12226. /**
  12227. * Creates a raw texture
  12228. * @param data defines the data to store in the texture
  12229. * @param width defines the width of the texture
  12230. * @param height defines the height of the texture
  12231. * @param format defines the format of the data
  12232. * @param generateMipMaps defines if the engine should generate the mip levels
  12233. * @param invertY defines if data must be stored with Y axis inverted
  12234. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12235. * @param compression defines the compression used (null by default)
  12236. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12237. * @returns the raw texture inside an InternalTexture
  12238. */
  12239. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12240. /**
  12241. * Update a raw texture
  12242. * @param texture defines the texture to update
  12243. * @param data defines the data to store in the texture
  12244. * @param format defines the format of the data
  12245. * @param invertY defines if data must be stored with Y axis inverted
  12246. */
  12247. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12248. /**
  12249. * Update a raw texture
  12250. * @param texture defines the texture to update
  12251. * @param data defines the data to store in the texture
  12252. * @param format defines the format of the data
  12253. * @param invertY defines if data must be stored with Y axis inverted
  12254. * @param compression defines the compression used (null by default)
  12255. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12256. */
  12257. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12258. /**
  12259. * Creates a new raw cube texture
  12260. * @param data defines the array of data to use to create each face
  12261. * @param size defines the size of the textures
  12262. * @param format defines the format of the data
  12263. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12264. * @param generateMipMaps defines if the engine should generate the mip levels
  12265. * @param invertY defines if data must be stored with Y axis inverted
  12266. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12267. * @param compression defines the compression used (null by default)
  12268. * @returns the cube texture as an InternalTexture
  12269. */
  12270. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12271. /**
  12272. * Update a raw cube texture
  12273. * @param texture defines the texture to udpdate
  12274. * @param data defines the data to store
  12275. * @param format defines the data format
  12276. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12277. * @param invertY defines if data must be stored with Y axis inverted
  12278. */
  12279. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12280. /**
  12281. * Update a raw cube texture
  12282. * @param texture defines the texture to udpdate
  12283. * @param data defines the data to store
  12284. * @param format defines the data format
  12285. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12286. * @param invertY defines if data must be stored with Y axis inverted
  12287. * @param compression defines the compression used (null by default)
  12288. */
  12289. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12290. /**
  12291. * Update a raw cube texture
  12292. * @param texture defines the texture to udpdate
  12293. * @param data defines the data to store
  12294. * @param format defines the data format
  12295. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12296. * @param invertY defines if data must be stored with Y axis inverted
  12297. * @param compression defines the compression used (null by default)
  12298. * @param level defines which level of the texture to update
  12299. */
  12300. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12301. /**
  12302. * Creates a new raw cube texture from a specified url
  12303. * @param url defines the url where the data is located
  12304. * @param scene defines the current scene
  12305. * @param size defines the size of the textures
  12306. * @param format defines the format of the data
  12307. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12308. * @param noMipmap defines if the engine should avoid generating the mip levels
  12309. * @param callback defines a callback used to extract texture data from loaded data
  12310. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12311. * @param onLoad defines a callback called when texture is loaded
  12312. * @param onError defines a callback called if there is an error
  12313. * @returns the cube texture as an InternalTexture
  12314. */
  12315. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12316. /**
  12317. * Creates a new raw cube texture from a specified url
  12318. * @param url defines the url where the data is located
  12319. * @param scene defines the current scene
  12320. * @param size defines the size of the textures
  12321. * @param format defines the format of the data
  12322. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12323. * @param noMipmap defines if the engine should avoid generating the mip levels
  12324. * @param callback defines a callback used to extract texture data from loaded data
  12325. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12326. * @param onLoad defines a callback called when texture is loaded
  12327. * @param onError defines a callback called if there is an error
  12328. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12329. * @param invertY defines if data must be stored with Y axis inverted
  12330. * @returns the cube texture as an InternalTexture
  12331. */
  12332. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12333. /**
  12334. * Creates a new raw 3D texture
  12335. * @param data defines the data used to create the texture
  12336. * @param width defines the width of the texture
  12337. * @param height defines the height of the texture
  12338. * @param depth defines the depth of the texture
  12339. * @param format defines the format of the texture
  12340. * @param generateMipMaps defines if the engine must generate mip levels
  12341. * @param invertY defines if data must be stored with Y axis inverted
  12342. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12343. * @param compression defines the compressed used (can be null)
  12344. * @param textureType defines the compressed used (can be null)
  12345. * @returns a new raw 3D texture (stored in an InternalTexture)
  12346. */
  12347. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12348. /**
  12349. * Update a raw 3D texture
  12350. * @param texture defines the texture to update
  12351. * @param data defines the data to store
  12352. * @param format defines the data format
  12353. * @param invertY defines if data must be stored with Y axis inverted
  12354. */
  12355. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12356. /**
  12357. * Update a raw 3D texture
  12358. * @param texture defines the texture to update
  12359. * @param data defines the data to store
  12360. * @param format defines the data format
  12361. * @param invertY defines if data must be stored with Y axis inverted
  12362. * @param compression defines the used compression (can be null)
  12363. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12364. */
  12365. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12366. }
  12367. }
  12368. declare module BABYLON {
  12369. /**
  12370. * Raw texture can help creating a texture directly from an array of data.
  12371. * This can be super useful if you either get the data from an uncompressed source or
  12372. * if you wish to create your texture pixel by pixel.
  12373. */
  12374. export class RawTexture extends Texture {
  12375. /**
  12376. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12377. */
  12378. format: number;
  12379. private _engine;
  12380. /**
  12381. * Instantiates a new RawTexture.
  12382. * Raw texture can help creating a texture directly from an array of data.
  12383. * This can be super useful if you either get the data from an uncompressed source or
  12384. * if you wish to create your texture pixel by pixel.
  12385. * @param data define the array of data to use to create the texture
  12386. * @param width define the width of the texture
  12387. * @param height define the height of the texture
  12388. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12389. * @param scene define the scene the texture belongs to
  12390. * @param generateMipMaps define whether mip maps should be generated or not
  12391. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12392. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12393. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12394. */
  12395. constructor(data: ArrayBufferView, width: number, height: number,
  12396. /**
  12397. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12398. */
  12399. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12400. /**
  12401. * Updates the texture underlying data.
  12402. * @param data Define the new data of the texture
  12403. */
  12404. update(data: ArrayBufferView): void;
  12405. /**
  12406. * Creates a luminance texture from some data.
  12407. * @param data Define the texture data
  12408. * @param width Define the width of the texture
  12409. * @param height Define the height of the texture
  12410. * @param scene Define the scene the texture belongs to
  12411. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12412. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12413. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12414. * @returns the luminance texture
  12415. */
  12416. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12417. /**
  12418. * Creates a luminance alpha texture from some data.
  12419. * @param data Define the texture data
  12420. * @param width Define the width of the texture
  12421. * @param height Define the height of the texture
  12422. * @param scene Define the scene the texture belongs to
  12423. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12424. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12425. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12426. * @returns the luminance alpha texture
  12427. */
  12428. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12429. /**
  12430. * Creates an alpha texture from some data.
  12431. * @param data Define the texture data
  12432. * @param width Define the width of the texture
  12433. * @param height Define the height of the texture
  12434. * @param scene Define the scene the texture belongs to
  12435. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12436. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12437. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12438. * @returns the alpha texture
  12439. */
  12440. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12441. /**
  12442. * Creates a RGB texture from some data.
  12443. * @param data Define the texture data
  12444. * @param width Define the width of the texture
  12445. * @param height Define the height of the texture
  12446. * @param scene Define the scene the texture belongs to
  12447. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12448. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12449. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12450. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12451. * @returns the RGB alpha texture
  12452. */
  12453. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12454. /**
  12455. * Creates a RGBA texture from some data.
  12456. * @param data Define the texture data
  12457. * @param width Define the width of the texture
  12458. * @param height Define the height of the texture
  12459. * @param scene Define the scene the texture belongs to
  12460. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12461. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12462. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12463. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12464. * @returns the RGBA texture
  12465. */
  12466. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12467. /**
  12468. * Creates a R texture from some data.
  12469. * @param data Define the texture data
  12470. * @param width Define the width of the texture
  12471. * @param height Define the height of the texture
  12472. * @param scene Define the scene the texture belongs to
  12473. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12474. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12475. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12476. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12477. * @returns the R texture
  12478. */
  12479. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12480. }
  12481. }
  12482. declare module BABYLON {
  12483. /**
  12484. * Interface for the size containing width and height
  12485. */
  12486. export interface ISize {
  12487. /**
  12488. * Width
  12489. */
  12490. width: number;
  12491. /**
  12492. * Heighht
  12493. */
  12494. height: number;
  12495. }
  12496. /**
  12497. * Size containing widht and height
  12498. */
  12499. export class Size implements ISize {
  12500. /**
  12501. * Width
  12502. */
  12503. width: number;
  12504. /**
  12505. * Height
  12506. */
  12507. height: number;
  12508. /**
  12509. * Creates a Size object from the given width and height (floats).
  12510. * @param width width of the new size
  12511. * @param height height of the new size
  12512. */
  12513. constructor(width: number, height: number);
  12514. /**
  12515. * Returns a string with the Size width and height
  12516. * @returns a string with the Size width and height
  12517. */
  12518. toString(): string;
  12519. /**
  12520. * "Size"
  12521. * @returns the string "Size"
  12522. */
  12523. getClassName(): string;
  12524. /**
  12525. * Returns the Size hash code.
  12526. * @returns a hash code for a unique width and height
  12527. */
  12528. getHashCode(): number;
  12529. /**
  12530. * Updates the current size from the given one.
  12531. * @param src the given size
  12532. */
  12533. copyFrom(src: Size): void;
  12534. /**
  12535. * Updates in place the current Size from the given floats.
  12536. * @param width width of the new size
  12537. * @param height height of the new size
  12538. * @returns the updated Size.
  12539. */
  12540. copyFromFloats(width: number, height: number): Size;
  12541. /**
  12542. * Updates in place the current Size from the given floats.
  12543. * @param width width to set
  12544. * @param height height to set
  12545. * @returns the updated Size.
  12546. */
  12547. set(width: number, height: number): Size;
  12548. /**
  12549. * Multiplies the width and height by numbers
  12550. * @param w factor to multiple the width by
  12551. * @param h factor to multiple the height by
  12552. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12553. */
  12554. multiplyByFloats(w: number, h: number): Size;
  12555. /**
  12556. * Clones the size
  12557. * @returns a new Size copied from the given one.
  12558. */
  12559. clone(): Size;
  12560. /**
  12561. * True if the current Size and the given one width and height are strictly equal.
  12562. * @param other the other size to compare against
  12563. * @returns True if the current Size and the given one width and height are strictly equal.
  12564. */
  12565. equals(other: Size): boolean;
  12566. /**
  12567. * The surface of the Size : width * height (float).
  12568. */
  12569. readonly surface: number;
  12570. /**
  12571. * Create a new size of zero
  12572. * @returns a new Size set to (0.0, 0.0)
  12573. */
  12574. static Zero(): Size;
  12575. /**
  12576. * Sums the width and height of two sizes
  12577. * @param otherSize size to add to this size
  12578. * @returns a new Size set as the addition result of the current Size and the given one.
  12579. */
  12580. add(otherSize: Size): Size;
  12581. /**
  12582. * Subtracts the width and height of two
  12583. * @param otherSize size to subtract to this size
  12584. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12585. */
  12586. subtract(otherSize: Size): Size;
  12587. /**
  12588. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12589. * @param start starting size to lerp between
  12590. * @param end end size to lerp between
  12591. * @param amount amount to lerp between the start and end values
  12592. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12593. */
  12594. static Lerp(start: Size, end: Size, amount: number): Size;
  12595. }
  12596. }
  12597. declare module BABYLON {
  12598. /**
  12599. * Defines a runtime animation
  12600. */
  12601. export class RuntimeAnimation {
  12602. private _events;
  12603. /**
  12604. * The current frame of the runtime animation
  12605. */
  12606. private _currentFrame;
  12607. /**
  12608. * The animation used by the runtime animation
  12609. */
  12610. private _animation;
  12611. /**
  12612. * The target of the runtime animation
  12613. */
  12614. private _target;
  12615. /**
  12616. * The initiating animatable
  12617. */
  12618. private _host;
  12619. /**
  12620. * The original value of the runtime animation
  12621. */
  12622. private _originalValue;
  12623. /**
  12624. * The original blend value of the runtime animation
  12625. */
  12626. private _originalBlendValue;
  12627. /**
  12628. * The offsets cache of the runtime animation
  12629. */
  12630. private _offsetsCache;
  12631. /**
  12632. * The high limits cache of the runtime animation
  12633. */
  12634. private _highLimitsCache;
  12635. /**
  12636. * Specifies if the runtime animation has been stopped
  12637. */
  12638. private _stopped;
  12639. /**
  12640. * The blending factor of the runtime animation
  12641. */
  12642. private _blendingFactor;
  12643. /**
  12644. * The BabylonJS scene
  12645. */
  12646. private _scene;
  12647. /**
  12648. * The current value of the runtime animation
  12649. */
  12650. private _currentValue;
  12651. /** @hidden */
  12652. _animationState: _IAnimationState;
  12653. /**
  12654. * The active target of the runtime animation
  12655. */
  12656. private _activeTargets;
  12657. private _currentActiveTarget;
  12658. private _directTarget;
  12659. /**
  12660. * The target path of the runtime animation
  12661. */
  12662. private _targetPath;
  12663. /**
  12664. * The weight of the runtime animation
  12665. */
  12666. private _weight;
  12667. /**
  12668. * The ratio offset of the runtime animation
  12669. */
  12670. private _ratioOffset;
  12671. /**
  12672. * The previous delay of the runtime animation
  12673. */
  12674. private _previousDelay;
  12675. /**
  12676. * The previous ratio of the runtime animation
  12677. */
  12678. private _previousRatio;
  12679. private _enableBlending;
  12680. private _keys;
  12681. private _minFrame;
  12682. private _maxFrame;
  12683. private _minValue;
  12684. private _maxValue;
  12685. private _targetIsArray;
  12686. /**
  12687. * Gets the current frame of the runtime animation
  12688. */
  12689. readonly currentFrame: number;
  12690. /**
  12691. * Gets the weight of the runtime animation
  12692. */
  12693. readonly weight: number;
  12694. /**
  12695. * Gets the current value of the runtime animation
  12696. */
  12697. readonly currentValue: any;
  12698. /**
  12699. * Gets the target path of the runtime animation
  12700. */
  12701. readonly targetPath: string;
  12702. /**
  12703. * Gets the actual target of the runtime animation
  12704. */
  12705. readonly target: any;
  12706. /** @hidden */
  12707. _onLoop: () => void;
  12708. /**
  12709. * Create a new RuntimeAnimation object
  12710. * @param target defines the target of the animation
  12711. * @param animation defines the source animation object
  12712. * @param scene defines the hosting scene
  12713. * @param host defines the initiating Animatable
  12714. */
  12715. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12716. private _preparePath;
  12717. /**
  12718. * Gets the animation from the runtime animation
  12719. */
  12720. readonly animation: Animation;
  12721. /**
  12722. * Resets the runtime animation to the beginning
  12723. * @param restoreOriginal defines whether to restore the target property to the original value
  12724. */
  12725. reset(restoreOriginal?: boolean): void;
  12726. /**
  12727. * Specifies if the runtime animation is stopped
  12728. * @returns Boolean specifying if the runtime animation is stopped
  12729. */
  12730. isStopped(): boolean;
  12731. /**
  12732. * Disposes of the runtime animation
  12733. */
  12734. dispose(): void;
  12735. /**
  12736. * Apply the interpolated value to the target
  12737. * @param currentValue defines the value computed by the animation
  12738. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12739. */
  12740. setValue(currentValue: any, weight: number): void;
  12741. private _getOriginalValues;
  12742. private _setValue;
  12743. /**
  12744. * Gets the loop pmode of the runtime animation
  12745. * @returns Loop Mode
  12746. */
  12747. private _getCorrectLoopMode;
  12748. /**
  12749. * Move the current animation to a given frame
  12750. * @param frame defines the frame to move to
  12751. */
  12752. goToFrame(frame: number): void;
  12753. /**
  12754. * @hidden Internal use only
  12755. */
  12756. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12757. /**
  12758. * Execute the current animation
  12759. * @param delay defines the delay to add to the current frame
  12760. * @param from defines the lower bound of the animation range
  12761. * @param to defines the upper bound of the animation range
  12762. * @param loop defines if the current animation must loop
  12763. * @param speedRatio defines the current speed ratio
  12764. * @param weight defines the weight of the animation (default is -1 so no weight)
  12765. * @param onLoop optional callback called when animation loops
  12766. * @returns a boolean indicating if the animation is running
  12767. */
  12768. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12769. }
  12770. }
  12771. declare module BABYLON {
  12772. /**
  12773. * Class used to store an actual running animation
  12774. */
  12775. export class Animatable {
  12776. /** defines the target object */
  12777. target: any;
  12778. /** defines the starting frame number (default is 0) */
  12779. fromFrame: number;
  12780. /** defines the ending frame number (default is 100) */
  12781. toFrame: number;
  12782. /** defines if the animation must loop (default is false) */
  12783. loopAnimation: boolean;
  12784. /** defines a callback to call when animation ends if it is not looping */
  12785. onAnimationEnd?: (() => void) | null | undefined;
  12786. /** defines a callback to call when animation loops */
  12787. onAnimationLoop?: (() => void) | null | undefined;
  12788. private _localDelayOffset;
  12789. private _pausedDelay;
  12790. private _runtimeAnimations;
  12791. private _paused;
  12792. private _scene;
  12793. private _speedRatio;
  12794. private _weight;
  12795. private _syncRoot;
  12796. /**
  12797. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12798. * This will only apply for non looping animation (default is true)
  12799. */
  12800. disposeOnEnd: boolean;
  12801. /**
  12802. * Gets a boolean indicating if the animation has started
  12803. */
  12804. animationStarted: boolean;
  12805. /**
  12806. * Observer raised when the animation ends
  12807. */
  12808. onAnimationEndObservable: Observable<Animatable>;
  12809. /**
  12810. * Observer raised when the animation loops
  12811. */
  12812. onAnimationLoopObservable: Observable<Animatable>;
  12813. /**
  12814. * Gets the root Animatable used to synchronize and normalize animations
  12815. */
  12816. readonly syncRoot: Nullable<Animatable>;
  12817. /**
  12818. * Gets the current frame of the first RuntimeAnimation
  12819. * Used to synchronize Animatables
  12820. */
  12821. readonly masterFrame: number;
  12822. /**
  12823. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12824. */
  12825. weight: number;
  12826. /**
  12827. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12828. */
  12829. speedRatio: number;
  12830. /**
  12831. * Creates a new Animatable
  12832. * @param scene defines the hosting scene
  12833. * @param target defines the target object
  12834. * @param fromFrame defines the starting frame number (default is 0)
  12835. * @param toFrame defines the ending frame number (default is 100)
  12836. * @param loopAnimation defines if the animation must loop (default is false)
  12837. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12838. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12839. * @param animations defines a group of animation to add to the new Animatable
  12840. * @param onAnimationLoop defines a callback to call when animation loops
  12841. */
  12842. constructor(scene: Scene,
  12843. /** defines the target object */
  12844. target: any,
  12845. /** defines the starting frame number (default is 0) */
  12846. fromFrame?: number,
  12847. /** defines the ending frame number (default is 100) */
  12848. toFrame?: number,
  12849. /** defines if the animation must loop (default is false) */
  12850. loopAnimation?: boolean, speedRatio?: number,
  12851. /** defines a callback to call when animation ends if it is not looping */
  12852. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12853. /** defines a callback to call when animation loops */
  12854. onAnimationLoop?: (() => void) | null | undefined);
  12855. /**
  12856. * Synchronize and normalize current Animatable with a source Animatable
  12857. * This is useful when using animation weights and when animations are not of the same length
  12858. * @param root defines the root Animatable to synchronize with
  12859. * @returns the current Animatable
  12860. */
  12861. syncWith(root: Animatable): Animatable;
  12862. /**
  12863. * Gets the list of runtime animations
  12864. * @returns an array of RuntimeAnimation
  12865. */
  12866. getAnimations(): RuntimeAnimation[];
  12867. /**
  12868. * Adds more animations to the current animatable
  12869. * @param target defines the target of the animations
  12870. * @param animations defines the new animations to add
  12871. */
  12872. appendAnimations(target: any, animations: Animation[]): void;
  12873. /**
  12874. * Gets the source animation for a specific property
  12875. * @param property defines the propertyu to look for
  12876. * @returns null or the source animation for the given property
  12877. */
  12878. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12879. /**
  12880. * Gets the runtime animation for a specific property
  12881. * @param property defines the propertyu to look for
  12882. * @returns null or the runtime animation for the given property
  12883. */
  12884. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12885. /**
  12886. * Resets the animatable to its original state
  12887. */
  12888. reset(): void;
  12889. /**
  12890. * Allows the animatable to blend with current running animations
  12891. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12892. * @param blendingSpeed defines the blending speed to use
  12893. */
  12894. enableBlending(blendingSpeed: number): void;
  12895. /**
  12896. * Disable animation blending
  12897. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12898. */
  12899. disableBlending(): void;
  12900. /**
  12901. * Jump directly to a given frame
  12902. * @param frame defines the frame to jump to
  12903. */
  12904. goToFrame(frame: number): void;
  12905. /**
  12906. * Pause the animation
  12907. */
  12908. pause(): void;
  12909. /**
  12910. * Restart the animation
  12911. */
  12912. restart(): void;
  12913. private _raiseOnAnimationEnd;
  12914. /**
  12915. * Stop and delete the current animation
  12916. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12917. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  12918. */
  12919. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12920. /**
  12921. * Wait asynchronously for the animation to end
  12922. * @returns a promise which will be fullfilled when the animation ends
  12923. */
  12924. waitAsync(): Promise<Animatable>;
  12925. /** @hidden */
  12926. _animate(delay: number): boolean;
  12927. }
  12928. interface Scene {
  12929. /** @hidden */
  12930. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12931. /** @hidden */
  12932. _processLateAnimationBindingsForMatrices(holder: {
  12933. totalWeight: number;
  12934. animations: RuntimeAnimation[];
  12935. originalValue: Matrix;
  12936. }): any;
  12937. /** @hidden */
  12938. _processLateAnimationBindingsForQuaternions(holder: {
  12939. totalWeight: number;
  12940. animations: RuntimeAnimation[];
  12941. originalValue: Quaternion;
  12942. }, refQuaternion: Quaternion): Quaternion;
  12943. /** @hidden */
  12944. _processLateAnimationBindings(): void;
  12945. /**
  12946. * Will start the animation sequence of a given target
  12947. * @param target defines the target
  12948. * @param from defines from which frame should animation start
  12949. * @param to defines until which frame should animation run.
  12950. * @param weight defines the weight to apply to the animation (1.0 by default)
  12951. * @param loop defines if the animation loops
  12952. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12953. * @param onAnimationEnd defines the function to be executed when the animation ends
  12954. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12955. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12956. * @param onAnimationLoop defines the callback to call when an animation loops
  12957. * @returns the animatable object created for this animation
  12958. */
  12959. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12960. /**
  12961. * Will start the animation sequence of a given target
  12962. * @param target defines the target
  12963. * @param from defines from which frame should animation start
  12964. * @param to defines until which frame should animation run.
  12965. * @param loop defines if the animation loops
  12966. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12967. * @param onAnimationEnd defines the function to be executed when the animation ends
  12968. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12969. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12970. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12971. * @param onAnimationLoop defines the callback to call when an animation loops
  12972. * @returns the animatable object created for this animation
  12973. */
  12974. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12975. /**
  12976. * Will start the animation sequence of a given target and its hierarchy
  12977. * @param target defines the target
  12978. * @param 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.
  12979. * @param from defines from which frame should animation start
  12980. * @param to defines until which frame should animation run.
  12981. * @param loop defines if the animation loops
  12982. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12983. * @param onAnimationEnd defines the function to be executed when the animation ends
  12984. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12985. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12986. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12987. * @param onAnimationLoop defines the callback to call when an animation loops
  12988. * @returns the list of created animatables
  12989. */
  12990. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  12991. /**
  12992. * Begin a new animation on a given node
  12993. * @param target defines the target where the animation will take place
  12994. * @param animations defines the list of animations to start
  12995. * @param from defines the initial value
  12996. * @param to defines the final value
  12997. * @param loop defines if you want animation to loop (off by default)
  12998. * @param speedRatio defines the speed ratio to apply to all animations
  12999. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13000. * @param onAnimationLoop defines the callback to call when an animation loops
  13001. * @returns the list of created animatables
  13002. */
  13003. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13004. /**
  13005. * Begin a new animation on a given node and its hierarchy
  13006. * @param target defines the root node where the animation will take place
  13007. * @param 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.
  13008. * @param animations defines the list of animations to start
  13009. * @param from defines the initial value
  13010. * @param to defines the final value
  13011. * @param loop defines if you want animation to loop (off by default)
  13012. * @param speedRatio defines the speed ratio to apply to all animations
  13013. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13014. * @param onAnimationLoop defines the callback to call when an animation loops
  13015. * @returns the list of animatables created for all nodes
  13016. */
  13017. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13018. /**
  13019. * Gets the animatable associated with a specific target
  13020. * @param target defines the target of the animatable
  13021. * @returns the required animatable if found
  13022. */
  13023. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13024. /**
  13025. * Gets all animatables associated with a given target
  13026. * @param target defines the target to look animatables for
  13027. * @returns an array of Animatables
  13028. */
  13029. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13030. /**
  13031. * Stops and removes all animations that have been applied to the scene
  13032. */
  13033. stopAllAnimations(): void;
  13034. }
  13035. interface Bone {
  13036. /**
  13037. * Copy an animation range from another bone
  13038. * @param source defines the source bone
  13039. * @param rangeName defines the range name to copy
  13040. * @param frameOffset defines the frame offset
  13041. * @param rescaleAsRequired defines if rescaling must be applied if required
  13042. * @param skelDimensionsRatio defines the scaling ratio
  13043. * @returns true if operation was successful
  13044. */
  13045. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13046. }
  13047. }
  13048. declare module BABYLON {
  13049. /**
  13050. * Class used to override all child animations of a given target
  13051. */
  13052. export class AnimationPropertiesOverride {
  13053. /**
  13054. * Gets or sets a value indicating if animation blending must be used
  13055. */
  13056. enableBlending: boolean;
  13057. /**
  13058. * Gets or sets the blending speed to use when enableBlending is true
  13059. */
  13060. blendingSpeed: number;
  13061. /**
  13062. * Gets or sets the default loop mode to use
  13063. */
  13064. loopMode: number;
  13065. }
  13066. }
  13067. declare module BABYLON {
  13068. /**
  13069. * Class used to handle skinning animations
  13070. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13071. */
  13072. export class Skeleton implements IAnimatable {
  13073. /** defines the skeleton name */
  13074. name: string;
  13075. /** defines the skeleton Id */
  13076. id: string;
  13077. /**
  13078. * Defines the list of child bones
  13079. */
  13080. bones: Bone[];
  13081. /**
  13082. * Defines an estimate of the dimension of the skeleton at rest
  13083. */
  13084. dimensionsAtRest: Vector3;
  13085. /**
  13086. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13087. */
  13088. needInitialSkinMatrix: boolean;
  13089. /**
  13090. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13091. */
  13092. overrideMesh: Nullable<AbstractMesh>;
  13093. /**
  13094. * Gets the list of animations attached to this skeleton
  13095. */
  13096. animations: Array<Animation>;
  13097. private _scene;
  13098. private _isDirty;
  13099. private _transformMatrices;
  13100. private _transformMatrixTexture;
  13101. private _meshesWithPoseMatrix;
  13102. private _animatables;
  13103. private _identity;
  13104. private _synchronizedWithMesh;
  13105. private _ranges;
  13106. private _lastAbsoluteTransformsUpdateId;
  13107. private _canUseTextureForBones;
  13108. private _uniqueId;
  13109. /** @hidden */
  13110. _numBonesWithLinkedTransformNode: number;
  13111. /** @hidden */
  13112. _hasWaitingData: Nullable<boolean>;
  13113. /**
  13114. * Specifies if the skeleton should be serialized
  13115. */
  13116. doNotSerialize: boolean;
  13117. private _useTextureToStoreBoneMatrices;
  13118. /**
  13119. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13120. * Please note that this option is not available if the hardware does not support it
  13121. */
  13122. useTextureToStoreBoneMatrices: boolean;
  13123. private _animationPropertiesOverride;
  13124. /**
  13125. * Gets or sets the animation properties override
  13126. */
  13127. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13128. /**
  13129. * List of inspectable custom properties (used by the Inspector)
  13130. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13131. */
  13132. inspectableCustomProperties: IInspectable[];
  13133. /**
  13134. * An observable triggered before computing the skeleton's matrices
  13135. */
  13136. onBeforeComputeObservable: Observable<Skeleton>;
  13137. /**
  13138. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13139. */
  13140. readonly isUsingTextureForMatrices: boolean;
  13141. /**
  13142. * Gets the unique ID of this skeleton
  13143. */
  13144. readonly uniqueId: number;
  13145. /**
  13146. * Creates a new skeleton
  13147. * @param name defines the skeleton name
  13148. * @param id defines the skeleton Id
  13149. * @param scene defines the hosting scene
  13150. */
  13151. constructor(
  13152. /** defines the skeleton name */
  13153. name: string,
  13154. /** defines the skeleton Id */
  13155. id: string, scene: Scene);
  13156. /**
  13157. * Gets the current object class name.
  13158. * @return the class name
  13159. */
  13160. getClassName(): string;
  13161. /**
  13162. * Returns an array containing the root bones
  13163. * @returns an array containing the root bones
  13164. */
  13165. getChildren(): Array<Bone>;
  13166. /**
  13167. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13168. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13169. * @returns a Float32Array containing matrices data
  13170. */
  13171. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13172. /**
  13173. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13174. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13175. * @returns a raw texture containing the data
  13176. */
  13177. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13178. /**
  13179. * Gets the current hosting scene
  13180. * @returns a scene object
  13181. */
  13182. getScene(): Scene;
  13183. /**
  13184. * Gets a string representing the current skeleton data
  13185. * @param fullDetails defines a boolean indicating if we want a verbose version
  13186. * @returns a string representing the current skeleton data
  13187. */
  13188. toString(fullDetails?: boolean): string;
  13189. /**
  13190. * Get bone's index searching by name
  13191. * @param name defines bone's name to search for
  13192. * @return the indice of the bone. Returns -1 if not found
  13193. */
  13194. getBoneIndexByName(name: string): number;
  13195. /**
  13196. * Creater a new animation range
  13197. * @param name defines the name of the range
  13198. * @param from defines the start key
  13199. * @param to defines the end key
  13200. */
  13201. createAnimationRange(name: string, from: number, to: number): void;
  13202. /**
  13203. * Delete a specific animation range
  13204. * @param name defines the name of the range
  13205. * @param deleteFrames defines if frames must be removed as well
  13206. */
  13207. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13208. /**
  13209. * Gets a specific animation range
  13210. * @param name defines the name of the range to look for
  13211. * @returns the requested animation range or null if not found
  13212. */
  13213. getAnimationRange(name: string): Nullable<AnimationRange>;
  13214. /**
  13215. * Gets the list of all animation ranges defined on this skeleton
  13216. * @returns an array
  13217. */
  13218. getAnimationRanges(): Nullable<AnimationRange>[];
  13219. /**
  13220. * Copy animation range from a source skeleton.
  13221. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13222. * @param source defines the source skeleton
  13223. * @param name defines the name of the range to copy
  13224. * @param rescaleAsRequired defines if rescaling must be applied if required
  13225. * @returns true if operation was successful
  13226. */
  13227. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13228. /**
  13229. * Forces the skeleton to go to rest pose
  13230. */
  13231. returnToRest(): void;
  13232. private _getHighestAnimationFrame;
  13233. /**
  13234. * Begin a specific animation range
  13235. * @param name defines the name of the range to start
  13236. * @param loop defines if looping must be turned on (false by default)
  13237. * @param speedRatio defines the speed ratio to apply (1 by default)
  13238. * @param onAnimationEnd defines a callback which will be called when animation will end
  13239. * @returns a new animatable
  13240. */
  13241. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13242. /** @hidden */
  13243. _markAsDirty(): void;
  13244. /** @hidden */
  13245. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13246. /** @hidden */
  13247. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13248. private _computeTransformMatrices;
  13249. /**
  13250. * Build all resources required to render a skeleton
  13251. */
  13252. prepare(): void;
  13253. /**
  13254. * Gets the list of animatables currently running for this skeleton
  13255. * @returns an array of animatables
  13256. */
  13257. getAnimatables(): IAnimatable[];
  13258. /**
  13259. * Clone the current skeleton
  13260. * @param name defines the name of the new skeleton
  13261. * @param id defines the id of the new skeleton
  13262. * @returns the new skeleton
  13263. */
  13264. clone(name: string, id: string): Skeleton;
  13265. /**
  13266. * Enable animation blending for this skeleton
  13267. * @param blendingSpeed defines the blending speed to apply
  13268. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13269. */
  13270. enableBlending(blendingSpeed?: number): void;
  13271. /**
  13272. * Releases all resources associated with the current skeleton
  13273. */
  13274. dispose(): void;
  13275. /**
  13276. * Serialize the skeleton in a JSON object
  13277. * @returns a JSON object
  13278. */
  13279. serialize(): any;
  13280. /**
  13281. * Creates a new skeleton from serialized data
  13282. * @param parsedSkeleton defines the serialized data
  13283. * @param scene defines the hosting scene
  13284. * @returns a new skeleton
  13285. */
  13286. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13287. /**
  13288. * Compute all node absolute transforms
  13289. * @param forceUpdate defines if computation must be done even if cache is up to date
  13290. */
  13291. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13292. /**
  13293. * Gets the root pose matrix
  13294. * @returns a matrix
  13295. */
  13296. getPoseMatrix(): Nullable<Matrix>;
  13297. /**
  13298. * Sorts bones per internal index
  13299. */
  13300. sortBones(): void;
  13301. private _sortBones;
  13302. }
  13303. }
  13304. declare module BABYLON {
  13305. /**
  13306. * Class used to store bone information
  13307. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13308. */
  13309. export class Bone extends Node {
  13310. /**
  13311. * defines the bone name
  13312. */
  13313. name: string;
  13314. private static _tmpVecs;
  13315. private static _tmpQuat;
  13316. private static _tmpMats;
  13317. /**
  13318. * Gets the list of child bones
  13319. */
  13320. children: Bone[];
  13321. /** Gets the animations associated with this bone */
  13322. animations: Animation[];
  13323. /**
  13324. * Gets or sets bone length
  13325. */
  13326. length: number;
  13327. /**
  13328. * @hidden Internal only
  13329. * Set this value to map this bone to a different index in the transform matrices
  13330. * Set this value to -1 to exclude the bone from the transform matrices
  13331. */
  13332. _index: Nullable<number>;
  13333. private _skeleton;
  13334. private _localMatrix;
  13335. private _restPose;
  13336. private _baseMatrix;
  13337. private _absoluteTransform;
  13338. private _invertedAbsoluteTransform;
  13339. private _parent;
  13340. private _scalingDeterminant;
  13341. private _worldTransform;
  13342. private _localScaling;
  13343. private _localRotation;
  13344. private _localPosition;
  13345. private _needToDecompose;
  13346. private _needToCompose;
  13347. /** @hidden */
  13348. _linkedTransformNode: Nullable<TransformNode>;
  13349. /** @hidden */
  13350. _waitingTransformNodeId: Nullable<string>;
  13351. /** @hidden */
  13352. /** @hidden */
  13353. _matrix: Matrix;
  13354. /**
  13355. * Create a new bone
  13356. * @param name defines the bone name
  13357. * @param skeleton defines the parent skeleton
  13358. * @param parentBone defines the parent (can be null if the bone is the root)
  13359. * @param localMatrix defines the local matrix
  13360. * @param restPose defines the rest pose matrix
  13361. * @param baseMatrix defines the base matrix
  13362. * @param index defines index of the bone in the hiearchy
  13363. */
  13364. constructor(
  13365. /**
  13366. * defines the bone name
  13367. */
  13368. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13369. /**
  13370. * Gets the current object class name.
  13371. * @return the class name
  13372. */
  13373. getClassName(): string;
  13374. /**
  13375. * Gets the parent skeleton
  13376. * @returns a skeleton
  13377. */
  13378. getSkeleton(): Skeleton;
  13379. /**
  13380. * Gets parent bone
  13381. * @returns a bone or null if the bone is the root of the bone hierarchy
  13382. */
  13383. getParent(): Nullable<Bone>;
  13384. /**
  13385. * Returns an array containing the root bones
  13386. * @returns an array containing the root bones
  13387. */
  13388. getChildren(): Array<Bone>;
  13389. /**
  13390. * Sets the parent bone
  13391. * @param parent defines the parent (can be null if the bone is the root)
  13392. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13393. */
  13394. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13395. /**
  13396. * Gets the local matrix
  13397. * @returns a matrix
  13398. */
  13399. getLocalMatrix(): Matrix;
  13400. /**
  13401. * Gets the base matrix (initial matrix which remains unchanged)
  13402. * @returns a matrix
  13403. */
  13404. getBaseMatrix(): Matrix;
  13405. /**
  13406. * Gets the rest pose matrix
  13407. * @returns a matrix
  13408. */
  13409. getRestPose(): Matrix;
  13410. /**
  13411. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13412. */
  13413. getWorldMatrix(): Matrix;
  13414. /**
  13415. * Sets the local matrix to rest pose matrix
  13416. */
  13417. returnToRest(): void;
  13418. /**
  13419. * Gets the inverse of the absolute transform matrix.
  13420. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13421. * @returns a matrix
  13422. */
  13423. getInvertedAbsoluteTransform(): Matrix;
  13424. /**
  13425. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13426. * @returns a matrix
  13427. */
  13428. getAbsoluteTransform(): Matrix;
  13429. /**
  13430. * Links with the given transform node.
  13431. * The local matrix of this bone is copied from the transform node every frame.
  13432. * @param transformNode defines the transform node to link to
  13433. */
  13434. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13435. /**
  13436. * Gets the node used to drive the bone's transformation
  13437. * @returns a transform node or null
  13438. */
  13439. getTransformNode(): Nullable<TransformNode>;
  13440. /** Gets or sets current position (in local space) */
  13441. position: Vector3;
  13442. /** Gets or sets current rotation (in local space) */
  13443. rotation: Vector3;
  13444. /** Gets or sets current rotation quaternion (in local space) */
  13445. rotationQuaternion: Quaternion;
  13446. /** Gets or sets current scaling (in local space) */
  13447. scaling: Vector3;
  13448. /**
  13449. * Gets the animation properties override
  13450. */
  13451. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13452. private _decompose;
  13453. private _compose;
  13454. /**
  13455. * Update the base and local matrices
  13456. * @param matrix defines the new base or local matrix
  13457. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13458. * @param updateLocalMatrix defines if the local matrix should be updated
  13459. */
  13460. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13461. /** @hidden */
  13462. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13463. /**
  13464. * Flag the bone as dirty (Forcing it to update everything)
  13465. */
  13466. markAsDirty(): void;
  13467. /** @hidden */
  13468. _markAsDirtyAndCompose(): void;
  13469. private _markAsDirtyAndDecompose;
  13470. /**
  13471. * Translate the bone in local or world space
  13472. * @param vec The amount to translate the bone
  13473. * @param space The space that the translation is in
  13474. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13475. */
  13476. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13477. /**
  13478. * Set the postion of the bone in local or world space
  13479. * @param position The position to set the bone
  13480. * @param space The space that the position is in
  13481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13482. */
  13483. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13484. /**
  13485. * Set the absolute position of the bone (world space)
  13486. * @param position The position to set the bone
  13487. * @param mesh The mesh that this bone is attached to
  13488. */
  13489. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13490. /**
  13491. * Scale the bone on the x, y and z axes (in local space)
  13492. * @param x The amount to scale the bone on the x axis
  13493. * @param y The amount to scale the bone on the y axis
  13494. * @param z The amount to scale the bone on the z axis
  13495. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13496. */
  13497. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13498. /**
  13499. * Set the bone scaling in local space
  13500. * @param scale defines the scaling vector
  13501. */
  13502. setScale(scale: Vector3): void;
  13503. /**
  13504. * Gets the current scaling in local space
  13505. * @returns the current scaling vector
  13506. */
  13507. getScale(): Vector3;
  13508. /**
  13509. * Gets the current scaling in local space and stores it in a target vector
  13510. * @param result defines the target vector
  13511. */
  13512. getScaleToRef(result: Vector3): void;
  13513. /**
  13514. * Set the yaw, pitch, and roll of the bone in local or world space
  13515. * @param yaw The rotation of the bone on the y axis
  13516. * @param pitch The rotation of the bone on the x axis
  13517. * @param roll The rotation of the bone on the z axis
  13518. * @param space The space that the axes of rotation are in
  13519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13520. */
  13521. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13522. /**
  13523. * Add a rotation to the bone on an axis in local or world space
  13524. * @param axis The axis to rotate the bone on
  13525. * @param amount The amount to rotate the bone
  13526. * @param space The space that the axis is in
  13527. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13528. */
  13529. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13530. /**
  13531. * Set the rotation of the bone to a particular axis angle in local or world space
  13532. * @param axis The axis to rotate the bone on
  13533. * @param angle The angle that the bone should be rotated to
  13534. * @param space The space that the axis is in
  13535. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13536. */
  13537. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13538. /**
  13539. * Set the euler rotation of the bone in local of world space
  13540. * @param rotation The euler rotation that the bone should be set to
  13541. * @param space The space that the rotation is in
  13542. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13543. */
  13544. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13545. /**
  13546. * Set the quaternion rotation of the bone in local of world space
  13547. * @param quat The quaternion rotation that the bone should be set to
  13548. * @param space The space that the rotation is in
  13549. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13550. */
  13551. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13552. /**
  13553. * Set the rotation matrix of the bone in local of world space
  13554. * @param rotMat The rotation matrix that the bone should be set to
  13555. * @param space The space that the rotation is in
  13556. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13557. */
  13558. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13559. private _rotateWithMatrix;
  13560. private _getNegativeRotationToRef;
  13561. /**
  13562. * Get the position of the bone in local or world space
  13563. * @param space The space that the returned position is in
  13564. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13565. * @returns The position of the bone
  13566. */
  13567. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13568. /**
  13569. * Copy the position of the bone to a vector3 in local or world space
  13570. * @param space The space that the returned position is in
  13571. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13572. * @param result The vector3 to copy the position to
  13573. */
  13574. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13575. /**
  13576. * Get the absolute position of the bone (world space)
  13577. * @param mesh The mesh that this bone is attached to
  13578. * @returns The absolute position of the bone
  13579. */
  13580. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13581. /**
  13582. * Copy the absolute position of the bone (world space) to the result param
  13583. * @param mesh The mesh that this bone is attached to
  13584. * @param result The vector3 to copy the absolute position to
  13585. */
  13586. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13587. /**
  13588. * Compute the absolute transforms of this bone and its children
  13589. */
  13590. computeAbsoluteTransforms(): void;
  13591. /**
  13592. * Get the world direction from an axis that is in the local space of the bone
  13593. * @param localAxis The local direction that is used to compute the world direction
  13594. * @param mesh The mesh that this bone is attached to
  13595. * @returns The world direction
  13596. */
  13597. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13598. /**
  13599. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13600. * @param localAxis The local direction that is used to compute the world direction
  13601. * @param mesh The mesh that this bone is attached to
  13602. * @param result The vector3 that the world direction will be copied to
  13603. */
  13604. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13605. /**
  13606. * Get the euler rotation of the bone in local or world space
  13607. * @param space The space that the rotation should be in
  13608. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13609. * @returns The euler rotation
  13610. */
  13611. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13612. /**
  13613. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13614. * @param space The space that the rotation should be in
  13615. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13616. * @param result The vector3 that the rotation should be copied to
  13617. */
  13618. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13619. /**
  13620. * Get the quaternion rotation of the bone in either local or world space
  13621. * @param space The space that the rotation should be in
  13622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13623. * @returns The quaternion rotation
  13624. */
  13625. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13626. /**
  13627. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13628. * @param space The space that the rotation should be in
  13629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13630. * @param result The quaternion that the rotation should be copied to
  13631. */
  13632. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13633. /**
  13634. * Get the rotation matrix of the bone in local or world space
  13635. * @param space The space that the rotation should be in
  13636. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13637. * @returns The rotation matrix
  13638. */
  13639. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13640. /**
  13641. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13642. * @param space The space that the rotation should be in
  13643. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13644. * @param result The quaternion that the rotation should be copied to
  13645. */
  13646. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13647. /**
  13648. * Get the world position of a point that is in the local space of the bone
  13649. * @param position The local position
  13650. * @param mesh The mesh that this bone is attached to
  13651. * @returns The world position
  13652. */
  13653. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13654. /**
  13655. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13656. * @param position The local position
  13657. * @param mesh The mesh that this bone is attached to
  13658. * @param result The vector3 that the world position should be copied to
  13659. */
  13660. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13661. /**
  13662. * Get the local position of a point that is in world space
  13663. * @param position The world position
  13664. * @param mesh The mesh that this bone is attached to
  13665. * @returns The local position
  13666. */
  13667. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13668. /**
  13669. * Get the local position of a point that is in world space and copy it to the result param
  13670. * @param position The world position
  13671. * @param mesh The mesh that this bone is attached to
  13672. * @param result The vector3 that the local position should be copied to
  13673. */
  13674. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13675. }
  13676. }
  13677. declare module BABYLON {
  13678. /**
  13679. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13680. * @see https://doc.babylonjs.com/how_to/transformnode
  13681. */
  13682. export class TransformNode extends Node {
  13683. /**
  13684. * Object will not rotate to face the camera
  13685. */
  13686. static BILLBOARDMODE_NONE: number;
  13687. /**
  13688. * Object will rotate to face the camera but only on the x axis
  13689. */
  13690. static BILLBOARDMODE_X: number;
  13691. /**
  13692. * Object will rotate to face the camera but only on the y axis
  13693. */
  13694. static BILLBOARDMODE_Y: number;
  13695. /**
  13696. * Object will rotate to face the camera but only on the z axis
  13697. */
  13698. static BILLBOARDMODE_Z: number;
  13699. /**
  13700. * Object will rotate to face the camera
  13701. */
  13702. static BILLBOARDMODE_ALL: number;
  13703. /**
  13704. * Object will rotate to face the camera's position instead of orientation
  13705. */
  13706. static BILLBOARDMODE_USE_POSITION: number;
  13707. private _forward;
  13708. private _forwardInverted;
  13709. private _up;
  13710. private _right;
  13711. private _rightInverted;
  13712. private _position;
  13713. private _rotation;
  13714. private _rotationQuaternion;
  13715. protected _scaling: Vector3;
  13716. protected _isDirty: boolean;
  13717. private _transformToBoneReferal;
  13718. private _isAbsoluteSynced;
  13719. private _billboardMode;
  13720. /**
  13721. * Gets or sets the billboard mode. Default is 0.
  13722. *
  13723. * | Value | Type | Description |
  13724. * | --- | --- | --- |
  13725. * | 0 | BILLBOARDMODE_NONE | |
  13726. * | 1 | BILLBOARDMODE_X | |
  13727. * | 2 | BILLBOARDMODE_Y | |
  13728. * | 4 | BILLBOARDMODE_Z | |
  13729. * | 7 | BILLBOARDMODE_ALL | |
  13730. *
  13731. */
  13732. billboardMode: number;
  13733. private _preserveParentRotationForBillboard;
  13734. /**
  13735. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13736. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13737. */
  13738. preserveParentRotationForBillboard: boolean;
  13739. /**
  13740. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  13741. */
  13742. scalingDeterminant: number;
  13743. private _infiniteDistance;
  13744. /**
  13745. * Gets or sets the distance of the object to max, often used by skybox
  13746. */
  13747. infiniteDistance: boolean;
  13748. /**
  13749. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13750. * By default the system will update normals to compensate
  13751. */
  13752. ignoreNonUniformScaling: boolean;
  13753. /**
  13754. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  13755. */
  13756. reIntegrateRotationIntoRotationQuaternion: boolean;
  13757. /** @hidden */
  13758. _poseMatrix: Nullable<Matrix>;
  13759. /** @hidden */
  13760. _localMatrix: Matrix;
  13761. private _usePivotMatrix;
  13762. private _absolutePosition;
  13763. private _absoluteScaling;
  13764. private _absoluteRotationQuaternion;
  13765. private _pivotMatrix;
  13766. private _pivotMatrixInverse;
  13767. protected _postMultiplyPivotMatrix: boolean;
  13768. protected _isWorldMatrixFrozen: boolean;
  13769. /** @hidden */
  13770. _indexInSceneTransformNodesArray: number;
  13771. /**
  13772. * An event triggered after the world matrix is updated
  13773. */
  13774. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13775. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13776. /**
  13777. * Gets a string identifying the name of the class
  13778. * @returns "TransformNode" string
  13779. */
  13780. getClassName(): string;
  13781. /**
  13782. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13783. */
  13784. position: Vector3;
  13785. /**
  13786. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13787. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13788. */
  13789. rotation: Vector3;
  13790. /**
  13791. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13792. */
  13793. scaling: Vector3;
  13794. /**
  13795. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  13796. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13797. */
  13798. rotationQuaternion: Nullable<Quaternion>;
  13799. /**
  13800. * The forward direction of that transform in world space.
  13801. */
  13802. readonly forward: Vector3;
  13803. /**
  13804. * The up direction of that transform in world space.
  13805. */
  13806. readonly up: Vector3;
  13807. /**
  13808. * The right direction of that transform in world space.
  13809. */
  13810. readonly right: Vector3;
  13811. /**
  13812. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13813. * @param matrix the matrix to copy the pose from
  13814. * @returns this TransformNode.
  13815. */
  13816. updatePoseMatrix(matrix: Matrix): TransformNode;
  13817. /**
  13818. * Returns the mesh Pose matrix.
  13819. * @returns the pose matrix
  13820. */
  13821. getPoseMatrix(): Matrix;
  13822. /** @hidden */
  13823. _isSynchronized(): boolean;
  13824. /** @hidden */
  13825. _initCache(): void;
  13826. /**
  13827. * Flag the transform node as dirty (Forcing it to update everything)
  13828. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13829. * @returns this transform node
  13830. */
  13831. markAsDirty(property: string): TransformNode;
  13832. /**
  13833. * Returns the current mesh absolute position.
  13834. * Returns a Vector3.
  13835. */
  13836. readonly absolutePosition: Vector3;
  13837. /**
  13838. * Returns the current mesh absolute scaling.
  13839. * Returns a Vector3.
  13840. */
  13841. readonly absoluteScaling: Vector3;
  13842. /**
  13843. * Returns the current mesh absolute rotation.
  13844. * Returns a Quaternion.
  13845. */
  13846. readonly absoluteRotationQuaternion: Quaternion;
  13847. /**
  13848. * Sets a new matrix to apply before all other transformation
  13849. * @param matrix defines the transform matrix
  13850. * @returns the current TransformNode
  13851. */
  13852. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13853. /**
  13854. * Sets a new pivot matrix to the current node
  13855. * @param matrix defines the new pivot matrix to use
  13856. * @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
  13857. * @returns the current TransformNode
  13858. */
  13859. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13860. /**
  13861. * Returns the mesh pivot matrix.
  13862. * Default : Identity.
  13863. * @returns the matrix
  13864. */
  13865. getPivotMatrix(): Matrix;
  13866. /**
  13867. * Instantiate (when possible) or clone that node with its hierarchy
  13868. * @param newParent defines the new parent to use for the instance (or clone)
  13869. * @returns an instance (or a clone) of the current node with its hiearchy
  13870. */
  13871. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13872. /**
  13873. * Prevents the World matrix to be computed any longer
  13874. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13875. * @returns the TransformNode.
  13876. */
  13877. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13878. /**
  13879. * Allows back the World matrix computation.
  13880. * @returns the TransformNode.
  13881. */
  13882. unfreezeWorldMatrix(): this;
  13883. /**
  13884. * True if the World matrix has been frozen.
  13885. */
  13886. readonly isWorldMatrixFrozen: boolean;
  13887. /**
  13888. * Retuns the mesh absolute position in the World.
  13889. * @returns a Vector3.
  13890. */
  13891. getAbsolutePosition(): Vector3;
  13892. /**
  13893. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13894. * @param absolutePosition the absolute position to set
  13895. * @returns the TransformNode.
  13896. */
  13897. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13898. /**
  13899. * Sets the mesh position in its local space.
  13900. * @param vector3 the position to set in localspace
  13901. * @returns the TransformNode.
  13902. */
  13903. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13904. /**
  13905. * Returns the mesh position in the local space from the current World matrix values.
  13906. * @returns a new Vector3.
  13907. */
  13908. getPositionExpressedInLocalSpace(): Vector3;
  13909. /**
  13910. * Translates the mesh along the passed Vector3 in its local space.
  13911. * @param vector3 the distance to translate in localspace
  13912. * @returns the TransformNode.
  13913. */
  13914. locallyTranslate(vector3: Vector3): TransformNode;
  13915. private static _lookAtVectorCache;
  13916. /**
  13917. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13918. * @param targetPoint the position (must be in same space as current mesh) to look at
  13919. * @param yawCor optional yaw (y-axis) correction in radians
  13920. * @param pitchCor optional pitch (x-axis) correction in radians
  13921. * @param rollCor optional roll (z-axis) correction in radians
  13922. * @param space the choosen space of the target
  13923. * @returns the TransformNode.
  13924. */
  13925. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13926. /**
  13927. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13928. * This Vector3 is expressed in the World space.
  13929. * @param localAxis axis to rotate
  13930. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13931. */
  13932. getDirection(localAxis: Vector3): Vector3;
  13933. /**
  13934. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13935. * localAxis is expressed in the mesh local space.
  13936. * result is computed in the Wordl space from the mesh World matrix.
  13937. * @param localAxis axis to rotate
  13938. * @param result the resulting transformnode
  13939. * @returns this TransformNode.
  13940. */
  13941. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13942. /**
  13943. * Sets this transform node rotation to the given local axis.
  13944. * @param localAxis the axis in local space
  13945. * @param yawCor optional yaw (y-axis) correction in radians
  13946. * @param pitchCor optional pitch (x-axis) correction in radians
  13947. * @param rollCor optional roll (z-axis) correction in radians
  13948. * @returns this TransformNode
  13949. */
  13950. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13951. /**
  13952. * Sets a new pivot point to the current node
  13953. * @param point defines the new pivot point to use
  13954. * @param space defines if the point is in world or local space (local by default)
  13955. * @returns the current TransformNode
  13956. */
  13957. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13958. /**
  13959. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13960. * @returns the pivot point
  13961. */
  13962. getPivotPoint(): Vector3;
  13963. /**
  13964. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13965. * @param result the vector3 to store the result
  13966. * @returns this TransformNode.
  13967. */
  13968. getPivotPointToRef(result: Vector3): TransformNode;
  13969. /**
  13970. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13971. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13972. */
  13973. getAbsolutePivotPoint(): Vector3;
  13974. /**
  13975. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13976. * @param result vector3 to store the result
  13977. * @returns this TransformNode.
  13978. */
  13979. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13980. /**
  13981. * Defines the passed node as the parent of the current node.
  13982. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13983. * @see https://doc.babylonjs.com/how_to/parenting
  13984. * @param node the node ot set as the parent
  13985. * @returns this TransformNode.
  13986. */
  13987. setParent(node: Nullable<Node>): TransformNode;
  13988. private _nonUniformScaling;
  13989. /**
  13990. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13991. */
  13992. readonly nonUniformScaling: boolean;
  13993. /** @hidden */
  13994. _updateNonUniformScalingState(value: boolean): boolean;
  13995. /**
  13996. * Attach the current TransformNode to another TransformNode associated with a bone
  13997. * @param bone Bone affecting the TransformNode
  13998. * @param affectedTransformNode TransformNode associated with the bone
  13999. * @returns this object
  14000. */
  14001. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14002. /**
  14003. * Detach the transform node if its associated with a bone
  14004. * @returns this object
  14005. */
  14006. detachFromBone(): TransformNode;
  14007. private static _rotationAxisCache;
  14008. /**
  14009. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14010. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14011. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14012. * The passed axis is also normalized.
  14013. * @param axis the axis to rotate around
  14014. * @param amount the amount to rotate in radians
  14015. * @param space Space to rotate in (Default: local)
  14016. * @returns the TransformNode.
  14017. */
  14018. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14019. /**
  14020. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14021. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14022. * The passed axis is also normalized. .
  14023. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14024. * @param point the point to rotate around
  14025. * @param axis the axis to rotate around
  14026. * @param amount the amount to rotate in radians
  14027. * @returns the TransformNode
  14028. */
  14029. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14030. /**
  14031. * Translates the mesh along the axis vector for the passed distance in the given space.
  14032. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14033. * @param axis the axis to translate in
  14034. * @param distance the distance to translate
  14035. * @param space Space to rotate in (Default: local)
  14036. * @returns the TransformNode.
  14037. */
  14038. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14039. /**
  14040. * Adds a rotation step to the mesh current rotation.
  14041. * x, y, z are Euler angles expressed in radians.
  14042. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14043. * This means this rotation is made in the mesh local space only.
  14044. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14045. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14046. * ```javascript
  14047. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14048. * ```
  14049. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14050. * 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.
  14051. * @param x Rotation to add
  14052. * @param y Rotation to add
  14053. * @param z Rotation to add
  14054. * @returns the TransformNode.
  14055. */
  14056. addRotation(x: number, y: number, z: number): TransformNode;
  14057. /**
  14058. * @hidden
  14059. */
  14060. protected _getEffectiveParent(): Nullable<Node>;
  14061. /**
  14062. * Computes the world matrix of the node
  14063. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14064. * @returns the world matrix
  14065. */
  14066. computeWorldMatrix(force?: boolean): Matrix;
  14067. protected _afterComputeWorldMatrix(): void;
  14068. /**
  14069. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14070. * @param func callback function to add
  14071. *
  14072. * @returns the TransformNode.
  14073. */
  14074. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14075. /**
  14076. * Removes a registered callback function.
  14077. * @param func callback function to remove
  14078. * @returns the TransformNode.
  14079. */
  14080. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14081. /**
  14082. * Gets the position of the current mesh in camera space
  14083. * @param camera defines the camera to use
  14084. * @returns a position
  14085. */
  14086. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14087. /**
  14088. * Returns the distance from the mesh to the active camera
  14089. * @param camera defines the camera to use
  14090. * @returns the distance
  14091. */
  14092. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14093. /**
  14094. * Clone the current transform node
  14095. * @param name Name of the new clone
  14096. * @param newParent New parent for the clone
  14097. * @param doNotCloneChildren Do not clone children hierarchy
  14098. * @returns the new transform node
  14099. */
  14100. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14101. /**
  14102. * Serializes the objects information.
  14103. * @param currentSerializationObject defines the object to serialize in
  14104. * @returns the serialized object
  14105. */
  14106. serialize(currentSerializationObject?: any): any;
  14107. /**
  14108. * Returns a new TransformNode object parsed from the source provided.
  14109. * @param parsedTransformNode is the source.
  14110. * @param scene the scne the object belongs to
  14111. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14112. * @returns a new TransformNode object parsed from the source provided.
  14113. */
  14114. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14115. /**
  14116. * Get all child-transformNodes of this node
  14117. * @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
  14118. * @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
  14119. * @returns an array of TransformNode
  14120. */
  14121. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14122. /**
  14123. * Releases resources associated with this transform node.
  14124. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14125. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14126. */
  14127. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14128. /**
  14129. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14130. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14131. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14132. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14133. * @returns the current mesh
  14134. */
  14135. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14136. private _syncAbsoluteScalingAndRotation;
  14137. }
  14138. }
  14139. declare module BABYLON {
  14140. /**
  14141. * Defines the types of pose enabled controllers that are supported
  14142. */
  14143. export enum PoseEnabledControllerType {
  14144. /**
  14145. * HTC Vive
  14146. */
  14147. VIVE = 0,
  14148. /**
  14149. * Oculus Rift
  14150. */
  14151. OCULUS = 1,
  14152. /**
  14153. * Windows mixed reality
  14154. */
  14155. WINDOWS = 2,
  14156. /**
  14157. * Samsung gear VR
  14158. */
  14159. GEAR_VR = 3,
  14160. /**
  14161. * Google Daydream
  14162. */
  14163. DAYDREAM = 4,
  14164. /**
  14165. * Generic
  14166. */
  14167. GENERIC = 5
  14168. }
  14169. /**
  14170. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14171. */
  14172. export interface MutableGamepadButton {
  14173. /**
  14174. * Value of the button/trigger
  14175. */
  14176. value: number;
  14177. /**
  14178. * If the button/trigger is currently touched
  14179. */
  14180. touched: boolean;
  14181. /**
  14182. * If the button/trigger is currently pressed
  14183. */
  14184. pressed: boolean;
  14185. }
  14186. /**
  14187. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14188. * @hidden
  14189. */
  14190. export interface ExtendedGamepadButton extends GamepadButton {
  14191. /**
  14192. * If the button/trigger is currently pressed
  14193. */
  14194. readonly pressed: boolean;
  14195. /**
  14196. * If the button/trigger is currently touched
  14197. */
  14198. readonly touched: boolean;
  14199. /**
  14200. * Value of the button/trigger
  14201. */
  14202. readonly value: number;
  14203. }
  14204. /** @hidden */
  14205. export interface _GamePadFactory {
  14206. /**
  14207. * Returns wether or not the current gamepad can be created for this type of controller.
  14208. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14209. * @returns true if it can be created, otherwise false
  14210. */
  14211. canCreate(gamepadInfo: any): boolean;
  14212. /**
  14213. * Creates a new instance of the Gamepad.
  14214. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14215. * @returns the new gamepad instance
  14216. */
  14217. create(gamepadInfo: any): Gamepad;
  14218. }
  14219. /**
  14220. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14221. */
  14222. export class PoseEnabledControllerHelper {
  14223. /** @hidden */
  14224. static _ControllerFactories: _GamePadFactory[];
  14225. /** @hidden */
  14226. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14227. /**
  14228. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14229. * @param vrGamepad the gamepad to initialized
  14230. * @returns a vr controller of the type the gamepad identified as
  14231. */
  14232. static InitiateController(vrGamepad: any): Gamepad;
  14233. }
  14234. /**
  14235. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14236. */
  14237. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14238. /**
  14239. * If the controller is used in a webXR session
  14240. */
  14241. isXR: boolean;
  14242. private _deviceRoomPosition;
  14243. private _deviceRoomRotationQuaternion;
  14244. /**
  14245. * The device position in babylon space
  14246. */
  14247. devicePosition: Vector3;
  14248. /**
  14249. * The device rotation in babylon space
  14250. */
  14251. deviceRotationQuaternion: Quaternion;
  14252. /**
  14253. * The scale factor of the device in babylon space
  14254. */
  14255. deviceScaleFactor: number;
  14256. /**
  14257. * (Likely devicePosition should be used instead) The device position in its room space
  14258. */
  14259. position: Vector3;
  14260. /**
  14261. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14262. */
  14263. rotationQuaternion: Quaternion;
  14264. /**
  14265. * The type of controller (Eg. Windows mixed reality)
  14266. */
  14267. controllerType: PoseEnabledControllerType;
  14268. protected _calculatedPosition: Vector3;
  14269. private _calculatedRotation;
  14270. /**
  14271. * The raw pose from the device
  14272. */
  14273. rawPose: DevicePose;
  14274. private _trackPosition;
  14275. private _maxRotationDistFromHeadset;
  14276. private _draggedRoomRotation;
  14277. /**
  14278. * @hidden
  14279. */
  14280. _disableTrackPosition(fixedPosition: Vector3): void;
  14281. /**
  14282. * Internal, the mesh attached to the controller
  14283. * @hidden
  14284. */
  14285. _mesh: Nullable<AbstractMesh>;
  14286. private _poseControlledCamera;
  14287. private _leftHandSystemQuaternion;
  14288. /**
  14289. * Internal, matrix used to convert room space to babylon space
  14290. * @hidden
  14291. */
  14292. _deviceToWorld: Matrix;
  14293. /**
  14294. * Node to be used when casting a ray from the controller
  14295. * @hidden
  14296. */
  14297. _pointingPoseNode: Nullable<TransformNode>;
  14298. /**
  14299. * Name of the child mesh that can be used to cast a ray from the controller
  14300. */
  14301. static readonly POINTING_POSE: string;
  14302. /**
  14303. * Creates a new PoseEnabledController from a gamepad
  14304. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14305. */
  14306. constructor(browserGamepad: any);
  14307. private _workingMatrix;
  14308. /**
  14309. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14310. */
  14311. update(): void;
  14312. /**
  14313. * Updates only the pose device and mesh without doing any button event checking
  14314. */
  14315. protected _updatePoseAndMesh(): void;
  14316. /**
  14317. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14318. * @param poseData raw pose fromthe device
  14319. */
  14320. updateFromDevice(poseData: DevicePose): void;
  14321. /**
  14322. * @hidden
  14323. */
  14324. _meshAttachedObservable: Observable<AbstractMesh>;
  14325. /**
  14326. * Attaches a mesh to the controller
  14327. * @param mesh the mesh to be attached
  14328. */
  14329. attachToMesh(mesh: AbstractMesh): void;
  14330. /**
  14331. * Attaches the controllers mesh to a camera
  14332. * @param camera the camera the mesh should be attached to
  14333. */
  14334. attachToPoseControlledCamera(camera: TargetCamera): void;
  14335. /**
  14336. * Disposes of the controller
  14337. */
  14338. dispose(): void;
  14339. /**
  14340. * The mesh that is attached to the controller
  14341. */
  14342. readonly mesh: Nullable<AbstractMesh>;
  14343. /**
  14344. * Gets the ray of the controller in the direction the controller is pointing
  14345. * @param length the length the resulting ray should be
  14346. * @returns a ray in the direction the controller is pointing
  14347. */
  14348. getForwardRay(length?: number): Ray;
  14349. }
  14350. }
  14351. declare module BABYLON {
  14352. /**
  14353. * Defines the WebVRController object that represents controllers tracked in 3D space
  14354. */
  14355. export abstract class WebVRController extends PoseEnabledController {
  14356. /**
  14357. * Internal, the default controller model for the controller
  14358. */
  14359. protected _defaultModel: AbstractMesh;
  14360. /**
  14361. * Fired when the trigger state has changed
  14362. */
  14363. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14364. /**
  14365. * Fired when the main button state has changed
  14366. */
  14367. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14368. /**
  14369. * Fired when the secondary button state has changed
  14370. */
  14371. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14372. /**
  14373. * Fired when the pad state has changed
  14374. */
  14375. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14376. /**
  14377. * Fired when controllers stick values have changed
  14378. */
  14379. onPadValuesChangedObservable: Observable<StickValues>;
  14380. /**
  14381. * Array of button availible on the controller
  14382. */
  14383. protected _buttons: Array<MutableGamepadButton>;
  14384. private _onButtonStateChange;
  14385. /**
  14386. * Fired when a controller button's state has changed
  14387. * @param callback the callback containing the button that was modified
  14388. */
  14389. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14390. /**
  14391. * X and Y axis corresponding to the controllers joystick
  14392. */
  14393. pad: StickValues;
  14394. /**
  14395. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14396. */
  14397. hand: string;
  14398. /**
  14399. * The default controller model for the controller
  14400. */
  14401. readonly defaultModel: AbstractMesh;
  14402. /**
  14403. * Creates a new WebVRController from a gamepad
  14404. * @param vrGamepad the gamepad that the WebVRController should be created from
  14405. */
  14406. constructor(vrGamepad: any);
  14407. /**
  14408. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14409. */
  14410. update(): void;
  14411. /**
  14412. * Function to be called when a button is modified
  14413. */
  14414. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14415. /**
  14416. * Loads a mesh and attaches it to the controller
  14417. * @param scene the scene the mesh should be added to
  14418. * @param meshLoaded callback for when the mesh has been loaded
  14419. */
  14420. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14421. private _setButtonValue;
  14422. private _changes;
  14423. private _checkChanges;
  14424. /**
  14425. * Disposes of th webVRCOntroller
  14426. */
  14427. dispose(): void;
  14428. }
  14429. }
  14430. declare module BABYLON {
  14431. /**
  14432. * The HemisphericLight simulates the ambient environment light,
  14433. * so the passed direction is the light reflection direction, not the incoming direction.
  14434. */
  14435. export class HemisphericLight extends Light {
  14436. /**
  14437. * The groundColor is the light in the opposite direction to the one specified during creation.
  14438. * 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.
  14439. */
  14440. groundColor: Color3;
  14441. /**
  14442. * The light reflection direction, not the incoming direction.
  14443. */
  14444. direction: Vector3;
  14445. /**
  14446. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14447. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14448. * The HemisphericLight can't cast shadows.
  14449. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14450. * @param name The friendly name of the light
  14451. * @param direction The direction of the light reflection
  14452. * @param scene The scene the light belongs to
  14453. */
  14454. constructor(name: string, direction: Vector3, scene: Scene);
  14455. protected _buildUniformLayout(): void;
  14456. /**
  14457. * Returns the string "HemisphericLight".
  14458. * @return The class name
  14459. */
  14460. getClassName(): string;
  14461. /**
  14462. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14463. * Returns the updated direction.
  14464. * @param target The target the direction should point to
  14465. * @return The computed direction
  14466. */
  14467. setDirectionToTarget(target: Vector3): Vector3;
  14468. /**
  14469. * Returns the shadow generator associated to the light.
  14470. * @returns Always null for hemispheric lights because it does not support shadows.
  14471. */
  14472. getShadowGenerator(): Nullable<IShadowGenerator>;
  14473. /**
  14474. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14475. * @param effect The effect to update
  14476. * @param lightIndex The index of the light in the effect to update
  14477. * @returns The hemispheric light
  14478. */
  14479. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14480. /**
  14481. * Computes the world matrix of the node
  14482. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14483. * @param useWasUpdatedFlag defines a reserved property
  14484. * @returns the world matrix
  14485. */
  14486. computeWorldMatrix(): Matrix;
  14487. /**
  14488. * Returns the integer 3.
  14489. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14490. */
  14491. getTypeID(): number;
  14492. /**
  14493. * Prepares the list of defines specific to the light type.
  14494. * @param defines the list of defines
  14495. * @param lightIndex defines the index of the light for the effect
  14496. */
  14497. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14498. }
  14499. }
  14500. declare module BABYLON {
  14501. /** @hidden */
  14502. export var vrMultiviewToSingleviewPixelShader: {
  14503. name: string;
  14504. shader: string;
  14505. };
  14506. }
  14507. declare module BABYLON {
  14508. /**
  14509. * Renders to multiple views with a single draw call
  14510. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14511. */
  14512. export class MultiviewRenderTarget extends RenderTargetTexture {
  14513. /**
  14514. * Creates a multiview render target
  14515. * @param scene scene used with the render target
  14516. * @param size the size of the render target (used for each view)
  14517. */
  14518. constructor(scene: Scene, size?: number | {
  14519. width: number;
  14520. height: number;
  14521. } | {
  14522. ratio: number;
  14523. });
  14524. /**
  14525. * @hidden
  14526. * @param faceIndex the face index, if its a cube texture
  14527. */
  14528. _bindFrameBuffer(faceIndex?: number): void;
  14529. /**
  14530. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14531. * @returns the view count
  14532. */
  14533. getViewCount(): number;
  14534. }
  14535. }
  14536. declare module BABYLON {
  14537. /**
  14538. * Reprasents a camera frustum
  14539. */
  14540. export class Frustum {
  14541. /**
  14542. * Gets the planes representing the frustum
  14543. * @param transform matrix to be applied to the returned planes
  14544. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14545. */
  14546. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14547. /**
  14548. * Gets the near frustum plane transformed by the transform matrix
  14549. * @param transform transformation matrix to be applied to the resulting frustum plane
  14550. * @param frustumPlane the resuling frustum plane
  14551. */
  14552. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14553. /**
  14554. * Gets the far frustum plane transformed by the transform matrix
  14555. * @param transform transformation matrix to be applied to the resulting frustum plane
  14556. * @param frustumPlane the resuling frustum plane
  14557. */
  14558. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14559. /**
  14560. * Gets the left frustum plane transformed by the transform matrix
  14561. * @param transform transformation matrix to be applied to the resulting frustum plane
  14562. * @param frustumPlane the resuling frustum plane
  14563. */
  14564. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14565. /**
  14566. * Gets the right frustum plane transformed by the transform matrix
  14567. * @param transform transformation matrix to be applied to the resulting frustum plane
  14568. * @param frustumPlane the resuling frustum plane
  14569. */
  14570. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14571. /**
  14572. * Gets the top frustum plane transformed by the transform matrix
  14573. * @param transform transformation matrix to be applied to the resulting frustum plane
  14574. * @param frustumPlane the resuling frustum plane
  14575. */
  14576. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14577. /**
  14578. * Gets the bottom frustum plane transformed by the transform matrix
  14579. * @param transform transformation matrix to be applied to the resulting frustum plane
  14580. * @param frustumPlane the resuling frustum plane
  14581. */
  14582. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14583. /**
  14584. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14585. * @param transform transformation matrix to be applied to the resulting frustum planes
  14586. * @param frustumPlanes the resuling frustum planes
  14587. */
  14588. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14589. }
  14590. }
  14591. declare module BABYLON {
  14592. interface Engine {
  14593. /**
  14594. * Creates a new multiview render target
  14595. * @param width defines the width of the texture
  14596. * @param height defines the height of the texture
  14597. * @returns the created multiview texture
  14598. */
  14599. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14600. /**
  14601. * Binds a multiview framebuffer to be drawn to
  14602. * @param multiviewTexture texture to bind
  14603. */
  14604. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14605. }
  14606. interface Camera {
  14607. /**
  14608. * @hidden
  14609. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14610. */
  14611. _useMultiviewToSingleView: boolean;
  14612. /**
  14613. * @hidden
  14614. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14615. */
  14616. _multiviewTexture: Nullable<RenderTargetTexture>;
  14617. /**
  14618. * @hidden
  14619. * ensures the multiview texture of the camera exists and has the specified width/height
  14620. * @param width height to set on the multiview texture
  14621. * @param height width to set on the multiview texture
  14622. */
  14623. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14624. }
  14625. interface Scene {
  14626. /** @hidden */
  14627. _transformMatrixR: Matrix;
  14628. /** @hidden */
  14629. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14630. /** @hidden */
  14631. _createMultiviewUbo(): void;
  14632. /** @hidden */
  14633. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14634. /** @hidden */
  14635. _renderMultiviewToSingleView(camera: Camera): void;
  14636. }
  14637. }
  14638. declare module BABYLON {
  14639. /**
  14640. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14641. * This will not be used for webXR as it supports displaying texture arrays directly
  14642. */
  14643. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14644. /**
  14645. * Initializes a VRMultiviewToSingleview
  14646. * @param name name of the post process
  14647. * @param camera camera to be applied to
  14648. * @param scaleFactor scaling factor to the size of the output texture
  14649. */
  14650. constructor(name: string, camera: Camera, scaleFactor: number);
  14651. }
  14652. }
  14653. declare module BABYLON {
  14654. interface Engine {
  14655. /** @hidden */
  14656. _vrDisplay: any;
  14657. /** @hidden */
  14658. _vrSupported: boolean;
  14659. /** @hidden */
  14660. _oldSize: Size;
  14661. /** @hidden */
  14662. _oldHardwareScaleFactor: number;
  14663. /** @hidden */
  14664. _vrExclusivePointerMode: boolean;
  14665. /** @hidden */
  14666. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14667. /** @hidden */
  14668. _onVRDisplayPointerRestricted: () => void;
  14669. /** @hidden */
  14670. _onVRDisplayPointerUnrestricted: () => void;
  14671. /** @hidden */
  14672. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14673. /** @hidden */
  14674. _onVrDisplayDisconnect: Nullable<() => void>;
  14675. /** @hidden */
  14676. _onVrDisplayPresentChange: Nullable<() => void>;
  14677. /**
  14678. * Observable signaled when VR display mode changes
  14679. */
  14680. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14681. /**
  14682. * Observable signaled when VR request present is complete
  14683. */
  14684. onVRRequestPresentComplete: Observable<boolean>;
  14685. /**
  14686. * Observable signaled when VR request present starts
  14687. */
  14688. onVRRequestPresentStart: Observable<Engine>;
  14689. /**
  14690. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14691. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14692. */
  14693. isInVRExclusivePointerMode: boolean;
  14694. /**
  14695. * Gets a boolean indicating if a webVR device was detected
  14696. * @returns true if a webVR device was detected
  14697. */
  14698. isVRDevicePresent(): boolean;
  14699. /**
  14700. * Gets the current webVR device
  14701. * @returns the current webVR device (or null)
  14702. */
  14703. getVRDevice(): any;
  14704. /**
  14705. * Initializes a webVR display and starts listening to display change events
  14706. * The onVRDisplayChangedObservable will be notified upon these changes
  14707. * @returns A promise containing a VRDisplay and if vr is supported
  14708. */
  14709. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14710. /** @hidden */
  14711. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14712. /**
  14713. * Call this function to switch to webVR mode
  14714. * Will do nothing if webVR is not supported or if there is no webVR device
  14715. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14716. */
  14717. enableVR(): void;
  14718. /** @hidden */
  14719. _onVRFullScreenTriggered(): void;
  14720. }
  14721. }
  14722. declare module BABYLON {
  14723. /**
  14724. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14725. * IMPORTANT!! The data is right-hand data.
  14726. * @export
  14727. * @interface DevicePose
  14728. */
  14729. export interface DevicePose {
  14730. /**
  14731. * The position of the device, values in array are [x,y,z].
  14732. */
  14733. readonly position: Nullable<Float32Array>;
  14734. /**
  14735. * The linearVelocity of the device, values in array are [x,y,z].
  14736. */
  14737. readonly linearVelocity: Nullable<Float32Array>;
  14738. /**
  14739. * The linearAcceleration of the device, values in array are [x,y,z].
  14740. */
  14741. readonly linearAcceleration: Nullable<Float32Array>;
  14742. /**
  14743. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14744. */
  14745. readonly orientation: Nullable<Float32Array>;
  14746. /**
  14747. * The angularVelocity of the device, values in array are [x,y,z].
  14748. */
  14749. readonly angularVelocity: Nullable<Float32Array>;
  14750. /**
  14751. * The angularAcceleration of the device, values in array are [x,y,z].
  14752. */
  14753. readonly angularAcceleration: Nullable<Float32Array>;
  14754. }
  14755. /**
  14756. * Interface representing a pose controlled object in Babylon.
  14757. * A pose controlled object has both regular pose values as well as pose values
  14758. * from an external device such as a VR head mounted display
  14759. */
  14760. export interface PoseControlled {
  14761. /**
  14762. * The position of the object in babylon space.
  14763. */
  14764. position: Vector3;
  14765. /**
  14766. * The rotation quaternion of the object in babylon space.
  14767. */
  14768. rotationQuaternion: Quaternion;
  14769. /**
  14770. * The position of the device in babylon space.
  14771. */
  14772. devicePosition?: Vector3;
  14773. /**
  14774. * The rotation quaternion of the device in babylon space.
  14775. */
  14776. deviceRotationQuaternion: Quaternion;
  14777. /**
  14778. * The raw pose coming from the device.
  14779. */
  14780. rawPose: Nullable<DevicePose>;
  14781. /**
  14782. * The scale of the device to be used when translating from device space to babylon space.
  14783. */
  14784. deviceScaleFactor: number;
  14785. /**
  14786. * Updates the poseControlled values based on the input device pose.
  14787. * @param poseData the pose data to update the object with
  14788. */
  14789. updateFromDevice(poseData: DevicePose): void;
  14790. }
  14791. /**
  14792. * Set of options to customize the webVRCamera
  14793. */
  14794. export interface WebVROptions {
  14795. /**
  14796. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14797. */
  14798. trackPosition?: boolean;
  14799. /**
  14800. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14801. */
  14802. positionScale?: number;
  14803. /**
  14804. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14805. */
  14806. displayName?: string;
  14807. /**
  14808. * Should the native controller meshes be initialized. (default: true)
  14809. */
  14810. controllerMeshes?: boolean;
  14811. /**
  14812. * Creating a default HemiLight only on controllers. (default: true)
  14813. */
  14814. defaultLightingOnControllers?: boolean;
  14815. /**
  14816. * If you don't want to use the default VR button of the helper. (default: false)
  14817. */
  14818. useCustomVRButton?: boolean;
  14819. /**
  14820. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14821. */
  14822. customVRButton?: HTMLButtonElement;
  14823. /**
  14824. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14825. */
  14826. rayLength?: number;
  14827. /**
  14828. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14829. */
  14830. defaultHeight?: number;
  14831. /**
  14832. * If multiview should be used if availible (default: false)
  14833. */
  14834. useMultiview?: boolean;
  14835. }
  14836. /**
  14837. * This represents a WebVR camera.
  14838. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14839. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14840. */
  14841. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14842. private webVROptions;
  14843. /**
  14844. * @hidden
  14845. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14846. */
  14847. _vrDevice: any;
  14848. /**
  14849. * The rawPose of the vrDevice.
  14850. */
  14851. rawPose: Nullable<DevicePose>;
  14852. private _onVREnabled;
  14853. private _specsVersion;
  14854. private _attached;
  14855. private _frameData;
  14856. protected _descendants: Array<Node>;
  14857. private _deviceRoomPosition;
  14858. /** @hidden */
  14859. _deviceRoomRotationQuaternion: Quaternion;
  14860. private _standingMatrix;
  14861. /**
  14862. * Represents device position in babylon space.
  14863. */
  14864. devicePosition: Vector3;
  14865. /**
  14866. * Represents device rotation in babylon space.
  14867. */
  14868. deviceRotationQuaternion: Quaternion;
  14869. /**
  14870. * The scale of the device to be used when translating from device space to babylon space.
  14871. */
  14872. deviceScaleFactor: number;
  14873. private _deviceToWorld;
  14874. private _worldToDevice;
  14875. /**
  14876. * References to the webVR controllers for the vrDevice.
  14877. */
  14878. controllers: Array<WebVRController>;
  14879. /**
  14880. * Emits an event when a controller is attached.
  14881. */
  14882. onControllersAttachedObservable: Observable<WebVRController[]>;
  14883. /**
  14884. * Emits an event when a controller's mesh has been loaded;
  14885. */
  14886. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14887. /**
  14888. * Emits an event when the HMD's pose has been updated.
  14889. */
  14890. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14891. private _poseSet;
  14892. /**
  14893. * If the rig cameras be used as parent instead of this camera.
  14894. */
  14895. rigParenting: boolean;
  14896. private _lightOnControllers;
  14897. private _defaultHeight?;
  14898. /**
  14899. * Instantiates a WebVRFreeCamera.
  14900. * @param name The name of the WebVRFreeCamera
  14901. * @param position The starting anchor position for the camera
  14902. * @param scene The scene the camera belongs to
  14903. * @param webVROptions a set of customizable options for the webVRCamera
  14904. */
  14905. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14906. /**
  14907. * Gets the device distance from the ground in meters.
  14908. * @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.
  14909. */
  14910. deviceDistanceToRoomGround(): number;
  14911. /**
  14912. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14913. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14914. */
  14915. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14916. /**
  14917. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14918. * @returns A promise with a boolean set to if the standing matrix is supported.
  14919. */
  14920. useStandingMatrixAsync(): Promise<boolean>;
  14921. /**
  14922. * Disposes the camera
  14923. */
  14924. dispose(): void;
  14925. /**
  14926. * Gets a vrController by name.
  14927. * @param name The name of the controller to retreive
  14928. * @returns the controller matching the name specified or null if not found
  14929. */
  14930. getControllerByName(name: string): Nullable<WebVRController>;
  14931. private _leftController;
  14932. /**
  14933. * The controller corresponding to the users left hand.
  14934. */
  14935. readonly leftController: Nullable<WebVRController>;
  14936. private _rightController;
  14937. /**
  14938. * The controller corresponding to the users right hand.
  14939. */
  14940. readonly rightController: Nullable<WebVRController>;
  14941. /**
  14942. * Casts a ray forward from the vrCamera's gaze.
  14943. * @param length Length of the ray (default: 100)
  14944. * @returns the ray corresponding to the gaze
  14945. */
  14946. getForwardRay(length?: number): Ray;
  14947. /**
  14948. * @hidden
  14949. * Updates the camera based on device's frame data
  14950. */
  14951. _checkInputs(): void;
  14952. /**
  14953. * Updates the poseControlled values based on the input device pose.
  14954. * @param poseData Pose coming from the device
  14955. */
  14956. updateFromDevice(poseData: DevicePose): void;
  14957. private _htmlElementAttached;
  14958. private _detachIfAttached;
  14959. /**
  14960. * WebVR's attach control will start broadcasting frames to the device.
  14961. * Note that in certain browsers (chrome for example) this function must be called
  14962. * within a user-interaction callback. Example:
  14963. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14964. *
  14965. * @param element html element to attach the vrDevice to
  14966. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14967. */
  14968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14969. /**
  14970. * Detaches the camera from the html element and disables VR
  14971. *
  14972. * @param element html element to detach from
  14973. */
  14974. detachControl(element: HTMLElement): void;
  14975. /**
  14976. * @returns the name of this class
  14977. */
  14978. getClassName(): string;
  14979. /**
  14980. * Calls resetPose on the vrDisplay
  14981. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14982. */
  14983. resetToCurrentRotation(): void;
  14984. /**
  14985. * @hidden
  14986. * Updates the rig cameras (left and right eye)
  14987. */
  14988. _updateRigCameras(): void;
  14989. private _workingVector;
  14990. private _oneVector;
  14991. private _workingMatrix;
  14992. private updateCacheCalled;
  14993. private _correctPositionIfNotTrackPosition;
  14994. /**
  14995. * @hidden
  14996. * Updates the cached values of the camera
  14997. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14998. */
  14999. _updateCache(ignoreParentClass?: boolean): void;
  15000. /**
  15001. * @hidden
  15002. * Get current device position in babylon world
  15003. */
  15004. _computeDevicePosition(): void;
  15005. /**
  15006. * Updates the current device position and rotation in the babylon world
  15007. */
  15008. update(): void;
  15009. /**
  15010. * @hidden
  15011. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15012. * @returns an identity matrix
  15013. */
  15014. _getViewMatrix(): Matrix;
  15015. private _tmpMatrix;
  15016. /**
  15017. * This function is called by the two RIG cameras.
  15018. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15019. * @hidden
  15020. */
  15021. _getWebVRViewMatrix(): Matrix;
  15022. /** @hidden */
  15023. _getWebVRProjectionMatrix(): Matrix;
  15024. private _onGamepadConnectedObserver;
  15025. private _onGamepadDisconnectedObserver;
  15026. private _updateCacheWhenTrackingDisabledObserver;
  15027. /**
  15028. * Initializes the controllers and their meshes
  15029. */
  15030. initControllers(): void;
  15031. }
  15032. }
  15033. declare module BABYLON {
  15034. /**
  15035. * Size options for a post process
  15036. */
  15037. export type PostProcessOptions = {
  15038. width: number;
  15039. height: number;
  15040. };
  15041. /**
  15042. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15043. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15044. */
  15045. export class PostProcess {
  15046. /** Name of the PostProcess. */
  15047. name: string;
  15048. /**
  15049. * Gets or sets the unique id of the post process
  15050. */
  15051. uniqueId: number;
  15052. /**
  15053. * Width of the texture to apply the post process on
  15054. */
  15055. width: number;
  15056. /**
  15057. * Height of the texture to apply the post process on
  15058. */
  15059. height: number;
  15060. /**
  15061. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15062. * @hidden
  15063. */
  15064. _outputTexture: Nullable<InternalTexture>;
  15065. /**
  15066. * Sampling mode used by the shader
  15067. * See https://doc.babylonjs.com/classes/3.1/texture
  15068. */
  15069. renderTargetSamplingMode: number;
  15070. /**
  15071. * Clear color to use when screen clearing
  15072. */
  15073. clearColor: Color4;
  15074. /**
  15075. * If the buffer needs to be cleared before applying the post process. (default: true)
  15076. * Should be set to false if shader will overwrite all previous pixels.
  15077. */
  15078. autoClear: boolean;
  15079. /**
  15080. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15081. */
  15082. alphaMode: number;
  15083. /**
  15084. * Sets the setAlphaBlendConstants of the babylon engine
  15085. */
  15086. alphaConstants: Color4;
  15087. /**
  15088. * Animations to be used for the post processing
  15089. */
  15090. animations: Animation[];
  15091. /**
  15092. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15093. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15094. */
  15095. enablePixelPerfectMode: boolean;
  15096. /**
  15097. * Force the postprocess to be applied without taking in account viewport
  15098. */
  15099. forceFullscreenViewport: boolean;
  15100. /**
  15101. * List of inspectable custom properties (used by the Inspector)
  15102. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15103. */
  15104. inspectableCustomProperties: IInspectable[];
  15105. /**
  15106. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15107. *
  15108. * | Value | Type | Description |
  15109. * | ----- | ----------------------------------- | ----------- |
  15110. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15111. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15112. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15113. *
  15114. */
  15115. scaleMode: number;
  15116. /**
  15117. * Force textures to be a power of two (default: false)
  15118. */
  15119. alwaysForcePOT: boolean;
  15120. private _samples;
  15121. /**
  15122. * Number of sample textures (default: 1)
  15123. */
  15124. samples: number;
  15125. /**
  15126. * Modify the scale of the post process to be the same as the viewport (default: false)
  15127. */
  15128. adaptScaleToCurrentViewport: boolean;
  15129. private _camera;
  15130. private _scene;
  15131. private _engine;
  15132. private _options;
  15133. private _reusable;
  15134. private _textureType;
  15135. /**
  15136. * Smart array of input and output textures for the post process.
  15137. * @hidden
  15138. */
  15139. _textures: SmartArray<InternalTexture>;
  15140. /**
  15141. * The index in _textures that corresponds to the output texture.
  15142. * @hidden
  15143. */
  15144. _currentRenderTextureInd: number;
  15145. private _effect;
  15146. private _samplers;
  15147. private _fragmentUrl;
  15148. private _vertexUrl;
  15149. private _parameters;
  15150. private _scaleRatio;
  15151. protected _indexParameters: any;
  15152. private _shareOutputWithPostProcess;
  15153. private _texelSize;
  15154. private _forcedOutputTexture;
  15155. /**
  15156. * Returns the fragment url or shader name used in the post process.
  15157. * @returns the fragment url or name in the shader store.
  15158. */
  15159. getEffectName(): string;
  15160. /**
  15161. * An event triggered when the postprocess is activated.
  15162. */
  15163. onActivateObservable: Observable<Camera>;
  15164. private _onActivateObserver;
  15165. /**
  15166. * A function that is added to the onActivateObservable
  15167. */
  15168. onActivate: Nullable<(camera: Camera) => void>;
  15169. /**
  15170. * An event triggered when the postprocess changes its size.
  15171. */
  15172. onSizeChangedObservable: Observable<PostProcess>;
  15173. private _onSizeChangedObserver;
  15174. /**
  15175. * A function that is added to the onSizeChangedObservable
  15176. */
  15177. onSizeChanged: (postProcess: PostProcess) => void;
  15178. /**
  15179. * An event triggered when the postprocess applies its effect.
  15180. */
  15181. onApplyObservable: Observable<Effect>;
  15182. private _onApplyObserver;
  15183. /**
  15184. * A function that is added to the onApplyObservable
  15185. */
  15186. onApply: (effect: Effect) => void;
  15187. /**
  15188. * An event triggered before rendering the postprocess
  15189. */
  15190. onBeforeRenderObservable: Observable<Effect>;
  15191. private _onBeforeRenderObserver;
  15192. /**
  15193. * A function that is added to the onBeforeRenderObservable
  15194. */
  15195. onBeforeRender: (effect: Effect) => void;
  15196. /**
  15197. * An event triggered after rendering the postprocess
  15198. */
  15199. onAfterRenderObservable: Observable<Effect>;
  15200. private _onAfterRenderObserver;
  15201. /**
  15202. * A function that is added to the onAfterRenderObservable
  15203. */
  15204. onAfterRender: (efect: Effect) => void;
  15205. /**
  15206. * 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
  15207. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15208. */
  15209. inputTexture: InternalTexture;
  15210. /**
  15211. * Gets the camera which post process is applied to.
  15212. * @returns The camera the post process is applied to.
  15213. */
  15214. getCamera(): Camera;
  15215. /**
  15216. * Gets the texel size of the postprocess.
  15217. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15218. */
  15219. readonly texelSize: Vector2;
  15220. /**
  15221. * Creates a new instance PostProcess
  15222. * @param name The name of the PostProcess.
  15223. * @param fragmentUrl The url of the fragment shader to be used.
  15224. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15225. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15226. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15227. * @param camera The camera to apply the render pass to.
  15228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15229. * @param engine The engine which the post process will be applied. (default: current engine)
  15230. * @param reusable If the post process can be reused on the same frame. (default: false)
  15231. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15232. * @param textureType Type of textures used when performing the post process. (default: 0)
  15233. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15234. * @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
  15235. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15236. */
  15237. constructor(
  15238. /** Name of the PostProcess. */
  15239. 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);
  15240. /**
  15241. * Gets a string idenfifying the name of the class
  15242. * @returns "PostProcess" string
  15243. */
  15244. getClassName(): string;
  15245. /**
  15246. * Gets the engine which this post process belongs to.
  15247. * @returns The engine the post process was enabled with.
  15248. */
  15249. getEngine(): Engine;
  15250. /**
  15251. * The effect that is created when initializing the post process.
  15252. * @returns The created effect corresponding the the postprocess.
  15253. */
  15254. getEffect(): Effect;
  15255. /**
  15256. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15257. * @param postProcess The post process to share the output with.
  15258. * @returns This post process.
  15259. */
  15260. shareOutputWith(postProcess: PostProcess): PostProcess;
  15261. /**
  15262. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15263. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15264. */
  15265. useOwnOutput(): void;
  15266. /**
  15267. * Updates the effect with the current post process compile time values and recompiles the shader.
  15268. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15269. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15270. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15271. * @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
  15272. * @param onCompiled Called when the shader has been compiled.
  15273. * @param onError Called if there is an error when compiling a shader.
  15274. */
  15275. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15276. /**
  15277. * The post process is reusable if it can be used multiple times within one frame.
  15278. * @returns If the post process is reusable
  15279. */
  15280. isReusable(): boolean;
  15281. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15282. markTextureDirty(): void;
  15283. /**
  15284. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15285. * 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.
  15286. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15287. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15288. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15289. * @returns The target texture that was bound to be written to.
  15290. */
  15291. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15292. /**
  15293. * If the post process is supported.
  15294. */
  15295. readonly isSupported: boolean;
  15296. /**
  15297. * The aspect ratio of the output texture.
  15298. */
  15299. readonly aspectRatio: number;
  15300. /**
  15301. * Get a value indicating if the post-process is ready to be used
  15302. * @returns true if the post-process is ready (shader is compiled)
  15303. */
  15304. isReady(): boolean;
  15305. /**
  15306. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15307. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15308. */
  15309. apply(): Nullable<Effect>;
  15310. private _disposeTextures;
  15311. /**
  15312. * Disposes the post process.
  15313. * @param camera The camera to dispose the post process on.
  15314. */
  15315. dispose(camera?: Camera): void;
  15316. }
  15317. }
  15318. declare module BABYLON {
  15319. /** @hidden */
  15320. export var kernelBlurVaryingDeclaration: {
  15321. name: string;
  15322. shader: string;
  15323. };
  15324. }
  15325. declare module BABYLON {
  15326. /** @hidden */
  15327. export var kernelBlurFragment: {
  15328. name: string;
  15329. shader: string;
  15330. };
  15331. }
  15332. declare module BABYLON {
  15333. /** @hidden */
  15334. export var kernelBlurFragment2: {
  15335. name: string;
  15336. shader: string;
  15337. };
  15338. }
  15339. declare module BABYLON {
  15340. /** @hidden */
  15341. export var kernelBlurPixelShader: {
  15342. name: string;
  15343. shader: string;
  15344. };
  15345. }
  15346. declare module BABYLON {
  15347. /** @hidden */
  15348. export var kernelBlurVertex: {
  15349. name: string;
  15350. shader: string;
  15351. };
  15352. }
  15353. declare module BABYLON {
  15354. /** @hidden */
  15355. export var kernelBlurVertexShader: {
  15356. name: string;
  15357. shader: string;
  15358. };
  15359. }
  15360. declare module BABYLON {
  15361. /**
  15362. * The Blur Post Process which blurs an image based on a kernel and direction.
  15363. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15364. */
  15365. export class BlurPostProcess extends PostProcess {
  15366. /** The direction in which to blur the image. */
  15367. direction: Vector2;
  15368. private blockCompilation;
  15369. protected _kernel: number;
  15370. protected _idealKernel: number;
  15371. protected _packedFloat: boolean;
  15372. private _staticDefines;
  15373. /**
  15374. * Sets the length in pixels of the blur sample region
  15375. */
  15376. /**
  15377. * Gets the length in pixels of the blur sample region
  15378. */
  15379. kernel: number;
  15380. /**
  15381. * Sets wether or not the blur needs to unpack/repack floats
  15382. */
  15383. /**
  15384. * Gets wether or not the blur is unpacking/repacking floats
  15385. */
  15386. packedFloat: boolean;
  15387. /**
  15388. * Creates a new instance BlurPostProcess
  15389. * @param name The name of the effect.
  15390. * @param direction The direction in which to blur the image.
  15391. * @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.
  15392. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15393. * @param camera The camera to apply the render pass to.
  15394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15395. * @param engine The engine which the post process will be applied. (default: current engine)
  15396. * @param reusable If the post process can be reused on the same frame. (default: false)
  15397. * @param textureType Type of textures used when performing the post process. (default: 0)
  15398. * @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)
  15399. */
  15400. constructor(name: string,
  15401. /** The direction in which to blur the image. */
  15402. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15403. /**
  15404. * Updates the effect with the current post process compile time values and recompiles the shader.
  15405. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15406. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15407. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15408. * @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
  15409. * @param onCompiled Called when the shader has been compiled.
  15410. * @param onError Called if there is an error when compiling a shader.
  15411. */
  15412. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15413. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15414. /**
  15415. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15416. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15417. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15418. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15419. * The gaps between physical kernels are compensated for in the weighting of the samples
  15420. * @param idealKernel Ideal blur kernel.
  15421. * @return Nearest best kernel.
  15422. */
  15423. protected _nearestBestKernel(idealKernel: number): number;
  15424. /**
  15425. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15426. * @param x The point on the Gaussian distribution to sample.
  15427. * @return the value of the Gaussian function at x.
  15428. */
  15429. protected _gaussianWeight(x: number): number;
  15430. /**
  15431. * Generates a string that can be used as a floating point number in GLSL.
  15432. * @param x Value to print.
  15433. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15434. * @return GLSL float string.
  15435. */
  15436. protected _glslFloat(x: number, decimalFigures?: number): string;
  15437. }
  15438. }
  15439. declare module BABYLON {
  15440. /**
  15441. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15442. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15443. * You can then easily use it as a reflectionTexture on a flat surface.
  15444. * In case the surface is not a plane, please consider relying on reflection probes.
  15445. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15446. */
  15447. export class MirrorTexture extends RenderTargetTexture {
  15448. private scene;
  15449. /**
  15450. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15451. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  15452. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15453. */
  15454. mirrorPlane: Plane;
  15455. /**
  15456. * Define the blur ratio used to blur the reflection if needed.
  15457. */
  15458. blurRatio: number;
  15459. /**
  15460. * Define the adaptive blur kernel used to blur the reflection if needed.
  15461. * This will autocompute the closest best match for the `blurKernel`
  15462. */
  15463. adaptiveBlurKernel: number;
  15464. /**
  15465. * Define the blur kernel used to blur the reflection if needed.
  15466. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15467. */
  15468. blurKernel: number;
  15469. /**
  15470. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15471. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15472. */
  15473. blurKernelX: number;
  15474. /**
  15475. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15476. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15477. */
  15478. blurKernelY: number;
  15479. private _autoComputeBlurKernel;
  15480. protected _onRatioRescale(): void;
  15481. private _updateGammaSpace;
  15482. private _imageProcessingConfigChangeObserver;
  15483. private _transformMatrix;
  15484. private _mirrorMatrix;
  15485. private _savedViewMatrix;
  15486. private _blurX;
  15487. private _blurY;
  15488. private _adaptiveBlurKernel;
  15489. private _blurKernelX;
  15490. private _blurKernelY;
  15491. private _blurRatio;
  15492. /**
  15493. * Instantiates a Mirror Texture.
  15494. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15495. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15496. * You can then easily use it as a reflectionTexture on a flat surface.
  15497. * In case the surface is not a plane, please consider relying on reflection probes.
  15498. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15499. * @param name
  15500. * @param size
  15501. * @param scene
  15502. * @param generateMipMaps
  15503. * @param type
  15504. * @param samplingMode
  15505. * @param generateDepthBuffer
  15506. */
  15507. constructor(name: string, size: number | {
  15508. width: number;
  15509. height: number;
  15510. } | {
  15511. ratio: number;
  15512. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15513. private _preparePostProcesses;
  15514. /**
  15515. * Clone the mirror texture.
  15516. * @returns the cloned texture
  15517. */
  15518. clone(): MirrorTexture;
  15519. /**
  15520. * Serialize the texture to a JSON representation you could use in Parse later on
  15521. * @returns the serialized JSON representation
  15522. */
  15523. serialize(): any;
  15524. /**
  15525. * Dispose the texture and release its associated resources.
  15526. */
  15527. dispose(): void;
  15528. }
  15529. }
  15530. declare module BABYLON {
  15531. /**
  15532. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15533. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15534. */
  15535. export class Texture extends BaseTexture {
  15536. /** @hidden */
  15537. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15538. /** @hidden */
  15539. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15540. /** @hidden */
  15541. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15542. /** nearest is mag = nearest and min = nearest and mip = linear */
  15543. static readonly NEAREST_SAMPLINGMODE: number;
  15544. /** nearest is mag = nearest and min = nearest and mip = linear */
  15545. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15546. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15547. static readonly BILINEAR_SAMPLINGMODE: number;
  15548. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15549. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15550. /** Trilinear is mag = linear and min = linear and mip = linear */
  15551. static readonly TRILINEAR_SAMPLINGMODE: number;
  15552. /** Trilinear is mag = linear and min = linear and mip = linear */
  15553. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15554. /** mag = nearest and min = nearest and mip = nearest */
  15555. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15556. /** mag = nearest and min = linear and mip = nearest */
  15557. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15558. /** mag = nearest and min = linear and mip = linear */
  15559. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15560. /** mag = nearest and min = linear and mip = none */
  15561. static readonly NEAREST_LINEAR: number;
  15562. /** mag = nearest and min = nearest and mip = none */
  15563. static readonly NEAREST_NEAREST: number;
  15564. /** mag = linear and min = nearest and mip = nearest */
  15565. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15566. /** mag = linear and min = nearest and mip = linear */
  15567. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15568. /** mag = linear and min = linear and mip = none */
  15569. static readonly LINEAR_LINEAR: number;
  15570. /** mag = linear and min = nearest and mip = none */
  15571. static readonly LINEAR_NEAREST: number;
  15572. /** Explicit coordinates mode */
  15573. static readonly EXPLICIT_MODE: number;
  15574. /** Spherical coordinates mode */
  15575. static readonly SPHERICAL_MODE: number;
  15576. /** Planar coordinates mode */
  15577. static readonly PLANAR_MODE: number;
  15578. /** Cubic coordinates mode */
  15579. static readonly CUBIC_MODE: number;
  15580. /** Projection coordinates mode */
  15581. static readonly PROJECTION_MODE: number;
  15582. /** Inverse Cubic coordinates mode */
  15583. static readonly SKYBOX_MODE: number;
  15584. /** Inverse Cubic coordinates mode */
  15585. static readonly INVCUBIC_MODE: number;
  15586. /** Equirectangular coordinates mode */
  15587. static readonly EQUIRECTANGULAR_MODE: number;
  15588. /** Equirectangular Fixed coordinates mode */
  15589. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15590. /** Equirectangular Fixed Mirrored coordinates mode */
  15591. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15592. /** Texture is not repeating outside of 0..1 UVs */
  15593. static readonly CLAMP_ADDRESSMODE: number;
  15594. /** Texture is repeating outside of 0..1 UVs */
  15595. static readonly WRAP_ADDRESSMODE: number;
  15596. /** Texture is repeating and mirrored */
  15597. static readonly MIRROR_ADDRESSMODE: number;
  15598. /**
  15599. * 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
  15600. */
  15601. static UseSerializedUrlIfAny: boolean;
  15602. /**
  15603. * Define the url of the texture.
  15604. */
  15605. url: Nullable<string>;
  15606. /**
  15607. * Define an offset on the texture to offset the u coordinates of the UVs
  15608. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15609. */
  15610. uOffset: number;
  15611. /**
  15612. * Define an offset on the texture to offset the v coordinates of the UVs
  15613. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15614. */
  15615. vOffset: number;
  15616. /**
  15617. * Define an offset on the texture to scale the u coordinates of the UVs
  15618. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15619. */
  15620. uScale: number;
  15621. /**
  15622. * Define an offset on the texture to scale the v coordinates of the UVs
  15623. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15624. */
  15625. vScale: number;
  15626. /**
  15627. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15628. * @see http://doc.babylonjs.com/how_to/more_materials
  15629. */
  15630. uAng: number;
  15631. /**
  15632. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15633. * @see http://doc.babylonjs.com/how_to/more_materials
  15634. */
  15635. vAng: number;
  15636. /**
  15637. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15638. * @see http://doc.babylonjs.com/how_to/more_materials
  15639. */
  15640. wAng: number;
  15641. /**
  15642. * Defines the center of rotation (U)
  15643. */
  15644. uRotationCenter: number;
  15645. /**
  15646. * Defines the center of rotation (V)
  15647. */
  15648. vRotationCenter: number;
  15649. /**
  15650. * Defines the center of rotation (W)
  15651. */
  15652. wRotationCenter: number;
  15653. /**
  15654. * Are mip maps generated for this texture or not.
  15655. */
  15656. readonly noMipmap: boolean;
  15657. /**
  15658. * List of inspectable custom properties (used by the Inspector)
  15659. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15660. */
  15661. inspectableCustomProperties: Nullable<IInspectable[]>;
  15662. private _noMipmap;
  15663. /** @hidden */
  15664. _invertY: boolean;
  15665. private _rowGenerationMatrix;
  15666. private _cachedTextureMatrix;
  15667. private _projectionModeMatrix;
  15668. private _t0;
  15669. private _t1;
  15670. private _t2;
  15671. private _cachedUOffset;
  15672. private _cachedVOffset;
  15673. private _cachedUScale;
  15674. private _cachedVScale;
  15675. private _cachedUAng;
  15676. private _cachedVAng;
  15677. private _cachedWAng;
  15678. private _cachedProjectionMatrixId;
  15679. private _cachedCoordinatesMode;
  15680. /** @hidden */
  15681. protected _initialSamplingMode: number;
  15682. /** @hidden */
  15683. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  15684. private _deleteBuffer;
  15685. protected _format: Nullable<number>;
  15686. private _delayedOnLoad;
  15687. private _delayedOnError;
  15688. /**
  15689. * Observable triggered once the texture has been loaded.
  15690. */
  15691. onLoadObservable: Observable<Texture>;
  15692. protected _isBlocking: boolean;
  15693. /**
  15694. * Is the texture preventing material to render while loading.
  15695. * If false, a default texture will be used instead of the loading one during the preparation step.
  15696. */
  15697. isBlocking: boolean;
  15698. /**
  15699. * Get the current sampling mode associated with the texture.
  15700. */
  15701. readonly samplingMode: number;
  15702. /**
  15703. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15704. */
  15705. readonly invertY: boolean;
  15706. /**
  15707. * Instantiates a new texture.
  15708. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15709. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15710. * @param url define the url of the picture to load as a texture
  15711. * @param scene define the scene or engine the texture will belong to
  15712. * @param noMipmap define if the texture will require mip maps or not
  15713. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15714. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15715. * @param onLoad define a callback triggered when the texture has been loaded
  15716. * @param onError define a callback triggered when an error occurred during the loading session
  15717. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15718. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15719. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15720. */
  15721. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15722. /**
  15723. * Update the url (and optional buffer) of this texture if url was null during construction.
  15724. * @param url the url of the texture
  15725. * @param buffer the buffer of the texture (defaults to null)
  15726. * @param onLoad callback called when the texture is loaded (defaults to null)
  15727. */
  15728. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15729. /**
  15730. * Finish the loading sequence of a texture flagged as delayed load.
  15731. * @hidden
  15732. */
  15733. delayLoad(): void;
  15734. private _prepareRowForTextureGeneration;
  15735. /**
  15736. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15737. * @returns the transform matrix of the texture.
  15738. */
  15739. getTextureMatrix(): Matrix;
  15740. /**
  15741. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15742. * @returns The reflection texture transform
  15743. */
  15744. getReflectionTextureMatrix(): Matrix;
  15745. /**
  15746. * Clones the texture.
  15747. * @returns the cloned texture
  15748. */
  15749. clone(): Texture;
  15750. /**
  15751. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15752. * @returns The JSON representation of the texture
  15753. */
  15754. serialize(): any;
  15755. /**
  15756. * Get the current class name of the texture useful for serialization or dynamic coding.
  15757. * @returns "Texture"
  15758. */
  15759. getClassName(): string;
  15760. /**
  15761. * Dispose the texture and release its associated resources.
  15762. */
  15763. dispose(): void;
  15764. /**
  15765. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15766. * @param parsedTexture Define the JSON representation of the texture
  15767. * @param scene Define the scene the parsed texture should be instantiated in
  15768. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15769. * @returns The parsed texture if successful
  15770. */
  15771. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15772. /**
  15773. * Creates a texture from its base 64 representation.
  15774. * @param data Define the base64 payload without the data: prefix
  15775. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15776. * @param scene Define the scene the texture should belong to
  15777. * @param noMipmap Forces the texture to not create mip map information if true
  15778. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15779. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15780. * @param onLoad define a callback triggered when the texture has been loaded
  15781. * @param onError define a callback triggered when an error occurred during the loading session
  15782. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15783. * @returns the created texture
  15784. */
  15785. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15786. /**
  15787. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15788. * @param data Define the base64 payload without the data: prefix
  15789. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15790. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15791. * @param scene Define the scene the texture should belong to
  15792. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15793. * @param noMipmap Forces the texture to not create mip map information if true
  15794. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15795. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15796. * @param onLoad define a callback triggered when the texture has been loaded
  15797. * @param onError define a callback triggered when an error occurred during the loading session
  15798. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15799. * @returns the created texture
  15800. */
  15801. 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;
  15802. }
  15803. }
  15804. declare module BABYLON {
  15805. /**
  15806. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15807. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15808. */
  15809. export class PostProcessManager {
  15810. private _scene;
  15811. private _indexBuffer;
  15812. private _vertexBuffers;
  15813. /**
  15814. * Creates a new instance PostProcess
  15815. * @param scene The scene that the post process is associated with.
  15816. */
  15817. constructor(scene: Scene);
  15818. private _prepareBuffers;
  15819. private _buildIndexBuffer;
  15820. /**
  15821. * Rebuilds the vertex buffers of the manager.
  15822. * @hidden
  15823. */
  15824. _rebuild(): void;
  15825. /**
  15826. * Prepares a frame to be run through a post process.
  15827. * @param sourceTexture The input texture to the post procesess. (default: null)
  15828. * @param postProcesses An array of post processes to be run. (default: null)
  15829. * @returns True if the post processes were able to be run.
  15830. * @hidden
  15831. */
  15832. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15833. /**
  15834. * Manually render a set of post processes to a texture.
  15835. * @param postProcesses An array of post processes to be run.
  15836. * @param targetTexture The target texture to render to.
  15837. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15838. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15839. * @param lodLevel defines which lod of the texture to render to
  15840. */
  15841. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15842. /**
  15843. * Finalize the result of the output of the postprocesses.
  15844. * @param doNotPresent If true the result will not be displayed to the screen.
  15845. * @param targetTexture The target texture to render to.
  15846. * @param faceIndex The index of the face to bind the target texture to.
  15847. * @param postProcesses The array of post processes to render.
  15848. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15849. * @hidden
  15850. */
  15851. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15852. /**
  15853. * Disposes of the post process manager.
  15854. */
  15855. dispose(): void;
  15856. }
  15857. }
  15858. declare module BABYLON {
  15859. /** Interface used by value gradients (color, factor, ...) */
  15860. export interface IValueGradient {
  15861. /**
  15862. * Gets or sets the gradient value (between 0 and 1)
  15863. */
  15864. gradient: number;
  15865. }
  15866. /** Class used to store color4 gradient */
  15867. export class ColorGradient implements IValueGradient {
  15868. /**
  15869. * Gets or sets the gradient value (between 0 and 1)
  15870. */
  15871. gradient: number;
  15872. /**
  15873. * Gets or sets first associated color
  15874. */
  15875. color1: Color4;
  15876. /**
  15877. * Gets or sets second associated color
  15878. */
  15879. color2?: Color4;
  15880. /**
  15881. * Will get a color picked randomly between color1 and color2.
  15882. * If color2 is undefined then color1 will be used
  15883. * @param result defines the target Color4 to store the result in
  15884. */
  15885. getColorToRef(result: Color4): void;
  15886. }
  15887. /** Class used to store color 3 gradient */
  15888. export class Color3Gradient implements IValueGradient {
  15889. /**
  15890. * Gets or sets the gradient value (between 0 and 1)
  15891. */
  15892. gradient: number;
  15893. /**
  15894. * Gets or sets the associated color
  15895. */
  15896. color: Color3;
  15897. }
  15898. /** Class used to store factor gradient */
  15899. export class FactorGradient implements IValueGradient {
  15900. /**
  15901. * Gets or sets the gradient value (between 0 and 1)
  15902. */
  15903. gradient: number;
  15904. /**
  15905. * Gets or sets first associated factor
  15906. */
  15907. factor1: number;
  15908. /**
  15909. * Gets or sets second associated factor
  15910. */
  15911. factor2?: number;
  15912. /**
  15913. * Will get a number picked randomly between factor1 and factor2.
  15914. * If factor2 is undefined then factor1 will be used
  15915. * @returns the picked number
  15916. */
  15917. getFactor(): number;
  15918. }
  15919. /**
  15920. * Helper used to simplify some generic gradient tasks
  15921. */
  15922. export class GradientHelper {
  15923. /**
  15924. * Gets the current gradient from an array of IValueGradient
  15925. * @param ratio defines the current ratio to get
  15926. * @param gradients defines the array of IValueGradient
  15927. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15928. */
  15929. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15930. }
  15931. }
  15932. declare module BABYLON {
  15933. interface AbstractScene {
  15934. /**
  15935. * The list of procedural textures added to the scene
  15936. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15937. */
  15938. proceduralTextures: Array<ProceduralTexture>;
  15939. }
  15940. /**
  15941. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15942. * in a given scene.
  15943. */
  15944. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15945. /**
  15946. * The component name helpfull to identify the component in the list of scene components.
  15947. */
  15948. readonly name: string;
  15949. /**
  15950. * The scene the component belongs to.
  15951. */
  15952. scene: Scene;
  15953. /**
  15954. * Creates a new instance of the component for the given scene
  15955. * @param scene Defines the scene to register the component in
  15956. */
  15957. constructor(scene: Scene);
  15958. /**
  15959. * Registers the component in a given scene
  15960. */
  15961. register(): void;
  15962. /**
  15963. * Rebuilds the elements related to this component in case of
  15964. * context lost for instance.
  15965. */
  15966. rebuild(): void;
  15967. /**
  15968. * Disposes the component and the associated ressources.
  15969. */
  15970. dispose(): void;
  15971. private _beforeClear;
  15972. }
  15973. }
  15974. declare module BABYLON {
  15975. interface Engine {
  15976. /**
  15977. * Creates a new render target cube texture
  15978. * @param size defines the size of the texture
  15979. * @param options defines the options used to create the texture
  15980. * @returns a new render target cube texture stored in an InternalTexture
  15981. */
  15982. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15983. }
  15984. }
  15985. declare module BABYLON {
  15986. /** @hidden */
  15987. export var proceduralVertexShader: {
  15988. name: string;
  15989. shader: string;
  15990. };
  15991. }
  15992. declare module BABYLON {
  15993. /**
  15994. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  15995. * This is the base class of any Procedural texture and contains most of the shareable code.
  15996. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15997. */
  15998. export class ProceduralTexture extends Texture {
  15999. isCube: boolean;
  16000. /**
  16001. * Define if the texture is enabled or not (disabled texture will not render)
  16002. */
  16003. isEnabled: boolean;
  16004. /**
  16005. * Define if the texture must be cleared before rendering (default is true)
  16006. */
  16007. autoClear: boolean;
  16008. /**
  16009. * Callback called when the texture is generated
  16010. */
  16011. onGenerated: () => void;
  16012. /**
  16013. * Event raised when the texture is generated
  16014. */
  16015. onGeneratedObservable: Observable<ProceduralTexture>;
  16016. /** @hidden */
  16017. _generateMipMaps: boolean;
  16018. /** @hidden **/
  16019. _effect: Effect;
  16020. /** @hidden */
  16021. _textures: {
  16022. [key: string]: Texture;
  16023. };
  16024. private _size;
  16025. private _currentRefreshId;
  16026. private _refreshRate;
  16027. private _vertexBuffers;
  16028. private _indexBuffer;
  16029. private _uniforms;
  16030. private _samplers;
  16031. private _fragment;
  16032. private _floats;
  16033. private _ints;
  16034. private _floatsArrays;
  16035. private _colors3;
  16036. private _colors4;
  16037. private _vectors2;
  16038. private _vectors3;
  16039. private _matrices;
  16040. private _fallbackTexture;
  16041. private _fallbackTextureUsed;
  16042. private _engine;
  16043. private _cachedDefines;
  16044. private _contentUpdateId;
  16045. private _contentData;
  16046. /**
  16047. * Instantiates a new procedural texture.
  16048. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  16049. * This is the base class of any Procedural texture and contains most of the shareable code.
  16050. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16051. * @param name Define the name of the texture
  16052. * @param size Define the size of the texture to create
  16053. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16054. * @param scene Define the scene the texture belongs to
  16055. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16056. * @param generateMipMaps Define if the texture should creates mip maps or not
  16057. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16058. */
  16059. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16060. /**
  16061. * The effect that is created when initializing the post process.
  16062. * @returns The created effect corresponding the the postprocess.
  16063. */
  16064. getEffect(): Effect;
  16065. /**
  16066. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16067. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16068. */
  16069. getContent(): Nullable<ArrayBufferView>;
  16070. private _createIndexBuffer;
  16071. /** @hidden */
  16072. _rebuild(): void;
  16073. /**
  16074. * Resets the texture in order to recreate its associated resources.
  16075. * This can be called in case of context loss
  16076. */
  16077. reset(): void;
  16078. protected _getDefines(): string;
  16079. /**
  16080. * Is the texture ready to be used ? (rendered at least once)
  16081. * @returns true if ready, otherwise, false.
  16082. */
  16083. isReady(): boolean;
  16084. /**
  16085. * Resets the refresh counter of the texture and start bak from scratch.
  16086. * Could be useful to regenerate the texture if it is setup to render only once.
  16087. */
  16088. resetRefreshCounter(): void;
  16089. /**
  16090. * Set the fragment shader to use in order to render the texture.
  16091. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16092. */
  16093. setFragment(fragment: any): void;
  16094. /**
  16095. * Define the refresh rate of the texture or the rendering frequency.
  16096. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16097. */
  16098. refreshRate: number;
  16099. /** @hidden */
  16100. _shouldRender(): boolean;
  16101. /**
  16102. * Get the size the texture is rendering at.
  16103. * @returns the size (texture is always squared)
  16104. */
  16105. getRenderSize(): number;
  16106. /**
  16107. * Resize the texture to new value.
  16108. * @param size Define the new size the texture should have
  16109. * @param generateMipMaps Define whether the new texture should create mip maps
  16110. */
  16111. resize(size: number, generateMipMaps: boolean): void;
  16112. private _checkUniform;
  16113. /**
  16114. * Set a texture in the shader program used to render.
  16115. * @param name Define the name of the uniform samplers as defined in the shader
  16116. * @param texture Define the texture to bind to this sampler
  16117. * @return the texture itself allowing "fluent" like uniform updates
  16118. */
  16119. setTexture(name: string, texture: Texture): ProceduralTexture;
  16120. /**
  16121. * Set a float in the shader.
  16122. * @param name Define the name of the uniform as defined in the shader
  16123. * @param value Define the value to give to the uniform
  16124. * @return the texture itself allowing "fluent" like uniform updates
  16125. */
  16126. setFloat(name: string, value: number): ProceduralTexture;
  16127. /**
  16128. * Set a int in the shader.
  16129. * @param name Define the name of the uniform as defined in the shader
  16130. * @param value Define the value to give to the uniform
  16131. * @return the texture itself allowing "fluent" like uniform updates
  16132. */
  16133. setInt(name: string, value: number): ProceduralTexture;
  16134. /**
  16135. * Set an array of floats in the shader.
  16136. * @param name Define the name of the uniform as defined in the shader
  16137. * @param value Define the value to give to the uniform
  16138. * @return the texture itself allowing "fluent" like uniform updates
  16139. */
  16140. setFloats(name: string, value: number[]): ProceduralTexture;
  16141. /**
  16142. * Set a vec3 in the shader from a Color3.
  16143. * @param name Define the name of the uniform as defined in the shader
  16144. * @param value Define the value to give to the uniform
  16145. * @return the texture itself allowing "fluent" like uniform updates
  16146. */
  16147. setColor3(name: string, value: Color3): ProceduralTexture;
  16148. /**
  16149. * Set a vec4 in the shader from a Color4.
  16150. * @param name Define the name of the uniform as defined in the shader
  16151. * @param value Define the value to give to the uniform
  16152. * @return the texture itself allowing "fluent" like uniform updates
  16153. */
  16154. setColor4(name: string, value: Color4): ProceduralTexture;
  16155. /**
  16156. * Set a vec2 in the shader from a Vector2.
  16157. * @param name Define the name of the uniform as defined in the shader
  16158. * @param value Define the value to give to the uniform
  16159. * @return the texture itself allowing "fluent" like uniform updates
  16160. */
  16161. setVector2(name: string, value: Vector2): ProceduralTexture;
  16162. /**
  16163. * Set a vec3 in the shader from a Vector3.
  16164. * @param name Define the name of the uniform as defined in the shader
  16165. * @param value Define the value to give to the uniform
  16166. * @return the texture itself allowing "fluent" like uniform updates
  16167. */
  16168. setVector3(name: string, value: Vector3): ProceduralTexture;
  16169. /**
  16170. * Set a mat4 in the shader from a MAtrix.
  16171. * @param name Define the name of the uniform as defined in the shader
  16172. * @param value Define the value to give to the uniform
  16173. * @return the texture itself allowing "fluent" like uniform updates
  16174. */
  16175. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16176. /**
  16177. * Render the texture to its associated render target.
  16178. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16179. */
  16180. render(useCameraPostProcess?: boolean): void;
  16181. /**
  16182. * Clone the texture.
  16183. * @returns the cloned texture
  16184. */
  16185. clone(): ProceduralTexture;
  16186. /**
  16187. * Dispose the texture and release its asoociated resources.
  16188. */
  16189. dispose(): void;
  16190. }
  16191. }
  16192. declare module BABYLON {
  16193. /**
  16194. * This represents the base class for particle system in Babylon.
  16195. * 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.
  16196. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16197. * @example https://doc.babylonjs.com/babylon101/particles
  16198. */
  16199. export class BaseParticleSystem {
  16200. /**
  16201. * Source color is added to the destination color without alpha affecting the result
  16202. */
  16203. static BLENDMODE_ONEONE: number;
  16204. /**
  16205. * Blend current color and particle color using particle’s alpha
  16206. */
  16207. static BLENDMODE_STANDARD: number;
  16208. /**
  16209. * Add current color and particle color multiplied by particle’s alpha
  16210. */
  16211. static BLENDMODE_ADD: number;
  16212. /**
  16213. * Multiply current color with particle color
  16214. */
  16215. static BLENDMODE_MULTIPLY: number;
  16216. /**
  16217. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16218. */
  16219. static BLENDMODE_MULTIPLYADD: number;
  16220. /**
  16221. * List of animations used by the particle system.
  16222. */
  16223. animations: Animation[];
  16224. /**
  16225. * The id of the Particle system.
  16226. */
  16227. id: string;
  16228. /**
  16229. * The friendly name of the Particle system.
  16230. */
  16231. name: string;
  16232. /**
  16233. * The rendering group used by the Particle system to chose when to render.
  16234. */
  16235. renderingGroupId: number;
  16236. /**
  16237. * The emitter represents the Mesh or position we are attaching the particle system to.
  16238. */
  16239. emitter: Nullable<AbstractMesh | Vector3>;
  16240. /**
  16241. * The maximum number of particles to emit per frame
  16242. */
  16243. emitRate: number;
  16244. /**
  16245. * If you want to launch only a few particles at once, that can be done, as well.
  16246. */
  16247. manualEmitCount: number;
  16248. /**
  16249. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16250. */
  16251. updateSpeed: number;
  16252. /**
  16253. * The amount of time the particle system is running (depends of the overall update speed).
  16254. */
  16255. targetStopDuration: number;
  16256. /**
  16257. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16258. */
  16259. disposeOnStop: boolean;
  16260. /**
  16261. * Minimum power of emitting particles.
  16262. */
  16263. minEmitPower: number;
  16264. /**
  16265. * Maximum power of emitting particles.
  16266. */
  16267. maxEmitPower: number;
  16268. /**
  16269. * Minimum life time of emitting particles.
  16270. */
  16271. minLifeTime: number;
  16272. /**
  16273. * Maximum life time of emitting particles.
  16274. */
  16275. maxLifeTime: number;
  16276. /**
  16277. * Minimum Size of emitting particles.
  16278. */
  16279. minSize: number;
  16280. /**
  16281. * Maximum Size of emitting particles.
  16282. */
  16283. maxSize: number;
  16284. /**
  16285. * Minimum scale of emitting particles on X axis.
  16286. */
  16287. minScaleX: number;
  16288. /**
  16289. * Maximum scale of emitting particles on X axis.
  16290. */
  16291. maxScaleX: number;
  16292. /**
  16293. * Minimum scale of emitting particles on Y axis.
  16294. */
  16295. minScaleY: number;
  16296. /**
  16297. * Maximum scale of emitting particles on Y axis.
  16298. */
  16299. maxScaleY: number;
  16300. /**
  16301. * Gets or sets the minimal initial rotation in radians.
  16302. */
  16303. minInitialRotation: number;
  16304. /**
  16305. * Gets or sets the maximal initial rotation in radians.
  16306. */
  16307. maxInitialRotation: number;
  16308. /**
  16309. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16310. */
  16311. minAngularSpeed: number;
  16312. /**
  16313. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16314. */
  16315. maxAngularSpeed: number;
  16316. /**
  16317. * The texture used to render each particle. (this can be a spritesheet)
  16318. */
  16319. particleTexture: Nullable<Texture>;
  16320. /**
  16321. * The layer mask we are rendering the particles through.
  16322. */
  16323. layerMask: number;
  16324. /**
  16325. * This can help using your own shader to render the particle system.
  16326. * The according effect will be created
  16327. */
  16328. customShader: any;
  16329. /**
  16330. * By default particle system starts as soon as they are created. This prevents the
  16331. * automatic start to happen and let you decide when to start emitting particles.
  16332. */
  16333. preventAutoStart: boolean;
  16334. private _noiseTexture;
  16335. /**
  16336. * Gets or sets a texture used to add random noise to particle positions
  16337. */
  16338. noiseTexture: Nullable<ProceduralTexture>;
  16339. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16340. noiseStrength: Vector3;
  16341. /**
  16342. * Callback triggered when the particle animation is ending.
  16343. */
  16344. onAnimationEnd: Nullable<() => void>;
  16345. /**
  16346. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16347. */
  16348. blendMode: number;
  16349. /**
  16350. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16351. * to override the particles.
  16352. */
  16353. forceDepthWrite: boolean;
  16354. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  16355. preWarmCycles: number;
  16356. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16357. preWarmStepOffset: number;
  16358. /**
  16359. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  16360. */
  16361. spriteCellChangeSpeed: number;
  16362. /**
  16363. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16364. */
  16365. startSpriteCellID: number;
  16366. /**
  16367. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16368. */
  16369. endSpriteCellID: number;
  16370. /**
  16371. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16372. */
  16373. spriteCellWidth: number;
  16374. /**
  16375. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16376. */
  16377. spriteCellHeight: number;
  16378. /**
  16379. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16380. */
  16381. spriteRandomStartCell: boolean;
  16382. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16383. translationPivot: Vector2;
  16384. /** @hidden */
  16385. protected _isAnimationSheetEnabled: boolean;
  16386. /**
  16387. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16388. */
  16389. beginAnimationOnStart: boolean;
  16390. /**
  16391. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16392. */
  16393. beginAnimationFrom: number;
  16394. /**
  16395. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16396. */
  16397. beginAnimationTo: number;
  16398. /**
  16399. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16400. */
  16401. beginAnimationLoop: boolean;
  16402. /**
  16403. * Gets or sets a world offset applied to all particles
  16404. */
  16405. worldOffset: Vector3;
  16406. /**
  16407. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16408. */
  16409. isAnimationSheetEnabled: boolean;
  16410. /**
  16411. * Get hosting scene
  16412. * @returns the scene
  16413. */
  16414. getScene(): Scene;
  16415. /**
  16416. * You can use gravity if you want to give an orientation to your particles.
  16417. */
  16418. gravity: Vector3;
  16419. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16420. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16421. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16422. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16423. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16424. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16425. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16426. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16427. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16428. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16429. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16430. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16431. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16432. /**
  16433. * Defines the delay in milliseconds before starting the system (0 by default)
  16434. */
  16435. startDelay: number;
  16436. /**
  16437. * Gets the current list of drag gradients.
  16438. * You must use addDragGradient and removeDragGradient to udpate this list
  16439. * @returns the list of drag gradients
  16440. */
  16441. getDragGradients(): Nullable<Array<FactorGradient>>;
  16442. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16443. limitVelocityDamping: number;
  16444. /**
  16445. * Gets the current list of limit velocity gradients.
  16446. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16447. * @returns the list of limit velocity gradients
  16448. */
  16449. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16450. /**
  16451. * Gets the current list of color gradients.
  16452. * You must use addColorGradient and removeColorGradient to udpate this list
  16453. * @returns the list of color gradients
  16454. */
  16455. getColorGradients(): Nullable<Array<ColorGradient>>;
  16456. /**
  16457. * Gets the current list of size gradients.
  16458. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16459. * @returns the list of size gradients
  16460. */
  16461. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16462. /**
  16463. * Gets the current list of color remap gradients.
  16464. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16465. * @returns the list of color remap gradients
  16466. */
  16467. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16468. /**
  16469. * Gets the current list of alpha remap gradients.
  16470. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16471. * @returns the list of alpha remap gradients
  16472. */
  16473. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16474. /**
  16475. * Gets the current list of life time gradients.
  16476. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16477. * @returns the list of life time gradients
  16478. */
  16479. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16480. /**
  16481. * Gets the current list of angular speed gradients.
  16482. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16483. * @returns the list of angular speed gradients
  16484. */
  16485. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16486. /**
  16487. * Gets the current list of velocity gradients.
  16488. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16489. * @returns the list of velocity gradients
  16490. */
  16491. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16492. /**
  16493. * Gets the current list of start size gradients.
  16494. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16495. * @returns the list of start size gradients
  16496. */
  16497. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16498. /**
  16499. * Gets the current list of emit rate gradients.
  16500. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16501. * @returns the list of emit rate gradients
  16502. */
  16503. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16504. /**
  16505. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16506. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16507. */
  16508. direction1: Vector3;
  16509. /**
  16510. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16511. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16512. */
  16513. direction2: Vector3;
  16514. /**
  16515. * 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.
  16516. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16517. */
  16518. minEmitBox: Vector3;
  16519. /**
  16520. * 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.
  16521. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16522. */
  16523. maxEmitBox: Vector3;
  16524. /**
  16525. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16526. */
  16527. color1: Color4;
  16528. /**
  16529. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16530. */
  16531. color2: Color4;
  16532. /**
  16533. * Color the particle will have at the end of its lifetime
  16534. */
  16535. colorDead: Color4;
  16536. /**
  16537. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16538. */
  16539. textureMask: Color4;
  16540. /**
  16541. * The particle emitter type defines the emitter used by the particle system.
  16542. * It can be for example box, sphere, or cone...
  16543. */
  16544. particleEmitterType: IParticleEmitterType;
  16545. /** @hidden */
  16546. _isSubEmitter: boolean;
  16547. /**
  16548. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16549. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16550. */
  16551. billboardMode: number;
  16552. protected _isBillboardBased: boolean;
  16553. /**
  16554. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16555. */
  16556. isBillboardBased: boolean;
  16557. /**
  16558. * The scene the particle system belongs to.
  16559. */
  16560. protected _scene: Scene;
  16561. /**
  16562. * Local cache of defines for image processing.
  16563. */
  16564. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16565. /**
  16566. * Default configuration related to image processing available in the standard Material.
  16567. */
  16568. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16569. /**
  16570. * Gets the image processing configuration used either in this material.
  16571. */
  16572. /**
  16573. * Sets the Default image processing configuration used either in the this material.
  16574. *
  16575. * If sets to null, the scene one is in use.
  16576. */
  16577. imageProcessingConfiguration: ImageProcessingConfiguration;
  16578. /**
  16579. * Attaches a new image processing configuration to the Standard Material.
  16580. * @param configuration
  16581. */
  16582. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16583. /** @hidden */
  16584. protected _reset(): void;
  16585. /** @hidden */
  16586. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16587. /**
  16588. * Instantiates a particle system.
  16589. * 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.
  16590. * @param name The name of the particle system
  16591. */
  16592. constructor(name: string);
  16593. /**
  16594. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16595. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16596. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16597. * @returns the emitter
  16598. */
  16599. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16600. /**
  16601. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16602. * @param radius The radius of the hemisphere to emit from
  16603. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16604. * @returns the emitter
  16605. */
  16606. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16607. /**
  16608. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16609. * @param radius The radius of the sphere to emit from
  16610. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16611. * @returns the emitter
  16612. */
  16613. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16614. /**
  16615. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16616. * @param radius The radius of the sphere to emit from
  16617. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16618. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16619. * @returns the emitter
  16620. */
  16621. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16622. /**
  16623. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16624. * @param radius The radius of the emission cylinder
  16625. * @param height The height of the emission cylinder
  16626. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16627. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16628. * @returns the emitter
  16629. */
  16630. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16631. /**
  16632. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16633. * @param radius The radius of the cylinder to emit from
  16634. * @param height The height of the emission cylinder
  16635. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16636. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16637. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16638. * @returns the emitter
  16639. */
  16640. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16641. /**
  16642. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16643. * @param radius The radius of the cone to emit from
  16644. * @param angle The base angle of the cone
  16645. * @returns the emitter
  16646. */
  16647. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16648. /**
  16649. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16650. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16651. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16652. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16653. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16654. * @returns the emitter
  16655. */
  16656. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16657. }
  16658. }
  16659. declare module BABYLON {
  16660. /**
  16661. * Type of sub emitter
  16662. */
  16663. export enum SubEmitterType {
  16664. /**
  16665. * Attached to the particle over it's lifetime
  16666. */
  16667. ATTACHED = 0,
  16668. /**
  16669. * Created when the particle dies
  16670. */
  16671. END = 1
  16672. }
  16673. /**
  16674. * Sub emitter class used to emit particles from an existing particle
  16675. */
  16676. export class SubEmitter {
  16677. /**
  16678. * the particle system to be used by the sub emitter
  16679. */
  16680. particleSystem: ParticleSystem;
  16681. /**
  16682. * Type of the submitter (Default: END)
  16683. */
  16684. type: SubEmitterType;
  16685. /**
  16686. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  16687. * Note: This only is supported when using an emitter of type Mesh
  16688. */
  16689. inheritDirection: boolean;
  16690. /**
  16691. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16692. */
  16693. inheritedVelocityAmount: number;
  16694. /**
  16695. * Creates a sub emitter
  16696. * @param particleSystem the particle system to be used by the sub emitter
  16697. */
  16698. constructor(
  16699. /**
  16700. * the particle system to be used by the sub emitter
  16701. */
  16702. particleSystem: ParticleSystem);
  16703. /**
  16704. * Clones the sub emitter
  16705. * @returns the cloned sub emitter
  16706. */
  16707. clone(): SubEmitter;
  16708. /**
  16709. * Serialize current object to a JSON object
  16710. * @returns the serialized object
  16711. */
  16712. serialize(): any;
  16713. /** @hidden */
  16714. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16715. /**
  16716. * Creates a new SubEmitter from a serialized JSON version
  16717. * @param serializationObject defines the JSON object to read from
  16718. * @param scene defines the hosting scene
  16719. * @param rootUrl defines the rootUrl for data loading
  16720. * @returns a new SubEmitter
  16721. */
  16722. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16723. /** Release associated resources */
  16724. dispose(): void;
  16725. }
  16726. }
  16727. declare module BABYLON {
  16728. /** @hidden */
  16729. export var clipPlaneFragmentDeclaration: {
  16730. name: string;
  16731. shader: string;
  16732. };
  16733. }
  16734. declare module BABYLON {
  16735. /** @hidden */
  16736. export var imageProcessingDeclaration: {
  16737. name: string;
  16738. shader: string;
  16739. };
  16740. }
  16741. declare module BABYLON {
  16742. /** @hidden */
  16743. export var imageProcessingFunctions: {
  16744. name: string;
  16745. shader: string;
  16746. };
  16747. }
  16748. declare module BABYLON {
  16749. /** @hidden */
  16750. export var clipPlaneFragment: {
  16751. name: string;
  16752. shader: string;
  16753. };
  16754. }
  16755. declare module BABYLON {
  16756. /** @hidden */
  16757. export var particlesPixelShader: {
  16758. name: string;
  16759. shader: string;
  16760. };
  16761. }
  16762. declare module BABYLON {
  16763. /** @hidden */
  16764. export var clipPlaneVertexDeclaration: {
  16765. name: string;
  16766. shader: string;
  16767. };
  16768. }
  16769. declare module BABYLON {
  16770. /** @hidden */
  16771. export var clipPlaneVertex: {
  16772. name: string;
  16773. shader: string;
  16774. };
  16775. }
  16776. declare module BABYLON {
  16777. /** @hidden */
  16778. export var particlesVertexShader: {
  16779. name: string;
  16780. shader: string;
  16781. };
  16782. }
  16783. declare module BABYLON {
  16784. /**
  16785. * This represents a particle system in Babylon.
  16786. * 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.
  16787. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16788. * @example https://doc.babylonjs.com/babylon101/particles
  16789. */
  16790. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16791. /**
  16792. * Billboard mode will only apply to Y axis
  16793. */
  16794. static readonly BILLBOARDMODE_Y: number;
  16795. /**
  16796. * Billboard mode will apply to all axes
  16797. */
  16798. static readonly BILLBOARDMODE_ALL: number;
  16799. /**
  16800. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16801. */
  16802. static readonly BILLBOARDMODE_STRETCHED: number;
  16803. /**
  16804. * This function can be defined to provide custom update for active particles.
  16805. * This function will be called instead of regular update (age, position, color, etc.).
  16806. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16807. */
  16808. updateFunction: (particles: Particle[]) => void;
  16809. private _emitterWorldMatrix;
  16810. /**
  16811. * This function can be defined to specify initial direction for every new particle.
  16812. * It by default use the emitterType defined function
  16813. */
  16814. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16815. /**
  16816. * This function can be defined to specify initial position for every new particle.
  16817. * It by default use the emitterType defined function
  16818. */
  16819. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16820. /**
  16821. * @hidden
  16822. */
  16823. _inheritedVelocityOffset: Vector3;
  16824. /**
  16825. * An event triggered when the system is disposed
  16826. */
  16827. onDisposeObservable: Observable<ParticleSystem>;
  16828. private _onDisposeObserver;
  16829. /**
  16830. * Sets a callback that will be triggered when the system is disposed
  16831. */
  16832. onDispose: () => void;
  16833. private _particles;
  16834. private _epsilon;
  16835. private _capacity;
  16836. private _stockParticles;
  16837. private _newPartsExcess;
  16838. private _vertexData;
  16839. private _vertexBuffer;
  16840. private _vertexBuffers;
  16841. private _spriteBuffer;
  16842. private _indexBuffer;
  16843. private _effect;
  16844. private _customEffect;
  16845. private _cachedDefines;
  16846. private _scaledColorStep;
  16847. private _colorDiff;
  16848. private _scaledDirection;
  16849. private _scaledGravity;
  16850. private _currentRenderId;
  16851. private _alive;
  16852. private _useInstancing;
  16853. private _started;
  16854. private _stopped;
  16855. private _actualFrame;
  16856. private _scaledUpdateSpeed;
  16857. private _vertexBufferSize;
  16858. /** @hidden */
  16859. _currentEmitRateGradient: Nullable<FactorGradient>;
  16860. /** @hidden */
  16861. _currentEmitRate1: number;
  16862. /** @hidden */
  16863. _currentEmitRate2: number;
  16864. /** @hidden */
  16865. _currentStartSizeGradient: Nullable<FactorGradient>;
  16866. /** @hidden */
  16867. _currentStartSize1: number;
  16868. /** @hidden */
  16869. _currentStartSize2: number;
  16870. private readonly _rawTextureWidth;
  16871. private _rampGradientsTexture;
  16872. private _useRampGradients;
  16873. /** Gets or sets a boolean indicating that ramp gradients must be used
  16874. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16875. */
  16876. useRampGradients: boolean;
  16877. /**
  16878. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  16879. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  16880. */
  16881. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16882. private _subEmitters;
  16883. /**
  16884. * @hidden
  16885. * If the particle systems emitter should be disposed when the particle system is disposed
  16886. */
  16887. _disposeEmitterOnDispose: boolean;
  16888. /**
  16889. * The current active Sub-systems, this property is used by the root particle system only.
  16890. */
  16891. activeSubSystems: Array<ParticleSystem>;
  16892. private _rootParticleSystem;
  16893. /**
  16894. * Gets the current list of active particles
  16895. */
  16896. readonly particles: Particle[];
  16897. /**
  16898. * Returns the string "ParticleSystem"
  16899. * @returns a string containing the class name
  16900. */
  16901. getClassName(): string;
  16902. /**
  16903. * Instantiates a particle system.
  16904. * 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.
  16905. * @param name The name of the particle system
  16906. * @param capacity The max number of particles alive at the same time
  16907. * @param scene The scene the particle system belongs to
  16908. * @param customEffect a custom effect used to change the way particles are rendered by default
  16909. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16910. * @param epsilon Offset used to render the particles
  16911. */
  16912. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16913. private _addFactorGradient;
  16914. private _removeFactorGradient;
  16915. /**
  16916. * Adds a new life time gradient
  16917. * @param gradient defines the gradient to use (between 0 and 1)
  16918. * @param factor defines the life time factor to affect to the specified gradient
  16919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16920. * @returns the current particle system
  16921. */
  16922. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16923. /**
  16924. * Remove a specific life time gradient
  16925. * @param gradient defines the gradient to remove
  16926. * @returns the current particle system
  16927. */
  16928. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16929. /**
  16930. * Adds a new size gradient
  16931. * @param gradient defines the gradient to use (between 0 and 1)
  16932. * @param factor defines the size factor to affect to the specified gradient
  16933. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16934. * @returns the current particle system
  16935. */
  16936. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16937. /**
  16938. * Remove a specific size gradient
  16939. * @param gradient defines the gradient to remove
  16940. * @returns the current particle system
  16941. */
  16942. removeSizeGradient(gradient: number): IParticleSystem;
  16943. /**
  16944. * Adds a new color remap gradient
  16945. * @param gradient defines the gradient to use (between 0 and 1)
  16946. * @param min defines the color remap minimal range
  16947. * @param max defines the color remap maximal range
  16948. * @returns the current particle system
  16949. */
  16950. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16951. /**
  16952. * Remove a specific color remap gradient
  16953. * @param gradient defines the gradient to remove
  16954. * @returns the current particle system
  16955. */
  16956. removeColorRemapGradient(gradient: number): IParticleSystem;
  16957. /**
  16958. * Adds a new alpha remap gradient
  16959. * @param gradient defines the gradient to use (between 0 and 1)
  16960. * @param min defines the alpha remap minimal range
  16961. * @param max defines the alpha remap maximal range
  16962. * @returns the current particle system
  16963. */
  16964. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16965. /**
  16966. * Remove a specific alpha remap gradient
  16967. * @param gradient defines the gradient to remove
  16968. * @returns the current particle system
  16969. */
  16970. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16971. /**
  16972. * Adds a new angular speed gradient
  16973. * @param gradient defines the gradient to use (between 0 and 1)
  16974. * @param factor defines the angular speed to affect to the specified gradient
  16975. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16976. * @returns the current particle system
  16977. */
  16978. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16979. /**
  16980. * Remove a specific angular speed gradient
  16981. * @param gradient defines the gradient to remove
  16982. * @returns the current particle system
  16983. */
  16984. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16985. /**
  16986. * Adds a new velocity gradient
  16987. * @param gradient defines the gradient to use (between 0 and 1)
  16988. * @param factor defines the velocity to affect to the specified gradient
  16989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16990. * @returns the current particle system
  16991. */
  16992. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16993. /**
  16994. * Remove a specific velocity gradient
  16995. * @param gradient defines the gradient to remove
  16996. * @returns the current particle system
  16997. */
  16998. removeVelocityGradient(gradient: number): IParticleSystem;
  16999. /**
  17000. * Adds a new limit velocity gradient
  17001. * @param gradient defines the gradient to use (between 0 and 1)
  17002. * @param factor defines the limit velocity value to affect to the specified gradient
  17003. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17004. * @returns the current particle system
  17005. */
  17006. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17007. /**
  17008. * Remove a specific limit velocity gradient
  17009. * @param gradient defines the gradient to remove
  17010. * @returns the current particle system
  17011. */
  17012. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17013. /**
  17014. * Adds a new drag gradient
  17015. * @param gradient defines the gradient to use (between 0 and 1)
  17016. * @param factor defines the drag value to affect to the specified gradient
  17017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17018. * @returns the current particle system
  17019. */
  17020. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17021. /**
  17022. * Remove a specific drag gradient
  17023. * @param gradient defines the gradient to remove
  17024. * @returns the current particle system
  17025. */
  17026. removeDragGradient(gradient: number): IParticleSystem;
  17027. /**
  17028. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17029. * @param gradient defines the gradient to use (between 0 and 1)
  17030. * @param factor defines the emit rate value to affect to the specified gradient
  17031. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17032. * @returns the current particle system
  17033. */
  17034. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17035. /**
  17036. * Remove a specific emit rate gradient
  17037. * @param gradient defines the gradient to remove
  17038. * @returns the current particle system
  17039. */
  17040. removeEmitRateGradient(gradient: number): IParticleSystem;
  17041. /**
  17042. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17043. * @param gradient defines the gradient to use (between 0 and 1)
  17044. * @param factor defines the start size value to affect to the specified gradient
  17045. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17046. * @returns the current particle system
  17047. */
  17048. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17049. /**
  17050. * Remove a specific start size gradient
  17051. * @param gradient defines the gradient to remove
  17052. * @returns the current particle system
  17053. */
  17054. removeStartSizeGradient(gradient: number): IParticleSystem;
  17055. private _createRampGradientTexture;
  17056. /**
  17057. * Gets the current list of ramp gradients.
  17058. * You must use addRampGradient and removeRampGradient to udpate this list
  17059. * @returns the list of ramp gradients
  17060. */
  17061. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17062. /**
  17063. * Adds a new ramp gradient used to remap particle colors
  17064. * @param gradient defines the gradient to use (between 0 and 1)
  17065. * @param color defines the color to affect to the specified gradient
  17066. * @returns the current particle system
  17067. */
  17068. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17069. /**
  17070. * Remove a specific ramp gradient
  17071. * @param gradient defines the gradient to remove
  17072. * @returns the current particle system
  17073. */
  17074. removeRampGradient(gradient: number): ParticleSystem;
  17075. /**
  17076. * Adds a new color gradient
  17077. * @param gradient defines the gradient to use (between 0 and 1)
  17078. * @param color1 defines the color to affect to the specified gradient
  17079. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17080. * @returns this particle system
  17081. */
  17082. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17083. /**
  17084. * Remove a specific color gradient
  17085. * @param gradient defines the gradient to remove
  17086. * @returns this particle system
  17087. */
  17088. removeColorGradient(gradient: number): IParticleSystem;
  17089. private _fetchR;
  17090. protected _reset(): void;
  17091. private _resetEffect;
  17092. private _createVertexBuffers;
  17093. private _createIndexBuffer;
  17094. /**
  17095. * Gets the maximum number of particles active at the same time.
  17096. * @returns The max number of active particles.
  17097. */
  17098. getCapacity(): number;
  17099. /**
  17100. * Gets whether there are still active particles in the system.
  17101. * @returns True if it is alive, otherwise false.
  17102. */
  17103. isAlive(): boolean;
  17104. /**
  17105. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17106. * @returns True if it has been started, otherwise false.
  17107. */
  17108. isStarted(): boolean;
  17109. private _prepareSubEmitterInternalArray;
  17110. /**
  17111. * Starts the particle system and begins to emit
  17112. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17113. */
  17114. start(delay?: number): void;
  17115. /**
  17116. * Stops the particle system.
  17117. * @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.
  17118. */
  17119. stop(stopSubEmitters?: boolean): void;
  17120. /**
  17121. * Remove all active particles
  17122. */
  17123. reset(): void;
  17124. /**
  17125. * @hidden (for internal use only)
  17126. */
  17127. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17128. /**
  17129. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17130. * Its lifetime will start back at 0.
  17131. */
  17132. recycleParticle: (particle: Particle) => void;
  17133. private _stopSubEmitters;
  17134. private _createParticle;
  17135. private _removeFromRoot;
  17136. private _emitFromParticle;
  17137. private _update;
  17138. /** @hidden */
  17139. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17140. /** @hidden */
  17141. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17142. /** @hidden */
  17143. private _getEffect;
  17144. /**
  17145. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17146. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17147. */
  17148. animate(preWarmOnly?: boolean): void;
  17149. private _appendParticleVertices;
  17150. /**
  17151. * Rebuilds the particle system.
  17152. */
  17153. rebuild(): void;
  17154. /**
  17155. * Is this system ready to be used/rendered
  17156. * @return true if the system is ready
  17157. */
  17158. isReady(): boolean;
  17159. private _render;
  17160. /**
  17161. * Renders the particle system in its current state.
  17162. * @returns the current number of particles
  17163. */
  17164. render(): number;
  17165. /**
  17166. * Disposes the particle system and free the associated resources
  17167. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17168. */
  17169. dispose(disposeTexture?: boolean): void;
  17170. /**
  17171. * Clones the particle system.
  17172. * @param name The name of the cloned object
  17173. * @param newEmitter The new emitter to use
  17174. * @returns the cloned particle system
  17175. */
  17176. clone(name: string, newEmitter: any): ParticleSystem;
  17177. /**
  17178. * Serializes the particle system to a JSON object.
  17179. * @returns the JSON object
  17180. */
  17181. serialize(): any;
  17182. /** @hidden */
  17183. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17184. /** @hidden */
  17185. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17186. /**
  17187. * Parses a JSON object to create a particle system.
  17188. * @param parsedParticleSystem The JSON object to parse
  17189. * @param scene The scene to create the particle system in
  17190. * @param rootUrl The root url to use to load external dependencies like texture
  17191. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17192. * @returns the Parsed particle system
  17193. */
  17194. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17195. }
  17196. }
  17197. declare module BABYLON {
  17198. /**
  17199. * A particle represents one of the element emitted by a particle system.
  17200. * This is mainly define by its coordinates, direction, velocity and age.
  17201. */
  17202. export class Particle {
  17203. /**
  17204. * The particle system the particle belongs to.
  17205. */
  17206. particleSystem: ParticleSystem;
  17207. private static _Count;
  17208. /**
  17209. * Unique ID of the particle
  17210. */
  17211. id: number;
  17212. /**
  17213. * The world position of the particle in the scene.
  17214. */
  17215. position: Vector3;
  17216. /**
  17217. * The world direction of the particle in the scene.
  17218. */
  17219. direction: Vector3;
  17220. /**
  17221. * The color of the particle.
  17222. */
  17223. color: Color4;
  17224. /**
  17225. * The color change of the particle per step.
  17226. */
  17227. colorStep: Color4;
  17228. /**
  17229. * Defines how long will the life of the particle be.
  17230. */
  17231. lifeTime: number;
  17232. /**
  17233. * The current age of the particle.
  17234. */
  17235. age: number;
  17236. /**
  17237. * The current size of the particle.
  17238. */
  17239. size: number;
  17240. /**
  17241. * The current scale of the particle.
  17242. */
  17243. scale: Vector2;
  17244. /**
  17245. * The current angle of the particle.
  17246. */
  17247. angle: number;
  17248. /**
  17249. * Defines how fast is the angle changing.
  17250. */
  17251. angularSpeed: number;
  17252. /**
  17253. * Defines the cell index used by the particle to be rendered from a sprite.
  17254. */
  17255. cellIndex: number;
  17256. /**
  17257. * The information required to support color remapping
  17258. */
  17259. remapData: Vector4;
  17260. /** @hidden */
  17261. _randomCellOffset?: number;
  17262. /** @hidden */
  17263. _initialDirection: Nullable<Vector3>;
  17264. /** @hidden */
  17265. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17266. /** @hidden */
  17267. _initialStartSpriteCellID: number;
  17268. /** @hidden */
  17269. _initialEndSpriteCellID: number;
  17270. /** @hidden */
  17271. _currentColorGradient: Nullable<ColorGradient>;
  17272. /** @hidden */
  17273. _currentColor1: Color4;
  17274. /** @hidden */
  17275. _currentColor2: Color4;
  17276. /** @hidden */
  17277. _currentSizeGradient: Nullable<FactorGradient>;
  17278. /** @hidden */
  17279. _currentSize1: number;
  17280. /** @hidden */
  17281. _currentSize2: number;
  17282. /** @hidden */
  17283. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17284. /** @hidden */
  17285. _currentAngularSpeed1: number;
  17286. /** @hidden */
  17287. _currentAngularSpeed2: number;
  17288. /** @hidden */
  17289. _currentVelocityGradient: Nullable<FactorGradient>;
  17290. /** @hidden */
  17291. _currentVelocity1: number;
  17292. /** @hidden */
  17293. _currentVelocity2: number;
  17294. /** @hidden */
  17295. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17296. /** @hidden */
  17297. _currentLimitVelocity1: number;
  17298. /** @hidden */
  17299. _currentLimitVelocity2: number;
  17300. /** @hidden */
  17301. _currentDragGradient: Nullable<FactorGradient>;
  17302. /** @hidden */
  17303. _currentDrag1: number;
  17304. /** @hidden */
  17305. _currentDrag2: number;
  17306. /** @hidden */
  17307. _randomNoiseCoordinates1: Vector3;
  17308. /** @hidden */
  17309. _randomNoiseCoordinates2: Vector3;
  17310. /**
  17311. * Creates a new instance Particle
  17312. * @param particleSystem the particle system the particle belongs to
  17313. */
  17314. constructor(
  17315. /**
  17316. * The particle system the particle belongs to.
  17317. */
  17318. particleSystem: ParticleSystem);
  17319. private updateCellInfoFromSystem;
  17320. /**
  17321. * Defines how the sprite cell index is updated for the particle
  17322. */
  17323. updateCellIndex(): void;
  17324. /** @hidden */
  17325. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17326. /** @hidden */
  17327. _inheritParticleInfoToSubEmitters(): void;
  17328. /** @hidden */
  17329. _reset(): void;
  17330. /**
  17331. * Copy the properties of particle to another one.
  17332. * @param other the particle to copy the information to.
  17333. */
  17334. copyTo(other: Particle): void;
  17335. }
  17336. }
  17337. declare module BABYLON {
  17338. /**
  17339. * Particle emitter represents a volume emitting particles.
  17340. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17341. */
  17342. export interface IParticleEmitterType {
  17343. /**
  17344. * Called by the particle System when the direction is computed for the created particle.
  17345. * @param worldMatrix is the world matrix of the particle system
  17346. * @param directionToUpdate is the direction vector to update with the result
  17347. * @param particle is the particle we are computed the direction for
  17348. */
  17349. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17350. /**
  17351. * Called by the particle System when the position is computed for the created particle.
  17352. * @param worldMatrix is the world matrix of the particle system
  17353. * @param positionToUpdate is the position vector to update with the result
  17354. * @param particle is the particle we are computed the position for
  17355. */
  17356. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17357. /**
  17358. * Clones the current emitter and returns a copy of it
  17359. * @returns the new emitter
  17360. */
  17361. clone(): IParticleEmitterType;
  17362. /**
  17363. * Called by the GPUParticleSystem to setup the update shader
  17364. * @param effect defines the update shader
  17365. */
  17366. applyToShader(effect: Effect): void;
  17367. /**
  17368. * Returns a string to use to update the GPU particles update shader
  17369. * @returns the effect defines string
  17370. */
  17371. getEffectDefines(): string;
  17372. /**
  17373. * Returns a string representing the class name
  17374. * @returns a string containing the class name
  17375. */
  17376. getClassName(): string;
  17377. /**
  17378. * Serializes the particle system to a JSON object.
  17379. * @returns the JSON object
  17380. */
  17381. serialize(): any;
  17382. /**
  17383. * Parse properties from a JSON object
  17384. * @param serializationObject defines the JSON object
  17385. */
  17386. parse(serializationObject: any): void;
  17387. }
  17388. }
  17389. declare module BABYLON {
  17390. /**
  17391. * Particle emitter emitting particles from the inside of a box.
  17392. * It emits the particles randomly between 2 given directions.
  17393. */
  17394. export class BoxParticleEmitter implements IParticleEmitterType {
  17395. /**
  17396. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17397. */
  17398. direction1: Vector3;
  17399. /**
  17400. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17401. */
  17402. direction2: Vector3;
  17403. /**
  17404. * 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.
  17405. */
  17406. minEmitBox: Vector3;
  17407. /**
  17408. * 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.
  17409. */
  17410. maxEmitBox: Vector3;
  17411. /**
  17412. * Creates a new instance BoxParticleEmitter
  17413. */
  17414. constructor();
  17415. /**
  17416. * Called by the particle System when the direction is computed for the created particle.
  17417. * @param worldMatrix is the world matrix of the particle system
  17418. * @param directionToUpdate is the direction vector to update with the result
  17419. * @param particle is the particle we are computed the direction for
  17420. */
  17421. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17422. /**
  17423. * Called by the particle System when the position is computed for the created particle.
  17424. * @param worldMatrix is the world matrix of the particle system
  17425. * @param positionToUpdate is the position vector to update with the result
  17426. * @param particle is the particle we are computed the position for
  17427. */
  17428. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17429. /**
  17430. * Clones the current emitter and returns a copy of it
  17431. * @returns the new emitter
  17432. */
  17433. clone(): BoxParticleEmitter;
  17434. /**
  17435. * Called by the GPUParticleSystem to setup the update shader
  17436. * @param effect defines the update shader
  17437. */
  17438. applyToShader(effect: Effect): void;
  17439. /**
  17440. * Returns a string to use to update the GPU particles update shader
  17441. * @returns a string containng the defines string
  17442. */
  17443. getEffectDefines(): string;
  17444. /**
  17445. * Returns the string "BoxParticleEmitter"
  17446. * @returns a string containing the class name
  17447. */
  17448. getClassName(): string;
  17449. /**
  17450. * Serializes the particle system to a JSON object.
  17451. * @returns the JSON object
  17452. */
  17453. serialize(): any;
  17454. /**
  17455. * Parse properties from a JSON object
  17456. * @param serializationObject defines the JSON object
  17457. */
  17458. parse(serializationObject: any): void;
  17459. }
  17460. }
  17461. declare module BABYLON {
  17462. /**
  17463. * Particle emitter emitting particles from the inside of a cone.
  17464. * It emits the particles alongside the cone volume from the base to the particle.
  17465. * The emission direction might be randomized.
  17466. */
  17467. export class ConeParticleEmitter implements IParticleEmitterType {
  17468. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17469. directionRandomizer: number;
  17470. private _radius;
  17471. private _angle;
  17472. private _height;
  17473. /**
  17474. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17475. */
  17476. radiusRange: number;
  17477. /**
  17478. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17479. */
  17480. heightRange: number;
  17481. /**
  17482. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17483. */
  17484. emitFromSpawnPointOnly: boolean;
  17485. /**
  17486. * Gets or sets the radius of the emission cone
  17487. */
  17488. radius: number;
  17489. /**
  17490. * Gets or sets the angle of the emission cone
  17491. */
  17492. angle: number;
  17493. private _buildHeight;
  17494. /**
  17495. * Creates a new instance ConeParticleEmitter
  17496. * @param radius the radius of the emission cone (1 by default)
  17497. * @param angle the cone base angle (PI by default)
  17498. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17499. */
  17500. constructor(radius?: number, angle?: number,
  17501. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17502. directionRandomizer?: number);
  17503. /**
  17504. * Called by the particle System when the direction is computed for the created particle.
  17505. * @param worldMatrix is the world matrix of the particle system
  17506. * @param directionToUpdate is the direction vector to update with the result
  17507. * @param particle is the particle we are computed the direction for
  17508. */
  17509. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17510. /**
  17511. * Called by the particle System when the position is computed for the created particle.
  17512. * @param worldMatrix is the world matrix of the particle system
  17513. * @param positionToUpdate is the position vector to update with the result
  17514. * @param particle is the particle we are computed the position for
  17515. */
  17516. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17517. /**
  17518. * Clones the current emitter and returns a copy of it
  17519. * @returns the new emitter
  17520. */
  17521. clone(): ConeParticleEmitter;
  17522. /**
  17523. * Called by the GPUParticleSystem to setup the update shader
  17524. * @param effect defines the update shader
  17525. */
  17526. applyToShader(effect: Effect): void;
  17527. /**
  17528. * Returns a string to use to update the GPU particles update shader
  17529. * @returns a string containng the defines string
  17530. */
  17531. getEffectDefines(): string;
  17532. /**
  17533. * Returns the string "ConeParticleEmitter"
  17534. * @returns a string containing the class name
  17535. */
  17536. getClassName(): string;
  17537. /**
  17538. * Serializes the particle system to a JSON object.
  17539. * @returns the JSON object
  17540. */
  17541. serialize(): any;
  17542. /**
  17543. * Parse properties from a JSON object
  17544. * @param serializationObject defines the JSON object
  17545. */
  17546. parse(serializationObject: any): void;
  17547. }
  17548. }
  17549. declare module BABYLON {
  17550. /**
  17551. * Particle emitter emitting particles from the inside of a cylinder.
  17552. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17553. */
  17554. export class CylinderParticleEmitter implements IParticleEmitterType {
  17555. /**
  17556. * The radius of the emission cylinder.
  17557. */
  17558. radius: number;
  17559. /**
  17560. * The height of the emission cylinder.
  17561. */
  17562. height: number;
  17563. /**
  17564. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17565. */
  17566. radiusRange: number;
  17567. /**
  17568. * How much to randomize the particle direction [0-1].
  17569. */
  17570. directionRandomizer: number;
  17571. /**
  17572. * Creates a new instance CylinderParticleEmitter
  17573. * @param radius the radius of the emission cylinder (1 by default)
  17574. * @param height the height of the emission cylinder (1 by default)
  17575. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17576. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17577. */
  17578. constructor(
  17579. /**
  17580. * The radius of the emission cylinder.
  17581. */
  17582. radius?: number,
  17583. /**
  17584. * The height of the emission cylinder.
  17585. */
  17586. height?: number,
  17587. /**
  17588. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17589. */
  17590. radiusRange?: number,
  17591. /**
  17592. * How much to randomize the particle direction [0-1].
  17593. */
  17594. directionRandomizer?: number);
  17595. /**
  17596. * Called by the particle System when the direction is computed for the created particle.
  17597. * @param worldMatrix is the world matrix of the particle system
  17598. * @param directionToUpdate is the direction vector to update with the result
  17599. * @param particle is the particle we are computed the direction for
  17600. */
  17601. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17602. /**
  17603. * Called by the particle System when the position is computed for the created particle.
  17604. * @param worldMatrix is the world matrix of the particle system
  17605. * @param positionToUpdate is the position vector to update with the result
  17606. * @param particle is the particle we are computed the position for
  17607. */
  17608. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17609. /**
  17610. * Clones the current emitter and returns a copy of it
  17611. * @returns the new emitter
  17612. */
  17613. clone(): CylinderParticleEmitter;
  17614. /**
  17615. * Called by the GPUParticleSystem to setup the update shader
  17616. * @param effect defines the update shader
  17617. */
  17618. applyToShader(effect: Effect): void;
  17619. /**
  17620. * Returns a string to use to update the GPU particles update shader
  17621. * @returns a string containng the defines string
  17622. */
  17623. getEffectDefines(): string;
  17624. /**
  17625. * Returns the string "CylinderParticleEmitter"
  17626. * @returns a string containing the class name
  17627. */
  17628. getClassName(): string;
  17629. /**
  17630. * Serializes the particle system to a JSON object.
  17631. * @returns the JSON object
  17632. */
  17633. serialize(): any;
  17634. /**
  17635. * Parse properties from a JSON object
  17636. * @param serializationObject defines the JSON object
  17637. */
  17638. parse(serializationObject: any): void;
  17639. }
  17640. /**
  17641. * Particle emitter emitting particles from the inside of a cylinder.
  17642. * It emits the particles randomly between two vectors.
  17643. */
  17644. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17645. /**
  17646. * The min limit of the emission direction.
  17647. */
  17648. direction1: Vector3;
  17649. /**
  17650. * The max limit of the emission direction.
  17651. */
  17652. direction2: Vector3;
  17653. /**
  17654. * Creates a new instance CylinderDirectedParticleEmitter
  17655. * @param radius the radius of the emission cylinder (1 by default)
  17656. * @param height the height of the emission cylinder (1 by default)
  17657. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17658. * @param direction1 the min limit of the emission direction (up vector by default)
  17659. * @param direction2 the max limit of the emission direction (up vector by default)
  17660. */
  17661. constructor(radius?: number, height?: number, radiusRange?: number,
  17662. /**
  17663. * The min limit of the emission direction.
  17664. */
  17665. direction1?: Vector3,
  17666. /**
  17667. * The max limit of the emission direction.
  17668. */
  17669. direction2?: Vector3);
  17670. /**
  17671. * Called by the particle System when the direction is computed for the created particle.
  17672. * @param worldMatrix is the world matrix of the particle system
  17673. * @param directionToUpdate is the direction vector to update with the result
  17674. * @param particle is the particle we are computed the direction for
  17675. */
  17676. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17677. /**
  17678. * Clones the current emitter and returns a copy of it
  17679. * @returns the new emitter
  17680. */
  17681. clone(): CylinderDirectedParticleEmitter;
  17682. /**
  17683. * Called by the GPUParticleSystem to setup the update shader
  17684. * @param effect defines the update shader
  17685. */
  17686. applyToShader(effect: Effect): void;
  17687. /**
  17688. * Returns a string to use to update the GPU particles update shader
  17689. * @returns a string containng the defines string
  17690. */
  17691. getEffectDefines(): string;
  17692. /**
  17693. * Returns the string "CylinderDirectedParticleEmitter"
  17694. * @returns a string containing the class name
  17695. */
  17696. getClassName(): string;
  17697. /**
  17698. * Serializes the particle system to a JSON object.
  17699. * @returns the JSON object
  17700. */
  17701. serialize(): any;
  17702. /**
  17703. * Parse properties from a JSON object
  17704. * @param serializationObject defines the JSON object
  17705. */
  17706. parse(serializationObject: any): void;
  17707. }
  17708. }
  17709. declare module BABYLON {
  17710. /**
  17711. * Particle emitter emitting particles from the inside of a hemisphere.
  17712. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17713. */
  17714. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17715. /**
  17716. * The radius of the emission hemisphere.
  17717. */
  17718. radius: number;
  17719. /**
  17720. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17721. */
  17722. radiusRange: number;
  17723. /**
  17724. * How much to randomize the particle direction [0-1].
  17725. */
  17726. directionRandomizer: number;
  17727. /**
  17728. * Creates a new instance HemisphericParticleEmitter
  17729. * @param radius the radius of the emission hemisphere (1 by default)
  17730. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17731. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17732. */
  17733. constructor(
  17734. /**
  17735. * The radius of the emission hemisphere.
  17736. */
  17737. radius?: number,
  17738. /**
  17739. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17740. */
  17741. radiusRange?: number,
  17742. /**
  17743. * How much to randomize the particle direction [0-1].
  17744. */
  17745. directionRandomizer?: number);
  17746. /**
  17747. * Called by the particle System when the direction is computed for the created particle.
  17748. * @param worldMatrix is the world matrix of the particle system
  17749. * @param directionToUpdate is the direction vector to update with the result
  17750. * @param particle is the particle we are computed the direction for
  17751. */
  17752. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17753. /**
  17754. * Called by the particle System when the position is computed for the created particle.
  17755. * @param worldMatrix is the world matrix of the particle system
  17756. * @param positionToUpdate is the position vector to update with the result
  17757. * @param particle is the particle we are computed the position for
  17758. */
  17759. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17760. /**
  17761. * Clones the current emitter and returns a copy of it
  17762. * @returns the new emitter
  17763. */
  17764. clone(): HemisphericParticleEmitter;
  17765. /**
  17766. * Called by the GPUParticleSystem to setup the update shader
  17767. * @param effect defines the update shader
  17768. */
  17769. applyToShader(effect: Effect): void;
  17770. /**
  17771. * Returns a string to use to update the GPU particles update shader
  17772. * @returns a string containng the defines string
  17773. */
  17774. getEffectDefines(): string;
  17775. /**
  17776. * Returns the string "HemisphericParticleEmitter"
  17777. * @returns a string containing the class name
  17778. */
  17779. getClassName(): string;
  17780. /**
  17781. * Serializes the particle system to a JSON object.
  17782. * @returns the JSON object
  17783. */
  17784. serialize(): any;
  17785. /**
  17786. * Parse properties from a JSON object
  17787. * @param serializationObject defines the JSON object
  17788. */
  17789. parse(serializationObject: any): void;
  17790. }
  17791. }
  17792. declare module BABYLON {
  17793. /**
  17794. * Particle emitter emitting particles from a point.
  17795. * It emits the particles randomly between 2 given directions.
  17796. */
  17797. export class PointParticleEmitter implements IParticleEmitterType {
  17798. /**
  17799. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17800. */
  17801. direction1: Vector3;
  17802. /**
  17803. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17804. */
  17805. direction2: Vector3;
  17806. /**
  17807. * Creates a new instance PointParticleEmitter
  17808. */
  17809. constructor();
  17810. /**
  17811. * Called by the particle System when the direction is computed for the created particle.
  17812. * @param worldMatrix is the world matrix of the particle system
  17813. * @param directionToUpdate is the direction vector to update with the result
  17814. * @param particle is the particle we are computed the direction for
  17815. */
  17816. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17817. /**
  17818. * Called by the particle System when the position is computed for the created particle.
  17819. * @param worldMatrix is the world matrix of the particle system
  17820. * @param positionToUpdate is the position vector to update with the result
  17821. * @param particle is the particle we are computed the position for
  17822. */
  17823. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17824. /**
  17825. * Clones the current emitter and returns a copy of it
  17826. * @returns the new emitter
  17827. */
  17828. clone(): PointParticleEmitter;
  17829. /**
  17830. * Called by the GPUParticleSystem to setup the update shader
  17831. * @param effect defines the update shader
  17832. */
  17833. applyToShader(effect: Effect): void;
  17834. /**
  17835. * Returns a string to use to update the GPU particles update shader
  17836. * @returns a string containng the defines string
  17837. */
  17838. getEffectDefines(): string;
  17839. /**
  17840. * Returns the string "PointParticleEmitter"
  17841. * @returns a string containing the class name
  17842. */
  17843. getClassName(): string;
  17844. /**
  17845. * Serializes the particle system to a JSON object.
  17846. * @returns the JSON object
  17847. */
  17848. serialize(): any;
  17849. /**
  17850. * Parse properties from a JSON object
  17851. * @param serializationObject defines the JSON object
  17852. */
  17853. parse(serializationObject: any): void;
  17854. }
  17855. }
  17856. declare module BABYLON {
  17857. /**
  17858. * Particle emitter emitting particles from the inside of a sphere.
  17859. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17860. */
  17861. export class SphereParticleEmitter implements IParticleEmitterType {
  17862. /**
  17863. * The radius of the emission sphere.
  17864. */
  17865. radius: number;
  17866. /**
  17867. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17868. */
  17869. radiusRange: number;
  17870. /**
  17871. * How much to randomize the particle direction [0-1].
  17872. */
  17873. directionRandomizer: number;
  17874. /**
  17875. * Creates a new instance SphereParticleEmitter
  17876. * @param radius the radius of the emission sphere (1 by default)
  17877. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17878. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17879. */
  17880. constructor(
  17881. /**
  17882. * The radius of the emission sphere.
  17883. */
  17884. radius?: number,
  17885. /**
  17886. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17887. */
  17888. radiusRange?: number,
  17889. /**
  17890. * How much to randomize the particle direction [0-1].
  17891. */
  17892. directionRandomizer?: number);
  17893. /**
  17894. * Called by the particle System when the direction is computed for the created particle.
  17895. * @param worldMatrix is the world matrix of the particle system
  17896. * @param directionToUpdate is the direction vector to update with the result
  17897. * @param particle is the particle we are computed the direction for
  17898. */
  17899. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17900. /**
  17901. * Called by the particle System when the position is computed for the created particle.
  17902. * @param worldMatrix is the world matrix of the particle system
  17903. * @param positionToUpdate is the position vector to update with the result
  17904. * @param particle is the particle we are computed the position for
  17905. */
  17906. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17907. /**
  17908. * Clones the current emitter and returns a copy of it
  17909. * @returns the new emitter
  17910. */
  17911. clone(): SphereParticleEmitter;
  17912. /**
  17913. * Called by the GPUParticleSystem to setup the update shader
  17914. * @param effect defines the update shader
  17915. */
  17916. applyToShader(effect: Effect): void;
  17917. /**
  17918. * Returns a string to use to update the GPU particles update shader
  17919. * @returns a string containng the defines string
  17920. */
  17921. getEffectDefines(): string;
  17922. /**
  17923. * Returns the string "SphereParticleEmitter"
  17924. * @returns a string containing the class name
  17925. */
  17926. getClassName(): string;
  17927. /**
  17928. * Serializes the particle system to a JSON object.
  17929. * @returns the JSON object
  17930. */
  17931. serialize(): any;
  17932. /**
  17933. * Parse properties from a JSON object
  17934. * @param serializationObject defines the JSON object
  17935. */
  17936. parse(serializationObject: any): void;
  17937. }
  17938. /**
  17939. * Particle emitter emitting particles from the inside of a sphere.
  17940. * It emits the particles randomly between two vectors.
  17941. */
  17942. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17943. /**
  17944. * The min limit of the emission direction.
  17945. */
  17946. direction1: Vector3;
  17947. /**
  17948. * The max limit of the emission direction.
  17949. */
  17950. direction2: Vector3;
  17951. /**
  17952. * Creates a new instance SphereDirectedParticleEmitter
  17953. * @param radius the radius of the emission sphere (1 by default)
  17954. * @param direction1 the min limit of the emission direction (up vector by default)
  17955. * @param direction2 the max limit of the emission direction (up vector by default)
  17956. */
  17957. constructor(radius?: number,
  17958. /**
  17959. * The min limit of the emission direction.
  17960. */
  17961. direction1?: Vector3,
  17962. /**
  17963. * The max limit of the emission direction.
  17964. */
  17965. direction2?: Vector3);
  17966. /**
  17967. * Called by the particle System when the direction is computed for the created particle.
  17968. * @param worldMatrix is the world matrix of the particle system
  17969. * @param directionToUpdate is the direction vector to update with the result
  17970. * @param particle is the particle we are computed the direction for
  17971. */
  17972. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17973. /**
  17974. * Clones the current emitter and returns a copy of it
  17975. * @returns the new emitter
  17976. */
  17977. clone(): SphereDirectedParticleEmitter;
  17978. /**
  17979. * Called by the GPUParticleSystem to setup the update shader
  17980. * @param effect defines the update shader
  17981. */
  17982. applyToShader(effect: Effect): void;
  17983. /**
  17984. * Returns a string to use to update the GPU particles update shader
  17985. * @returns a string containng the defines string
  17986. */
  17987. getEffectDefines(): string;
  17988. /**
  17989. * Returns the string "SphereDirectedParticleEmitter"
  17990. * @returns a string containing the class name
  17991. */
  17992. getClassName(): string;
  17993. /**
  17994. * Serializes the particle system to a JSON object.
  17995. * @returns the JSON object
  17996. */
  17997. serialize(): any;
  17998. /**
  17999. * Parse properties from a JSON object
  18000. * @param serializationObject defines the JSON object
  18001. */
  18002. parse(serializationObject: any): void;
  18003. }
  18004. }
  18005. declare module BABYLON {
  18006. /**
  18007. * Interface representing a particle system in Babylon.js.
  18008. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18009. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18010. */
  18011. export interface IParticleSystem {
  18012. /**
  18013. * List of animations used by the particle system.
  18014. */
  18015. animations: Animation[];
  18016. /**
  18017. * The id of the Particle system.
  18018. */
  18019. id: string;
  18020. /**
  18021. * The name of the Particle system.
  18022. */
  18023. name: string;
  18024. /**
  18025. * The emitter represents the Mesh or position we are attaching the particle system to.
  18026. */
  18027. emitter: Nullable<AbstractMesh | Vector3>;
  18028. /**
  18029. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18030. */
  18031. isBillboardBased: boolean;
  18032. /**
  18033. * The rendering group used by the Particle system to chose when to render.
  18034. */
  18035. renderingGroupId: number;
  18036. /**
  18037. * The layer mask we are rendering the particles through.
  18038. */
  18039. layerMask: number;
  18040. /**
  18041. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18042. */
  18043. updateSpeed: number;
  18044. /**
  18045. * The amount of time the particle system is running (depends of the overall update speed).
  18046. */
  18047. targetStopDuration: number;
  18048. /**
  18049. * The texture used to render each particle. (this can be a spritesheet)
  18050. */
  18051. particleTexture: Nullable<Texture>;
  18052. /**
  18053. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18054. */
  18055. blendMode: number;
  18056. /**
  18057. * Minimum life time of emitting particles.
  18058. */
  18059. minLifeTime: number;
  18060. /**
  18061. * Maximum life time of emitting particles.
  18062. */
  18063. maxLifeTime: number;
  18064. /**
  18065. * Minimum Size of emitting particles.
  18066. */
  18067. minSize: number;
  18068. /**
  18069. * Maximum Size of emitting particles.
  18070. */
  18071. maxSize: number;
  18072. /**
  18073. * Minimum scale of emitting particles on X axis.
  18074. */
  18075. minScaleX: number;
  18076. /**
  18077. * Maximum scale of emitting particles on X axis.
  18078. */
  18079. maxScaleX: number;
  18080. /**
  18081. * Minimum scale of emitting particles on Y axis.
  18082. */
  18083. minScaleY: number;
  18084. /**
  18085. * Maximum scale of emitting particles on Y axis.
  18086. */
  18087. maxScaleY: number;
  18088. /**
  18089. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18090. */
  18091. color1: Color4;
  18092. /**
  18093. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18094. */
  18095. color2: Color4;
  18096. /**
  18097. * Color the particle will have at the end of its lifetime.
  18098. */
  18099. colorDead: Color4;
  18100. /**
  18101. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18102. */
  18103. emitRate: number;
  18104. /**
  18105. * You can use gravity if you want to give an orientation to your particles.
  18106. */
  18107. gravity: Vector3;
  18108. /**
  18109. * Minimum power of emitting particles.
  18110. */
  18111. minEmitPower: number;
  18112. /**
  18113. * Maximum power of emitting particles.
  18114. */
  18115. maxEmitPower: number;
  18116. /**
  18117. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18118. */
  18119. minAngularSpeed: number;
  18120. /**
  18121. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18122. */
  18123. maxAngularSpeed: number;
  18124. /**
  18125. * Gets or sets the minimal initial rotation in radians.
  18126. */
  18127. minInitialRotation: number;
  18128. /**
  18129. * Gets or sets the maximal initial rotation in radians.
  18130. */
  18131. maxInitialRotation: number;
  18132. /**
  18133. * The particle emitter type defines the emitter used by the particle system.
  18134. * It can be for example box, sphere, or cone...
  18135. */
  18136. particleEmitterType: Nullable<IParticleEmitterType>;
  18137. /**
  18138. * Defines the delay in milliseconds before starting the system (0 by default)
  18139. */
  18140. startDelay: number;
  18141. /**
  18142. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  18143. */
  18144. preWarmCycles: number;
  18145. /**
  18146. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18147. */
  18148. preWarmStepOffset: number;
  18149. /**
  18150. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  18151. */
  18152. spriteCellChangeSpeed: number;
  18153. /**
  18154. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18155. */
  18156. startSpriteCellID: number;
  18157. /**
  18158. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18159. */
  18160. endSpriteCellID: number;
  18161. /**
  18162. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18163. */
  18164. spriteCellWidth: number;
  18165. /**
  18166. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18167. */
  18168. spriteCellHeight: number;
  18169. /**
  18170. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18171. */
  18172. spriteRandomStartCell: boolean;
  18173. /**
  18174. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18175. */
  18176. isAnimationSheetEnabled: boolean;
  18177. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18178. translationPivot: Vector2;
  18179. /**
  18180. * Gets or sets a texture used to add random noise to particle positions
  18181. */
  18182. noiseTexture: Nullable<BaseTexture>;
  18183. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18184. noiseStrength: Vector3;
  18185. /**
  18186. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18187. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18188. */
  18189. billboardMode: number;
  18190. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18191. limitVelocityDamping: number;
  18192. /**
  18193. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18194. */
  18195. beginAnimationOnStart: boolean;
  18196. /**
  18197. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18198. */
  18199. beginAnimationFrom: number;
  18200. /**
  18201. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18202. */
  18203. beginAnimationTo: number;
  18204. /**
  18205. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18206. */
  18207. beginAnimationLoop: boolean;
  18208. /**
  18209. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18210. */
  18211. disposeOnStop: boolean;
  18212. /**
  18213. * Gets the maximum number of particles active at the same time.
  18214. * @returns The max number of active particles.
  18215. */
  18216. getCapacity(): number;
  18217. /**
  18218. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18219. * @returns True if it has been started, otherwise false.
  18220. */
  18221. isStarted(): boolean;
  18222. /**
  18223. * Animates the particle system for this frame.
  18224. */
  18225. animate(): void;
  18226. /**
  18227. * Renders the particle system in its current state.
  18228. * @returns the current number of particles
  18229. */
  18230. render(): number;
  18231. /**
  18232. * Dispose the particle system and frees its associated resources.
  18233. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18234. */
  18235. dispose(disposeTexture?: boolean): void;
  18236. /**
  18237. * Clones the particle system.
  18238. * @param name The name of the cloned object
  18239. * @param newEmitter The new emitter to use
  18240. * @returns the cloned particle system
  18241. */
  18242. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18243. /**
  18244. * Serializes the particle system to a JSON object.
  18245. * @returns the JSON object
  18246. */
  18247. serialize(): any;
  18248. /**
  18249. * Rebuild the particle system
  18250. */
  18251. rebuild(): void;
  18252. /**
  18253. * Starts the particle system and begins to emit
  18254. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18255. */
  18256. start(delay?: number): void;
  18257. /**
  18258. * Stops the particle system.
  18259. */
  18260. stop(): void;
  18261. /**
  18262. * Remove all active particles
  18263. */
  18264. reset(): void;
  18265. /**
  18266. * Is this system ready to be used/rendered
  18267. * @return true if the system is ready
  18268. */
  18269. isReady(): boolean;
  18270. /**
  18271. * Adds a new color gradient
  18272. * @param gradient defines the gradient to use (between 0 and 1)
  18273. * @param color1 defines the color to affect to the specified gradient
  18274. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18275. * @returns the current particle system
  18276. */
  18277. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18278. /**
  18279. * Remove a specific color gradient
  18280. * @param gradient defines the gradient to remove
  18281. * @returns the current particle system
  18282. */
  18283. removeColorGradient(gradient: number): IParticleSystem;
  18284. /**
  18285. * Adds a new size gradient
  18286. * @param gradient defines the gradient to use (between 0 and 1)
  18287. * @param factor defines the size factor to affect to the specified gradient
  18288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18289. * @returns the current particle system
  18290. */
  18291. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18292. /**
  18293. * Remove a specific size gradient
  18294. * @param gradient defines the gradient to remove
  18295. * @returns the current particle system
  18296. */
  18297. removeSizeGradient(gradient: number): IParticleSystem;
  18298. /**
  18299. * Gets the current list of color gradients.
  18300. * You must use addColorGradient and removeColorGradient to udpate this list
  18301. * @returns the list of color gradients
  18302. */
  18303. getColorGradients(): Nullable<Array<ColorGradient>>;
  18304. /**
  18305. * Gets the current list of size gradients.
  18306. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18307. * @returns the list of size gradients
  18308. */
  18309. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18310. /**
  18311. * Gets the current list of angular speed gradients.
  18312. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18313. * @returns the list of angular speed gradients
  18314. */
  18315. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18316. /**
  18317. * Adds a new angular speed gradient
  18318. * @param gradient defines the gradient to use (between 0 and 1)
  18319. * @param factor defines the angular speed to affect to the specified gradient
  18320. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18321. * @returns the current particle system
  18322. */
  18323. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18324. /**
  18325. * Remove a specific angular speed gradient
  18326. * @param gradient defines the gradient to remove
  18327. * @returns the current particle system
  18328. */
  18329. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18330. /**
  18331. * Gets the current list of velocity gradients.
  18332. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18333. * @returns the list of velocity gradients
  18334. */
  18335. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18336. /**
  18337. * Adds a new velocity gradient
  18338. * @param gradient defines the gradient to use (between 0 and 1)
  18339. * @param factor defines the velocity to affect to the specified gradient
  18340. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18341. * @returns the current particle system
  18342. */
  18343. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18344. /**
  18345. * Remove a specific velocity gradient
  18346. * @param gradient defines the gradient to remove
  18347. * @returns the current particle system
  18348. */
  18349. removeVelocityGradient(gradient: number): IParticleSystem;
  18350. /**
  18351. * Gets the current list of limit velocity gradients.
  18352. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18353. * @returns the list of limit velocity gradients
  18354. */
  18355. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18356. /**
  18357. * Adds a new limit velocity gradient
  18358. * @param gradient defines the gradient to use (between 0 and 1)
  18359. * @param factor defines the limit velocity to affect to the specified gradient
  18360. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18361. * @returns the current particle system
  18362. */
  18363. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18364. /**
  18365. * Remove a specific limit velocity gradient
  18366. * @param gradient defines the gradient to remove
  18367. * @returns the current particle system
  18368. */
  18369. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18370. /**
  18371. * Adds a new drag gradient
  18372. * @param gradient defines the gradient to use (between 0 and 1)
  18373. * @param factor defines the drag to affect to the specified gradient
  18374. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18375. * @returns the current particle system
  18376. */
  18377. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18378. /**
  18379. * Remove a specific drag gradient
  18380. * @param gradient defines the gradient to remove
  18381. * @returns the current particle system
  18382. */
  18383. removeDragGradient(gradient: number): IParticleSystem;
  18384. /**
  18385. * Gets the current list of drag gradients.
  18386. * You must use addDragGradient and removeDragGradient to udpate this list
  18387. * @returns the list of drag gradients
  18388. */
  18389. getDragGradients(): Nullable<Array<FactorGradient>>;
  18390. /**
  18391. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18392. * @param gradient defines the gradient to use (between 0 and 1)
  18393. * @param factor defines the emit rate to affect to the specified gradient
  18394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18395. * @returns the current particle system
  18396. */
  18397. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18398. /**
  18399. * Remove a specific emit rate gradient
  18400. * @param gradient defines the gradient to remove
  18401. * @returns the current particle system
  18402. */
  18403. removeEmitRateGradient(gradient: number): IParticleSystem;
  18404. /**
  18405. * Gets the current list of emit rate gradients.
  18406. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18407. * @returns the list of emit rate gradients
  18408. */
  18409. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18410. /**
  18411. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18412. * @param gradient defines the gradient to use (between 0 and 1)
  18413. * @param factor defines the start size to affect to the specified gradient
  18414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18415. * @returns the current particle system
  18416. */
  18417. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18418. /**
  18419. * Remove a specific start size gradient
  18420. * @param gradient defines the gradient to remove
  18421. * @returns the current particle system
  18422. */
  18423. removeStartSizeGradient(gradient: number): IParticleSystem;
  18424. /**
  18425. * Gets the current list of start size gradients.
  18426. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18427. * @returns the list of start size gradients
  18428. */
  18429. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18430. /**
  18431. * Adds a new life time gradient
  18432. * @param gradient defines the gradient to use (between 0 and 1)
  18433. * @param factor defines the life time factor to affect to the specified gradient
  18434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18435. * @returns the current particle system
  18436. */
  18437. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18438. /**
  18439. * Remove a specific life time gradient
  18440. * @param gradient defines the gradient to remove
  18441. * @returns the current particle system
  18442. */
  18443. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18444. /**
  18445. * Gets the current list of life time gradients.
  18446. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18447. * @returns the list of life time gradients
  18448. */
  18449. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18450. /**
  18451. * Gets the current list of color gradients.
  18452. * You must use addColorGradient and removeColorGradient to udpate this list
  18453. * @returns the list of color gradients
  18454. */
  18455. getColorGradients(): Nullable<Array<ColorGradient>>;
  18456. /**
  18457. * Adds a new ramp gradient used to remap particle colors
  18458. * @param gradient defines the gradient to use (between 0 and 1)
  18459. * @param color defines the color to affect to the specified gradient
  18460. * @returns the current particle system
  18461. */
  18462. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18463. /**
  18464. * Gets the current list of ramp gradients.
  18465. * You must use addRampGradient and removeRampGradient to udpate this list
  18466. * @returns the list of ramp gradients
  18467. */
  18468. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18469. /** Gets or sets a boolean indicating that ramp gradients must be used
  18470. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18471. */
  18472. useRampGradients: boolean;
  18473. /**
  18474. * Adds a new color remap gradient
  18475. * @param gradient defines the gradient to use (between 0 and 1)
  18476. * @param min defines the color remap minimal range
  18477. * @param max defines the color remap maximal range
  18478. * @returns the current particle system
  18479. */
  18480. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18481. /**
  18482. * Gets the current list of color remap gradients.
  18483. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18484. * @returns the list of color remap gradients
  18485. */
  18486. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18487. /**
  18488. * Adds a new alpha remap gradient
  18489. * @param gradient defines the gradient to use (between 0 and 1)
  18490. * @param min defines the alpha remap minimal range
  18491. * @param max defines the alpha remap maximal range
  18492. * @returns the current particle system
  18493. */
  18494. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18495. /**
  18496. * Gets the current list of alpha remap gradients.
  18497. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18498. * @returns the list of alpha remap gradients
  18499. */
  18500. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18501. /**
  18502. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18503. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18504. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18505. * @returns the emitter
  18506. */
  18507. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18508. /**
  18509. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18510. * @param radius The radius of the hemisphere to emit from
  18511. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18512. * @returns the emitter
  18513. */
  18514. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18515. /**
  18516. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18517. * @param radius The radius of the sphere to emit from
  18518. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18519. * @returns the emitter
  18520. */
  18521. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18522. /**
  18523. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18524. * @param radius The radius of the sphere to emit from
  18525. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18526. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18527. * @returns the emitter
  18528. */
  18529. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18530. /**
  18531. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18532. * @param radius The radius of the emission cylinder
  18533. * @param height The height of the emission cylinder
  18534. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18535. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18536. * @returns the emitter
  18537. */
  18538. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18539. /**
  18540. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18541. * @param radius The radius of the cylinder to emit from
  18542. * @param height The height of the emission cylinder
  18543. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18544. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18545. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18546. * @returns the emitter
  18547. */
  18548. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18549. /**
  18550. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18551. * @param radius The radius of the cone to emit from
  18552. * @param angle The base angle of the cone
  18553. * @returns the emitter
  18554. */
  18555. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18556. /**
  18557. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18558. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18559. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18560. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18561. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18562. * @returns the emitter
  18563. */
  18564. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18565. /**
  18566. * Get hosting scene
  18567. * @returns the scene
  18568. */
  18569. getScene(): Scene;
  18570. }
  18571. }
  18572. declare module BABYLON {
  18573. /**
  18574. * Creates an instance based on a source mesh.
  18575. */
  18576. export class InstancedMesh extends AbstractMesh {
  18577. private _sourceMesh;
  18578. private _currentLOD;
  18579. /** @hidden */
  18580. _indexInSourceMeshInstanceArray: number;
  18581. constructor(name: string, source: Mesh);
  18582. /**
  18583. * Returns the string "InstancedMesh".
  18584. */
  18585. getClassName(): string;
  18586. /** Gets the list of lights affecting that mesh */
  18587. readonly lightSources: Light[];
  18588. _resyncLightSources(): void;
  18589. _resyncLighSource(light: Light): void;
  18590. _removeLightSource(light: Light): void;
  18591. /**
  18592. * If the source mesh receives shadows
  18593. */
  18594. readonly receiveShadows: boolean;
  18595. /**
  18596. * The material of the source mesh
  18597. */
  18598. readonly material: Nullable<Material>;
  18599. /**
  18600. * Visibility of the source mesh
  18601. */
  18602. readonly visibility: number;
  18603. /**
  18604. * Skeleton of the source mesh
  18605. */
  18606. readonly skeleton: Nullable<Skeleton>;
  18607. /**
  18608. * Rendering ground id of the source mesh
  18609. */
  18610. renderingGroupId: number;
  18611. /**
  18612. * Returns the total number of vertices (integer).
  18613. */
  18614. getTotalVertices(): number;
  18615. /**
  18616. * Returns a positive integer : the total number of indices in this mesh geometry.
  18617. * @returns the numner of indices or zero if the mesh has no geometry.
  18618. */
  18619. getTotalIndices(): number;
  18620. /**
  18621. * The source mesh of the instance
  18622. */
  18623. readonly sourceMesh: Mesh;
  18624. /**
  18625. * Is this node ready to be used/rendered
  18626. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18627. * @return {boolean} is it ready
  18628. */
  18629. isReady(completeCheck?: boolean): boolean;
  18630. /**
  18631. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18632. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18633. * @param copyWhenShared If 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.
  18634. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18635. */
  18636. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18637. /**
  18638. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18639. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18640. * The `data` are either a numeric array either a Float32Array.
  18641. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18642. * 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).
  18643. * Note that a new underlying VertexBuffer object is created each call.
  18644. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18645. *
  18646. * Possible `kind` values :
  18647. * - VertexBuffer.PositionKind
  18648. * - VertexBuffer.UVKind
  18649. * - VertexBuffer.UV2Kind
  18650. * - VertexBuffer.UV3Kind
  18651. * - VertexBuffer.UV4Kind
  18652. * - VertexBuffer.UV5Kind
  18653. * - VertexBuffer.UV6Kind
  18654. * - VertexBuffer.ColorKind
  18655. * - VertexBuffer.MatricesIndicesKind
  18656. * - VertexBuffer.MatricesIndicesExtraKind
  18657. * - VertexBuffer.MatricesWeightsKind
  18658. * - VertexBuffer.MatricesWeightsExtraKind
  18659. *
  18660. * Returns the Mesh.
  18661. */
  18662. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18663. /**
  18664. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18665. * If the mesh has no geometry, it is simply returned as it is.
  18666. * The `data` are either a numeric array either a Float32Array.
  18667. * No new underlying VertexBuffer object is created.
  18668. * 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.
  18669. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18670. *
  18671. * Possible `kind` values :
  18672. * - VertexBuffer.PositionKind
  18673. * - VertexBuffer.UVKind
  18674. * - VertexBuffer.UV2Kind
  18675. * - VertexBuffer.UV3Kind
  18676. * - VertexBuffer.UV4Kind
  18677. * - VertexBuffer.UV5Kind
  18678. * - VertexBuffer.UV6Kind
  18679. * - VertexBuffer.ColorKind
  18680. * - VertexBuffer.MatricesIndicesKind
  18681. * - VertexBuffer.MatricesIndicesExtraKind
  18682. * - VertexBuffer.MatricesWeightsKind
  18683. * - VertexBuffer.MatricesWeightsExtraKind
  18684. *
  18685. * Returns the Mesh.
  18686. */
  18687. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18688. /**
  18689. * Sets the mesh indices.
  18690. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18691. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18692. * This method creates a new index buffer each call.
  18693. * Returns the Mesh.
  18694. */
  18695. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18696. /**
  18697. * Boolean : True if the mesh owns the requested kind of data.
  18698. */
  18699. isVerticesDataPresent(kind: string): boolean;
  18700. /**
  18701. * Returns an array of indices (IndicesArray).
  18702. */
  18703. getIndices(): Nullable<IndicesArray>;
  18704. readonly _positions: Nullable<Vector3[]>;
  18705. /**
  18706. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18707. * This means the mesh underlying bounding box and sphere are recomputed.
  18708. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18709. * @returns the current mesh
  18710. */
  18711. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18712. /** @hidden */
  18713. _preActivate(): InstancedMesh;
  18714. /** @hidden */
  18715. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18716. /** @hidden */
  18717. _postActivate(): void;
  18718. getWorldMatrix(): Matrix;
  18719. readonly isAnInstance: boolean;
  18720. /**
  18721. * Returns the current associated LOD AbstractMesh.
  18722. */
  18723. getLOD(camera: Camera): AbstractMesh;
  18724. /** @hidden */
  18725. _syncSubMeshes(): InstancedMesh;
  18726. /** @hidden */
  18727. _generatePointsArray(): boolean;
  18728. /**
  18729. * Creates a new InstancedMesh from the current mesh.
  18730. * - name (string) : the cloned mesh name
  18731. * - newParent (optional Node) : the optional Node to parent the clone to.
  18732. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18733. *
  18734. * Returns the clone.
  18735. */
  18736. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18737. /**
  18738. * Disposes the InstancedMesh.
  18739. * Returns nothing.
  18740. */
  18741. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18742. }
  18743. }
  18744. declare module BABYLON {
  18745. /**
  18746. * Defines the options associated with the creation of a shader material.
  18747. */
  18748. export interface IShaderMaterialOptions {
  18749. /**
  18750. * Does the material work in alpha blend mode
  18751. */
  18752. needAlphaBlending: boolean;
  18753. /**
  18754. * Does the material work in alpha test mode
  18755. */
  18756. needAlphaTesting: boolean;
  18757. /**
  18758. * The list of attribute names used in the shader
  18759. */
  18760. attributes: string[];
  18761. /**
  18762. * The list of unifrom names used in the shader
  18763. */
  18764. uniforms: string[];
  18765. /**
  18766. * The list of UBO names used in the shader
  18767. */
  18768. uniformBuffers: string[];
  18769. /**
  18770. * The list of sampler names used in the shader
  18771. */
  18772. samplers: string[];
  18773. /**
  18774. * The list of defines used in the shader
  18775. */
  18776. defines: string[];
  18777. }
  18778. /**
  18779. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  18780. *
  18781. * This returned material effects how the mesh will look based on the code in the shaders.
  18782. *
  18783. * @see http://doc.babylonjs.com/how_to/shader_material
  18784. */
  18785. export class ShaderMaterial extends Material {
  18786. private _shaderPath;
  18787. private _options;
  18788. private _textures;
  18789. private _textureArrays;
  18790. private _floats;
  18791. private _ints;
  18792. private _floatsArrays;
  18793. private _colors3;
  18794. private _colors3Arrays;
  18795. private _colors4;
  18796. private _colors4Arrays;
  18797. private _vectors2;
  18798. private _vectors3;
  18799. private _vectors4;
  18800. private _matrices;
  18801. private _matrices3x3;
  18802. private _matrices2x2;
  18803. private _vectors2Arrays;
  18804. private _vectors3Arrays;
  18805. private _vectors4Arrays;
  18806. private _cachedWorldViewMatrix;
  18807. private _cachedWorldViewProjectionMatrix;
  18808. private _renderId;
  18809. /**
  18810. * Instantiate a new shader material.
  18811. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  18812. * This returned material effects how the mesh will look based on the code in the shaders.
  18813. * @see http://doc.babylonjs.com/how_to/shader_material
  18814. * @param name Define the name of the material in the scene
  18815. * @param scene Define the scene the material belongs to
  18816. * @param shaderPath Defines the route to the shader code in one of three ways:
  18817. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18818. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18819. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18820. * @param options Define the options used to create the shader
  18821. */
  18822. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18823. /**
  18824. * Gets the options used to compile the shader.
  18825. * They can be modified to trigger a new compilation
  18826. */
  18827. readonly options: IShaderMaterialOptions;
  18828. /**
  18829. * Gets the current class name of the material e.g. "ShaderMaterial"
  18830. * Mainly use in serialization.
  18831. * @returns the class name
  18832. */
  18833. getClassName(): string;
  18834. /**
  18835. * Specifies if the material will require alpha blending
  18836. * @returns a boolean specifying if alpha blending is needed
  18837. */
  18838. needAlphaBlending(): boolean;
  18839. /**
  18840. * Specifies if this material should be rendered in alpha test mode
  18841. * @returns a boolean specifying if an alpha test is needed.
  18842. */
  18843. needAlphaTesting(): boolean;
  18844. private _checkUniform;
  18845. /**
  18846. * Set a texture in the shader.
  18847. * @param name Define the name of the uniform samplers as defined in the shader
  18848. * @param texture Define the texture to bind to this sampler
  18849. * @return the material itself allowing "fluent" like uniform updates
  18850. */
  18851. setTexture(name: string, texture: Texture): ShaderMaterial;
  18852. /**
  18853. * Set a texture array in the shader.
  18854. * @param name Define the name of the uniform sampler array as defined in the shader
  18855. * @param textures Define the list of textures to bind to this sampler
  18856. * @return the material itself allowing "fluent" like uniform updates
  18857. */
  18858. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18859. /**
  18860. * Set a float in the shader.
  18861. * @param name Define the name of the uniform as defined in the shader
  18862. * @param value Define the value to give to the uniform
  18863. * @return the material itself allowing "fluent" like uniform updates
  18864. */
  18865. setFloat(name: string, value: number): ShaderMaterial;
  18866. /**
  18867. * Set a int in the shader.
  18868. * @param name Define the name of the uniform as defined in the shader
  18869. * @param value Define the value to give to the uniform
  18870. * @return the material itself allowing "fluent" like uniform updates
  18871. */
  18872. setInt(name: string, value: number): ShaderMaterial;
  18873. /**
  18874. * Set an array of floats in the shader.
  18875. * @param name Define the name of the uniform as defined in the shader
  18876. * @param value Define the value to give to the uniform
  18877. * @return the material itself allowing "fluent" like uniform updates
  18878. */
  18879. setFloats(name: string, value: number[]): ShaderMaterial;
  18880. /**
  18881. * Set a vec3 in the shader from a Color3.
  18882. * @param name Define the name of the uniform as defined in the shader
  18883. * @param value Define the value to give to the uniform
  18884. * @return the material itself allowing "fluent" like uniform updates
  18885. */
  18886. setColor3(name: string, value: Color3): ShaderMaterial;
  18887. /**
  18888. * Set a vec3 array in the shader from a Color3 array.
  18889. * @param name Define the name of the uniform as defined in the shader
  18890. * @param value Define the value to give to the uniform
  18891. * @return the material itself allowing "fluent" like uniform updates
  18892. */
  18893. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18894. /**
  18895. * Set a vec4 in the shader from a Color4.
  18896. * @param name Define the name of the uniform as defined in the shader
  18897. * @param value Define the value to give to the uniform
  18898. * @return the material itself allowing "fluent" like uniform updates
  18899. */
  18900. setColor4(name: string, value: Color4): ShaderMaterial;
  18901. /**
  18902. * Set a vec4 array in the shader from a Color4 array.
  18903. * @param name Define the name of the uniform as defined in the shader
  18904. * @param value Define the value to give to the uniform
  18905. * @return the material itself allowing "fluent" like uniform updates
  18906. */
  18907. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18908. /**
  18909. * Set a vec2 in the shader from a Vector2.
  18910. * @param name Define the name of the uniform as defined in the shader
  18911. * @param value Define the value to give to the uniform
  18912. * @return the material itself allowing "fluent" like uniform updates
  18913. */
  18914. setVector2(name: string, value: Vector2): ShaderMaterial;
  18915. /**
  18916. * Set a vec3 in the shader from a Vector3.
  18917. * @param name Define the name of the uniform as defined in the shader
  18918. * @param value Define the value to give to the uniform
  18919. * @return the material itself allowing "fluent" like uniform updates
  18920. */
  18921. setVector3(name: string, value: Vector3): ShaderMaterial;
  18922. /**
  18923. * Set a vec4 in the shader from a Vector4.
  18924. * @param name Define the name of the uniform as defined in the shader
  18925. * @param value Define the value to give to the uniform
  18926. * @return the material itself allowing "fluent" like uniform updates
  18927. */
  18928. setVector4(name: string, value: Vector4): ShaderMaterial;
  18929. /**
  18930. * Set a mat4 in the shader from a Matrix.
  18931. * @param name Define the name of the uniform as defined in the shader
  18932. * @param value Define the value to give to the uniform
  18933. * @return the material itself allowing "fluent" like uniform updates
  18934. */
  18935. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18936. /**
  18937. * Set a mat3 in the shader from a Float32Array.
  18938. * @param name Define the name of the uniform as defined in the shader
  18939. * @param value Define the value to give to the uniform
  18940. * @return the material itself allowing "fluent" like uniform updates
  18941. */
  18942. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18943. /**
  18944. * Set a mat2 in the shader from a Float32Array.
  18945. * @param name Define the name of the uniform as defined in the shader
  18946. * @param value Define the value to give to the uniform
  18947. * @return the material itself allowing "fluent" like uniform updates
  18948. */
  18949. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18950. /**
  18951. * Set a vec2 array in the shader from a number array.
  18952. * @param name Define the name of the uniform as defined in the shader
  18953. * @param value Define the value to give to the uniform
  18954. * @return the material itself allowing "fluent" like uniform updates
  18955. */
  18956. setArray2(name: string, value: number[]): ShaderMaterial;
  18957. /**
  18958. * Set a vec3 array in the shader from a number array.
  18959. * @param name Define the name of the uniform as defined in the shader
  18960. * @param value Define the value to give to the uniform
  18961. * @return the material itself allowing "fluent" like uniform updates
  18962. */
  18963. setArray3(name: string, value: number[]): ShaderMaterial;
  18964. /**
  18965. * Set a vec4 array in the shader from a number array.
  18966. * @param name Define the name of the uniform as defined in the shader
  18967. * @param value Define the value to give to the uniform
  18968. * @return the material itself allowing "fluent" like uniform updates
  18969. */
  18970. setArray4(name: string, value: number[]): ShaderMaterial;
  18971. private _checkCache;
  18972. /**
  18973. * Specifies that the submesh is ready to be used
  18974. * @param mesh defines the mesh to check
  18975. * @param subMesh defines which submesh to check
  18976. * @param useInstances specifies that instances should be used
  18977. * @returns a boolean indicating that the submesh is ready or not
  18978. */
  18979. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18980. /**
  18981. * Checks if the material is ready to render the requested mesh
  18982. * @param mesh Define the mesh to render
  18983. * @param useInstances Define whether or not the material is used with instances
  18984. * @returns true if ready, otherwise false
  18985. */
  18986. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18987. /**
  18988. * Binds the world matrix to the material
  18989. * @param world defines the world transformation matrix
  18990. */
  18991. bindOnlyWorldMatrix(world: Matrix): void;
  18992. /**
  18993. * Binds the material to the mesh
  18994. * @param world defines the world transformation matrix
  18995. * @param mesh defines the mesh to bind the material to
  18996. */
  18997. bind(world: Matrix, mesh?: Mesh): void;
  18998. /**
  18999. * Gets the active textures from the material
  19000. * @returns an array of textures
  19001. */
  19002. getActiveTextures(): BaseTexture[];
  19003. /**
  19004. * Specifies if the material uses a texture
  19005. * @param texture defines the texture to check against the material
  19006. * @returns a boolean specifying if the material uses the texture
  19007. */
  19008. hasTexture(texture: BaseTexture): boolean;
  19009. /**
  19010. * Makes a duplicate of the material, and gives it a new name
  19011. * @param name defines the new name for the duplicated material
  19012. * @returns the cloned material
  19013. */
  19014. clone(name: string): ShaderMaterial;
  19015. /**
  19016. * Disposes the material
  19017. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19018. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19019. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19020. */
  19021. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19022. /**
  19023. * Serializes this material in a JSON representation
  19024. * @returns the serialized material object
  19025. */
  19026. serialize(): any;
  19027. /**
  19028. * Creates a shader material from parsed shader material data
  19029. * @param source defines the JSON represnetation of the material
  19030. * @param scene defines the hosting scene
  19031. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19032. * @returns a new material
  19033. */
  19034. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19035. }
  19036. }
  19037. declare module BABYLON {
  19038. /** @hidden */
  19039. export var colorPixelShader: {
  19040. name: string;
  19041. shader: string;
  19042. };
  19043. }
  19044. declare module BABYLON {
  19045. /** @hidden */
  19046. export var colorVertexShader: {
  19047. name: string;
  19048. shader: string;
  19049. };
  19050. }
  19051. declare module BABYLON {
  19052. /**
  19053. * Line mesh
  19054. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19055. */
  19056. export class LinesMesh extends Mesh {
  19057. /**
  19058. * If vertex color should be applied to the mesh
  19059. */
  19060. readonly useVertexColor?: boolean | undefined;
  19061. /**
  19062. * If vertex alpha should be applied to the mesh
  19063. */
  19064. readonly useVertexAlpha?: boolean | undefined;
  19065. /**
  19066. * Color of the line (Default: White)
  19067. */
  19068. color: Color3;
  19069. /**
  19070. * Alpha of the line (Default: 1)
  19071. */
  19072. alpha: number;
  19073. /**
  19074. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19075. * This margin is expressed in world space coordinates, so its value may vary.
  19076. * Default value is 0.1
  19077. */
  19078. intersectionThreshold: number;
  19079. private _colorShader;
  19080. private color4;
  19081. /**
  19082. * Creates a new LinesMesh
  19083. * @param name defines the name
  19084. * @param scene defines the hosting scene
  19085. * @param parent defines the parent mesh if any
  19086. * @param source defines the optional source LinesMesh used to clone data from
  19087. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19088. * When false, achieved by calling a clone(), also passing False.
  19089. * This will make creation of children, recursive.
  19090. * @param useVertexColor defines if this LinesMesh supports vertex color
  19091. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19092. */
  19093. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19094. /**
  19095. * If vertex color should be applied to the mesh
  19096. */
  19097. useVertexColor?: boolean | undefined,
  19098. /**
  19099. * If vertex alpha should be applied to the mesh
  19100. */
  19101. useVertexAlpha?: boolean | undefined);
  19102. private _addClipPlaneDefine;
  19103. private _removeClipPlaneDefine;
  19104. isReady(): boolean;
  19105. /**
  19106. * Returns the string "LineMesh"
  19107. */
  19108. getClassName(): string;
  19109. /**
  19110. * @hidden
  19111. */
  19112. /**
  19113. * @hidden
  19114. */
  19115. material: Material;
  19116. /**
  19117. * @hidden
  19118. */
  19119. readonly checkCollisions: boolean;
  19120. /** @hidden */
  19121. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19122. /** @hidden */
  19123. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19124. /**
  19125. * Disposes of the line mesh
  19126. * @param doNotRecurse If children should be disposed
  19127. */
  19128. dispose(doNotRecurse?: boolean): void;
  19129. /**
  19130. * Returns a new LineMesh object cloned from the current one.
  19131. */
  19132. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19133. /**
  19134. * Creates a new InstancedLinesMesh object from the mesh model.
  19135. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19136. * @param name defines the name of the new instance
  19137. * @returns a new InstancedLinesMesh
  19138. */
  19139. createInstance(name: string): InstancedLinesMesh;
  19140. }
  19141. /**
  19142. * Creates an instance based on a source LinesMesh
  19143. */
  19144. export class InstancedLinesMesh extends InstancedMesh {
  19145. /**
  19146. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19147. * This margin is expressed in world space coordinates, so its value may vary.
  19148. * Initilized with the intersectionThreshold value of the source LinesMesh
  19149. */
  19150. intersectionThreshold: number;
  19151. constructor(name: string, source: LinesMesh);
  19152. /**
  19153. * Returns the string "InstancedLinesMesh".
  19154. */
  19155. getClassName(): string;
  19156. }
  19157. }
  19158. declare module BABYLON {
  19159. /** @hidden */
  19160. export var linePixelShader: {
  19161. name: string;
  19162. shader: string;
  19163. };
  19164. }
  19165. declare module BABYLON {
  19166. /** @hidden */
  19167. export var lineVertexShader: {
  19168. name: string;
  19169. shader: string;
  19170. };
  19171. }
  19172. declare module BABYLON {
  19173. interface AbstractMesh {
  19174. /**
  19175. * Gets the edgesRenderer associated with the mesh
  19176. */
  19177. edgesRenderer: Nullable<EdgesRenderer>;
  19178. }
  19179. interface LinesMesh {
  19180. /**
  19181. * Enables the edge rendering mode on the mesh.
  19182. * This mode makes the mesh edges visible
  19183. * @param epsilon defines the maximal distance between two angles to detect a face
  19184. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19185. * @returns the currentAbstractMesh
  19186. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19187. */
  19188. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19189. }
  19190. interface InstancedLinesMesh {
  19191. /**
  19192. * Enables the edge rendering mode on the mesh.
  19193. * This mode makes the mesh edges visible
  19194. * @param epsilon defines the maximal distance between two angles to detect a face
  19195. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19196. * @returns the current InstancedLinesMesh
  19197. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19198. */
  19199. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19200. }
  19201. /**
  19202. * Defines the minimum contract an Edges renderer should follow.
  19203. */
  19204. export interface IEdgesRenderer extends IDisposable {
  19205. /**
  19206. * Gets or sets a boolean indicating if the edgesRenderer is active
  19207. */
  19208. isEnabled: boolean;
  19209. /**
  19210. * Renders the edges of the attached mesh,
  19211. */
  19212. render(): void;
  19213. /**
  19214. * Checks wether or not the edges renderer is ready to render.
  19215. * @return true if ready, otherwise false.
  19216. */
  19217. isReady(): boolean;
  19218. }
  19219. /**
  19220. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19221. */
  19222. export class EdgesRenderer implements IEdgesRenderer {
  19223. /**
  19224. * Define the size of the edges with an orthographic camera
  19225. */
  19226. edgesWidthScalerForOrthographic: number;
  19227. /**
  19228. * Define the size of the edges with a perspective camera
  19229. */
  19230. edgesWidthScalerForPerspective: number;
  19231. protected _source: AbstractMesh;
  19232. protected _linesPositions: number[];
  19233. protected _linesNormals: number[];
  19234. protected _linesIndices: number[];
  19235. protected _epsilon: number;
  19236. protected _indicesCount: number;
  19237. protected _lineShader: ShaderMaterial;
  19238. protected _ib: DataBuffer;
  19239. protected _buffers: {
  19240. [key: string]: Nullable<VertexBuffer>;
  19241. };
  19242. protected _checkVerticesInsteadOfIndices: boolean;
  19243. private _meshRebuildObserver;
  19244. private _meshDisposeObserver;
  19245. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19246. isEnabled: boolean;
  19247. /**
  19248. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19249. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19250. * @param source Mesh used to create edges
  19251. * @param epsilon sum of angles in adjacency to check for edge
  19252. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19253. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19254. */
  19255. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19256. protected _prepareRessources(): void;
  19257. /** @hidden */
  19258. _rebuild(): void;
  19259. /**
  19260. * Releases the required resources for the edges renderer
  19261. */
  19262. dispose(): void;
  19263. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19264. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19265. /**
  19266. * Checks if the pair of p0 and p1 is en edge
  19267. * @param faceIndex
  19268. * @param edge
  19269. * @param faceNormals
  19270. * @param p0
  19271. * @param p1
  19272. * @private
  19273. */
  19274. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19275. /**
  19276. * push line into the position, normal and index buffer
  19277. * @protected
  19278. */
  19279. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19280. /**
  19281. * Generates lines edges from adjacencjes
  19282. * @private
  19283. */
  19284. _generateEdgesLines(): void;
  19285. /**
  19286. * Checks wether or not the edges renderer is ready to render.
  19287. * @return true if ready, otherwise false.
  19288. */
  19289. isReady(): boolean;
  19290. /**
  19291. * Renders the edges of the attached mesh,
  19292. */
  19293. render(): void;
  19294. }
  19295. /**
  19296. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19297. */
  19298. export class LineEdgesRenderer extends EdgesRenderer {
  19299. /**
  19300. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19301. * @param source LineMesh used to generate edges
  19302. * @param epsilon not important (specified angle for edge detection)
  19303. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19304. */
  19305. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19306. /**
  19307. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19308. */
  19309. _generateEdgesLines(): void;
  19310. }
  19311. }
  19312. declare module BABYLON {
  19313. /**
  19314. * This represents the object necessary to create a rendering group.
  19315. * This is exclusively used and created by the rendering manager.
  19316. * To modify the behavior, you use the available helpers in your scene or meshes.
  19317. * @hidden
  19318. */
  19319. export class RenderingGroup {
  19320. index: number;
  19321. private static _zeroVector;
  19322. private _scene;
  19323. private _opaqueSubMeshes;
  19324. private _transparentSubMeshes;
  19325. private _alphaTestSubMeshes;
  19326. private _depthOnlySubMeshes;
  19327. private _particleSystems;
  19328. private _spriteManagers;
  19329. private _opaqueSortCompareFn;
  19330. private _alphaTestSortCompareFn;
  19331. private _transparentSortCompareFn;
  19332. private _renderOpaque;
  19333. private _renderAlphaTest;
  19334. private _renderTransparent;
  19335. /** @hidden */
  19336. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19337. onBeforeTransparentRendering: () => void;
  19338. /**
  19339. * Set the opaque sort comparison function.
  19340. * If null the sub meshes will be render in the order they were created
  19341. */
  19342. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19343. /**
  19344. * Set the alpha test sort comparison function.
  19345. * If null the sub meshes will be render in the order they were created
  19346. */
  19347. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19348. /**
  19349. * Set the transparent sort comparison function.
  19350. * If null the sub meshes will be render in the order they were created
  19351. */
  19352. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19353. /**
  19354. * Creates a new rendering group.
  19355. * @param index The rendering group index
  19356. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19357. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19358. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19359. */
  19360. 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>);
  19361. /**
  19362. * Render all the sub meshes contained in the group.
  19363. * @param customRenderFunction Used to override the default render behaviour of the group.
  19364. * @returns true if rendered some submeshes.
  19365. */
  19366. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19367. /**
  19368. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19369. * @param subMeshes The submeshes to render
  19370. */
  19371. private renderOpaqueSorted;
  19372. /**
  19373. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19374. * @param subMeshes The submeshes to render
  19375. */
  19376. private renderAlphaTestSorted;
  19377. /**
  19378. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19379. * @param subMeshes The submeshes to render
  19380. */
  19381. private renderTransparentSorted;
  19382. /**
  19383. * Renders the submeshes in a specified order.
  19384. * @param subMeshes The submeshes to sort before render
  19385. * @param sortCompareFn The comparison function use to sort
  19386. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19387. * @param transparent Specifies to activate blending if true
  19388. */
  19389. private static renderSorted;
  19390. /**
  19391. * Renders the submeshes in the order they were dispatched (no sort applied).
  19392. * @param subMeshes The submeshes to render
  19393. */
  19394. private static renderUnsorted;
  19395. /**
  19396. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19397. * are rendered back to front if in the same alpha index.
  19398. *
  19399. * @param a The first submesh
  19400. * @param b The second submesh
  19401. * @returns The result of the comparison
  19402. */
  19403. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19404. /**
  19405. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19406. * are rendered back to front.
  19407. *
  19408. * @param a The first submesh
  19409. * @param b The second submesh
  19410. * @returns The result of the comparison
  19411. */
  19412. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19413. /**
  19414. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19415. * are rendered front to back (prevent overdraw).
  19416. *
  19417. * @param a The first submesh
  19418. * @param b The second submesh
  19419. * @returns The result of the comparison
  19420. */
  19421. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19422. /**
  19423. * Resets the different lists of submeshes to prepare a new frame.
  19424. */
  19425. prepare(): void;
  19426. dispose(): void;
  19427. /**
  19428. * Inserts the submesh in its correct queue depending on its material.
  19429. * @param subMesh The submesh to dispatch
  19430. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19431. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19432. */
  19433. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19434. dispatchSprites(spriteManager: ISpriteManager): void;
  19435. dispatchParticles(particleSystem: IParticleSystem): void;
  19436. private _renderParticles;
  19437. private _renderSprites;
  19438. }
  19439. }
  19440. declare module BABYLON {
  19441. /**
  19442. * Interface describing the different options available in the rendering manager
  19443. * regarding Auto Clear between groups.
  19444. */
  19445. export interface IRenderingManagerAutoClearSetup {
  19446. /**
  19447. * Defines whether or not autoclear is enable.
  19448. */
  19449. autoClear: boolean;
  19450. /**
  19451. * Defines whether or not to autoclear the depth buffer.
  19452. */
  19453. depth: boolean;
  19454. /**
  19455. * Defines whether or not to autoclear the stencil buffer.
  19456. */
  19457. stencil: boolean;
  19458. }
  19459. /**
  19460. * This class is used by the onRenderingGroupObservable
  19461. */
  19462. export class RenderingGroupInfo {
  19463. /**
  19464. * The Scene that being rendered
  19465. */
  19466. scene: Scene;
  19467. /**
  19468. * The camera currently used for the rendering pass
  19469. */
  19470. camera: Nullable<Camera>;
  19471. /**
  19472. * The ID of the renderingGroup being processed
  19473. */
  19474. renderingGroupId: number;
  19475. }
  19476. /**
  19477. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19478. * It is enable to manage the different groups as well as the different necessary sort functions.
  19479. * This should not be used directly aside of the few static configurations
  19480. */
  19481. export class RenderingManager {
  19482. /**
  19483. * The max id used for rendering groups (not included)
  19484. */
  19485. static MAX_RENDERINGGROUPS: number;
  19486. /**
  19487. * The min id used for rendering groups (included)
  19488. */
  19489. static MIN_RENDERINGGROUPS: number;
  19490. /**
  19491. * Used to globally prevent autoclearing scenes.
  19492. */
  19493. static AUTOCLEAR: boolean;
  19494. /**
  19495. * @hidden
  19496. */
  19497. _useSceneAutoClearSetup: boolean;
  19498. private _scene;
  19499. private _renderingGroups;
  19500. private _depthStencilBufferAlreadyCleaned;
  19501. private _autoClearDepthStencil;
  19502. private _customOpaqueSortCompareFn;
  19503. private _customAlphaTestSortCompareFn;
  19504. private _customTransparentSortCompareFn;
  19505. private _renderingGroupInfo;
  19506. /**
  19507. * Instantiates a new rendering group for a particular scene
  19508. * @param scene Defines the scene the groups belongs to
  19509. */
  19510. constructor(scene: Scene);
  19511. private _clearDepthStencilBuffer;
  19512. /**
  19513. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19514. * @hidden
  19515. */
  19516. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19517. /**
  19518. * Resets the different information of the group to prepare a new frame
  19519. * @hidden
  19520. */
  19521. reset(): void;
  19522. /**
  19523. * Dispose and release the group and its associated resources.
  19524. * @hidden
  19525. */
  19526. dispose(): void;
  19527. /**
  19528. * Clear the info related to rendering groups preventing retention points during dispose.
  19529. */
  19530. freeRenderingGroups(): void;
  19531. private _prepareRenderingGroup;
  19532. /**
  19533. * Add a sprite manager to the rendering manager in order to render it this frame.
  19534. * @param spriteManager Define the sprite manager to render
  19535. */
  19536. dispatchSprites(spriteManager: ISpriteManager): void;
  19537. /**
  19538. * Add a particle system to the rendering manager in order to render it this frame.
  19539. * @param particleSystem Define the particle system to render
  19540. */
  19541. dispatchParticles(particleSystem: IParticleSystem): void;
  19542. /**
  19543. * Add a submesh to the manager in order to render it this frame
  19544. * @param subMesh The submesh to dispatch
  19545. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19546. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19547. */
  19548. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19549. /**
  19550. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19551. * This allowed control for front to back rendering or reversly depending of the special needs.
  19552. *
  19553. * @param renderingGroupId The rendering group id corresponding to its index
  19554. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19555. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19556. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19557. */
  19558. 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;
  19559. /**
  19560. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19561. *
  19562. * @param renderingGroupId The rendering group id corresponding to its index
  19563. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19564. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19565. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19566. */
  19567. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19568. /**
  19569. * Gets the current auto clear configuration for one rendering group of the rendering
  19570. * manager.
  19571. * @param index the rendering group index to get the information for
  19572. * @returns The auto clear setup for the requested rendering group
  19573. */
  19574. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19575. }
  19576. }
  19577. declare module BABYLON {
  19578. /**
  19579. * This Helps creating a texture that will be created from a camera in your scene.
  19580. * It is basically a dynamic texture that could be used to create special effects for instance.
  19581. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19582. */
  19583. export class RenderTargetTexture extends Texture {
  19584. isCube: boolean;
  19585. /**
  19586. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19587. */
  19588. static readonly REFRESHRATE_RENDER_ONCE: number;
  19589. /**
  19590. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19591. */
  19592. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19593. /**
  19594. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19595. * the central point of your effect and can save a lot of performances.
  19596. */
  19597. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19598. /**
  19599. * Use this predicate to dynamically define the list of mesh you want to render.
  19600. * If set, the renderList property will be overwritten.
  19601. */
  19602. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19603. private _renderList;
  19604. /**
  19605. * Use this list to define the list of mesh you want to render.
  19606. */
  19607. renderList: Nullable<Array<AbstractMesh>>;
  19608. private _hookArray;
  19609. /**
  19610. * Define if particles should be rendered in your texture.
  19611. */
  19612. renderParticles: boolean;
  19613. /**
  19614. * Define if sprites should be rendered in your texture.
  19615. */
  19616. renderSprites: boolean;
  19617. /**
  19618. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19619. */
  19620. coordinatesMode: number;
  19621. /**
  19622. * Define the camera used to render the texture.
  19623. */
  19624. activeCamera: Nullable<Camera>;
  19625. /**
  19626. * Override the render function of the texture with your own one.
  19627. */
  19628. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19629. /**
  19630. * Define if camera post processes should be use while rendering the texture.
  19631. */
  19632. useCameraPostProcesses: boolean;
  19633. /**
  19634. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19635. */
  19636. ignoreCameraViewport: boolean;
  19637. private _postProcessManager;
  19638. private _postProcesses;
  19639. private _resizeObserver;
  19640. /**
  19641. * An event triggered when the texture is unbind.
  19642. */
  19643. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19644. /**
  19645. * An event triggered when the texture is unbind.
  19646. */
  19647. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19648. private _onAfterUnbindObserver;
  19649. /**
  19650. * Set a after unbind callback in the texture.
  19651. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19652. */
  19653. onAfterUnbind: () => void;
  19654. /**
  19655. * An event triggered before rendering the texture
  19656. */
  19657. onBeforeRenderObservable: Observable<number>;
  19658. private _onBeforeRenderObserver;
  19659. /**
  19660. * Set a before render callback in the texture.
  19661. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19662. */
  19663. onBeforeRender: (faceIndex: number) => void;
  19664. /**
  19665. * An event triggered after rendering the texture
  19666. */
  19667. onAfterRenderObservable: Observable<number>;
  19668. private _onAfterRenderObserver;
  19669. /**
  19670. * Set a after render callback in the texture.
  19671. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19672. */
  19673. onAfterRender: (faceIndex: number) => void;
  19674. /**
  19675. * An event triggered after the texture clear
  19676. */
  19677. onClearObservable: Observable<Engine>;
  19678. private _onClearObserver;
  19679. /**
  19680. * Set a clear callback in the texture.
  19681. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19682. */
  19683. onClear: (Engine: Engine) => void;
  19684. /**
  19685. * An event triggered when the texture is resized.
  19686. */
  19687. onResizeObservable: Observable<RenderTargetTexture>;
  19688. /**
  19689. * Define the clear color of the Render Target if it should be different from the scene.
  19690. */
  19691. clearColor: Color4;
  19692. protected _size: number | {
  19693. width: number;
  19694. height: number;
  19695. };
  19696. protected _initialSizeParameter: number | {
  19697. width: number;
  19698. height: number;
  19699. } | {
  19700. ratio: number;
  19701. };
  19702. protected _sizeRatio: Nullable<number>;
  19703. /** @hidden */
  19704. _generateMipMaps: boolean;
  19705. protected _renderingManager: RenderingManager;
  19706. /** @hidden */
  19707. _waitingRenderList: string[];
  19708. protected _doNotChangeAspectRatio: boolean;
  19709. protected _currentRefreshId: number;
  19710. protected _refreshRate: number;
  19711. protected _textureMatrix: Matrix;
  19712. protected _samples: number;
  19713. protected _renderTargetOptions: RenderTargetCreationOptions;
  19714. /**
  19715. * Gets render target creation options that were used.
  19716. */
  19717. readonly renderTargetOptions: RenderTargetCreationOptions;
  19718. protected _engine: Engine;
  19719. protected _onRatioRescale(): void;
  19720. /**
  19721. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19722. * It must define where the camera used to render the texture is set
  19723. */
  19724. boundingBoxPosition: Vector3;
  19725. private _boundingBoxSize;
  19726. /**
  19727. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19728. * When defined, the cubemap will switch to local mode
  19729. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19730. * @example https://www.babylonjs-playground.com/#RNASML
  19731. */
  19732. boundingBoxSize: Vector3;
  19733. /**
  19734. * In case the RTT has been created with a depth texture, get the associated
  19735. * depth texture.
  19736. * Otherwise, return null.
  19737. */
  19738. depthStencilTexture: Nullable<InternalTexture>;
  19739. /**
  19740. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19741. * or used a shadow, depth texture...
  19742. * @param name The friendly name of the texture
  19743. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  19744. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19745. * @param generateMipMaps True if mip maps need to be generated after render.
  19746. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19747. * @param type The type of the buffer in the RTT (int, half float, float...)
  19748. * @param isCube True if a cube texture needs to be created
  19749. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19750. * @param generateDepthBuffer True to generate a depth buffer
  19751. * @param generateStencilBuffer True to generate a stencil buffer
  19752. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19753. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19754. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19755. */
  19756. constructor(name: string, size: number | {
  19757. width: number;
  19758. height: number;
  19759. } | {
  19760. ratio: number;
  19761. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19762. /**
  19763. * Creates a depth stencil texture.
  19764. * This is only available in WebGL 2 or with the depth texture extension available.
  19765. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19766. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19767. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19768. */
  19769. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19770. private _processSizeParameter;
  19771. /**
  19772. * Define the number of samples to use in case of MSAA.
  19773. * It defaults to one meaning no MSAA has been enabled.
  19774. */
  19775. samples: number;
  19776. /**
  19777. * Resets the refresh counter of the texture and start bak from scratch.
  19778. * Could be useful to regenerate the texture if it is setup to render only once.
  19779. */
  19780. resetRefreshCounter(): void;
  19781. /**
  19782. * Define the refresh rate of the texture or the rendering frequency.
  19783. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19784. */
  19785. refreshRate: number;
  19786. /**
  19787. * Adds a post process to the render target rendering passes.
  19788. * @param postProcess define the post process to add
  19789. */
  19790. addPostProcess(postProcess: PostProcess): void;
  19791. /**
  19792. * Clear all the post processes attached to the render target
  19793. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19794. */
  19795. clearPostProcesses(dispose?: boolean): void;
  19796. /**
  19797. * Remove one of the post process from the list of attached post processes to the texture
  19798. * @param postProcess define the post process to remove from the list
  19799. */
  19800. removePostProcess(postProcess: PostProcess): void;
  19801. /** @hidden */
  19802. _shouldRender(): boolean;
  19803. /**
  19804. * Gets the actual render size of the texture.
  19805. * @returns the width of the render size
  19806. */
  19807. getRenderSize(): number;
  19808. /**
  19809. * Gets the actual render width of the texture.
  19810. * @returns the width of the render size
  19811. */
  19812. getRenderWidth(): number;
  19813. /**
  19814. * Gets the actual render height of the texture.
  19815. * @returns the height of the render size
  19816. */
  19817. getRenderHeight(): number;
  19818. /**
  19819. * Get if the texture can be rescaled or not.
  19820. */
  19821. readonly canRescale: boolean;
  19822. /**
  19823. * Resize the texture using a ratio.
  19824. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19825. */
  19826. scale(ratio: number): void;
  19827. /**
  19828. * Get the texture reflection matrix used to rotate/transform the reflection.
  19829. * @returns the reflection matrix
  19830. */
  19831. getReflectionTextureMatrix(): Matrix;
  19832. /**
  19833. * Resize the texture to a new desired size.
  19834. * Be carrefull as it will recreate all the data in the new texture.
  19835. * @param size Define the new size. It can be:
  19836. * - a number for squared texture,
  19837. * - an object containing { width: number, height: number }
  19838. * - or an object containing a ratio { ratio: number }
  19839. */
  19840. resize(size: number | {
  19841. width: number;
  19842. height: number;
  19843. } | {
  19844. ratio: number;
  19845. }): void;
  19846. /**
  19847. * Renders all the objects from the render list into the texture.
  19848. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19849. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19850. */
  19851. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19852. private _bestReflectionRenderTargetDimension;
  19853. /**
  19854. * @hidden
  19855. * @param faceIndex face index to bind to if this is a cubetexture
  19856. */
  19857. _bindFrameBuffer(faceIndex?: number): void;
  19858. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19859. private renderToTarget;
  19860. /**
  19861. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19862. * This allowed control for front to back rendering or reversly depending of the special needs.
  19863. *
  19864. * @param renderingGroupId The rendering group id corresponding to its index
  19865. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19866. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19867. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19868. */
  19869. 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;
  19870. /**
  19871. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19872. *
  19873. * @param renderingGroupId The rendering group id corresponding to its index
  19874. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19875. */
  19876. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19877. /**
  19878. * Clones the texture.
  19879. * @returns the cloned texture
  19880. */
  19881. clone(): RenderTargetTexture;
  19882. /**
  19883. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19884. * @returns The JSON representation of the texture
  19885. */
  19886. serialize(): any;
  19887. /**
  19888. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19889. */
  19890. disposeFramebufferObjects(): void;
  19891. /**
  19892. * Dispose the texture and release its associated resources.
  19893. */
  19894. dispose(): void;
  19895. /** @hidden */
  19896. _rebuild(): void;
  19897. /**
  19898. * Clear the info related to rendering groups preventing retention point in material dispose.
  19899. */
  19900. freeRenderingGroups(): void;
  19901. /**
  19902. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19903. * @returns the view count
  19904. */
  19905. getViewCount(): number;
  19906. }
  19907. }
  19908. declare module BABYLON {
  19909. /**
  19910. * Base class for the main features of a material in Babylon.js
  19911. */
  19912. export class Material implements IAnimatable {
  19913. /**
  19914. * Returns the triangle fill mode
  19915. */
  19916. static readonly TriangleFillMode: number;
  19917. /**
  19918. * Returns the wireframe mode
  19919. */
  19920. static readonly WireFrameFillMode: number;
  19921. /**
  19922. * Returns the point fill mode
  19923. */
  19924. static readonly PointFillMode: number;
  19925. /**
  19926. * Returns the point list draw mode
  19927. */
  19928. static readonly PointListDrawMode: number;
  19929. /**
  19930. * Returns the line list draw mode
  19931. */
  19932. static readonly LineListDrawMode: number;
  19933. /**
  19934. * Returns the line loop draw mode
  19935. */
  19936. static readonly LineLoopDrawMode: number;
  19937. /**
  19938. * Returns the line strip draw mode
  19939. */
  19940. static readonly LineStripDrawMode: number;
  19941. /**
  19942. * Returns the triangle strip draw mode
  19943. */
  19944. static readonly TriangleStripDrawMode: number;
  19945. /**
  19946. * Returns the triangle fan draw mode
  19947. */
  19948. static readonly TriangleFanDrawMode: number;
  19949. /**
  19950. * Stores the clock-wise side orientation
  19951. */
  19952. static readonly ClockWiseSideOrientation: number;
  19953. /**
  19954. * Stores the counter clock-wise side orientation
  19955. */
  19956. static readonly CounterClockWiseSideOrientation: number;
  19957. /**
  19958. * The dirty texture flag value
  19959. */
  19960. static readonly TextureDirtyFlag: number;
  19961. /**
  19962. * The dirty light flag value
  19963. */
  19964. static readonly LightDirtyFlag: number;
  19965. /**
  19966. * The dirty fresnel flag value
  19967. */
  19968. static readonly FresnelDirtyFlag: number;
  19969. /**
  19970. * The dirty attribute flag value
  19971. */
  19972. static readonly AttributesDirtyFlag: number;
  19973. /**
  19974. * The dirty misc flag value
  19975. */
  19976. static readonly MiscDirtyFlag: number;
  19977. /**
  19978. * The all dirty flag value
  19979. */
  19980. static readonly AllDirtyFlag: number;
  19981. /**
  19982. * The ID of the material
  19983. */
  19984. id: string;
  19985. /**
  19986. * Gets or sets the unique id of the material
  19987. */
  19988. uniqueId: number;
  19989. /**
  19990. * The name of the material
  19991. */
  19992. name: string;
  19993. /**
  19994. * Gets or sets user defined metadata
  19995. */
  19996. metadata: any;
  19997. /**
  19998. * For internal use only. Please do not use.
  19999. */
  20000. reservedDataStore: any;
  20001. /**
  20002. * Specifies if the ready state should be checked on each call
  20003. */
  20004. checkReadyOnEveryCall: boolean;
  20005. /**
  20006. * Specifies if the ready state should be checked once
  20007. */
  20008. checkReadyOnlyOnce: boolean;
  20009. /**
  20010. * The state of the material
  20011. */
  20012. state: string;
  20013. /**
  20014. * The alpha value of the material
  20015. */
  20016. protected _alpha: number;
  20017. /**
  20018. * List of inspectable custom properties (used by the Inspector)
  20019. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20020. */
  20021. inspectableCustomProperties: IInspectable[];
  20022. /**
  20023. * Sets the alpha value of the material
  20024. */
  20025. /**
  20026. * Gets the alpha value of the material
  20027. */
  20028. alpha: number;
  20029. /**
  20030. * Specifies if back face culling is enabled
  20031. */
  20032. protected _backFaceCulling: boolean;
  20033. /**
  20034. * Sets the back-face culling state
  20035. */
  20036. /**
  20037. * Gets the back-face culling state
  20038. */
  20039. backFaceCulling: boolean;
  20040. /**
  20041. * Stores the value for side orientation
  20042. */
  20043. sideOrientation: number;
  20044. /**
  20045. * Callback triggered when the material is compiled
  20046. */
  20047. onCompiled: Nullable<(effect: Effect) => void>;
  20048. /**
  20049. * Callback triggered when an error occurs
  20050. */
  20051. onError: Nullable<(effect: Effect, errors: string) => void>;
  20052. /**
  20053. * Callback triggered to get the render target textures
  20054. */
  20055. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20056. /**
  20057. * Gets a boolean indicating that current material needs to register RTT
  20058. */
  20059. readonly hasRenderTargetTextures: boolean;
  20060. /**
  20061. * Specifies if the material should be serialized
  20062. */
  20063. doNotSerialize: boolean;
  20064. /**
  20065. * @hidden
  20066. */
  20067. _storeEffectOnSubMeshes: boolean;
  20068. /**
  20069. * Stores the animations for the material
  20070. */
  20071. animations: Nullable<Array<Animation>>;
  20072. /**
  20073. * An event triggered when the material is disposed
  20074. */
  20075. onDisposeObservable: Observable<Material>;
  20076. /**
  20077. * An observer which watches for dispose events
  20078. */
  20079. private _onDisposeObserver;
  20080. private _onUnBindObservable;
  20081. /**
  20082. * Called during a dispose event
  20083. */
  20084. onDispose: () => void;
  20085. private _onBindObservable;
  20086. /**
  20087. * An event triggered when the material is bound
  20088. */
  20089. readonly onBindObservable: Observable<AbstractMesh>;
  20090. /**
  20091. * An observer which watches for bind events
  20092. */
  20093. private _onBindObserver;
  20094. /**
  20095. * Called during a bind event
  20096. */
  20097. onBind: (Mesh: AbstractMesh) => void;
  20098. /**
  20099. * An event triggered when the material is unbound
  20100. */
  20101. readonly onUnBindObservable: Observable<Material>;
  20102. /**
  20103. * Stores the value of the alpha mode
  20104. */
  20105. private _alphaMode;
  20106. /**
  20107. * Sets the value of the alpha mode.
  20108. *
  20109. * | Value | Type | Description |
  20110. * | --- | --- | --- |
  20111. * | 0 | ALPHA_DISABLE | |
  20112. * | 1 | ALPHA_ADD | |
  20113. * | 2 | ALPHA_COMBINE | |
  20114. * | 3 | ALPHA_SUBTRACT | |
  20115. * | 4 | ALPHA_MULTIPLY | |
  20116. * | 5 | ALPHA_MAXIMIZED | |
  20117. * | 6 | ALPHA_ONEONE | |
  20118. * | 7 | ALPHA_PREMULTIPLIED | |
  20119. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20120. * | 9 | ALPHA_INTERPOLATE | |
  20121. * | 10 | ALPHA_SCREENMODE | |
  20122. *
  20123. */
  20124. /**
  20125. * Gets the value of the alpha mode
  20126. */
  20127. alphaMode: number;
  20128. /**
  20129. * Stores the state of the need depth pre-pass value
  20130. */
  20131. private _needDepthPrePass;
  20132. /**
  20133. * Sets the need depth pre-pass value
  20134. */
  20135. /**
  20136. * Gets the depth pre-pass value
  20137. */
  20138. needDepthPrePass: boolean;
  20139. /**
  20140. * Specifies if depth writing should be disabled
  20141. */
  20142. disableDepthWrite: boolean;
  20143. /**
  20144. * Specifies if depth writing should be forced
  20145. */
  20146. forceDepthWrite: boolean;
  20147. /**
  20148. * Specifies if there should be a separate pass for culling
  20149. */
  20150. separateCullingPass: boolean;
  20151. /**
  20152. * Stores the state specifing if fog should be enabled
  20153. */
  20154. private _fogEnabled;
  20155. /**
  20156. * Sets the state for enabling fog
  20157. */
  20158. /**
  20159. * Gets the value of the fog enabled state
  20160. */
  20161. fogEnabled: boolean;
  20162. /**
  20163. * Stores the size of points
  20164. */
  20165. pointSize: number;
  20166. /**
  20167. * Stores the z offset value
  20168. */
  20169. zOffset: number;
  20170. /**
  20171. * Gets a value specifying if wireframe mode is enabled
  20172. */
  20173. /**
  20174. * Sets the state of wireframe mode
  20175. */
  20176. wireframe: boolean;
  20177. /**
  20178. * Gets the value specifying if point clouds are enabled
  20179. */
  20180. /**
  20181. * Sets the state of point cloud mode
  20182. */
  20183. pointsCloud: boolean;
  20184. /**
  20185. * Gets the material fill mode
  20186. */
  20187. /**
  20188. * Sets the material fill mode
  20189. */
  20190. fillMode: number;
  20191. /**
  20192. * @hidden
  20193. * Stores the effects for the material
  20194. */
  20195. _effect: Nullable<Effect>;
  20196. /**
  20197. * @hidden
  20198. * Specifies if the material was previously ready
  20199. */
  20200. _wasPreviouslyReady: boolean;
  20201. /**
  20202. * Specifies if uniform buffers should be used
  20203. */
  20204. private _useUBO;
  20205. /**
  20206. * Stores a reference to the scene
  20207. */
  20208. private _scene;
  20209. /**
  20210. * Stores the fill mode state
  20211. */
  20212. private _fillMode;
  20213. /**
  20214. * Specifies if the depth write state should be cached
  20215. */
  20216. private _cachedDepthWriteState;
  20217. /**
  20218. * Stores the uniform buffer
  20219. */
  20220. protected _uniformBuffer: UniformBuffer;
  20221. /** @hidden */
  20222. _indexInSceneMaterialArray: number;
  20223. /** @hidden */
  20224. meshMap: Nullable<{
  20225. [id: string]: AbstractMesh | undefined;
  20226. }>;
  20227. /**
  20228. * Creates a material instance
  20229. * @param name defines the name of the material
  20230. * @param scene defines the scene to reference
  20231. * @param doNotAdd specifies if the material should be added to the scene
  20232. */
  20233. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20234. /**
  20235. * Returns a string representation of the current material
  20236. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20237. * @returns a string with material information
  20238. */
  20239. toString(fullDetails?: boolean): string;
  20240. /**
  20241. * Gets the class name of the material
  20242. * @returns a string with the class name of the material
  20243. */
  20244. getClassName(): string;
  20245. /**
  20246. * Specifies if updates for the material been locked
  20247. */
  20248. readonly isFrozen: boolean;
  20249. /**
  20250. * Locks updates for the material
  20251. */
  20252. freeze(): void;
  20253. /**
  20254. * Unlocks updates for the material
  20255. */
  20256. unfreeze(): void;
  20257. /**
  20258. * Specifies if the material is ready to be used
  20259. * @param mesh defines the mesh to check
  20260. * @param useInstances specifies if instances should be used
  20261. * @returns a boolean indicating if the material is ready to be used
  20262. */
  20263. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20264. /**
  20265. * Specifies that the submesh is ready to be used
  20266. * @param mesh defines the mesh to check
  20267. * @param subMesh defines which submesh to check
  20268. * @param useInstances specifies that instances should be used
  20269. * @returns a boolean indicating that the submesh is ready or not
  20270. */
  20271. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20272. /**
  20273. * Returns the material effect
  20274. * @returns the effect associated with the material
  20275. */
  20276. getEffect(): Nullable<Effect>;
  20277. /**
  20278. * Returns the current scene
  20279. * @returns a Scene
  20280. */
  20281. getScene(): Scene;
  20282. /**
  20283. * Specifies if the material will require alpha blending
  20284. * @returns a boolean specifying if alpha blending is needed
  20285. */
  20286. needAlphaBlending(): boolean;
  20287. /**
  20288. * Specifies if the mesh will require alpha blending
  20289. * @param mesh defines the mesh to check
  20290. * @returns a boolean specifying if alpha blending is needed for the mesh
  20291. */
  20292. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20293. /**
  20294. * Specifies if this material should be rendered in alpha test mode
  20295. * @returns a boolean specifying if an alpha test is needed.
  20296. */
  20297. needAlphaTesting(): boolean;
  20298. /**
  20299. * Gets the texture used for the alpha test
  20300. * @returns the texture to use for alpha testing
  20301. */
  20302. getAlphaTestTexture(): Nullable<BaseTexture>;
  20303. /**
  20304. * Marks the material to indicate that it needs to be re-calculated
  20305. */
  20306. markDirty(): void;
  20307. /** @hidden */
  20308. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20309. /**
  20310. * Binds the material to the mesh
  20311. * @param world defines the world transformation matrix
  20312. * @param mesh defines the mesh to bind the material to
  20313. */
  20314. bind(world: Matrix, mesh?: Mesh): void;
  20315. /**
  20316. * Binds the submesh to the material
  20317. * @param world defines the world transformation matrix
  20318. * @param mesh defines the mesh containing the submesh
  20319. * @param subMesh defines the submesh to bind the material to
  20320. */
  20321. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20322. /**
  20323. * Binds the world matrix to the material
  20324. * @param world defines the world transformation matrix
  20325. */
  20326. bindOnlyWorldMatrix(world: Matrix): void;
  20327. /**
  20328. * Binds the scene's uniform buffer to the effect.
  20329. * @param effect defines the effect to bind to the scene uniform buffer
  20330. * @param sceneUbo defines the uniform buffer storing scene data
  20331. */
  20332. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20333. /**
  20334. * Binds the view matrix to the effect
  20335. * @param effect defines the effect to bind the view matrix to
  20336. */
  20337. bindView(effect: Effect): void;
  20338. /**
  20339. * Binds the view projection matrix to the effect
  20340. * @param effect defines the effect to bind the view projection matrix to
  20341. */
  20342. bindViewProjection(effect: Effect): void;
  20343. /**
  20344. * Specifies if material alpha testing should be turned on for the mesh
  20345. * @param mesh defines the mesh to check
  20346. */
  20347. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20348. /**
  20349. * Processes to execute after binding the material to a mesh
  20350. * @param mesh defines the rendered mesh
  20351. */
  20352. protected _afterBind(mesh?: Mesh): void;
  20353. /**
  20354. * Unbinds the material from the mesh
  20355. */
  20356. unbind(): void;
  20357. /**
  20358. * Gets the active textures from the material
  20359. * @returns an array of textures
  20360. */
  20361. getActiveTextures(): BaseTexture[];
  20362. /**
  20363. * Specifies if the material uses a texture
  20364. * @param texture defines the texture to check against the material
  20365. * @returns a boolean specifying if the material uses the texture
  20366. */
  20367. hasTexture(texture: BaseTexture): boolean;
  20368. /**
  20369. * Makes a duplicate of the material, and gives it a new name
  20370. * @param name defines the new name for the duplicated material
  20371. * @returns the cloned material
  20372. */
  20373. clone(name: string): Nullable<Material>;
  20374. /**
  20375. * Gets the meshes bound to the material
  20376. * @returns an array of meshes bound to the material
  20377. */
  20378. getBindedMeshes(): AbstractMesh[];
  20379. /**
  20380. * Force shader compilation
  20381. * @param mesh defines the mesh associated with this material
  20382. * @param onCompiled defines a function to execute once the material is compiled
  20383. * @param options defines the options to configure the compilation
  20384. */
  20385. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20386. clipPlane: boolean;
  20387. }>): void;
  20388. /**
  20389. * Force shader compilation
  20390. * @param mesh defines the mesh that will use this material
  20391. * @param options defines additional options for compiling the shaders
  20392. * @returns a promise that resolves when the compilation completes
  20393. */
  20394. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20395. clipPlane: boolean;
  20396. }>): Promise<void>;
  20397. private static readonly _AllDirtyCallBack;
  20398. private static readonly _ImageProcessingDirtyCallBack;
  20399. private static readonly _TextureDirtyCallBack;
  20400. private static readonly _FresnelDirtyCallBack;
  20401. private static readonly _MiscDirtyCallBack;
  20402. private static readonly _LightsDirtyCallBack;
  20403. private static readonly _AttributeDirtyCallBack;
  20404. private static _FresnelAndMiscDirtyCallBack;
  20405. private static _TextureAndMiscDirtyCallBack;
  20406. private static readonly _DirtyCallbackArray;
  20407. private static readonly _RunDirtyCallBacks;
  20408. /**
  20409. * Marks a define in the material to indicate that it needs to be re-computed
  20410. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20411. */
  20412. markAsDirty(flag: number): void;
  20413. /**
  20414. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20415. * @param func defines a function which checks material defines against the submeshes
  20416. */
  20417. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20418. /**
  20419. * Indicates that we need to re-calculated for all submeshes
  20420. */
  20421. protected _markAllSubMeshesAsAllDirty(): void;
  20422. /**
  20423. * Indicates that image processing needs to be re-calculated for all submeshes
  20424. */
  20425. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20426. /**
  20427. * Indicates that textures need to be re-calculated for all submeshes
  20428. */
  20429. protected _markAllSubMeshesAsTexturesDirty(): void;
  20430. /**
  20431. * Indicates that fresnel needs to be re-calculated for all submeshes
  20432. */
  20433. protected _markAllSubMeshesAsFresnelDirty(): void;
  20434. /**
  20435. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20436. */
  20437. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20438. /**
  20439. * Indicates that lights need to be re-calculated for all submeshes
  20440. */
  20441. protected _markAllSubMeshesAsLightsDirty(): void;
  20442. /**
  20443. * Indicates that attributes need to be re-calculated for all submeshes
  20444. */
  20445. protected _markAllSubMeshesAsAttributesDirty(): void;
  20446. /**
  20447. * Indicates that misc needs to be re-calculated for all submeshes
  20448. */
  20449. protected _markAllSubMeshesAsMiscDirty(): void;
  20450. /**
  20451. * Indicates that textures and misc need to be re-calculated for all submeshes
  20452. */
  20453. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20454. /**
  20455. * Disposes the material
  20456. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20457. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20458. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20459. */
  20460. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20461. /** @hidden */
  20462. private releaseVertexArrayObject;
  20463. /**
  20464. * Serializes this material
  20465. * @returns the serialized material object
  20466. */
  20467. serialize(): any;
  20468. /**
  20469. * Creates a material from parsed material data
  20470. * @param parsedMaterial defines parsed material data
  20471. * @param scene defines the hosting scene
  20472. * @param rootUrl defines the root URL to use to load textures
  20473. * @returns a new material
  20474. */
  20475. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20476. }
  20477. }
  20478. declare module BABYLON {
  20479. /**
  20480. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20481. * separate meshes. This can be use to improve performances.
  20482. * @see http://doc.babylonjs.com/how_to/multi_materials
  20483. */
  20484. export class MultiMaterial extends Material {
  20485. private _subMaterials;
  20486. /**
  20487. * Gets or Sets the list of Materials used within the multi material.
  20488. * They need to be ordered according to the submeshes order in the associated mesh
  20489. */
  20490. subMaterials: Nullable<Material>[];
  20491. /**
  20492. * Function used to align with Node.getChildren()
  20493. * @returns the list of Materials used within the multi material
  20494. */
  20495. getChildren(): Nullable<Material>[];
  20496. /**
  20497. * Instantiates a new Multi Material
  20498. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20499. * separate meshes. This can be use to improve performances.
  20500. * @see http://doc.babylonjs.com/how_to/multi_materials
  20501. * @param name Define the name in the scene
  20502. * @param scene Define the scene the material belongs to
  20503. */
  20504. constructor(name: string, scene: Scene);
  20505. private _hookArray;
  20506. /**
  20507. * Get one of the submaterial by its index in the submaterials array
  20508. * @param index The index to look the sub material at
  20509. * @returns The Material if the index has been defined
  20510. */
  20511. getSubMaterial(index: number): Nullable<Material>;
  20512. /**
  20513. * Get the list of active textures for the whole sub materials list.
  20514. * @returns All the textures that will be used during the rendering
  20515. */
  20516. getActiveTextures(): BaseTexture[];
  20517. /**
  20518. * Gets the current class name of the material e.g. "MultiMaterial"
  20519. * Mainly use in serialization.
  20520. * @returns the class name
  20521. */
  20522. getClassName(): string;
  20523. /**
  20524. * Checks if the material is ready to render the requested sub mesh
  20525. * @param mesh Define the mesh the submesh belongs to
  20526. * @param subMesh Define the sub mesh to look readyness for
  20527. * @param useInstances Define whether or not the material is used with instances
  20528. * @returns true if ready, otherwise false
  20529. */
  20530. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20531. /**
  20532. * Clones the current material and its related sub materials
  20533. * @param name Define the name of the newly cloned material
  20534. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20535. * @returns the cloned material
  20536. */
  20537. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20538. /**
  20539. * Serializes the materials into a JSON representation.
  20540. * @returns the JSON representation
  20541. */
  20542. serialize(): any;
  20543. /**
  20544. * Dispose the material and release its associated resources
  20545. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  20546. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  20547. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  20548. */
  20549. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20550. /**
  20551. * Creates a MultiMaterial from parsed MultiMaterial data.
  20552. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20553. * @param scene defines the hosting scene
  20554. * @returns a new MultiMaterial
  20555. */
  20556. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20557. }
  20558. }
  20559. declare module BABYLON {
  20560. /**
  20561. * Base class for submeshes
  20562. */
  20563. export class BaseSubMesh {
  20564. /** @hidden */
  20565. _materialDefines: Nullable<MaterialDefines>;
  20566. /** @hidden */
  20567. _materialEffect: Nullable<Effect>;
  20568. /**
  20569. * Gets associated effect
  20570. */
  20571. readonly effect: Nullable<Effect>;
  20572. /**
  20573. * Sets associated effect (effect used to render this submesh)
  20574. * @param effect defines the effect to associate with
  20575. * @param defines defines the set of defines used to compile this effect
  20576. */
  20577. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20578. }
  20579. /**
  20580. * Defines a subdivision inside a mesh
  20581. */
  20582. export class SubMesh extends BaseSubMesh implements ICullable {
  20583. /** the material index to use */
  20584. materialIndex: number;
  20585. /** vertex index start */
  20586. verticesStart: number;
  20587. /** vertices count */
  20588. verticesCount: number;
  20589. /** index start */
  20590. indexStart: number;
  20591. /** indices count */
  20592. indexCount: number;
  20593. /** @hidden */
  20594. _linesIndexCount: number;
  20595. private _mesh;
  20596. private _renderingMesh;
  20597. private _boundingInfo;
  20598. private _linesIndexBuffer;
  20599. /** @hidden */
  20600. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20601. /** @hidden */
  20602. _trianglePlanes: Plane[];
  20603. /** @hidden */
  20604. _lastColliderTransformMatrix: Nullable<Matrix>;
  20605. /** @hidden */
  20606. _renderId: number;
  20607. /** @hidden */
  20608. _alphaIndex: number;
  20609. /** @hidden */
  20610. _distanceToCamera: number;
  20611. /** @hidden */
  20612. _id: number;
  20613. private _currentMaterial;
  20614. /**
  20615. * Add a new submesh to a mesh
  20616. * @param materialIndex defines the material index to use
  20617. * @param verticesStart defines vertex index start
  20618. * @param verticesCount defines vertices count
  20619. * @param indexStart defines index start
  20620. * @param indexCount defines indices count
  20621. * @param mesh defines the parent mesh
  20622. * @param renderingMesh defines an optional rendering mesh
  20623. * @param createBoundingBox defines if bounding box should be created for this submesh
  20624. * @returns the new submesh
  20625. */
  20626. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20627. /**
  20628. * Creates a new submesh
  20629. * @param materialIndex defines the material index to use
  20630. * @param verticesStart defines vertex index start
  20631. * @param verticesCount defines vertices count
  20632. * @param indexStart defines index start
  20633. * @param indexCount defines indices count
  20634. * @param mesh defines the parent mesh
  20635. * @param renderingMesh defines an optional rendering mesh
  20636. * @param createBoundingBox defines if bounding box should be created for this submesh
  20637. */
  20638. constructor(
  20639. /** the material index to use */
  20640. materialIndex: number,
  20641. /** vertex index start */
  20642. verticesStart: number,
  20643. /** vertices count */
  20644. verticesCount: number,
  20645. /** index start */
  20646. indexStart: number,
  20647. /** indices count */
  20648. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20649. /**
  20650. * Returns true if this submesh covers the entire parent mesh
  20651. * @ignorenaming
  20652. */
  20653. readonly IsGlobal: boolean;
  20654. /**
  20655. * Returns the submesh BoudingInfo object
  20656. * @returns current bounding info (or mesh's one if the submesh is global)
  20657. */
  20658. getBoundingInfo(): BoundingInfo;
  20659. /**
  20660. * Sets the submesh BoundingInfo
  20661. * @param boundingInfo defines the new bounding info to use
  20662. * @returns the SubMesh
  20663. */
  20664. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20665. /**
  20666. * Returns the mesh of the current submesh
  20667. * @return the parent mesh
  20668. */
  20669. getMesh(): AbstractMesh;
  20670. /**
  20671. * Returns the rendering mesh of the submesh
  20672. * @returns the rendering mesh (could be different from parent mesh)
  20673. */
  20674. getRenderingMesh(): Mesh;
  20675. /**
  20676. * Returns the submesh material
  20677. * @returns null or the current material
  20678. */
  20679. getMaterial(): Nullable<Material>;
  20680. /**
  20681. * Sets a new updated BoundingInfo object to the submesh
  20682. * @param data defines an optional position array to use to determine the bounding info
  20683. * @returns the SubMesh
  20684. */
  20685. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20686. /** @hidden */
  20687. _checkCollision(collider: Collider): boolean;
  20688. /**
  20689. * Updates the submesh BoundingInfo
  20690. * @param world defines the world matrix to use to update the bounding info
  20691. * @returns the submesh
  20692. */
  20693. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20694. /**
  20695. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20696. * @param frustumPlanes defines the frustum planes
  20697. * @returns true if the submesh is intersecting with the frustum
  20698. */
  20699. isInFrustum(frustumPlanes: Plane[]): boolean;
  20700. /**
  20701. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20702. * @param frustumPlanes defines the frustum planes
  20703. * @returns true if the submesh is inside the frustum
  20704. */
  20705. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20706. /**
  20707. * Renders the submesh
  20708. * @param enableAlphaMode defines if alpha needs to be used
  20709. * @returns the submesh
  20710. */
  20711. render(enableAlphaMode: boolean): SubMesh;
  20712. /**
  20713. * @hidden
  20714. */
  20715. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20716. /**
  20717. * Checks if the submesh intersects with a ray
  20718. * @param ray defines the ray to test
  20719. * @returns true is the passed ray intersects the submesh bounding box
  20720. */
  20721. canIntersects(ray: Ray): boolean;
  20722. /**
  20723. * Intersects current submesh with a ray
  20724. * @param ray defines the ray to test
  20725. * @param positions defines mesh's positions array
  20726. * @param indices defines mesh's indices array
  20727. * @param fastCheck defines if only bounding info should be used
  20728. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20729. * @returns intersection info or null if no intersection
  20730. */
  20731. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20732. /** @hidden */
  20733. private _intersectLines;
  20734. /** @hidden */
  20735. private _intersectUnIndexedLines;
  20736. /** @hidden */
  20737. private _intersectTriangles;
  20738. /** @hidden */
  20739. private _intersectUnIndexedTriangles;
  20740. /** @hidden */
  20741. _rebuild(): void;
  20742. /**
  20743. * Creates a new submesh from the passed mesh
  20744. * @param newMesh defines the new hosting mesh
  20745. * @param newRenderingMesh defines an optional rendering mesh
  20746. * @returns the new submesh
  20747. */
  20748. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20749. /**
  20750. * Release associated resources
  20751. */
  20752. dispose(): void;
  20753. /**
  20754. * Gets the class name
  20755. * @returns the string "SubMesh".
  20756. */
  20757. getClassName(): string;
  20758. /**
  20759. * Creates a new submesh from indices data
  20760. * @param materialIndex the index of the main mesh material
  20761. * @param startIndex the index where to start the copy in the mesh indices array
  20762. * @param indexCount the number of indices to copy then from the startIndex
  20763. * @param mesh the main mesh to create the submesh from
  20764. * @param renderingMesh the optional rendering mesh
  20765. * @returns a new submesh
  20766. */
  20767. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20768. }
  20769. }
  20770. declare module BABYLON {
  20771. /**
  20772. * Class used to represent data loading progression
  20773. */
  20774. export class SceneLoaderFlags {
  20775. private static _ForceFullSceneLoadingForIncremental;
  20776. private static _ShowLoadingScreen;
  20777. private static _CleanBoneMatrixWeights;
  20778. private static _loggingLevel;
  20779. /**
  20780. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20781. */
  20782. static ForceFullSceneLoadingForIncremental: boolean;
  20783. /**
  20784. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20785. */
  20786. static ShowLoadingScreen: boolean;
  20787. /**
  20788. * Defines the current logging level (while loading the scene)
  20789. * @ignorenaming
  20790. */
  20791. static loggingLevel: number;
  20792. /**
  20793. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20794. */
  20795. static CleanBoneMatrixWeights: boolean;
  20796. }
  20797. }
  20798. declare module BABYLON {
  20799. /**
  20800. * Class used to store geometry data (vertex buffers + index buffer)
  20801. */
  20802. export class Geometry implements IGetSetVerticesData {
  20803. /**
  20804. * Gets or sets the ID of the geometry
  20805. */
  20806. id: string;
  20807. /**
  20808. * Gets or sets the unique ID of the geometry
  20809. */
  20810. uniqueId: number;
  20811. /**
  20812. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20813. */
  20814. delayLoadState: number;
  20815. /**
  20816. * Gets the file containing the data to load when running in delay load state
  20817. */
  20818. delayLoadingFile: Nullable<string>;
  20819. /**
  20820. * Callback called when the geometry is updated
  20821. */
  20822. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20823. private _scene;
  20824. private _engine;
  20825. private _meshes;
  20826. private _totalVertices;
  20827. /** @hidden */
  20828. _indices: IndicesArray;
  20829. /** @hidden */
  20830. _vertexBuffers: {
  20831. [key: string]: VertexBuffer;
  20832. };
  20833. private _isDisposed;
  20834. private _extend;
  20835. private _boundingBias;
  20836. /** @hidden */
  20837. _delayInfo: Array<string>;
  20838. private _indexBuffer;
  20839. private _indexBufferIsUpdatable;
  20840. /** @hidden */
  20841. _boundingInfo: Nullable<BoundingInfo>;
  20842. /** @hidden */
  20843. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20844. /** @hidden */
  20845. _softwareSkinningFrameId: number;
  20846. private _vertexArrayObjects;
  20847. private _updatable;
  20848. /** @hidden */
  20849. _positions: Nullable<Vector3[]>;
  20850. /**
  20851. * 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
  20852. */
  20853. /**
  20854. * 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
  20855. */
  20856. boundingBias: Vector2;
  20857. /**
  20858. * Static function used to attach a new empty geometry to a mesh
  20859. * @param mesh defines the mesh to attach the geometry to
  20860. * @returns the new Geometry
  20861. */
  20862. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20863. /**
  20864. * Creates a new geometry
  20865. * @param id defines the unique ID
  20866. * @param scene defines the hosting scene
  20867. * @param vertexData defines the VertexData used to get geometry data
  20868. * @param updatable defines if geometry must be updatable (false by default)
  20869. * @param mesh defines the mesh that will be associated with the geometry
  20870. */
  20871. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20872. /**
  20873. * Gets the current extend of the geometry
  20874. */
  20875. readonly extend: {
  20876. minimum: Vector3;
  20877. maximum: Vector3;
  20878. };
  20879. /**
  20880. * Gets the hosting scene
  20881. * @returns the hosting Scene
  20882. */
  20883. getScene(): Scene;
  20884. /**
  20885. * Gets the hosting engine
  20886. * @returns the hosting Engine
  20887. */
  20888. getEngine(): Engine;
  20889. /**
  20890. * Defines if the geometry is ready to use
  20891. * @returns true if the geometry is ready to be used
  20892. */
  20893. isReady(): boolean;
  20894. /**
  20895. * Gets a value indicating that the geometry should not be serialized
  20896. */
  20897. readonly doNotSerialize: boolean;
  20898. /** @hidden */
  20899. _rebuild(): void;
  20900. /**
  20901. * Affects all geometry data in one call
  20902. * @param vertexData defines the geometry data
  20903. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20904. */
  20905. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20906. /**
  20907. * Set specific vertex data
  20908. * @param kind defines the data kind (Position, normal, etc...)
  20909. * @param data defines the vertex data to use
  20910. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20911. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20912. */
  20913. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20914. /**
  20915. * Removes a specific vertex data
  20916. * @param kind defines the data kind (Position, normal, etc...)
  20917. */
  20918. removeVerticesData(kind: string): void;
  20919. /**
  20920. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20921. * @param buffer defines the vertex buffer to use
  20922. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20923. */
  20924. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20925. /**
  20926. * Update a specific vertex buffer
  20927. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20928. * It will do nothing if the buffer is not updatable
  20929. * @param kind defines the data kind (Position, normal, etc...)
  20930. * @param data defines the data to use
  20931. * @param offset defines the offset in the target buffer where to store the data
  20932. * @param useBytes set to true if the offset is in bytes
  20933. */
  20934. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20935. /**
  20936. * Update a specific vertex buffer
  20937. * This function will create a new buffer if the current one is not updatable
  20938. * @param kind defines the data kind (Position, normal, etc...)
  20939. * @param data defines the data to use
  20940. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20941. */
  20942. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20943. private _updateBoundingInfo;
  20944. /** @hidden */
  20945. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20946. /**
  20947. * Gets total number of vertices
  20948. * @returns the total number of vertices
  20949. */
  20950. getTotalVertices(): number;
  20951. /**
  20952. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20953. * @param kind defines the data kind (Position, normal, etc...)
  20954. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20955. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20956. * @returns a float array containing vertex data
  20957. */
  20958. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20959. /**
  20960. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20961. * @param kind defines the data kind (Position, normal, etc...)
  20962. * @returns true if the vertex buffer with the specified kind is updatable
  20963. */
  20964. isVertexBufferUpdatable(kind: string): boolean;
  20965. /**
  20966. * Gets a specific vertex buffer
  20967. * @param kind defines the data kind (Position, normal, etc...)
  20968. * @returns a VertexBuffer
  20969. */
  20970. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20971. /**
  20972. * Returns all vertex buffers
  20973. * @return an object holding all vertex buffers indexed by kind
  20974. */
  20975. getVertexBuffers(): Nullable<{
  20976. [key: string]: VertexBuffer;
  20977. }>;
  20978. /**
  20979. * Gets a boolean indicating if specific vertex buffer is present
  20980. * @param kind defines the data kind (Position, normal, etc...)
  20981. * @returns true if data is present
  20982. */
  20983. isVerticesDataPresent(kind: string): boolean;
  20984. /**
  20985. * Gets a list of all attached data kinds (Position, normal, etc...)
  20986. * @returns a list of string containing all kinds
  20987. */
  20988. getVerticesDataKinds(): string[];
  20989. /**
  20990. * Update index buffer
  20991. * @param indices defines the indices to store in the index buffer
  20992. * @param offset defines the offset in the target buffer where to store the data
  20993. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  20994. */
  20995. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20996. /**
  20997. * Creates a new index buffer
  20998. * @param indices defines the indices to store in the index buffer
  20999. * @param totalVertices defines the total number of vertices (could be null)
  21000. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21001. */
  21002. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21003. /**
  21004. * Return the total number of indices
  21005. * @returns the total number of indices
  21006. */
  21007. getTotalIndices(): number;
  21008. /**
  21009. * Gets the index buffer array
  21010. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21011. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21012. * @returns the index buffer array
  21013. */
  21014. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21015. /**
  21016. * Gets the index buffer
  21017. * @return the index buffer
  21018. */
  21019. getIndexBuffer(): Nullable<DataBuffer>;
  21020. /** @hidden */
  21021. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21022. /**
  21023. * Release the associated resources for a specific mesh
  21024. * @param mesh defines the source mesh
  21025. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21026. */
  21027. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21028. /**
  21029. * Apply current geometry to a given mesh
  21030. * @param mesh defines the mesh to apply geometry to
  21031. */
  21032. applyToMesh(mesh: Mesh): void;
  21033. private _updateExtend;
  21034. private _applyToMesh;
  21035. private notifyUpdate;
  21036. /**
  21037. * Load the geometry if it was flagged as delay loaded
  21038. * @param scene defines the hosting scene
  21039. * @param onLoaded defines a callback called when the geometry is loaded
  21040. */
  21041. load(scene: Scene, onLoaded?: () => void): void;
  21042. private _queueLoad;
  21043. /**
  21044. * Invert the geometry to move from a right handed system to a left handed one.
  21045. */
  21046. toLeftHanded(): void;
  21047. /** @hidden */
  21048. _resetPointsArrayCache(): void;
  21049. /** @hidden */
  21050. _generatePointsArray(): boolean;
  21051. /**
  21052. * Gets a value indicating if the geometry is disposed
  21053. * @returns true if the geometry was disposed
  21054. */
  21055. isDisposed(): boolean;
  21056. private _disposeVertexArrayObjects;
  21057. /**
  21058. * Free all associated resources
  21059. */
  21060. dispose(): void;
  21061. /**
  21062. * Clone the current geometry into a new geometry
  21063. * @param id defines the unique ID of the new geometry
  21064. * @returns a new geometry object
  21065. */
  21066. copy(id: string): Geometry;
  21067. /**
  21068. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21069. * @return a JSON representation of the current geometry data (without the vertices data)
  21070. */
  21071. serialize(): any;
  21072. private toNumberArray;
  21073. /**
  21074. * Serialize all vertices data into a JSON oject
  21075. * @returns a JSON representation of the current geometry data
  21076. */
  21077. serializeVerticeData(): any;
  21078. /**
  21079. * Extracts a clone of a mesh geometry
  21080. * @param mesh defines the source mesh
  21081. * @param id defines the unique ID of the new geometry object
  21082. * @returns the new geometry object
  21083. */
  21084. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21085. /**
  21086. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21087. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21088. * Be aware Math.random() could cause collisions, but:
  21089. * "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"
  21090. * @returns a string containing a new GUID
  21091. */
  21092. static RandomId(): string;
  21093. /** @hidden */
  21094. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21095. private static _CleanMatricesWeights;
  21096. /**
  21097. * Create a new geometry from persisted data (Using .babylon file format)
  21098. * @param parsedVertexData defines the persisted data
  21099. * @param scene defines the hosting scene
  21100. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21101. * @returns the new geometry object
  21102. */
  21103. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21104. }
  21105. }
  21106. declare module BABYLON {
  21107. /**
  21108. * Define an interface for all classes that will get and set the data on vertices
  21109. */
  21110. export interface IGetSetVerticesData {
  21111. /**
  21112. * Gets a boolean indicating if specific vertex data is present
  21113. * @param kind defines the vertex data kind to use
  21114. * @returns true is data kind is present
  21115. */
  21116. isVerticesDataPresent(kind: string): boolean;
  21117. /**
  21118. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21119. * @param kind defines the data kind (Position, normal, etc...)
  21120. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21121. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21122. * @returns a float array containing vertex data
  21123. */
  21124. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21125. /**
  21126. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21127. * @param copyWhenShared If 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.
  21128. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21129. * @returns the indices array or an empty array if the mesh has no geometry
  21130. */
  21131. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21132. /**
  21133. * Set specific vertex data
  21134. * @param kind defines the data kind (Position, normal, etc...)
  21135. * @param data defines the vertex data to use
  21136. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21137. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21138. */
  21139. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21140. /**
  21141. * Update a specific associated vertex buffer
  21142. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21143. * - VertexBuffer.PositionKind
  21144. * - VertexBuffer.UVKind
  21145. * - VertexBuffer.UV2Kind
  21146. * - VertexBuffer.UV3Kind
  21147. * - VertexBuffer.UV4Kind
  21148. * - VertexBuffer.UV5Kind
  21149. * - VertexBuffer.UV6Kind
  21150. * - VertexBuffer.ColorKind
  21151. * - VertexBuffer.MatricesIndicesKind
  21152. * - VertexBuffer.MatricesIndicesExtraKind
  21153. * - VertexBuffer.MatricesWeightsKind
  21154. * - VertexBuffer.MatricesWeightsExtraKind
  21155. * @param data defines the data source
  21156. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21157. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  21158. */
  21159. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21160. /**
  21161. * Creates a new index buffer
  21162. * @param indices defines the indices to store in the index buffer
  21163. * @param totalVertices defines the total number of vertices (could be null)
  21164. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21165. */
  21166. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21167. }
  21168. /**
  21169. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21170. */
  21171. export class VertexData {
  21172. /**
  21173. * Mesh side orientation : usually the external or front surface
  21174. */
  21175. static readonly FRONTSIDE: number;
  21176. /**
  21177. * Mesh side orientation : usually the internal or back surface
  21178. */
  21179. static readonly BACKSIDE: number;
  21180. /**
  21181. * Mesh side orientation : both internal and external or front and back surfaces
  21182. */
  21183. static readonly DOUBLESIDE: number;
  21184. /**
  21185. * Mesh side orientation : by default, `FRONTSIDE`
  21186. */
  21187. static readonly DEFAULTSIDE: number;
  21188. /**
  21189. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21190. */
  21191. positions: Nullable<FloatArray>;
  21192. /**
  21193. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21194. */
  21195. normals: Nullable<FloatArray>;
  21196. /**
  21197. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21198. */
  21199. tangents: Nullable<FloatArray>;
  21200. /**
  21201. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21202. */
  21203. uvs: Nullable<FloatArray>;
  21204. /**
  21205. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21206. */
  21207. uvs2: Nullable<FloatArray>;
  21208. /**
  21209. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21210. */
  21211. uvs3: Nullable<FloatArray>;
  21212. /**
  21213. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21214. */
  21215. uvs4: Nullable<FloatArray>;
  21216. /**
  21217. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21218. */
  21219. uvs5: Nullable<FloatArray>;
  21220. /**
  21221. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21222. */
  21223. uvs6: Nullable<FloatArray>;
  21224. /**
  21225. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21226. */
  21227. colors: Nullable<FloatArray>;
  21228. /**
  21229. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  21230. */
  21231. matricesIndices: Nullable<FloatArray>;
  21232. /**
  21233. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21234. */
  21235. matricesWeights: Nullable<FloatArray>;
  21236. /**
  21237. * An array extending the number of possible indices
  21238. */
  21239. matricesIndicesExtra: Nullable<FloatArray>;
  21240. /**
  21241. * An array extending the number of possible weights when the number of indices is extended
  21242. */
  21243. matricesWeightsExtra: Nullable<FloatArray>;
  21244. /**
  21245. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21246. */
  21247. indices: Nullable<IndicesArray>;
  21248. /**
  21249. * Uses the passed data array to set the set the values for the specified kind of data
  21250. * @param data a linear array of floating numbers
  21251. * @param kind the type of data that is being set, eg positions, colors etc
  21252. */
  21253. set(data: FloatArray, kind: string): void;
  21254. /**
  21255. * Associates the vertexData to the passed Mesh.
  21256. * Sets it as updatable or not (default `false`)
  21257. * @param mesh the mesh the vertexData is applied to
  21258. * @param updatable when used and having the value true allows new data to update the vertexData
  21259. * @returns the VertexData
  21260. */
  21261. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21262. /**
  21263. * Associates the vertexData to the passed Geometry.
  21264. * Sets it as updatable or not (default `false`)
  21265. * @param geometry the geometry the vertexData is applied to
  21266. * @param updatable when used and having the value true allows new data to update the vertexData
  21267. * @returns VertexData
  21268. */
  21269. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21270. /**
  21271. * Updates the associated mesh
  21272. * @param mesh the mesh to be updated
  21273. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21274. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  21275. * @returns VertexData
  21276. */
  21277. updateMesh(mesh: Mesh): VertexData;
  21278. /**
  21279. * Updates the associated geometry
  21280. * @param geometry the geometry to be updated
  21281. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21282. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  21283. * @returns VertexData.
  21284. */
  21285. updateGeometry(geometry: Geometry): VertexData;
  21286. private _applyTo;
  21287. private _update;
  21288. /**
  21289. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21290. * @param matrix the transforming matrix
  21291. * @returns the VertexData
  21292. */
  21293. transform(matrix: Matrix): VertexData;
  21294. /**
  21295. * Merges the passed VertexData into the current one
  21296. * @param other the VertexData to be merged into the current one
  21297. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21298. * @returns the modified VertexData
  21299. */
  21300. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21301. private _mergeElement;
  21302. private _validate;
  21303. /**
  21304. * Serializes the VertexData
  21305. * @returns a serialized object
  21306. */
  21307. serialize(): any;
  21308. /**
  21309. * Extracts the vertexData from a mesh
  21310. * @param mesh the mesh from which to extract the VertexData
  21311. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21312. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21313. * @returns the object VertexData associated to the passed mesh
  21314. */
  21315. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21316. /**
  21317. * Extracts the vertexData from the geometry
  21318. * @param geometry the geometry from which to extract the VertexData
  21319. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21320. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21321. * @returns the object VertexData associated to the passed mesh
  21322. */
  21323. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21324. private static _ExtractFrom;
  21325. /**
  21326. * Creates the VertexData for a Ribbon
  21327. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21328. * * pathArray array of paths, each of which an array of successive Vector3
  21329. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21330. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21331. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  21332. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21333. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21334. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21335. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21336. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21337. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21338. * @returns the VertexData of the ribbon
  21339. */
  21340. static CreateRibbon(options: {
  21341. pathArray: Vector3[][];
  21342. closeArray?: boolean;
  21343. closePath?: boolean;
  21344. offset?: number;
  21345. sideOrientation?: number;
  21346. frontUVs?: Vector4;
  21347. backUVs?: Vector4;
  21348. invertUV?: boolean;
  21349. uvs?: Vector2[];
  21350. colors?: Color4[];
  21351. }): VertexData;
  21352. /**
  21353. * Creates the VertexData for a box
  21354. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21355. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21356. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21357. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21358. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21359. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21360. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21361. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21362. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21363. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21364. * @returns the VertexData of the box
  21365. */
  21366. static CreateBox(options: {
  21367. size?: number;
  21368. width?: number;
  21369. height?: number;
  21370. depth?: number;
  21371. faceUV?: Vector4[];
  21372. faceColors?: Color4[];
  21373. sideOrientation?: number;
  21374. frontUVs?: Vector4;
  21375. backUVs?: Vector4;
  21376. }): VertexData;
  21377. /**
  21378. * Creates the VertexData for a tiled box
  21379. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21380. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21381. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21382. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21383. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21384. * @returns the VertexData of the box
  21385. */
  21386. static CreateTiledBox(options: {
  21387. pattern?: number;
  21388. width?: number;
  21389. height?: number;
  21390. depth?: number;
  21391. tileSize?: number;
  21392. tileWidth?: number;
  21393. tileHeight?: number;
  21394. alignHorizontal?: number;
  21395. alignVertical?: number;
  21396. faceUV?: Vector4[];
  21397. faceColors?: Color4[];
  21398. sideOrientation?: number;
  21399. }): VertexData;
  21400. /**
  21401. * Creates the VertexData for a tiled plane
  21402. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21403. * * pattern a limited pattern arrangement depending on the number
  21404. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21405. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21406. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21407. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21408. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21409. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21410. * @returns the VertexData of the tiled plane
  21411. */
  21412. static CreateTiledPlane(options: {
  21413. pattern?: number;
  21414. tileSize?: number;
  21415. tileWidth?: number;
  21416. tileHeight?: number;
  21417. size?: number;
  21418. width?: number;
  21419. height?: number;
  21420. alignHorizontal?: number;
  21421. alignVertical?: number;
  21422. sideOrientation?: number;
  21423. frontUVs?: Vector4;
  21424. backUVs?: Vector4;
  21425. }): VertexData;
  21426. /**
  21427. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21428. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21429. * * segments sets the number of horizontal strips optional, default 32
  21430. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21431. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21432. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21433. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21434. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  21435. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  21436. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21437. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21438. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21439. * @returns the VertexData of the ellipsoid
  21440. */
  21441. static CreateSphere(options: {
  21442. segments?: number;
  21443. diameter?: number;
  21444. diameterX?: number;
  21445. diameterY?: number;
  21446. diameterZ?: number;
  21447. arc?: number;
  21448. slice?: number;
  21449. sideOrientation?: number;
  21450. frontUVs?: Vector4;
  21451. backUVs?: Vector4;
  21452. }): VertexData;
  21453. /**
  21454. * Creates the VertexData for a cylinder, cone or prism
  21455. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21456. * * height sets the height (y direction) of the cylinder, optional, default 2
  21457. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21458. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21459. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21460. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21461. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21462. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  21463. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21464. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21465. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21466. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21468. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21469. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21470. * @returns the VertexData of the cylinder, cone or prism
  21471. */
  21472. static CreateCylinder(options: {
  21473. height?: number;
  21474. diameterTop?: number;
  21475. diameterBottom?: number;
  21476. diameter?: number;
  21477. tessellation?: number;
  21478. subdivisions?: number;
  21479. arc?: number;
  21480. faceColors?: Color4[];
  21481. faceUV?: Vector4[];
  21482. hasRings?: boolean;
  21483. enclose?: boolean;
  21484. sideOrientation?: number;
  21485. frontUVs?: Vector4;
  21486. backUVs?: Vector4;
  21487. }): VertexData;
  21488. /**
  21489. * Creates the VertexData for a torus
  21490. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21491. * * diameter the diameter of the torus, optional default 1
  21492. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21493. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21494. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21495. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21496. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21497. * @returns the VertexData of the torus
  21498. */
  21499. static CreateTorus(options: {
  21500. diameter?: number;
  21501. thickness?: number;
  21502. tessellation?: number;
  21503. sideOrientation?: number;
  21504. frontUVs?: Vector4;
  21505. backUVs?: Vector4;
  21506. }): VertexData;
  21507. /**
  21508. * Creates the VertexData of the LineSystem
  21509. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21510. * - lines an array of lines, each line being an array of successive Vector3
  21511. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21512. * @returns the VertexData of the LineSystem
  21513. */
  21514. static CreateLineSystem(options: {
  21515. lines: Vector3[][];
  21516. colors?: Nullable<Color4[][]>;
  21517. }): VertexData;
  21518. /**
  21519. * Create the VertexData for a DashedLines
  21520. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21521. * - points an array successive Vector3
  21522. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21523. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21524. * - dashNb the intended total number of dashes, optional, default 200
  21525. * @returns the VertexData for the DashedLines
  21526. */
  21527. static CreateDashedLines(options: {
  21528. points: Vector3[];
  21529. dashSize?: number;
  21530. gapSize?: number;
  21531. dashNb?: number;
  21532. }): VertexData;
  21533. /**
  21534. * Creates the VertexData for a Ground
  21535. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21536. * - width the width (x direction) of the ground, optional, default 1
  21537. * - height the height (z direction) of the ground, optional, default 1
  21538. * - subdivisions the number of subdivisions per side, optional, default 1
  21539. * @returns the VertexData of the Ground
  21540. */
  21541. static CreateGround(options: {
  21542. width?: number;
  21543. height?: number;
  21544. subdivisions?: number;
  21545. subdivisionsX?: number;
  21546. subdivisionsY?: number;
  21547. }): VertexData;
  21548. /**
  21549. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21550. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21551. * * xmin the ground minimum X coordinate, optional, default -1
  21552. * * zmin the ground minimum Z coordinate, optional, default -1
  21553. * * xmax the ground maximum X coordinate, optional, default 1
  21554. * * zmax the ground maximum Z coordinate, optional, default 1
  21555. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  21556. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  21557. * @returns the VertexData of the TiledGround
  21558. */
  21559. static CreateTiledGround(options: {
  21560. xmin: number;
  21561. zmin: number;
  21562. xmax: number;
  21563. zmax: number;
  21564. subdivisions?: {
  21565. w: number;
  21566. h: number;
  21567. };
  21568. precision?: {
  21569. w: number;
  21570. h: number;
  21571. };
  21572. }): VertexData;
  21573. /**
  21574. * Creates the VertexData of the Ground designed from a heightmap
  21575. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21576. * * width the width (x direction) of the ground
  21577. * * height the height (z direction) of the ground
  21578. * * subdivisions the number of subdivisions per side
  21579. * * minHeight the minimum altitude on the ground, optional, default 0
  21580. * * maxHeight the maximum altitude on the ground, optional default 1
  21581. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21582. * * buffer the array holding the image color data
  21583. * * bufferWidth the width of image
  21584. * * bufferHeight the height of image
  21585. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21586. * @returns the VertexData of the Ground designed from a heightmap
  21587. */
  21588. static CreateGroundFromHeightMap(options: {
  21589. width: number;
  21590. height: number;
  21591. subdivisions: number;
  21592. minHeight: number;
  21593. maxHeight: number;
  21594. colorFilter: Color3;
  21595. buffer: Uint8Array;
  21596. bufferWidth: number;
  21597. bufferHeight: number;
  21598. alphaFilter: number;
  21599. }): VertexData;
  21600. /**
  21601. * Creates the VertexData for a Plane
  21602. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21603. * * size sets the width and height of the plane to the value of size, optional default 1
  21604. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21605. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21606. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21607. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21608. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21609. * @returns the VertexData of the box
  21610. */
  21611. static CreatePlane(options: {
  21612. size?: number;
  21613. width?: number;
  21614. height?: number;
  21615. sideOrientation?: number;
  21616. frontUVs?: Vector4;
  21617. backUVs?: Vector4;
  21618. }): VertexData;
  21619. /**
  21620. * Creates the VertexData of the Disc or regular Polygon
  21621. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21622. * * radius the radius of the disc, optional default 0.5
  21623. * * tessellation the number of polygon sides, optional, default 64
  21624. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  21625. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21626. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21627. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21628. * @returns the VertexData of the box
  21629. */
  21630. static CreateDisc(options: {
  21631. radius?: number;
  21632. tessellation?: number;
  21633. arc?: number;
  21634. sideOrientation?: number;
  21635. frontUVs?: Vector4;
  21636. backUVs?: Vector4;
  21637. }): VertexData;
  21638. /**
  21639. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21640. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21641. * @param polygon a mesh built from polygonTriangulation.build()
  21642. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21643. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21644. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21645. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21646. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21647. * @returns the VertexData of the Polygon
  21648. */
  21649. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21650. /**
  21651. * Creates the VertexData of the IcoSphere
  21652. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21653. * * radius the radius of the IcoSphere, optional default 1
  21654. * * radiusX allows stretching in the x direction, optional, default radius
  21655. * * radiusY allows stretching in the y direction, optional, default radius
  21656. * * radiusZ allows stretching in the z direction, optional, default radius
  21657. * * flat when true creates a flat shaded mesh, optional, default true
  21658. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21659. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21660. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21661. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21662. * @returns the VertexData of the IcoSphere
  21663. */
  21664. static CreateIcoSphere(options: {
  21665. radius?: number;
  21666. radiusX?: number;
  21667. radiusY?: number;
  21668. radiusZ?: number;
  21669. flat?: boolean;
  21670. subdivisions?: number;
  21671. sideOrientation?: number;
  21672. frontUVs?: Vector4;
  21673. backUVs?: Vector4;
  21674. }): VertexData;
  21675. /**
  21676. * Creates the VertexData for a Polyhedron
  21677. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21678. * * type provided types are:
  21679. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21680. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  21681. * * size the size of the IcoSphere, optional default 1
  21682. * * sizeX allows stretching in the x direction, optional, default size
  21683. * * sizeY allows stretching in the y direction, optional, default size
  21684. * * sizeZ allows stretching in the z direction, optional, default size
  21685. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  21686. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21687. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21688. * * flat when true creates a flat shaded mesh, optional, default true
  21689. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21690. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21691. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21692. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21693. * @returns the VertexData of the Polyhedron
  21694. */
  21695. static CreatePolyhedron(options: {
  21696. type?: number;
  21697. size?: number;
  21698. sizeX?: number;
  21699. sizeY?: number;
  21700. sizeZ?: number;
  21701. custom?: any;
  21702. faceUV?: Vector4[];
  21703. faceColors?: Color4[];
  21704. flat?: boolean;
  21705. sideOrientation?: number;
  21706. frontUVs?: Vector4;
  21707. backUVs?: Vector4;
  21708. }): VertexData;
  21709. /**
  21710. * Creates the VertexData for a TorusKnot
  21711. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21712. * * radius the radius of the torus knot, optional, default 2
  21713. * * tube the thickness of the tube, optional, default 0.5
  21714. * * radialSegments the number of sides on each tube segments, optional, default 32
  21715. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21716. * * p the number of windings around the z axis, optional, default 2
  21717. * * q the number of windings around the x axis, optional, default 3
  21718. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21719. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21720. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21721. * @returns the VertexData of the Torus Knot
  21722. */
  21723. static CreateTorusKnot(options: {
  21724. radius?: number;
  21725. tube?: number;
  21726. radialSegments?: number;
  21727. tubularSegments?: number;
  21728. p?: number;
  21729. q?: number;
  21730. sideOrientation?: number;
  21731. frontUVs?: Vector4;
  21732. backUVs?: Vector4;
  21733. }): VertexData;
  21734. /**
  21735. * Compute normals for given positions and indices
  21736. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21737. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21738. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21739. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21740. * * facetNormals : optional array of facet normals (vector3)
  21741. * * facetPositions : optional array of facet positions (vector3)
  21742. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21743. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21744. * * bInfo : optional bounding info, required for facetPartitioning computation
  21745. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21746. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21747. * * useRightHandedSystem: optional boolean to for right handed system computation
  21748. * * depthSort : optional boolean to enable the facet depth sort computation
  21749. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21750. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21751. */
  21752. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21753. facetNormals?: any;
  21754. facetPositions?: any;
  21755. facetPartitioning?: any;
  21756. ratio?: number;
  21757. bInfo?: any;
  21758. bbSize?: Vector3;
  21759. subDiv?: any;
  21760. useRightHandedSystem?: boolean;
  21761. depthSort?: boolean;
  21762. distanceTo?: Vector3;
  21763. depthSortedFacets?: any;
  21764. }): void;
  21765. /** @hidden */
  21766. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21767. /**
  21768. * Applies VertexData created from the imported parameters to the geometry
  21769. * @param parsedVertexData the parsed data from an imported file
  21770. * @param geometry the geometry to apply the VertexData to
  21771. */
  21772. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21773. }
  21774. }
  21775. declare module BABYLON {
  21776. /**
  21777. * Defines a target to use with MorphTargetManager
  21778. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21779. */
  21780. export class MorphTarget implements IAnimatable {
  21781. /** defines the name of the target */
  21782. name: string;
  21783. /**
  21784. * Gets or sets the list of animations
  21785. */
  21786. animations: Animation[];
  21787. private _scene;
  21788. private _positions;
  21789. private _normals;
  21790. private _tangents;
  21791. private _uvs;
  21792. private _influence;
  21793. /**
  21794. * Observable raised when the influence changes
  21795. */
  21796. onInfluenceChanged: Observable<boolean>;
  21797. /** @hidden */
  21798. _onDataLayoutChanged: Observable<void>;
  21799. /**
  21800. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21801. */
  21802. influence: number;
  21803. /**
  21804. * Gets or sets the id of the morph Target
  21805. */
  21806. id: string;
  21807. private _animationPropertiesOverride;
  21808. /**
  21809. * Gets or sets the animation properties override
  21810. */
  21811. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21812. /**
  21813. * Creates a new MorphTarget
  21814. * @param name defines the name of the target
  21815. * @param influence defines the influence to use
  21816. * @param scene defines the scene the morphtarget belongs to
  21817. */
  21818. constructor(
  21819. /** defines the name of the target */
  21820. name: string, influence?: number, scene?: Nullable<Scene>);
  21821. /**
  21822. * Gets a boolean defining if the target contains position data
  21823. */
  21824. readonly hasPositions: boolean;
  21825. /**
  21826. * Gets a boolean defining if the target contains normal data
  21827. */
  21828. readonly hasNormals: boolean;
  21829. /**
  21830. * Gets a boolean defining if the target contains tangent data
  21831. */
  21832. readonly hasTangents: boolean;
  21833. /**
  21834. * Gets a boolean defining if the target contains texture coordinates data
  21835. */
  21836. readonly hasUVs: boolean;
  21837. /**
  21838. * Affects position data to this target
  21839. * @param data defines the position data to use
  21840. */
  21841. setPositions(data: Nullable<FloatArray>): void;
  21842. /**
  21843. * Gets the position data stored in this target
  21844. * @returns a FloatArray containing the position data (or null if not present)
  21845. */
  21846. getPositions(): Nullable<FloatArray>;
  21847. /**
  21848. * Affects normal data to this target
  21849. * @param data defines the normal data to use
  21850. */
  21851. setNormals(data: Nullable<FloatArray>): void;
  21852. /**
  21853. * Gets the normal data stored in this target
  21854. * @returns a FloatArray containing the normal data (or null if not present)
  21855. */
  21856. getNormals(): Nullable<FloatArray>;
  21857. /**
  21858. * Affects tangent data to this target
  21859. * @param data defines the tangent data to use
  21860. */
  21861. setTangents(data: Nullable<FloatArray>): void;
  21862. /**
  21863. * Gets the tangent data stored in this target
  21864. * @returns a FloatArray containing the tangent data (or null if not present)
  21865. */
  21866. getTangents(): Nullable<FloatArray>;
  21867. /**
  21868. * Affects texture coordinates data to this target
  21869. * @param data defines the texture coordinates data to use
  21870. */
  21871. setUVs(data: Nullable<FloatArray>): void;
  21872. /**
  21873. * Gets the texture coordinates data stored in this target
  21874. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21875. */
  21876. getUVs(): Nullable<FloatArray>;
  21877. /**
  21878. * Serializes the current target into a Serialization object
  21879. * @returns the serialized object
  21880. */
  21881. serialize(): any;
  21882. /**
  21883. * Returns the string "MorphTarget"
  21884. * @returns "MorphTarget"
  21885. */
  21886. getClassName(): string;
  21887. /**
  21888. * Creates a new target from serialized data
  21889. * @param serializationObject defines the serialized data to use
  21890. * @returns a new MorphTarget
  21891. */
  21892. static Parse(serializationObject: any): MorphTarget;
  21893. /**
  21894. * Creates a MorphTarget from mesh data
  21895. * @param mesh defines the source mesh
  21896. * @param name defines the name to use for the new target
  21897. * @param influence defines the influence to attach to the target
  21898. * @returns a new MorphTarget
  21899. */
  21900. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21901. }
  21902. }
  21903. declare module BABYLON {
  21904. /**
  21905. * This class is used to deform meshes using morphing between different targets
  21906. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21907. */
  21908. export class MorphTargetManager {
  21909. private _targets;
  21910. private _targetInfluenceChangedObservers;
  21911. private _targetDataLayoutChangedObservers;
  21912. private _activeTargets;
  21913. private _scene;
  21914. private _influences;
  21915. private _supportsNormals;
  21916. private _supportsTangents;
  21917. private _supportsUVs;
  21918. private _vertexCount;
  21919. private _uniqueId;
  21920. private _tempInfluences;
  21921. /**
  21922. * Gets or sets a boolean indicating if normals must be morphed
  21923. */
  21924. enableNormalMorphing: boolean;
  21925. /**
  21926. * Gets or sets a boolean indicating if tangents must be morphed
  21927. */
  21928. enableTangentMorphing: boolean;
  21929. /**
  21930. * Gets or sets a boolean indicating if UV must be morphed
  21931. */
  21932. enableUVMorphing: boolean;
  21933. /**
  21934. * Creates a new MorphTargetManager
  21935. * @param scene defines the current scene
  21936. */
  21937. constructor(scene?: Nullable<Scene>);
  21938. /**
  21939. * Gets the unique ID of this manager
  21940. */
  21941. readonly uniqueId: number;
  21942. /**
  21943. * Gets the number of vertices handled by this manager
  21944. */
  21945. readonly vertexCount: number;
  21946. /**
  21947. * Gets a boolean indicating if this manager supports morphing of normals
  21948. */
  21949. readonly supportsNormals: boolean;
  21950. /**
  21951. * Gets a boolean indicating if this manager supports morphing of tangents
  21952. */
  21953. readonly supportsTangents: boolean;
  21954. /**
  21955. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21956. */
  21957. readonly supportsUVs: boolean;
  21958. /**
  21959. * Gets the number of targets stored in this manager
  21960. */
  21961. readonly numTargets: number;
  21962. /**
  21963. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21964. */
  21965. readonly numInfluencers: number;
  21966. /**
  21967. * Gets the list of influences (one per target)
  21968. */
  21969. readonly influences: Float32Array;
  21970. /**
  21971. * Gets the active target at specified index. An active target is a target with an influence > 0
  21972. * @param index defines the index to check
  21973. * @returns the requested target
  21974. */
  21975. getActiveTarget(index: number): MorphTarget;
  21976. /**
  21977. * Gets the target at specified index
  21978. * @param index defines the index to check
  21979. * @returns the requested target
  21980. */
  21981. getTarget(index: number): MorphTarget;
  21982. /**
  21983. * Add a new target to this manager
  21984. * @param target defines the target to add
  21985. */
  21986. addTarget(target: MorphTarget): void;
  21987. /**
  21988. * Removes a target from the manager
  21989. * @param target defines the target to remove
  21990. */
  21991. removeTarget(target: MorphTarget): void;
  21992. /**
  21993. * Serializes the current manager into a Serialization object
  21994. * @returns the serialized object
  21995. */
  21996. serialize(): any;
  21997. private _syncActiveTargets;
  21998. /**
  21999. * Syncrhonize the targets with all the meshes using this morph target manager
  22000. */
  22001. synchronize(): void;
  22002. /**
  22003. * Creates a new MorphTargetManager from serialized data
  22004. * @param serializationObject defines the serialized data
  22005. * @param scene defines the hosting scene
  22006. * @returns the new MorphTargetManager
  22007. */
  22008. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22009. }
  22010. }
  22011. declare module BABYLON {
  22012. /**
  22013. * Class used to represent a specific level of detail of a mesh
  22014. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22015. */
  22016. export class MeshLODLevel {
  22017. /** Defines the distance where this level should star being displayed */
  22018. distance: number;
  22019. /** Defines the mesh to use to render this level */
  22020. mesh: Nullable<Mesh>;
  22021. /**
  22022. * Creates a new LOD level
  22023. * @param distance defines the distance where this level should star being displayed
  22024. * @param mesh defines the mesh to use to render this level
  22025. */
  22026. constructor(
  22027. /** Defines the distance where this level should star being displayed */
  22028. distance: number,
  22029. /** Defines the mesh to use to render this level */
  22030. mesh: Nullable<Mesh>);
  22031. }
  22032. }
  22033. declare module BABYLON {
  22034. /**
  22035. * Mesh representing the gorund
  22036. */
  22037. export class GroundMesh extends Mesh {
  22038. /** If octree should be generated */
  22039. generateOctree: boolean;
  22040. private _heightQuads;
  22041. /** @hidden */
  22042. _subdivisionsX: number;
  22043. /** @hidden */
  22044. _subdivisionsY: number;
  22045. /** @hidden */
  22046. _width: number;
  22047. /** @hidden */
  22048. _height: number;
  22049. /** @hidden */
  22050. _minX: number;
  22051. /** @hidden */
  22052. _maxX: number;
  22053. /** @hidden */
  22054. _minZ: number;
  22055. /** @hidden */
  22056. _maxZ: number;
  22057. constructor(name: string, scene: Scene);
  22058. /**
  22059. * "GroundMesh"
  22060. * @returns "GroundMesh"
  22061. */
  22062. getClassName(): string;
  22063. /**
  22064. * The minimum of x and y subdivisions
  22065. */
  22066. readonly subdivisions: number;
  22067. /**
  22068. * X subdivisions
  22069. */
  22070. readonly subdivisionsX: number;
  22071. /**
  22072. * Y subdivisions
  22073. */
  22074. readonly subdivisionsY: number;
  22075. /**
  22076. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22077. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22078. * @param chunksCount the number of subdivisions for x and y
  22079. * @param octreeBlocksSize (Default: 32)
  22080. */
  22081. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22082. /**
  22083. * Returns a height (y) value in the Worl system :
  22084. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22085. * @param x x coordinate
  22086. * @param z z coordinate
  22087. * @returns the ground y position if (x, z) are outside the ground surface.
  22088. */
  22089. getHeightAtCoordinates(x: number, z: number): number;
  22090. /**
  22091. * Returns a normalized vector (Vector3) orthogonal to the ground
  22092. * at the ground coordinates (x, z) expressed in the World system.
  22093. * @param x x coordinate
  22094. * @param z z coordinate
  22095. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22096. */
  22097. getNormalAtCoordinates(x: number, z: number): Vector3;
  22098. /**
  22099. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22100. * at the ground coordinates (x, z) expressed in the World system.
  22101. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22102. * @param x x coordinate
  22103. * @param z z coordinate
  22104. * @param ref vector to store the result
  22105. * @returns the GroundMesh.
  22106. */
  22107. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22108. /**
  22109. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22110. * if the ground has been updated.
  22111. * This can be used in the render loop.
  22112. * @returns the GroundMesh.
  22113. */
  22114. updateCoordinateHeights(): GroundMesh;
  22115. private _getFacetAt;
  22116. private _initHeightQuads;
  22117. private _computeHeightQuads;
  22118. /**
  22119. * Serializes this ground mesh
  22120. * @param serializationObject object to write serialization to
  22121. */
  22122. serialize(serializationObject: any): void;
  22123. /**
  22124. * Parses a serialized ground mesh
  22125. * @param parsedMesh the serialized mesh
  22126. * @param scene the scene to create the ground mesh in
  22127. * @returns the created ground mesh
  22128. */
  22129. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22130. }
  22131. }
  22132. declare module BABYLON {
  22133. /**
  22134. * Interface for Physics-Joint data
  22135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22136. */
  22137. export interface PhysicsJointData {
  22138. /**
  22139. * The main pivot of the joint
  22140. */
  22141. mainPivot?: Vector3;
  22142. /**
  22143. * The connected pivot of the joint
  22144. */
  22145. connectedPivot?: Vector3;
  22146. /**
  22147. * The main axis of the joint
  22148. */
  22149. mainAxis?: Vector3;
  22150. /**
  22151. * The connected axis of the joint
  22152. */
  22153. connectedAxis?: Vector3;
  22154. /**
  22155. * The collision of the joint
  22156. */
  22157. collision?: boolean;
  22158. /**
  22159. * Native Oimo/Cannon/Energy data
  22160. */
  22161. nativeParams?: any;
  22162. }
  22163. /**
  22164. * This is a holder class for the physics joint created by the physics plugin
  22165. * It holds a set of functions to control the underlying joint
  22166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22167. */
  22168. export class PhysicsJoint {
  22169. /**
  22170. * The type of the physics joint
  22171. */
  22172. type: number;
  22173. /**
  22174. * The data for the physics joint
  22175. */
  22176. jointData: PhysicsJointData;
  22177. private _physicsJoint;
  22178. protected _physicsPlugin: IPhysicsEnginePlugin;
  22179. /**
  22180. * Initializes the physics joint
  22181. * @param type The type of the physics joint
  22182. * @param jointData The data for the physics joint
  22183. */
  22184. constructor(
  22185. /**
  22186. * The type of the physics joint
  22187. */
  22188. type: number,
  22189. /**
  22190. * The data for the physics joint
  22191. */
  22192. jointData: PhysicsJointData);
  22193. /**
  22194. * Gets the physics joint
  22195. */
  22196. /**
  22197. * Sets the physics joint
  22198. */
  22199. physicsJoint: any;
  22200. /**
  22201. * Sets the physics plugin
  22202. */
  22203. physicsPlugin: IPhysicsEnginePlugin;
  22204. /**
  22205. * Execute a function that is physics-plugin specific.
  22206. * @param {Function} func the function that will be executed.
  22207. * It accepts two parameters: the physics world and the physics joint
  22208. */
  22209. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22210. /**
  22211. * Distance-Joint type
  22212. */
  22213. static DistanceJoint: number;
  22214. /**
  22215. * Hinge-Joint type
  22216. */
  22217. static HingeJoint: number;
  22218. /**
  22219. * Ball-and-Socket joint type
  22220. */
  22221. static BallAndSocketJoint: number;
  22222. /**
  22223. * Wheel-Joint type
  22224. */
  22225. static WheelJoint: number;
  22226. /**
  22227. * Slider-Joint type
  22228. */
  22229. static SliderJoint: number;
  22230. /**
  22231. * Prismatic-Joint type
  22232. */
  22233. static PrismaticJoint: number;
  22234. /**
  22235. * Universal-Joint type
  22236. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22237. */
  22238. static UniversalJoint: number;
  22239. /**
  22240. * Hinge-Joint 2 type
  22241. */
  22242. static Hinge2Joint: number;
  22243. /**
  22244. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22245. */
  22246. static PointToPointJoint: number;
  22247. /**
  22248. * Spring-Joint type
  22249. */
  22250. static SpringJoint: number;
  22251. /**
  22252. * Lock-Joint type
  22253. */
  22254. static LockJoint: number;
  22255. }
  22256. /**
  22257. * A class representing a physics distance joint
  22258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22259. */
  22260. export class DistanceJoint extends PhysicsJoint {
  22261. /**
  22262. *
  22263. * @param jointData The data for the Distance-Joint
  22264. */
  22265. constructor(jointData: DistanceJointData);
  22266. /**
  22267. * Update the predefined distance.
  22268. * @param maxDistance The maximum preferred distance
  22269. * @param minDistance The minimum preferred distance
  22270. */
  22271. updateDistance(maxDistance: number, minDistance?: number): void;
  22272. }
  22273. /**
  22274. * Represents a Motor-Enabled Joint
  22275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22276. */
  22277. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22278. /**
  22279. * Initializes the Motor-Enabled Joint
  22280. * @param type The type of the joint
  22281. * @param jointData The physica joint data for the joint
  22282. */
  22283. constructor(type: number, jointData: PhysicsJointData);
  22284. /**
  22285. * Set the motor values.
  22286. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22287. * @param force the force to apply
  22288. * @param maxForce max force for this motor.
  22289. */
  22290. setMotor(force?: number, maxForce?: number): void;
  22291. /**
  22292. * Set the motor's limits.
  22293. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22294. * @param upperLimit The upper limit of the motor
  22295. * @param lowerLimit The lower limit of the motor
  22296. */
  22297. setLimit(upperLimit: number, lowerLimit?: number): void;
  22298. }
  22299. /**
  22300. * This class represents a single physics Hinge-Joint
  22301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22302. */
  22303. export class HingeJoint extends MotorEnabledJoint {
  22304. /**
  22305. * Initializes the Hinge-Joint
  22306. * @param jointData The joint data for the Hinge-Joint
  22307. */
  22308. constructor(jointData: PhysicsJointData);
  22309. /**
  22310. * Set the motor values.
  22311. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22312. * @param {number} force the force to apply
  22313. * @param {number} maxForce max force for this motor.
  22314. */
  22315. setMotor(force?: number, maxForce?: number): void;
  22316. /**
  22317. * Set the motor's limits.
  22318. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22319. * @param upperLimit The upper limit of the motor
  22320. * @param lowerLimit The lower limit of the motor
  22321. */
  22322. setLimit(upperLimit: number, lowerLimit?: number): void;
  22323. }
  22324. /**
  22325. * This class represents a dual hinge physics joint (same as wheel joint)
  22326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22327. */
  22328. export class Hinge2Joint extends MotorEnabledJoint {
  22329. /**
  22330. * Initializes the Hinge2-Joint
  22331. * @param jointData The joint data for the Hinge2-Joint
  22332. */
  22333. constructor(jointData: PhysicsJointData);
  22334. /**
  22335. * Set the motor values.
  22336. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22337. * @param {number} targetSpeed the speed the motor is to reach
  22338. * @param {number} maxForce max force for this motor.
  22339. * @param {motorIndex} the motor's index, 0 or 1.
  22340. */
  22341. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22342. /**
  22343. * Set the motor limits.
  22344. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22345. * @param {number} upperLimit the upper limit
  22346. * @param {number} lowerLimit lower limit
  22347. * @param {motorIndex} the motor's index, 0 or 1.
  22348. */
  22349. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22350. }
  22351. /**
  22352. * Interface for a motor enabled joint
  22353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22354. */
  22355. export interface IMotorEnabledJoint {
  22356. /**
  22357. * Physics joint
  22358. */
  22359. physicsJoint: any;
  22360. /**
  22361. * Sets the motor of the motor-enabled joint
  22362. * @param force The force of the motor
  22363. * @param maxForce The maximum force of the motor
  22364. * @param motorIndex The index of the motor
  22365. */
  22366. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22367. /**
  22368. * Sets the limit of the motor
  22369. * @param upperLimit The upper limit of the motor
  22370. * @param lowerLimit The lower limit of the motor
  22371. * @param motorIndex The index of the motor
  22372. */
  22373. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22374. }
  22375. /**
  22376. * Joint data for a Distance-Joint
  22377. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22378. */
  22379. export interface DistanceJointData extends PhysicsJointData {
  22380. /**
  22381. * Max distance the 2 joint objects can be apart
  22382. */
  22383. maxDistance: number;
  22384. }
  22385. /**
  22386. * Joint data from a spring joint
  22387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22388. */
  22389. export interface SpringJointData extends PhysicsJointData {
  22390. /**
  22391. * Length of the spring
  22392. */
  22393. length: number;
  22394. /**
  22395. * Stiffness of the spring
  22396. */
  22397. stiffness: number;
  22398. /**
  22399. * Damping of the spring
  22400. */
  22401. damping: number;
  22402. /** this callback will be called when applying the force to the impostors. */
  22403. forceApplicationCallback: () => void;
  22404. }
  22405. }
  22406. declare module BABYLON {
  22407. /**
  22408. * Holds the data for the raycast result
  22409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22410. */
  22411. export class PhysicsRaycastResult {
  22412. private _hasHit;
  22413. private _hitDistance;
  22414. private _hitNormalWorld;
  22415. private _hitPointWorld;
  22416. private _rayFromWorld;
  22417. private _rayToWorld;
  22418. /**
  22419. * Gets if there was a hit
  22420. */
  22421. readonly hasHit: boolean;
  22422. /**
  22423. * Gets the distance from the hit
  22424. */
  22425. readonly hitDistance: number;
  22426. /**
  22427. * Gets the hit normal/direction in the world
  22428. */
  22429. readonly hitNormalWorld: Vector3;
  22430. /**
  22431. * Gets the hit point in the world
  22432. */
  22433. readonly hitPointWorld: Vector3;
  22434. /**
  22435. * Gets the ray "start point" of the ray in the world
  22436. */
  22437. readonly rayFromWorld: Vector3;
  22438. /**
  22439. * Gets the ray "end point" of the ray in the world
  22440. */
  22441. readonly rayToWorld: Vector3;
  22442. /**
  22443. * Sets the hit data (normal & point in world space)
  22444. * @param hitNormalWorld defines the normal in world space
  22445. * @param hitPointWorld defines the point in world space
  22446. */
  22447. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22448. /**
  22449. * Sets the distance from the start point to the hit point
  22450. * @param distance
  22451. */
  22452. setHitDistance(distance: number): void;
  22453. /**
  22454. * Calculates the distance manually
  22455. */
  22456. calculateHitDistance(): void;
  22457. /**
  22458. * Resets all the values to default
  22459. * @param from The from point on world space
  22460. * @param to The to point on world space
  22461. */
  22462. reset(from?: Vector3, to?: Vector3): void;
  22463. }
  22464. /**
  22465. * Interface for the size containing width and height
  22466. */
  22467. interface IXYZ {
  22468. /**
  22469. * X
  22470. */
  22471. x: number;
  22472. /**
  22473. * Y
  22474. */
  22475. y: number;
  22476. /**
  22477. * Z
  22478. */
  22479. z: number;
  22480. }
  22481. }
  22482. declare module BABYLON {
  22483. /**
  22484. * Interface used to describe a physics joint
  22485. */
  22486. export interface PhysicsImpostorJoint {
  22487. /** Defines the main impostor to which the joint is linked */
  22488. mainImpostor: PhysicsImpostor;
  22489. /** Defines the impostor that is connected to the main impostor using this joint */
  22490. connectedImpostor: PhysicsImpostor;
  22491. /** Defines the joint itself */
  22492. joint: PhysicsJoint;
  22493. }
  22494. /** @hidden */
  22495. export interface IPhysicsEnginePlugin {
  22496. world: any;
  22497. name: string;
  22498. setGravity(gravity: Vector3): void;
  22499. setTimeStep(timeStep: number): void;
  22500. getTimeStep(): number;
  22501. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22502. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22503. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22504. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22505. removePhysicsBody(impostor: PhysicsImpostor): void;
  22506. generateJoint(joint: PhysicsImpostorJoint): void;
  22507. removeJoint(joint: PhysicsImpostorJoint): void;
  22508. isSupported(): boolean;
  22509. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22510. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22511. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22512. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22513. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22514. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22515. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22516. getBodyMass(impostor: PhysicsImpostor): number;
  22517. getBodyFriction(impostor: PhysicsImpostor): number;
  22518. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22519. getBodyRestitution(impostor: PhysicsImpostor): number;
  22520. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22521. getBodyPressure?(impostor: PhysicsImpostor): number;
  22522. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22523. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22524. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22525. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22526. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22527. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22528. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22529. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22530. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22531. sleepBody(impostor: PhysicsImpostor): void;
  22532. wakeUpBody(impostor: PhysicsImpostor): void;
  22533. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22534. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22535. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22536. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22537. getRadius(impostor: PhysicsImpostor): number;
  22538. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22539. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22540. dispose(): void;
  22541. }
  22542. /**
  22543. * Interface used to define a physics engine
  22544. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22545. */
  22546. export interface IPhysicsEngine {
  22547. /**
  22548. * Gets the gravity vector used by the simulation
  22549. */
  22550. gravity: Vector3;
  22551. /**
  22552. * Sets the gravity vector used by the simulation
  22553. * @param gravity defines the gravity vector to use
  22554. */
  22555. setGravity(gravity: Vector3): void;
  22556. /**
  22557. * Set the time step of the physics engine.
  22558. * Default is 1/60.
  22559. * To slow it down, enter 1/600 for example.
  22560. * To speed it up, 1/30
  22561. * @param newTimeStep the new timestep to apply to this world.
  22562. */
  22563. setTimeStep(newTimeStep: number): void;
  22564. /**
  22565. * Get the time step of the physics engine.
  22566. * @returns the current time step
  22567. */
  22568. getTimeStep(): number;
  22569. /**
  22570. * Release all resources
  22571. */
  22572. dispose(): void;
  22573. /**
  22574. * Gets the name of the current physics plugin
  22575. * @returns the name of the plugin
  22576. */
  22577. getPhysicsPluginName(): string;
  22578. /**
  22579. * Adding a new impostor for the impostor tracking.
  22580. * This will be done by the impostor itself.
  22581. * @param impostor the impostor to add
  22582. */
  22583. addImpostor(impostor: PhysicsImpostor): void;
  22584. /**
  22585. * Remove an impostor from the engine.
  22586. * This impostor and its mesh will not longer be updated by the physics engine.
  22587. * @param impostor the impostor to remove
  22588. */
  22589. removeImpostor(impostor: PhysicsImpostor): void;
  22590. /**
  22591. * Add a joint to the physics engine
  22592. * @param mainImpostor defines the main impostor to which the joint is added.
  22593. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22594. * @param joint defines the joint that will connect both impostors.
  22595. */
  22596. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22597. /**
  22598. * Removes a joint from the simulation
  22599. * @param mainImpostor defines the impostor used with the joint
  22600. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22601. * @param joint defines the joint to remove
  22602. */
  22603. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22604. /**
  22605. * Gets the current plugin used to run the simulation
  22606. * @returns current plugin
  22607. */
  22608. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22609. /**
  22610. * Gets the list of physic impostors
  22611. * @returns an array of PhysicsImpostor
  22612. */
  22613. getImpostors(): Array<PhysicsImpostor>;
  22614. /**
  22615. * Gets the impostor for a physics enabled object
  22616. * @param object defines the object impersonated by the impostor
  22617. * @returns the PhysicsImpostor or null if not found
  22618. */
  22619. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22620. /**
  22621. * Gets the impostor for a physics body object
  22622. * @param body defines physics body used by the impostor
  22623. * @returns the PhysicsImpostor or null if not found
  22624. */
  22625. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22626. /**
  22627. * Does a raycast in the physics world
  22628. * @param from when should the ray start?
  22629. * @param to when should the ray end?
  22630. * @returns PhysicsRaycastResult
  22631. */
  22632. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22633. /**
  22634. * Called by the scene. No need to call it.
  22635. * @param delta defines the timespam between frames
  22636. */
  22637. _step(delta: number): void;
  22638. }
  22639. }
  22640. declare module BABYLON {
  22641. /**
  22642. * The interface for the physics imposter parameters
  22643. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22644. */
  22645. export interface PhysicsImpostorParameters {
  22646. /**
  22647. * The mass of the physics imposter
  22648. */
  22649. mass: number;
  22650. /**
  22651. * The friction of the physics imposter
  22652. */
  22653. friction?: number;
  22654. /**
  22655. * The coefficient of restitution of the physics imposter
  22656. */
  22657. restitution?: number;
  22658. /**
  22659. * The native options of the physics imposter
  22660. */
  22661. nativeOptions?: any;
  22662. /**
  22663. * Specifies if the parent should be ignored
  22664. */
  22665. ignoreParent?: boolean;
  22666. /**
  22667. * Specifies if bi-directional transformations should be disabled
  22668. */
  22669. disableBidirectionalTransformation?: boolean;
  22670. /**
  22671. * The pressure inside the physics imposter, soft object only
  22672. */
  22673. pressure?: number;
  22674. /**
  22675. * The stiffness the physics imposter, soft object only
  22676. */
  22677. stiffness?: number;
  22678. /**
  22679. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22680. */
  22681. velocityIterations?: number;
  22682. /**
  22683. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22684. */
  22685. positionIterations?: number;
  22686. /**
  22687. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22688. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22689. * Add to fix multiple points
  22690. */
  22691. fixedPoints?: number;
  22692. /**
  22693. * The collision margin around a soft object
  22694. */
  22695. margin?: number;
  22696. /**
  22697. * The collision margin around a soft object
  22698. */
  22699. damping?: number;
  22700. /**
  22701. * The path for a rope based on an extrusion
  22702. */
  22703. path?: any;
  22704. /**
  22705. * The shape of an extrusion used for a rope based on an extrusion
  22706. */
  22707. shape?: any;
  22708. }
  22709. /**
  22710. * Interface for a physics-enabled object
  22711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22712. */
  22713. export interface IPhysicsEnabledObject {
  22714. /**
  22715. * The position of the physics-enabled object
  22716. */
  22717. position: Vector3;
  22718. /**
  22719. * The rotation of the physics-enabled object
  22720. */
  22721. rotationQuaternion: Nullable<Quaternion>;
  22722. /**
  22723. * The scale of the physics-enabled object
  22724. */
  22725. scaling: Vector3;
  22726. /**
  22727. * The rotation of the physics-enabled object
  22728. */
  22729. rotation?: Vector3;
  22730. /**
  22731. * The parent of the physics-enabled object
  22732. */
  22733. parent?: any;
  22734. /**
  22735. * The bounding info of the physics-enabled object
  22736. * @returns The bounding info of the physics-enabled object
  22737. */
  22738. getBoundingInfo(): BoundingInfo;
  22739. /**
  22740. * Computes the world matrix
  22741. * @param force Specifies if the world matrix should be computed by force
  22742. * @returns A world matrix
  22743. */
  22744. computeWorldMatrix(force: boolean): Matrix;
  22745. /**
  22746. * Gets the world matrix
  22747. * @returns A world matrix
  22748. */
  22749. getWorldMatrix?(): Matrix;
  22750. /**
  22751. * Gets the child meshes
  22752. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22753. * @returns An array of abstract meshes
  22754. */
  22755. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22756. /**
  22757. * Gets the vertex data
  22758. * @param kind The type of vertex data
  22759. * @returns A nullable array of numbers, or a float32 array
  22760. */
  22761. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22762. /**
  22763. * Gets the indices from the mesh
  22764. * @returns A nullable array of index arrays
  22765. */
  22766. getIndices?(): Nullable<IndicesArray>;
  22767. /**
  22768. * Gets the scene from the mesh
  22769. * @returns the indices array or null
  22770. */
  22771. getScene?(): Scene;
  22772. /**
  22773. * Gets the absolute position from the mesh
  22774. * @returns the absolute position
  22775. */
  22776. getAbsolutePosition(): Vector3;
  22777. /**
  22778. * Gets the absolute pivot point from the mesh
  22779. * @returns the absolute pivot point
  22780. */
  22781. getAbsolutePivotPoint(): Vector3;
  22782. /**
  22783. * Rotates the mesh
  22784. * @param axis The axis of rotation
  22785. * @param amount The amount of rotation
  22786. * @param space The space of the rotation
  22787. * @returns The rotation transform node
  22788. */
  22789. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22790. /**
  22791. * Translates the mesh
  22792. * @param axis The axis of translation
  22793. * @param distance The distance of translation
  22794. * @param space The space of the translation
  22795. * @returns The transform node
  22796. */
  22797. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22798. /**
  22799. * Sets the absolute position of the mesh
  22800. * @param absolutePosition The absolute position of the mesh
  22801. * @returns The transform node
  22802. */
  22803. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22804. /**
  22805. * Gets the class name of the mesh
  22806. * @returns The class name
  22807. */
  22808. getClassName(): string;
  22809. }
  22810. /**
  22811. * Represents a physics imposter
  22812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22813. */
  22814. export class PhysicsImpostor {
  22815. /**
  22816. * The physics-enabled object used as the physics imposter
  22817. */
  22818. object: IPhysicsEnabledObject;
  22819. /**
  22820. * The type of the physics imposter
  22821. */
  22822. type: number;
  22823. private _options;
  22824. private _scene?;
  22825. /**
  22826. * The default object size of the imposter
  22827. */
  22828. static DEFAULT_OBJECT_SIZE: Vector3;
  22829. /**
  22830. * The identity quaternion of the imposter
  22831. */
  22832. static IDENTITY_QUATERNION: Quaternion;
  22833. /** @hidden */
  22834. _pluginData: any;
  22835. private _physicsEngine;
  22836. private _physicsBody;
  22837. private _bodyUpdateRequired;
  22838. private _onBeforePhysicsStepCallbacks;
  22839. private _onAfterPhysicsStepCallbacks;
  22840. /** @hidden */
  22841. _onPhysicsCollideCallbacks: Array<{
  22842. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22843. otherImpostors: Array<PhysicsImpostor>;
  22844. }>;
  22845. private _deltaPosition;
  22846. private _deltaRotation;
  22847. private _deltaRotationConjugated;
  22848. /** @hidden */
  22849. _isFromLine: boolean;
  22850. private _parent;
  22851. private _isDisposed;
  22852. private static _tmpVecs;
  22853. private static _tmpQuat;
  22854. /**
  22855. * Specifies if the physics imposter is disposed
  22856. */
  22857. readonly isDisposed: boolean;
  22858. /**
  22859. * Gets the mass of the physics imposter
  22860. */
  22861. mass: number;
  22862. /**
  22863. * Gets the coefficient of friction
  22864. */
  22865. /**
  22866. * Sets the coefficient of friction
  22867. */
  22868. friction: number;
  22869. /**
  22870. * Gets the coefficient of restitution
  22871. */
  22872. /**
  22873. * Sets the coefficient of restitution
  22874. */
  22875. restitution: number;
  22876. /**
  22877. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22878. */
  22879. /**
  22880. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22881. */
  22882. pressure: number;
  22883. /**
  22884. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22885. */
  22886. /**
  22887. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22888. */
  22889. stiffness: number;
  22890. /**
  22891. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22892. */
  22893. /**
  22894. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22895. */
  22896. velocityIterations: number;
  22897. /**
  22898. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22899. */
  22900. /**
  22901. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22902. */
  22903. positionIterations: number;
  22904. /**
  22905. * The unique id of the physics imposter
  22906. * set by the physics engine when adding this impostor to the array
  22907. */
  22908. uniqueId: number;
  22909. /**
  22910. * @hidden
  22911. */
  22912. soft: boolean;
  22913. /**
  22914. * @hidden
  22915. */
  22916. segments: number;
  22917. private _joints;
  22918. /**
  22919. * Initializes the physics imposter
  22920. * @param object The physics-enabled object used as the physics imposter
  22921. * @param type The type of the physics imposter
  22922. * @param _options The options for the physics imposter
  22923. * @param _scene The Babylon scene
  22924. */
  22925. constructor(
  22926. /**
  22927. * The physics-enabled object used as the physics imposter
  22928. */
  22929. object: IPhysicsEnabledObject,
  22930. /**
  22931. * The type of the physics imposter
  22932. */
  22933. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22934. /**
  22935. * This function will completly initialize this impostor.
  22936. * It will create a new body - but only if this mesh has no parent.
  22937. * If it has, this impostor will not be used other than to define the impostor
  22938. * of the child mesh.
  22939. * @hidden
  22940. */
  22941. _init(): void;
  22942. private _getPhysicsParent;
  22943. /**
  22944. * Should a new body be generated.
  22945. * @returns boolean specifying if body initialization is required
  22946. */
  22947. isBodyInitRequired(): boolean;
  22948. /**
  22949. * Sets the updated scaling
  22950. * @param updated Specifies if the scaling is updated
  22951. */
  22952. setScalingUpdated(): void;
  22953. /**
  22954. * Force a regeneration of this or the parent's impostor's body.
  22955. * Use under cautious - This will remove all joints already implemented.
  22956. */
  22957. forceUpdate(): void;
  22958. /**
  22959. * Gets the body that holds this impostor. Either its own, or its parent.
  22960. */
  22961. /**
  22962. * Set the physics body. Used mainly by the physics engine/plugin
  22963. */
  22964. physicsBody: any;
  22965. /**
  22966. * Get the parent of the physics imposter
  22967. * @returns Physics imposter or null
  22968. */
  22969. /**
  22970. * Sets the parent of the physics imposter
  22971. */
  22972. parent: Nullable<PhysicsImpostor>;
  22973. /**
  22974. * Resets the update flags
  22975. */
  22976. resetUpdateFlags(): void;
  22977. /**
  22978. * Gets the object extend size
  22979. * @returns the object extend size
  22980. */
  22981. getObjectExtendSize(): Vector3;
  22982. /**
  22983. * Gets the object center
  22984. * @returns The object center
  22985. */
  22986. getObjectCenter(): Vector3;
  22987. /**
  22988. * Get a specific parametes from the options parameter
  22989. * @param paramName The object parameter name
  22990. * @returns The object parameter
  22991. */
  22992. getParam(paramName: string): any;
  22993. /**
  22994. * Sets a specific parameter in the options given to the physics plugin
  22995. * @param paramName The parameter name
  22996. * @param value The value of the parameter
  22997. */
  22998. setParam(paramName: string, value: number): void;
  22999. /**
  23000. * Specifically change the body's mass option. Won't recreate the physics body object
  23001. * @param mass The mass of the physics imposter
  23002. */
  23003. setMass(mass: number): void;
  23004. /**
  23005. * Gets the linear velocity
  23006. * @returns linear velocity or null
  23007. */
  23008. getLinearVelocity(): Nullable<Vector3>;
  23009. /**
  23010. * Sets the linear velocity
  23011. * @param velocity linear velocity or null
  23012. */
  23013. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23014. /**
  23015. * Gets the angular velocity
  23016. * @returns angular velocity or null
  23017. */
  23018. getAngularVelocity(): Nullable<Vector3>;
  23019. /**
  23020. * Sets the angular velocity
  23021. * @param velocity The velocity or null
  23022. */
  23023. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23024. /**
  23025. * Execute a function with the physics plugin native code
  23026. * Provide a function the will have two variables - the world object and the physics body object
  23027. * @param func The function to execute with the physics plugin native code
  23028. */
  23029. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23030. /**
  23031. * Register a function that will be executed before the physics world is stepping forward
  23032. * @param func The function to execute before the physics world is stepped forward
  23033. */
  23034. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23035. /**
  23036. * Unregister a function that will be executed before the physics world is stepping forward
  23037. * @param func The function to execute before the physics world is stepped forward
  23038. */
  23039. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23040. /**
  23041. * Register a function that will be executed after the physics step
  23042. * @param func The function to execute after physics step
  23043. */
  23044. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23045. /**
  23046. * Unregisters a function that will be executed after the physics step
  23047. * @param func The function to execute after physics step
  23048. */
  23049. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23050. /**
  23051. * register a function that will be executed when this impostor collides against a different body
  23052. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23053. * @param func Callback that is executed on collision
  23054. */
  23055. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23056. /**
  23057. * Unregisters the physics imposter on contact
  23058. * @param collideAgainst The physics object to collide against
  23059. * @param func Callback to execute on collision
  23060. */
  23061. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23062. private _tmpQuat;
  23063. private _tmpQuat2;
  23064. /**
  23065. * Get the parent rotation
  23066. * @returns The parent rotation
  23067. */
  23068. getParentsRotation(): Quaternion;
  23069. /**
  23070. * this function is executed by the physics engine.
  23071. */
  23072. beforeStep: () => void;
  23073. /**
  23074. * this function is executed by the physics engine
  23075. */
  23076. afterStep: () => void;
  23077. /**
  23078. * Legacy collision detection event support
  23079. */
  23080. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23081. /**
  23082. * event and body object due to cannon's event-based architecture.
  23083. */
  23084. onCollide: (e: {
  23085. body: any;
  23086. }) => void;
  23087. /**
  23088. * Apply a force
  23089. * @param force The force to apply
  23090. * @param contactPoint The contact point for the force
  23091. * @returns The physics imposter
  23092. */
  23093. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23094. /**
  23095. * Apply an impulse
  23096. * @param force The impulse force
  23097. * @param contactPoint The contact point for the impulse force
  23098. * @returns The physics imposter
  23099. */
  23100. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23101. /**
  23102. * A help function to create a joint
  23103. * @param otherImpostor A physics imposter used to create a joint
  23104. * @param jointType The type of joint
  23105. * @param jointData The data for the joint
  23106. * @returns The physics imposter
  23107. */
  23108. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23109. /**
  23110. * Add a joint to this impostor with a different impostor
  23111. * @param otherImpostor A physics imposter used to add a joint
  23112. * @param joint The joint to add
  23113. * @returns The physics imposter
  23114. */
  23115. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23116. /**
  23117. * Add an anchor to a cloth impostor
  23118. * @param otherImpostor rigid impostor to anchor to
  23119. * @param width ratio across width from 0 to 1
  23120. * @param height ratio up height from 0 to 1
  23121. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23122. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23123. * @returns impostor the soft imposter
  23124. */
  23125. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23126. /**
  23127. * Add a hook to a rope impostor
  23128. * @param otherImpostor rigid impostor to anchor to
  23129. * @param length ratio across rope from 0 to 1
  23130. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23131. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23132. * @returns impostor the rope imposter
  23133. */
  23134. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23135. /**
  23136. * Will keep this body still, in a sleep mode.
  23137. * @returns the physics imposter
  23138. */
  23139. sleep(): PhysicsImpostor;
  23140. /**
  23141. * Wake the body up.
  23142. * @returns The physics imposter
  23143. */
  23144. wakeUp(): PhysicsImpostor;
  23145. /**
  23146. * Clones the physics imposter
  23147. * @param newObject The physics imposter clones to this physics-enabled object
  23148. * @returns A nullable physics imposter
  23149. */
  23150. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23151. /**
  23152. * Disposes the physics imposter
  23153. */
  23154. dispose(): void;
  23155. /**
  23156. * Sets the delta position
  23157. * @param position The delta position amount
  23158. */
  23159. setDeltaPosition(position: Vector3): void;
  23160. /**
  23161. * Sets the delta rotation
  23162. * @param rotation The delta rotation amount
  23163. */
  23164. setDeltaRotation(rotation: Quaternion): void;
  23165. /**
  23166. * Gets the box size of the physics imposter and stores the result in the input parameter
  23167. * @param result Stores the box size
  23168. * @returns The physics imposter
  23169. */
  23170. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23171. /**
  23172. * Gets the radius of the physics imposter
  23173. * @returns Radius of the physics imposter
  23174. */
  23175. getRadius(): number;
  23176. /**
  23177. * Sync a bone with this impostor
  23178. * @param bone The bone to sync to the impostor.
  23179. * @param boneMesh The mesh that the bone is influencing.
  23180. * @param jointPivot The pivot of the joint / bone in local space.
  23181. * @param distToJoint Optional distance from the impostor to the joint.
  23182. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23183. */
  23184. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23185. /**
  23186. * Sync impostor to a bone
  23187. * @param bone The bone that the impostor will be synced to.
  23188. * @param boneMesh The mesh that the bone is influencing.
  23189. * @param jointPivot The pivot of the joint / bone in local space.
  23190. * @param distToJoint Optional distance from the impostor to the joint.
  23191. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23192. * @param boneAxis Optional vector3 axis the bone is aligned with
  23193. */
  23194. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23195. /**
  23196. * No-Imposter type
  23197. */
  23198. static NoImpostor: number;
  23199. /**
  23200. * Sphere-Imposter type
  23201. */
  23202. static SphereImpostor: number;
  23203. /**
  23204. * Box-Imposter type
  23205. */
  23206. static BoxImpostor: number;
  23207. /**
  23208. * Plane-Imposter type
  23209. */
  23210. static PlaneImpostor: number;
  23211. /**
  23212. * Mesh-imposter type
  23213. */
  23214. static MeshImpostor: number;
  23215. /**
  23216. * Capsule-Impostor type (Ammo.js plugin only)
  23217. */
  23218. static CapsuleImpostor: number;
  23219. /**
  23220. * Cylinder-Imposter type
  23221. */
  23222. static CylinderImpostor: number;
  23223. /**
  23224. * Particle-Imposter type
  23225. */
  23226. static ParticleImpostor: number;
  23227. /**
  23228. * Heightmap-Imposter type
  23229. */
  23230. static HeightmapImpostor: number;
  23231. /**
  23232. * ConvexHull-Impostor type (Ammo.js plugin only)
  23233. */
  23234. static ConvexHullImpostor: number;
  23235. /**
  23236. * Rope-Imposter type
  23237. */
  23238. static RopeImpostor: number;
  23239. /**
  23240. * Cloth-Imposter type
  23241. */
  23242. static ClothImpostor: number;
  23243. /**
  23244. * Softbody-Imposter type
  23245. */
  23246. static SoftbodyImpostor: number;
  23247. }
  23248. }
  23249. declare module BABYLON {
  23250. /**
  23251. * @hidden
  23252. **/
  23253. export class _CreationDataStorage {
  23254. closePath?: boolean;
  23255. closeArray?: boolean;
  23256. idx: number[];
  23257. dashSize: number;
  23258. gapSize: number;
  23259. path3D: Path3D;
  23260. pathArray: Vector3[][];
  23261. arc: number;
  23262. radius: number;
  23263. cap: number;
  23264. tessellation: number;
  23265. }
  23266. /**
  23267. * @hidden
  23268. **/
  23269. class _InstanceDataStorage {
  23270. visibleInstances: any;
  23271. batchCache: _InstancesBatch;
  23272. instancesBufferSize: number;
  23273. instancesBuffer: Nullable<Buffer>;
  23274. instancesData: Float32Array;
  23275. overridenInstanceCount: number;
  23276. isFrozen: boolean;
  23277. previousBatch: Nullable<_InstancesBatch>;
  23278. hardwareInstancedRendering: boolean;
  23279. sideOrientation: number;
  23280. }
  23281. /**
  23282. * @hidden
  23283. **/
  23284. export class _InstancesBatch {
  23285. mustReturn: boolean;
  23286. visibleInstances: Nullable<InstancedMesh[]>[];
  23287. renderSelf: boolean[];
  23288. hardwareInstancedRendering: boolean[];
  23289. }
  23290. /**
  23291. * Class used to represent renderable models
  23292. */
  23293. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23294. /**
  23295. * Mesh side orientation : usually the external or front surface
  23296. */
  23297. static readonly FRONTSIDE: number;
  23298. /**
  23299. * Mesh side orientation : usually the internal or back surface
  23300. */
  23301. static readonly BACKSIDE: number;
  23302. /**
  23303. * Mesh side orientation : both internal and external or front and back surfaces
  23304. */
  23305. static readonly DOUBLESIDE: number;
  23306. /**
  23307. * Mesh side orientation : by default, `FRONTSIDE`
  23308. */
  23309. static readonly DEFAULTSIDE: number;
  23310. /**
  23311. * Mesh cap setting : no cap
  23312. */
  23313. static readonly NO_CAP: number;
  23314. /**
  23315. * Mesh cap setting : one cap at the beginning of the mesh
  23316. */
  23317. static readonly CAP_START: number;
  23318. /**
  23319. * Mesh cap setting : one cap at the end of the mesh
  23320. */
  23321. static readonly CAP_END: number;
  23322. /**
  23323. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23324. */
  23325. static readonly CAP_ALL: number;
  23326. /**
  23327. * Mesh pattern setting : no flip or rotate
  23328. */
  23329. static readonly NO_FLIP: number;
  23330. /**
  23331. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23332. */
  23333. static readonly FLIP_TILE: number;
  23334. /**
  23335. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23336. */
  23337. static readonly ROTATE_TILE: number;
  23338. /**
  23339. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23340. */
  23341. static readonly FLIP_ROW: number;
  23342. /**
  23343. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23344. */
  23345. static readonly ROTATE_ROW: number;
  23346. /**
  23347. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23348. */
  23349. static readonly FLIP_N_ROTATE_TILE: number;
  23350. /**
  23351. * Mesh pattern setting : rotate pattern and rotate
  23352. */
  23353. static readonly FLIP_N_ROTATE_ROW: number;
  23354. /**
  23355. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23356. */
  23357. static readonly CENTER: number;
  23358. /**
  23359. * Mesh tile positioning : part tiles on left
  23360. */
  23361. static readonly LEFT: number;
  23362. /**
  23363. * Mesh tile positioning : part tiles on right
  23364. */
  23365. static readonly RIGHT: number;
  23366. /**
  23367. * Mesh tile positioning : part tiles on top
  23368. */
  23369. static readonly TOP: number;
  23370. /**
  23371. * Mesh tile positioning : part tiles on bottom
  23372. */
  23373. static readonly BOTTOM: number;
  23374. /**
  23375. * Gets the default side orientation.
  23376. * @param orientation the orientation to value to attempt to get
  23377. * @returns the default orientation
  23378. * @hidden
  23379. */
  23380. static _GetDefaultSideOrientation(orientation?: number): number;
  23381. private _internalMeshDataInfo;
  23382. /**
  23383. * An event triggered before rendering the mesh
  23384. */
  23385. readonly onBeforeRenderObservable: Observable<Mesh>;
  23386. /**
  23387. * An event triggered before binding the mesh
  23388. */
  23389. readonly onBeforeBindObservable: Observable<Mesh>;
  23390. /**
  23391. * An event triggered after rendering the mesh
  23392. */
  23393. readonly onAfterRenderObservable: Observable<Mesh>;
  23394. /**
  23395. * An event triggered before drawing the mesh
  23396. */
  23397. readonly onBeforeDrawObservable: Observable<Mesh>;
  23398. private _onBeforeDrawObserver;
  23399. /**
  23400. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23401. */
  23402. onBeforeDraw: () => void;
  23403. readonly hasInstances: boolean;
  23404. /**
  23405. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23406. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23407. */
  23408. delayLoadState: number;
  23409. /**
  23410. * Gets the list of instances created from this mesh
  23411. * it is not supposed to be modified manually.
  23412. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23413. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23414. */
  23415. instances: InstancedMesh[];
  23416. /**
  23417. * Gets the file containing delay loading data for this mesh
  23418. */
  23419. delayLoadingFile: string;
  23420. /** @hidden */
  23421. _binaryInfo: any;
  23422. /**
  23423. * User defined function used to change how LOD level selection is done
  23424. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23425. */
  23426. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23427. /**
  23428. * Gets or sets the morph target manager
  23429. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23430. */
  23431. morphTargetManager: Nullable<MorphTargetManager>;
  23432. /** @hidden */
  23433. _creationDataStorage: Nullable<_CreationDataStorage>;
  23434. /** @hidden */
  23435. _geometry: Nullable<Geometry>;
  23436. /** @hidden */
  23437. _delayInfo: Array<string>;
  23438. /** @hidden */
  23439. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23440. /** @hidden */
  23441. _instanceDataStorage: _InstanceDataStorage;
  23442. private _effectiveMaterial;
  23443. /** @hidden */
  23444. _shouldGenerateFlatShading: boolean;
  23445. /** @hidden */
  23446. _originalBuilderSideOrientation: number;
  23447. /**
  23448. * Use this property to change the original side orientation defined at construction time
  23449. */
  23450. overrideMaterialSideOrientation: Nullable<number>;
  23451. /**
  23452. * Gets the source mesh (the one used to clone this one from)
  23453. */
  23454. readonly source: Nullable<Mesh>;
  23455. /**
  23456. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23457. */
  23458. isUnIndexed: boolean;
  23459. /**
  23460. * @constructor
  23461. * @param name The value used by scene.getMeshByName() to do a lookup.
  23462. * @param scene The scene to add this mesh to.
  23463. * @param parent The parent of this mesh, if it has one
  23464. * @param source An optional Mesh from which geometry is shared, cloned.
  23465. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23466. * When false, achieved by calling a clone(), also passing False.
  23467. * This will make creation of children, recursive.
  23468. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23469. */
  23470. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23471. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23472. /**
  23473. * Gets the class name
  23474. * @returns the string "Mesh".
  23475. */
  23476. getClassName(): string;
  23477. /** @hidden */
  23478. readonly _isMesh: boolean;
  23479. /**
  23480. * Returns a description of this mesh
  23481. * @param fullDetails define if full details about this mesh must be used
  23482. * @returns a descriptive string representing this mesh
  23483. */
  23484. toString(fullDetails?: boolean): string;
  23485. /** @hidden */
  23486. _unBindEffect(): void;
  23487. /**
  23488. * Gets a boolean indicating if this mesh has LOD
  23489. */
  23490. readonly hasLODLevels: boolean;
  23491. /**
  23492. * Gets the list of MeshLODLevel associated with the current mesh
  23493. * @returns an array of MeshLODLevel
  23494. */
  23495. getLODLevels(): MeshLODLevel[];
  23496. private _sortLODLevels;
  23497. /**
  23498. * Add a mesh as LOD level triggered at the given distance.
  23499. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23500. * @param distance The distance from the center of the object to show this level
  23501. * @param mesh The mesh to be added as LOD level (can be null)
  23502. * @return This mesh (for chaining)
  23503. */
  23504. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23505. /**
  23506. * Returns the LOD level mesh at the passed distance or null if not found.
  23507. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23508. * @param distance The distance from the center of the object to show this level
  23509. * @returns a Mesh or `null`
  23510. */
  23511. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23512. /**
  23513. * Remove a mesh from the LOD array
  23514. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23515. * @param mesh defines the mesh to be removed
  23516. * @return This mesh (for chaining)
  23517. */
  23518. removeLODLevel(mesh: Mesh): Mesh;
  23519. /**
  23520. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23521. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23522. * @param camera defines the camera to use to compute distance
  23523. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23524. * @return This mesh (for chaining)
  23525. */
  23526. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23527. /**
  23528. * Gets the mesh internal Geometry object
  23529. */
  23530. readonly geometry: Nullable<Geometry>;
  23531. /**
  23532. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23533. * @returns the total number of vertices
  23534. */
  23535. getTotalVertices(): number;
  23536. /**
  23537. * Returns the content of an associated vertex buffer
  23538. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23539. * - VertexBuffer.PositionKind
  23540. * - VertexBuffer.UVKind
  23541. * - VertexBuffer.UV2Kind
  23542. * - VertexBuffer.UV3Kind
  23543. * - VertexBuffer.UV4Kind
  23544. * - VertexBuffer.UV5Kind
  23545. * - VertexBuffer.UV6Kind
  23546. * - VertexBuffer.ColorKind
  23547. * - VertexBuffer.MatricesIndicesKind
  23548. * - VertexBuffer.MatricesIndicesExtraKind
  23549. * - VertexBuffer.MatricesWeightsKind
  23550. * - VertexBuffer.MatricesWeightsExtraKind
  23551. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  23552. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23553. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23554. */
  23555. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23556. /**
  23557. * Returns the mesh VertexBuffer object from the requested `kind`
  23558. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23559. * - VertexBuffer.PositionKind
  23560. * - VertexBuffer.NormalKind
  23561. * - VertexBuffer.UVKind
  23562. * - VertexBuffer.UV2Kind
  23563. * - VertexBuffer.UV3Kind
  23564. * - VertexBuffer.UV4Kind
  23565. * - VertexBuffer.UV5Kind
  23566. * - VertexBuffer.UV6Kind
  23567. * - VertexBuffer.ColorKind
  23568. * - VertexBuffer.MatricesIndicesKind
  23569. * - VertexBuffer.MatricesIndicesExtraKind
  23570. * - VertexBuffer.MatricesWeightsKind
  23571. * - VertexBuffer.MatricesWeightsExtraKind
  23572. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23573. */
  23574. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23575. /**
  23576. * Tests if a specific vertex buffer is associated with this mesh
  23577. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23578. * - VertexBuffer.PositionKind
  23579. * - VertexBuffer.NormalKind
  23580. * - VertexBuffer.UVKind
  23581. * - VertexBuffer.UV2Kind
  23582. * - VertexBuffer.UV3Kind
  23583. * - VertexBuffer.UV4Kind
  23584. * - VertexBuffer.UV5Kind
  23585. * - VertexBuffer.UV6Kind
  23586. * - VertexBuffer.ColorKind
  23587. * - VertexBuffer.MatricesIndicesKind
  23588. * - VertexBuffer.MatricesIndicesExtraKind
  23589. * - VertexBuffer.MatricesWeightsKind
  23590. * - VertexBuffer.MatricesWeightsExtraKind
  23591. * @returns a boolean
  23592. */
  23593. isVerticesDataPresent(kind: string): boolean;
  23594. /**
  23595. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23596. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23597. * - VertexBuffer.PositionKind
  23598. * - VertexBuffer.UVKind
  23599. * - VertexBuffer.UV2Kind
  23600. * - VertexBuffer.UV3Kind
  23601. * - VertexBuffer.UV4Kind
  23602. * - VertexBuffer.UV5Kind
  23603. * - VertexBuffer.UV6Kind
  23604. * - VertexBuffer.ColorKind
  23605. * - VertexBuffer.MatricesIndicesKind
  23606. * - VertexBuffer.MatricesIndicesExtraKind
  23607. * - VertexBuffer.MatricesWeightsKind
  23608. * - VertexBuffer.MatricesWeightsExtraKind
  23609. * @returns a boolean
  23610. */
  23611. isVertexBufferUpdatable(kind: string): boolean;
  23612. /**
  23613. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23614. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23615. * - VertexBuffer.PositionKind
  23616. * - VertexBuffer.NormalKind
  23617. * - VertexBuffer.UVKind
  23618. * - VertexBuffer.UV2Kind
  23619. * - VertexBuffer.UV3Kind
  23620. * - VertexBuffer.UV4Kind
  23621. * - VertexBuffer.UV5Kind
  23622. * - VertexBuffer.UV6Kind
  23623. * - VertexBuffer.ColorKind
  23624. * - VertexBuffer.MatricesIndicesKind
  23625. * - VertexBuffer.MatricesIndicesExtraKind
  23626. * - VertexBuffer.MatricesWeightsKind
  23627. * - VertexBuffer.MatricesWeightsExtraKind
  23628. * @returns an array of strings
  23629. */
  23630. getVerticesDataKinds(): string[];
  23631. /**
  23632. * Returns a positive integer : the total number of indices in this mesh geometry.
  23633. * @returns the numner of indices or zero if the mesh has no geometry.
  23634. */
  23635. getTotalIndices(): number;
  23636. /**
  23637. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23638. * @param copyWhenShared If 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.
  23639. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23640. * @returns the indices array or an empty array if the mesh has no geometry
  23641. */
  23642. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23643. readonly isBlocked: boolean;
  23644. /**
  23645. * Determine if the current mesh is ready to be rendered
  23646. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23647. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23648. * @returns true if all associated assets are ready (material, textures, shaders)
  23649. */
  23650. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23651. /**
  23652. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  23653. */
  23654. readonly areNormalsFrozen: boolean;
  23655. /**
  23656. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  23657. * @returns the current mesh
  23658. */
  23659. freezeNormals(): Mesh;
  23660. /**
  23661. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  23662. * @returns the current mesh
  23663. */
  23664. unfreezeNormals(): Mesh;
  23665. /**
  23666. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23667. */
  23668. overridenInstanceCount: number;
  23669. /** @hidden */
  23670. _preActivate(): Mesh;
  23671. /** @hidden */
  23672. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23673. /** @hidden */
  23674. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23675. /**
  23676. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23677. * This means the mesh underlying bounding box and sphere are recomputed.
  23678. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23679. * @returns the current mesh
  23680. */
  23681. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23682. /** @hidden */
  23683. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23684. /**
  23685. * This function will subdivide the mesh into multiple submeshes
  23686. * @param count defines the expected number of submeshes
  23687. */
  23688. subdivide(count: number): void;
  23689. /**
  23690. * Copy a FloatArray into a specific associated vertex buffer
  23691. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23692. * - VertexBuffer.PositionKind
  23693. * - VertexBuffer.UVKind
  23694. * - VertexBuffer.UV2Kind
  23695. * - VertexBuffer.UV3Kind
  23696. * - VertexBuffer.UV4Kind
  23697. * - VertexBuffer.UV5Kind
  23698. * - VertexBuffer.UV6Kind
  23699. * - VertexBuffer.ColorKind
  23700. * - VertexBuffer.MatricesIndicesKind
  23701. * - VertexBuffer.MatricesIndicesExtraKind
  23702. * - VertexBuffer.MatricesWeightsKind
  23703. * - VertexBuffer.MatricesWeightsExtraKind
  23704. * @param data defines the data source
  23705. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23706. * @param stride defines the data stride size (can be null)
  23707. * @returns the current mesh
  23708. */
  23709. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23710. /**
  23711. * Flags an associated vertex buffer as updatable
  23712. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23713. * - VertexBuffer.PositionKind
  23714. * - VertexBuffer.UVKind
  23715. * - VertexBuffer.UV2Kind
  23716. * - VertexBuffer.UV3Kind
  23717. * - VertexBuffer.UV4Kind
  23718. * - VertexBuffer.UV5Kind
  23719. * - VertexBuffer.UV6Kind
  23720. * - VertexBuffer.ColorKind
  23721. * - VertexBuffer.MatricesIndicesKind
  23722. * - VertexBuffer.MatricesIndicesExtraKind
  23723. * - VertexBuffer.MatricesWeightsKind
  23724. * - VertexBuffer.MatricesWeightsExtraKind
  23725. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23726. */
  23727. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23728. /**
  23729. * Sets the mesh global Vertex Buffer
  23730. * @param buffer defines the buffer to use
  23731. * @returns the current mesh
  23732. */
  23733. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23734. /**
  23735. * Update a specific associated vertex buffer
  23736. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23737. * - VertexBuffer.PositionKind
  23738. * - VertexBuffer.UVKind
  23739. * - VertexBuffer.UV2Kind
  23740. * - VertexBuffer.UV3Kind
  23741. * - VertexBuffer.UV4Kind
  23742. * - VertexBuffer.UV5Kind
  23743. * - VertexBuffer.UV6Kind
  23744. * - VertexBuffer.ColorKind
  23745. * - VertexBuffer.MatricesIndicesKind
  23746. * - VertexBuffer.MatricesIndicesExtraKind
  23747. * - VertexBuffer.MatricesWeightsKind
  23748. * - VertexBuffer.MatricesWeightsExtraKind
  23749. * @param data defines the data source
  23750. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23751. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  23752. * @returns the current mesh
  23753. */
  23754. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23755. /**
  23756. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23757. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23758. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23759. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23760. * @returns the current mesh
  23761. */
  23762. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23763. /**
  23764. * Creates a un-shared specific occurence of the geometry for the mesh.
  23765. * @returns the current mesh
  23766. */
  23767. makeGeometryUnique(): Mesh;
  23768. /**
  23769. * Set the index buffer of this mesh
  23770. * @param indices defines the source data
  23771. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23772. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23773. * @returns the current mesh
  23774. */
  23775. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23776. /**
  23777. * Update the current index buffer
  23778. * @param indices defines the source data
  23779. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23780. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  23781. * @returns the current mesh
  23782. */
  23783. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23784. /**
  23785. * Invert the geometry to move from a right handed system to a left handed one.
  23786. * @returns the current mesh
  23787. */
  23788. toLeftHanded(): Mesh;
  23789. /** @hidden */
  23790. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23791. /** @hidden */
  23792. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23793. /**
  23794. * Registers for this mesh a javascript function called just before the rendering process
  23795. * @param func defines the function to call before rendering this mesh
  23796. * @returns the current mesh
  23797. */
  23798. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23799. /**
  23800. * Disposes a previously registered javascript function called before the rendering
  23801. * @param func defines the function to remove
  23802. * @returns the current mesh
  23803. */
  23804. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23805. /**
  23806. * Registers for this mesh a javascript function called just after the rendering is complete
  23807. * @param func defines the function to call after rendering this mesh
  23808. * @returns the current mesh
  23809. */
  23810. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23811. /**
  23812. * Disposes a previously registered javascript function called after the rendering.
  23813. * @param func defines the function to remove
  23814. * @returns the current mesh
  23815. */
  23816. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23817. /** @hidden */
  23818. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23819. /** @hidden */
  23820. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23821. /** @hidden */
  23822. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23823. /** @hidden */
  23824. _rebuild(): void;
  23825. /** @hidden */
  23826. _freeze(): void;
  23827. /** @hidden */
  23828. _unFreeze(): void;
  23829. /**
  23830. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  23831. * @param subMesh defines the subMesh to render
  23832. * @param enableAlphaMode defines if alpha mode can be changed
  23833. * @returns the current mesh
  23834. */
  23835. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23836. private _onBeforeDraw;
  23837. /**
  23838. * Renormalize the mesh and patch it up if there are no weights
  23839. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23840. * However in the case of zero weights then we set just a single influence to 1.
  23841. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23842. */
  23843. cleanMatrixWeights(): void;
  23844. private normalizeSkinFourWeights;
  23845. private normalizeSkinWeightsAndExtra;
  23846. /**
  23847. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23848. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23849. * the user know there was an issue with importing the mesh
  23850. * @returns a validation object with skinned, valid and report string
  23851. */
  23852. validateSkinning(): {
  23853. skinned: boolean;
  23854. valid: boolean;
  23855. report: string;
  23856. };
  23857. /** @hidden */
  23858. _checkDelayState(): Mesh;
  23859. private _queueLoad;
  23860. /**
  23861. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23862. * A mesh is in the frustum if its bounding box intersects the frustum
  23863. * @param frustumPlanes defines the frustum to test
  23864. * @returns true if the mesh is in the frustum planes
  23865. */
  23866. isInFrustum(frustumPlanes: Plane[]): boolean;
  23867. /**
  23868. * Sets the mesh material by the material or multiMaterial `id` property
  23869. * @param id is a string identifying the material or the multiMaterial
  23870. * @returns the current mesh
  23871. */
  23872. setMaterialByID(id: string): Mesh;
  23873. /**
  23874. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23875. * @returns an array of IAnimatable
  23876. */
  23877. getAnimatables(): IAnimatable[];
  23878. /**
  23879. * Modifies the mesh geometry according to the passed transformation matrix.
  23880. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23881. * The mesh normals are modified using the same transformation.
  23882. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23883. * @param transform defines the transform matrix to use
  23884. * @see http://doc.babylonjs.com/resources/baking_transformations
  23885. * @returns the current mesh
  23886. */
  23887. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23888. /**
  23889. * Modifies the mesh geometry according to its own current World Matrix.
  23890. * The mesh World Matrix is then reset.
  23891. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23892. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23893. * @see http://doc.babylonjs.com/resources/baking_transformations
  23894. * @returns the current mesh
  23895. */
  23896. bakeCurrentTransformIntoVertices(): Mesh;
  23897. /** @hidden */
  23898. readonly _positions: Nullable<Vector3[]>;
  23899. /** @hidden */
  23900. _resetPointsArrayCache(): Mesh;
  23901. /** @hidden */
  23902. _generatePointsArray(): boolean;
  23903. /**
  23904. * Returns a new Mesh object generated from the current mesh properties.
  23905. * This method must not get confused with createInstance()
  23906. * @param name is a string, the name given to the new mesh
  23907. * @param newParent can be any Node object (default `null`)
  23908. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23909. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23910. * @returns a new mesh
  23911. */
  23912. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23913. /**
  23914. * Releases resources associated with this mesh.
  23915. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23916. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23917. */
  23918. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23919. /**
  23920. * Modifies the mesh geometry according to a displacement map.
  23921. * 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.
  23922. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23923. * @param url is a string, the URL from the image file is to be downloaded.
  23924. * @param minHeight is the lower limit of the displacement.
  23925. * @param maxHeight is the upper limit of the displacement.
  23926. * @param 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.
  23927. * @param uvOffset is an optional vector2 used to offset UV.
  23928. * @param uvScale is an optional vector2 used to scale UV.
  23929. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  23930. * @returns the Mesh.
  23931. */
  23932. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23933. /**
  23934. * Modifies the mesh geometry according to a displacementMap buffer.
  23935. * 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.
  23936. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23937. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23938. * @param heightMapWidth is the width of the buffer image.
  23939. * @param heightMapHeight is the height of the buffer image.
  23940. * @param minHeight is the lower limit of the displacement.
  23941. * @param maxHeight is the upper limit of the displacement.
  23942. * @param 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.
  23943. * @param uvOffset is an optional vector2 used to offset UV.
  23944. * @param uvScale is an optional vector2 used to scale UV.
  23945. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  23946. * @returns the Mesh.
  23947. */
  23948. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23949. /**
  23950. * Modify the mesh to get a flat shading rendering.
  23951. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23952. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23953. * @returns current mesh
  23954. */
  23955. convertToFlatShadedMesh(): Mesh;
  23956. /**
  23957. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23958. * In other words, more vertices, no more indices and a single bigger VBO.
  23959. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23960. * @returns current mesh
  23961. */
  23962. convertToUnIndexedMesh(): Mesh;
  23963. /**
  23964. * Inverses facet orientations.
  23965. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23966. * @param flipNormals will also inverts the normals
  23967. * @returns current mesh
  23968. */
  23969. flipFaces(flipNormals?: boolean): Mesh;
  23970. /**
  23971. * Increase the number of facets and hence vertices in a mesh
  23972. * Vertex normals are interpolated from existing vertex normals
  23973. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23974. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23975. */
  23976. increaseVertices(numberPerEdge: number): void;
  23977. /**
  23978. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23979. * This will undo any application of covertToFlatShadedMesh
  23980. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23981. */
  23982. forceSharedVertices(): void;
  23983. /** @hidden */
  23984. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23985. /** @hidden */
  23986. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23987. /**
  23988. * Creates a new InstancedMesh object from the mesh model.
  23989. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23990. * @param name defines the name of the new instance
  23991. * @returns a new InstancedMesh
  23992. */
  23993. createInstance(name: string): InstancedMesh;
  23994. /**
  23995. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23996. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23997. * @returns the current mesh
  23998. */
  23999. synchronizeInstances(): Mesh;
  24000. /**
  24001. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24002. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24003. * This should be used together with the simplification to avoid disappearing triangles.
  24004. * @param successCallback an optional success callback to be called after the optimization finished.
  24005. * @returns the current mesh
  24006. */
  24007. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24008. /**
  24009. * Serialize current mesh
  24010. * @param serializationObject defines the object which will receive the serialization data
  24011. */
  24012. serialize(serializationObject: any): void;
  24013. /** @hidden */
  24014. _syncGeometryWithMorphTargetManager(): void;
  24015. /** @hidden */
  24016. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24017. /**
  24018. * Returns a new Mesh object parsed from the source provided.
  24019. * @param parsedMesh is the source
  24020. * @param scene defines the hosting scene
  24021. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24022. * @returns a new Mesh
  24023. */
  24024. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24025. /**
  24026. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24027. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24028. * @param name defines the name of the mesh to create
  24029. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24030. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24031. * @param closePath creates a seam between the first and the last points of each path of the path array
  24032. * @param offset is taken in account only if the `pathArray` is containing a single path
  24033. * @param scene defines the hosting scene
  24034. * @param updatable defines if the mesh must be flagged as updatable
  24035. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24036. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  24037. * @returns a new Mesh
  24038. */
  24039. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24040. /**
  24041. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24042. * @param name defines the name of the mesh to create
  24043. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24044. * @param 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
  24045. * @param scene defines the hosting scene
  24046. * @param updatable defines if the mesh must be flagged as updatable
  24047. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24048. * @returns a new Mesh
  24049. */
  24050. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24051. /**
  24052. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24053. * @param name defines the name of the mesh to create
  24054. * @param size sets the size (float) of each box side (default 1)
  24055. * @param scene defines the hosting scene
  24056. * @param updatable defines if the mesh must be flagged as updatable
  24057. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24058. * @returns a new Mesh
  24059. */
  24060. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24061. /**
  24062. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24063. * @param name defines the name of the mesh to create
  24064. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24065. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24066. * @param scene defines the hosting scene
  24067. * @param updatable defines if the mesh must be flagged as updatable
  24068. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24069. * @returns a new Mesh
  24070. */
  24071. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24072. /**
  24073. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24074. * @param name defines the name of the mesh to create
  24075. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24076. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24077. * @param scene defines the hosting scene
  24078. * @returns a new Mesh
  24079. */
  24080. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24081. /**
  24082. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24083. * @param name defines the name of the mesh to create
  24084. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24085. * @param diameterTop set the top cap diameter (floats, default 1)
  24086. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24087. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24088. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24089. * @param scene defines the hosting scene
  24090. * @param updatable defines if the mesh must be flagged as updatable
  24091. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24092. * @returns a new Mesh
  24093. */
  24094. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24095. /**
  24096. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24097. * @param name defines the name of the mesh to create
  24098. * @param diameter sets the diameter size (float) of the torus (default 1)
  24099. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24100. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24101. * @param scene defines the hosting scene
  24102. * @param updatable defines if the mesh must be flagged as updatable
  24103. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24104. * @returns a new Mesh
  24105. */
  24106. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24107. /**
  24108. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24109. * @param name defines the name of the mesh to create
  24110. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24111. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24112. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24113. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24114. * @param p the number of windings on X axis (positive integers, default 2)
  24115. * @param q the number of windings on Y axis (positive integers, default 3)
  24116. * @param scene defines the hosting scene
  24117. * @param updatable defines if the mesh must be flagged as updatable
  24118. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24119. * @returns a new Mesh
  24120. */
  24121. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24122. /**
  24123. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24124. * @param name defines the name of the mesh to create
  24125. * @param points is an array successive Vector3
  24126. * @param scene defines the hosting scene
  24127. * @param updatable defines if the mesh must be flagged as updatable
  24128. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  24129. * @returns a new Mesh
  24130. */
  24131. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24132. /**
  24133. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24134. * @param name defines the name of the mesh to create
  24135. * @param points is an array successive Vector3
  24136. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24137. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24138. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24139. * @param scene defines the hosting scene
  24140. * @param updatable defines if the mesh must be flagged as updatable
  24141. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  24142. * @returns a new Mesh
  24143. */
  24144. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24145. /**
  24146. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24147. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24148. * 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.
  24149. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24150. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24151. * Remember you can only change the shape positions, not their number when updating a polygon.
  24152. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24153. * @param name defines the name of the mesh to create
  24154. * @param 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
  24155. * @param scene defines the hosting scene
  24156. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24157. * @param updatable defines if the mesh must be flagged as updatable
  24158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24159. * @param earcutInjection can be used to inject your own earcut reference
  24160. * @returns a new Mesh
  24161. */
  24162. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24163. /**
  24164. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24165. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24166. * @param name defines the name of the mesh to create
  24167. * @param 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
  24168. * @param depth defines the height of extrusion
  24169. * @param scene defines the hosting scene
  24170. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24171. * @param updatable defines if the mesh must be flagged as updatable
  24172. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24173. * @param earcutInjection can be used to inject your own earcut reference
  24174. * @returns a new Mesh
  24175. */
  24176. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24177. /**
  24178. * Creates an extruded shape mesh.
  24179. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  24180. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24181. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24182. * @param name defines the name of the mesh to create
  24183. * @param 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 extruded along the Z axis
  24184. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24185. * @param scale is the value to scale the shape
  24186. * @param rotation 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
  24187. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24188. * @param scene defines the hosting scene
  24189. * @param updatable defines if the mesh must be flagged as updatable
  24190. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24191. * @param 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/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  24192. * @returns a new Mesh
  24193. */
  24194. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24195. /**
  24196. * Creates an custom extruded shape mesh.
  24197. * The custom extrusion is a parametric shape.
  24198. * It has no predefined shape. Its final shape will depend on the input parameters.
  24199. * Please consider using the same method from the MeshBuilder class instead
  24200. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24201. * @param name defines the name of the mesh to create
  24202. * @param 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 extruded along the Z axis
  24203. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24204. * @param scaleFunction is a custom Javascript function called on each path point
  24205. * @param rotationFunction is a custom Javascript function called on each path point
  24206. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24207. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24208. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24209. * @param scene defines the hosting scene
  24210. * @param updatable defines if the mesh must be flagged as updatable
  24211. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24212. * @param 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/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  24213. * @returns a new Mesh
  24214. */
  24215. 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;
  24216. /**
  24217. * Creates lathe mesh.
  24218. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24219. * Please consider using the same method from the MeshBuilder class instead
  24220. * @param name defines the name of the mesh to create
  24221. * @param 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 rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  24222. * @param radius is the radius value of the lathe
  24223. * @param tessellation is the side number of the lathe.
  24224. * @param scene defines the hosting scene
  24225. * @param updatable defines if the mesh must be flagged as updatable
  24226. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24227. * @returns a new Mesh
  24228. */
  24229. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24230. /**
  24231. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24232. * @param name defines the name of the mesh to create
  24233. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24234. * @param scene defines the hosting scene
  24235. * @param updatable defines if the mesh must be flagged as updatable
  24236. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24237. * @returns a new Mesh
  24238. */
  24239. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24240. /**
  24241. * Creates a ground mesh.
  24242. * Please consider using the same method from the MeshBuilder class instead
  24243. * @param name defines the name of the mesh to create
  24244. * @param width set the width of the ground
  24245. * @param height set the height of the ground
  24246. * @param subdivisions sets the number of subdivisions per side
  24247. * @param scene defines the hosting scene
  24248. * @param updatable defines if the mesh must be flagged as updatable
  24249. * @returns a new Mesh
  24250. */
  24251. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24252. /**
  24253. * Creates a tiled ground mesh.
  24254. * Please consider using the same method from the MeshBuilder class instead
  24255. * @param name defines the name of the mesh to create
  24256. * @param xmin set the ground minimum X coordinate
  24257. * @param zmin set the ground minimum Y coordinate
  24258. * @param xmax set the ground maximum X coordinate
  24259. * @param zmax set the ground maximum Z coordinate
  24260. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  24261. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  24262. * @param scene defines the hosting scene
  24263. * @param updatable defines if the mesh must be flagged as updatable
  24264. * @returns a new Mesh
  24265. */
  24266. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24267. w: number;
  24268. h: number;
  24269. }, precision: {
  24270. w: number;
  24271. h: number;
  24272. }, scene: Scene, updatable?: boolean): Mesh;
  24273. /**
  24274. * Creates a ground mesh from a height map.
  24275. * Please consider using the same method from the MeshBuilder class instead
  24276. * @see http://doc.babylonjs.com/babylon101/height_map
  24277. * @param name defines the name of the mesh to create
  24278. * @param url sets the URL of the height map image resource
  24279. * @param width set the ground width size
  24280. * @param height set the ground height size
  24281. * @param subdivisions sets the number of subdivision per side
  24282. * @param minHeight is the minimum altitude on the ground
  24283. * @param maxHeight is the maximum altitude on the ground
  24284. * @param scene defines the hosting scene
  24285. * @param updatable defines if the mesh must be flagged as updatable
  24286. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24287. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24288. * @returns a new Mesh
  24289. */
  24290. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  24291. /**
  24292. * Creates a tube mesh.
  24293. * The tube is a parametric shape.
  24294. * It has no predefined shape. Its final shape will depend on the input parameters.
  24295. * Please consider using the same method from the MeshBuilder class instead
  24296. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24297. * @param name defines the name of the mesh to create
  24298. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24299. * @param radius sets the tube radius size
  24300. * @param tessellation is the number of sides on the tubular surface
  24301. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. 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
  24302. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24303. * @param scene defines the hosting scene
  24304. * @param updatable defines if the mesh must be flagged as updatable
  24305. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24306. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  24307. * @returns a new Mesh
  24308. */
  24309. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24310. (i: number, distance: number): number;
  24311. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24312. /**
  24313. * Creates a polyhedron mesh.
  24314. * Please consider using the same method from the MeshBuilder class instead.
  24315. * * 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 to choose the wanted type
  24316. * * The parameter `size` (positive float, default 1) sets the polygon size
  24317. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24318. * * 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`
  24319. * * 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
  24320. * * 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)`)
  24321. * * 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 : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  24322. * * 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
  24323. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24324. * * 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). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24326. * @param name defines the name of the mesh to create
  24327. * @param options defines the options used to create the mesh
  24328. * @param scene defines the hosting scene
  24329. * @returns a new Mesh
  24330. */
  24331. static CreatePolyhedron(name: string, options: {
  24332. type?: number;
  24333. size?: number;
  24334. sizeX?: number;
  24335. sizeY?: number;
  24336. sizeZ?: number;
  24337. custom?: any;
  24338. faceUV?: Vector4[];
  24339. faceColors?: Color4[];
  24340. updatable?: boolean;
  24341. sideOrientation?: number;
  24342. }, scene: Scene): Mesh;
  24343. /**
  24344. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24345. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24346. * * 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`)
  24347. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24348. * * 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
  24349. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24350. * * 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). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24352. * @param name defines the name of the mesh
  24353. * @param options defines the options used to create the mesh
  24354. * @param scene defines the hosting scene
  24355. * @returns a new Mesh
  24356. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24357. */
  24358. static CreateIcoSphere(name: string, options: {
  24359. radius?: number;
  24360. flat?: boolean;
  24361. subdivisions?: number;
  24362. sideOrientation?: number;
  24363. updatable?: boolean;
  24364. }, scene: Scene): Mesh;
  24365. /**
  24366. * Creates a decal mesh.
  24367. * Please consider using the same method from the MeshBuilder class instead.
  24368. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24369. * @param name defines the name of the mesh
  24370. * @param sourceMesh defines the mesh receiving the decal
  24371. * @param position sets the position of the decal in world coordinates
  24372. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24373. * @param size sets the decal scaling
  24374. * @param angle sets the angle to rotate the decal
  24375. * @returns a new Mesh
  24376. */
  24377. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24378. /**
  24379. * Prepare internal position array for software CPU skinning
  24380. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24381. */
  24382. setPositionsForCPUSkinning(): Float32Array;
  24383. /**
  24384. * Prepare internal normal array for software CPU skinning
  24385. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24386. */
  24387. setNormalsForCPUSkinning(): Float32Array;
  24388. /**
  24389. * Updates the vertex buffer by applying transformation from the bones
  24390. * @param skeleton defines the skeleton to apply to current mesh
  24391. * @returns the current mesh
  24392. */
  24393. applySkeleton(skeleton: Skeleton): Mesh;
  24394. /**
  24395. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  24396. * @param meshes defines the list of meshes to scan
  24397. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24398. */
  24399. static MinMax(meshes: AbstractMesh[]): {
  24400. min: Vector3;
  24401. max: Vector3;
  24402. };
  24403. /**
  24404. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24405. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24406. * @returns a vector3
  24407. */
  24408. static Center(meshesOrMinMaxVector: {
  24409. min: Vector3;
  24410. max: Vector3;
  24411. } | AbstractMesh[]): Vector3;
  24412. /**
  24413. * Merge the array of meshes into a single mesh for performance reasons.
  24414. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24415. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24416. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24417. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24418. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24419. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24420. * @returns a new mesh
  24421. */
  24422. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24423. /** @hidden */
  24424. addInstance(instance: InstancedMesh): void;
  24425. /** @hidden */
  24426. removeInstance(instance: InstancedMesh): void;
  24427. }
  24428. }
  24429. declare module BABYLON {
  24430. /**
  24431. * This is the base class of all the camera used in the application.
  24432. * @see http://doc.babylonjs.com/features/cameras
  24433. */
  24434. export class Camera extends Node {
  24435. /** @hidden */
  24436. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24437. /**
  24438. * This is the default projection mode used by the cameras.
  24439. * It helps recreating a feeling of perspective and better appreciate depth.
  24440. * This is the best way to simulate real life cameras.
  24441. */
  24442. static readonly PERSPECTIVE_CAMERA: number;
  24443. /**
  24444. * This helps creating camera with an orthographic mode.
  24445. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  24446. */
  24447. static readonly ORTHOGRAPHIC_CAMERA: number;
  24448. /**
  24449. * This is the default FOV mode for perspective cameras.
  24450. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24451. */
  24452. static readonly FOVMODE_VERTICAL_FIXED: number;
  24453. /**
  24454. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24455. */
  24456. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24457. /**
  24458. * This specifies ther is no need for a camera rig.
  24459. * Basically only one eye is rendered corresponding to the camera.
  24460. */
  24461. static readonly RIG_MODE_NONE: number;
  24462. /**
  24463. * Simulates a camera Rig with one blue eye and one red eye.
  24464. * This can be use with 3d blue and red glasses.
  24465. */
  24466. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24467. /**
  24468. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24469. */
  24470. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24471. /**
  24472. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24473. */
  24474. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24475. /**
  24476. * Defines that both eyes of the camera will be rendered over under each other.
  24477. */
  24478. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24479. /**
  24480. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24481. */
  24482. static readonly RIG_MODE_VR: number;
  24483. /**
  24484. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24485. */
  24486. static readonly RIG_MODE_WEBVR: number;
  24487. /**
  24488. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24489. */
  24490. static readonly RIG_MODE_CUSTOM: number;
  24491. /**
  24492. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24493. */
  24494. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24495. /**
  24496. * Define the input manager associated with the camera.
  24497. */
  24498. inputs: CameraInputsManager<Camera>;
  24499. /** @hidden */
  24500. _position: Vector3;
  24501. /**
  24502. * Define the current local position of the camera in the scene
  24503. */
  24504. position: Vector3;
  24505. /**
  24506. * The vector the camera should consider as up.
  24507. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24508. */
  24509. upVector: Vector3;
  24510. /**
  24511. * Define the current limit on the left side for an orthographic camera
  24512. * In scene unit
  24513. */
  24514. orthoLeft: Nullable<number>;
  24515. /**
  24516. * Define the current limit on the right side for an orthographic camera
  24517. * In scene unit
  24518. */
  24519. orthoRight: Nullable<number>;
  24520. /**
  24521. * Define the current limit on the bottom side for an orthographic camera
  24522. * In scene unit
  24523. */
  24524. orthoBottom: Nullable<number>;
  24525. /**
  24526. * Define the current limit on the top side for an orthographic camera
  24527. * In scene unit
  24528. */
  24529. orthoTop: Nullable<number>;
  24530. /**
  24531. * Field Of View is set in Radians. (default is 0.8)
  24532. */
  24533. fov: number;
  24534. /**
  24535. * Define the minimum distance the camera can see from.
  24536. * This is important to note that the depth buffer are not infinite and the closer it starts
  24537. * the more your scene might encounter depth fighting issue.
  24538. */
  24539. minZ: number;
  24540. /**
  24541. * Define the maximum distance the camera can see to.
  24542. * This is important to note that the depth buffer are not infinite and the further it end
  24543. * the more your scene might encounter depth fighting issue.
  24544. */
  24545. maxZ: number;
  24546. /**
  24547. * Define the default inertia of the camera.
  24548. * This helps giving a smooth feeling to the camera movement.
  24549. */
  24550. inertia: number;
  24551. /**
  24552. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24553. */
  24554. mode: number;
  24555. /**
  24556. * Define wether the camera is intermediate.
  24557. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24558. */
  24559. isIntermediate: boolean;
  24560. /**
  24561. * Define the viewport of the camera.
  24562. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24563. */
  24564. viewport: Viewport;
  24565. /**
  24566. * Restricts the camera to viewing objects with the same layerMask.
  24567. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24568. */
  24569. layerMask: number;
  24570. /**
  24571. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24572. */
  24573. fovMode: number;
  24574. /**
  24575. * Rig mode of the camera.
  24576. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24577. * This is normally controlled byt the camera themselves as internal use.
  24578. */
  24579. cameraRigMode: number;
  24580. /**
  24581. * Defines the distance between both "eyes" in case of a RIG
  24582. */
  24583. interaxialDistance: number;
  24584. /**
  24585. * Defines if stereoscopic rendering is done side by side or over under.
  24586. */
  24587. isStereoscopicSideBySide: boolean;
  24588. /**
  24589. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  24590. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24591. * else in the scene. (Eg. security camera)
  24592. *
  24593. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  24594. */
  24595. customRenderTargets: RenderTargetTexture[];
  24596. /**
  24597. * When set, the camera will render to this render target instead of the default canvas
  24598. *
  24599. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24600. */
  24601. outputRenderTarget: Nullable<RenderTargetTexture>;
  24602. /**
  24603. * Observable triggered when the camera view matrix has changed.
  24604. */
  24605. onViewMatrixChangedObservable: Observable<Camera>;
  24606. /**
  24607. * Observable triggered when the camera Projection matrix has changed.
  24608. */
  24609. onProjectionMatrixChangedObservable: Observable<Camera>;
  24610. /**
  24611. * Observable triggered when the inputs have been processed.
  24612. */
  24613. onAfterCheckInputsObservable: Observable<Camera>;
  24614. /**
  24615. * Observable triggered when reset has been called and applied to the camera.
  24616. */
  24617. onRestoreStateObservable: Observable<Camera>;
  24618. /** @hidden */
  24619. _cameraRigParams: any;
  24620. /** @hidden */
  24621. _rigCameras: Camera[];
  24622. /** @hidden */
  24623. _rigPostProcess: Nullable<PostProcess>;
  24624. protected _webvrViewMatrix: Matrix;
  24625. /** @hidden */
  24626. _skipRendering: boolean;
  24627. /** @hidden */
  24628. _projectionMatrix: Matrix;
  24629. /** @hidden */
  24630. _postProcesses: Nullable<PostProcess>[];
  24631. /** @hidden */
  24632. _activeMeshes: SmartArray<AbstractMesh>;
  24633. protected _globalPosition: Vector3;
  24634. /** @hidden */
  24635. _computedViewMatrix: Matrix;
  24636. private _doNotComputeProjectionMatrix;
  24637. private _transformMatrix;
  24638. private _frustumPlanes;
  24639. private _refreshFrustumPlanes;
  24640. private _storedFov;
  24641. private _stateStored;
  24642. /**
  24643. * Instantiates a new camera object.
  24644. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24645. * @see http://doc.babylonjs.com/features/cameras
  24646. * @param name Defines the name of the camera in the scene
  24647. * @param position Defines the position of the camera
  24648. * @param scene Defines the scene the camera belongs too
  24649. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24650. */
  24651. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24652. /**
  24653. * Store current camera state (fov, position, etc..)
  24654. * @returns the camera
  24655. */
  24656. storeState(): Camera;
  24657. /**
  24658. * Restores the camera state values if it has been stored. You must call storeState() first
  24659. */
  24660. protected _restoreStateValues(): boolean;
  24661. /**
  24662. * Restored camera state. You must call storeState() first.
  24663. * @returns true if restored and false otherwise
  24664. */
  24665. restoreState(): boolean;
  24666. /**
  24667. * Gets the class name of the camera.
  24668. * @returns the class name
  24669. */
  24670. getClassName(): string;
  24671. /** @hidden */
  24672. readonly _isCamera: boolean;
  24673. /**
  24674. * Gets a string representation of the camera useful for debug purpose.
  24675. * @param fullDetails Defines that a more verboe level of logging is required
  24676. * @returns the string representation
  24677. */
  24678. toString(fullDetails?: boolean): string;
  24679. /**
  24680. * Gets the current world space position of the camera.
  24681. */
  24682. readonly globalPosition: Vector3;
  24683. /**
  24684. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24685. * @returns the active meshe list
  24686. */
  24687. getActiveMeshes(): SmartArray<AbstractMesh>;
  24688. /**
  24689. * Check wether a mesh is part of the current active mesh list of the camera
  24690. * @param mesh Defines the mesh to check
  24691. * @returns true if active, false otherwise
  24692. */
  24693. isActiveMesh(mesh: Mesh): boolean;
  24694. /**
  24695. * Is this camera ready to be used/rendered
  24696. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24697. * @return true if the camera is ready
  24698. */
  24699. isReady(completeCheck?: boolean): boolean;
  24700. /** @hidden */
  24701. _initCache(): void;
  24702. /** @hidden */
  24703. _updateCache(ignoreParentClass?: boolean): void;
  24704. /** @hidden */
  24705. _isSynchronized(): boolean;
  24706. /** @hidden */
  24707. _isSynchronizedViewMatrix(): boolean;
  24708. /** @hidden */
  24709. _isSynchronizedProjectionMatrix(): boolean;
  24710. /**
  24711. * Attach the input controls to a specific dom element to get the input from.
  24712. * @param element Defines the element the controls should be listened from
  24713. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24714. */
  24715. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24716. /**
  24717. * Detach the current controls from the specified dom element.
  24718. * @param element Defines the element to stop listening the inputs from
  24719. */
  24720. detachControl(element: HTMLElement): void;
  24721. /**
  24722. * Update the camera state according to the different inputs gathered during the frame.
  24723. */
  24724. update(): void;
  24725. /** @hidden */
  24726. _checkInputs(): void;
  24727. /** @hidden */
  24728. readonly rigCameras: Camera[];
  24729. /**
  24730. * Gets the post process used by the rig cameras
  24731. */
  24732. readonly rigPostProcess: Nullable<PostProcess>;
  24733. /**
  24734. * Internal, gets the first post proces.
  24735. * @returns the first post process to be run on this camera.
  24736. */
  24737. _getFirstPostProcess(): Nullable<PostProcess>;
  24738. private _cascadePostProcessesToRigCams;
  24739. /**
  24740. * Attach a post process to the camera.
  24741. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24742. * @param postProcess The post process to attach to the camera
  24743. * @param insertAt The position of the post process in case several of them are in use in the scene
  24744. * @returns the position the post process has been inserted at
  24745. */
  24746. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24747. /**
  24748. * Detach a post process to the camera.
  24749. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24750. * @param postProcess The post process to detach from the camera
  24751. */
  24752. detachPostProcess(postProcess: PostProcess): void;
  24753. /**
  24754. * Gets the current world matrix of the camera
  24755. */
  24756. getWorldMatrix(): Matrix;
  24757. /** @hidden */
  24758. _getViewMatrix(): Matrix;
  24759. /**
  24760. * Gets the current view matrix of the camera.
  24761. * @param force forces the camera to recompute the matrix without looking at the cached state
  24762. * @returns the view matrix
  24763. */
  24764. getViewMatrix(force?: boolean): Matrix;
  24765. /**
  24766. * Freeze the projection matrix.
  24767. * It will prevent the cache check of the camera projection compute and can speed up perf
  24768. * if no parameter of the camera are meant to change
  24769. * @param projection Defines manually a projection if necessary
  24770. */
  24771. freezeProjectionMatrix(projection?: Matrix): void;
  24772. /**
  24773. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24774. */
  24775. unfreezeProjectionMatrix(): void;
  24776. /**
  24777. * Gets the current projection matrix of the camera.
  24778. * @param force forces the camera to recompute the matrix without looking at the cached state
  24779. * @returns the projection matrix
  24780. */
  24781. getProjectionMatrix(force?: boolean): Matrix;
  24782. /**
  24783. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24784. * @returns a Matrix
  24785. */
  24786. getTransformationMatrix(): Matrix;
  24787. private _updateFrustumPlanes;
  24788. /**
  24789. * Checks if a cullable object (mesh...) is in the camera frustum
  24790. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24791. * @param target The object to check
  24792. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24793. * @returns true if the object is in frustum otherwise false
  24794. */
  24795. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24796. /**
  24797. * Checks if a cullable object (mesh...) is in the camera frustum
  24798. * Unlike isInFrustum this cheks the full bounding box
  24799. * @param target The object to check
  24800. * @returns true if the object is in frustum otherwise false
  24801. */
  24802. isCompletelyInFrustum(target: ICullable): boolean;
  24803. /**
  24804. * Gets a ray in the forward direction from the camera.
  24805. * @param length Defines the length of the ray to create
  24806. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24807. * @param origin Defines the start point of the ray which defaults to the camera position
  24808. * @returns the forward ray
  24809. */
  24810. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24811. /**
  24812. * Releases resources associated with this node.
  24813. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24814. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24815. */
  24816. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24817. /** @hidden */
  24818. _isLeftCamera: boolean;
  24819. /**
  24820. * Gets the left camera of a rig setup in case of Rigged Camera
  24821. */
  24822. readonly isLeftCamera: boolean;
  24823. /** @hidden */
  24824. _isRightCamera: boolean;
  24825. /**
  24826. * Gets the right camera of a rig setup in case of Rigged Camera
  24827. */
  24828. readonly isRightCamera: boolean;
  24829. /**
  24830. * Gets the left camera of a rig setup in case of Rigged Camera
  24831. */
  24832. readonly leftCamera: Nullable<FreeCamera>;
  24833. /**
  24834. * Gets the right camera of a rig setup in case of Rigged Camera
  24835. */
  24836. readonly rightCamera: Nullable<FreeCamera>;
  24837. /**
  24838. * Gets the left camera target of a rig setup in case of Rigged Camera
  24839. * @returns the target position
  24840. */
  24841. getLeftTarget(): Nullable<Vector3>;
  24842. /**
  24843. * Gets the right camera target of a rig setup in case of Rigged Camera
  24844. * @returns the target position
  24845. */
  24846. getRightTarget(): Nullable<Vector3>;
  24847. /**
  24848. * @hidden
  24849. */
  24850. setCameraRigMode(mode: number, rigParams: any): void;
  24851. /** @hidden */
  24852. static _setStereoscopicRigMode(camera: Camera): void;
  24853. /** @hidden */
  24854. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24855. /** @hidden */
  24856. static _setVRRigMode(camera: Camera, rigParams: any): void;
  24857. /** @hidden */
  24858. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24859. /** @hidden */
  24860. _getVRProjectionMatrix(): Matrix;
  24861. protected _updateCameraRotationMatrix(): void;
  24862. protected _updateWebVRCameraRotationMatrix(): void;
  24863. /**
  24864. * This function MUST be overwritten by the different WebVR cameras available.
  24865. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24866. * @hidden
  24867. */
  24868. _getWebVRProjectionMatrix(): Matrix;
  24869. /**
  24870. * This function MUST be overwritten by the different WebVR cameras available.
  24871. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24872. * @hidden
  24873. */
  24874. _getWebVRViewMatrix(): Matrix;
  24875. /** @hidden */
  24876. setCameraRigParameter(name: string, value: any): void;
  24877. /**
  24878. * needs to be overridden by children so sub has required properties to be copied
  24879. * @hidden
  24880. */
  24881. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24882. /**
  24883. * May need to be overridden by children
  24884. * @hidden
  24885. */
  24886. _updateRigCameras(): void;
  24887. /** @hidden */
  24888. _setupInputs(): void;
  24889. /**
  24890. * Serialiaze the camera setup to a json represention
  24891. * @returns the JSON representation
  24892. */
  24893. serialize(): any;
  24894. /**
  24895. * Clones the current camera.
  24896. * @param name The cloned camera name
  24897. * @returns the cloned camera
  24898. */
  24899. clone(name: string): Camera;
  24900. /**
  24901. * Gets the direction of the camera relative to a given local axis.
  24902. * @param localAxis Defines the reference axis to provide a relative direction.
  24903. * @return the direction
  24904. */
  24905. getDirection(localAxis: Vector3): Vector3;
  24906. /**
  24907. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24908. * @param localAxis Defines the reference axis to provide a relative direction.
  24909. * @param result Defines the vector to store the result in
  24910. */
  24911. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24912. /**
  24913. * Gets a camera constructor for a given camera type
  24914. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24915. * @param name The name of the camera the result will be able to instantiate
  24916. * @param scene The scene the result will construct the camera in
  24917. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24918. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24919. * @returns a factory method to construc the camera
  24920. */
  24921. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24922. /**
  24923. * Compute the world matrix of the camera.
  24924. * @returns the camera workd matrix
  24925. */
  24926. computeWorldMatrix(): Matrix;
  24927. /**
  24928. * Parse a JSON and creates the camera from the parsed information
  24929. * @param parsedCamera The JSON to parse
  24930. * @param scene The scene to instantiate the camera in
  24931. * @returns the newly constructed camera
  24932. */
  24933. static Parse(parsedCamera: any, scene: Scene): Camera;
  24934. }
  24935. }
  24936. declare module BABYLON {
  24937. /**
  24938. * Class containing static functions to help procedurally build meshes
  24939. */
  24940. export class DiscBuilder {
  24941. /**
  24942. * Creates a plane polygonal mesh. By default, this is a disc
  24943. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24944. * * 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
  24945. * * 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
  24946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24947. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24949. * @param name defines the name of the mesh
  24950. * @param options defines the options used to create the mesh
  24951. * @param scene defines the hosting scene
  24952. * @returns the plane polygonal mesh
  24953. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24954. */
  24955. static CreateDisc(name: string, options: {
  24956. radius?: number;
  24957. tessellation?: number;
  24958. arc?: number;
  24959. updatable?: boolean;
  24960. sideOrientation?: number;
  24961. frontUVs?: Vector4;
  24962. backUVs?: Vector4;
  24963. }, scene?: Nullable<Scene>): Mesh;
  24964. }
  24965. }
  24966. declare module BABYLON {
  24967. /**
  24968. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24969. *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.
  24970. * The SPS is also a particle system. It provides some methods to manage the particles.
  24971. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24972. *
  24973. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24974. */
  24975. export class SolidParticleSystem implements IDisposable {
  24976. /**
  24977. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24978. * Example : var p = SPS.particles[i];
  24979. */
  24980. particles: SolidParticle[];
  24981. /**
  24982. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24983. */
  24984. nbParticles: number;
  24985. /**
  24986. * If the particles must ever face the camera (default false). Useful for planar particles.
  24987. */
  24988. billboard: boolean;
  24989. /**
  24990. * Recompute normals when adding a shape
  24991. */
  24992. recomputeNormals: boolean;
  24993. /**
  24994. * This a counter ofr your own usage. It's not set by any SPS functions.
  24995. */
  24996. counter: number;
  24997. /**
  24998. * The SPS name. This name is also given to the underlying mesh.
  24999. */
  25000. name: string;
  25001. /**
  25002. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25003. */
  25004. mesh: Mesh;
  25005. /**
  25006. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25007. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25008. */
  25009. vars: any;
  25010. /**
  25011. * This array is populated when the SPS is set as 'pickable'.
  25012. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25013. * Each element of this array is an object `{idx: int, faceId: int}`.
  25014. * `idx` is the picked particle index in the `SPS.particles` array
  25015. * `faceId` is the picked face index counted within this particle.
  25016. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25017. */
  25018. pickedParticles: {
  25019. idx: number;
  25020. faceId: number;
  25021. }[];
  25022. /**
  25023. * This array is populated when `enableDepthSort` is set to true.
  25024. * Each element of this array is an instance of the class DepthSortedParticle.
  25025. */
  25026. depthSortedParticles: DepthSortedParticle[];
  25027. /**
  25028. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25029. * @hidden
  25030. */
  25031. _bSphereOnly: boolean;
  25032. /**
  25033. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25034. * @hidden
  25035. */
  25036. _bSphereRadiusFactor: number;
  25037. private _scene;
  25038. private _positions;
  25039. private _indices;
  25040. private _normals;
  25041. private _colors;
  25042. private _uvs;
  25043. private _indices32;
  25044. private _positions32;
  25045. private _normals32;
  25046. private _fixedNormal32;
  25047. private _colors32;
  25048. private _uvs32;
  25049. private _index;
  25050. private _updatable;
  25051. private _pickable;
  25052. private _isVisibilityBoxLocked;
  25053. private _alwaysVisible;
  25054. private _depthSort;
  25055. private _shapeCounter;
  25056. private _copy;
  25057. private _color;
  25058. private _computeParticleColor;
  25059. private _computeParticleTexture;
  25060. private _computeParticleRotation;
  25061. private _computeParticleVertex;
  25062. private _computeBoundingBox;
  25063. private _depthSortParticles;
  25064. private _camera;
  25065. private _mustUnrotateFixedNormals;
  25066. private _particlesIntersect;
  25067. private _needs32Bits;
  25068. /**
  25069. * Creates a SPS (Solid Particle System) object.
  25070. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25071. * @param scene (Scene) is the scene in which the SPS is added.
  25072. * @param options defines the options of the sps e.g.
  25073. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25074. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25075. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25076. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25077. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25078. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25079. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25080. */
  25081. constructor(name: string, scene: Scene, options?: {
  25082. updatable?: boolean;
  25083. isPickable?: boolean;
  25084. enableDepthSort?: boolean;
  25085. particleIntersection?: boolean;
  25086. boundingSphereOnly?: boolean;
  25087. bSphereRadiusFactor?: number;
  25088. });
  25089. /**
  25090. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25091. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25092. * @returns the created mesh
  25093. */
  25094. buildMesh(): Mesh;
  25095. /**
  25096. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25097. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25098. * Thus the particles generated from `digest()` have their property `position` set yet.
  25099. * @param mesh ( Mesh ) is the mesh to be digested
  25100. * @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
  25101. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25102. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25103. * @returns the current SPS
  25104. */
  25105. digest(mesh: Mesh, options?: {
  25106. facetNb?: number;
  25107. number?: number;
  25108. delta?: number;
  25109. }): SolidParticleSystem;
  25110. private _unrotateFixedNormals;
  25111. private _resetCopy;
  25112. private _meshBuilder;
  25113. private _posToShape;
  25114. private _uvsToShapeUV;
  25115. private _addParticle;
  25116. /**
  25117. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25118. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25119. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25120. * @param nb (positive integer) the number of particles to be created from this model
  25121. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25122. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25123. * @returns the number of shapes in the system
  25124. */
  25125. addShape(mesh: Mesh, nb: number, options?: {
  25126. positionFunction?: any;
  25127. vertexFunction?: any;
  25128. }): number;
  25129. private _rebuildParticle;
  25130. /**
  25131. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25132. * @returns the SPS.
  25133. */
  25134. rebuildMesh(): SolidParticleSystem;
  25135. /**
  25136. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25137. * This method calls `updateParticle()` for each particle of the SPS.
  25138. * For an animated SPS, it is usually called within the render loop.
  25139. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25140. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25141. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25142. * @returns the SPS.
  25143. */
  25144. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25145. /**
  25146. * Disposes the SPS.
  25147. */
  25148. dispose(): void;
  25149. /**
  25150. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25151. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25152. * @returns the SPS.
  25153. */
  25154. refreshVisibleSize(): SolidParticleSystem;
  25155. /**
  25156. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25157. * @param size the size (float) of the visibility box
  25158. * note : this doesn't lock the SPS mesh bounding box.
  25159. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25160. */
  25161. setVisibilityBox(size: number): void;
  25162. /**
  25163. * Gets whether the SPS as always visible or not
  25164. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25165. */
  25166. /**
  25167. * Sets the SPS as always visible or not
  25168. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25169. */
  25170. isAlwaysVisible: boolean;
  25171. /**
  25172. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25173. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25174. */
  25175. /**
  25176. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25177. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25178. */
  25179. isVisibilityBoxLocked: boolean;
  25180. /**
  25181. * Tells to `setParticles()` to compute the particle rotations or not.
  25182. * Default value : true. The SPS is faster when it's set to false.
  25183. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25184. */
  25185. /**
  25186. * Gets if `setParticles()` computes the particle rotations or not.
  25187. * Default value : true. The SPS is faster when it's set to false.
  25188. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25189. */
  25190. computeParticleRotation: boolean;
  25191. /**
  25192. * Tells to `setParticles()` to compute the particle colors or not.
  25193. * Default value : true. The SPS is faster when it's set to false.
  25194. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25195. */
  25196. /**
  25197. * Gets if `setParticles()` computes the particle colors or not.
  25198. * Default value : true. The SPS is faster when it's set to false.
  25199. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25200. */
  25201. computeParticleColor: boolean;
  25202. /**
  25203. * Gets if `setParticles()` computes the particle textures or not.
  25204. * Default value : true. The SPS is faster when it's set to false.
  25205. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25206. */
  25207. computeParticleTexture: boolean;
  25208. /**
  25209. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25210. * Default value : false. The SPS is faster when it's set to false.
  25211. * Note : the particle custom vertex positions aren't stored values.
  25212. */
  25213. /**
  25214. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25215. * Default value : false. The SPS is faster when it's set to false.
  25216. * Note : the particle custom vertex positions aren't stored values.
  25217. */
  25218. computeParticleVertex: boolean;
  25219. /**
  25220. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25221. */
  25222. /**
  25223. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25224. */
  25225. computeBoundingBox: boolean;
  25226. /**
  25227. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25228. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25229. * Default : `true`
  25230. */
  25231. /**
  25232. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25233. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25234. * Default : `true`
  25235. */
  25236. depthSortParticles: boolean;
  25237. /**
  25238. * This function does nothing. It may be overwritten to set all the particle first values.
  25239. * The SPS doesn't call this function, you may have to call it by your own.
  25240. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25241. */
  25242. initParticles(): void;
  25243. /**
  25244. * This function does nothing. It may be overwritten to recycle a particle.
  25245. * The SPS doesn't call this function, you may have to call it by your own.
  25246. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25247. * @param particle The particle to recycle
  25248. * @returns the recycled particle
  25249. */
  25250. recycleParticle(particle: SolidParticle): SolidParticle;
  25251. /**
  25252. * Updates a particle : this function should be overwritten by the user.
  25253. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25254. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25255. * @example : just set a particle position or velocity and recycle conditions
  25256. * @param particle The particle to update
  25257. * @returns the updated particle
  25258. */
  25259. updateParticle(particle: SolidParticle): SolidParticle;
  25260. /**
  25261. * Updates a vertex of a particle : it can be overwritten by the user.
  25262. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25263. * @param particle the current particle
  25264. * @param vertex the current index of the current particle
  25265. * @param pt the index of the current vertex in the particle shape
  25266. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25267. * @example : just set a vertex particle position
  25268. * @returns the updated vertex
  25269. */
  25270. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25271. /**
  25272. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25273. * This does nothing and may be overwritten by the user.
  25274. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25275. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25276. * @param update the boolean update value actually passed to setParticles()
  25277. */
  25278. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25279. /**
  25280. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25281. * This will be passed three parameters.
  25282. * This does nothing and may be overwritten by the user.
  25283. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25284. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25285. * @param update the boolean update value actually passed to setParticles()
  25286. */
  25287. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25288. }
  25289. }
  25290. declare module BABYLON {
  25291. /**
  25292. * Represents one particle of a solid particle system.
  25293. */
  25294. export class SolidParticle {
  25295. /**
  25296. * particle global index
  25297. */
  25298. idx: number;
  25299. /**
  25300. * The color of the particle
  25301. */
  25302. color: Nullable<Color4>;
  25303. /**
  25304. * The world space position of the particle.
  25305. */
  25306. position: Vector3;
  25307. /**
  25308. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25309. */
  25310. rotation: Vector3;
  25311. /**
  25312. * The world space rotation quaternion of the particle.
  25313. */
  25314. rotationQuaternion: Nullable<Quaternion>;
  25315. /**
  25316. * The scaling of the particle.
  25317. */
  25318. scaling: Vector3;
  25319. /**
  25320. * The uvs of the particle.
  25321. */
  25322. uvs: Vector4;
  25323. /**
  25324. * The current speed of the particle.
  25325. */
  25326. velocity: Vector3;
  25327. /**
  25328. * The pivot point in the particle local space.
  25329. */
  25330. pivot: Vector3;
  25331. /**
  25332. * Must the particle be translated from its pivot point in its local space ?
  25333. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25334. * Default : false
  25335. */
  25336. translateFromPivot: boolean;
  25337. /**
  25338. * Is the particle active or not ?
  25339. */
  25340. alive: boolean;
  25341. /**
  25342. * Is the particle visible or not ?
  25343. */
  25344. isVisible: boolean;
  25345. /**
  25346. * Index of this particle in the global "positions" array (Internal use)
  25347. * @hidden
  25348. */
  25349. _pos: number;
  25350. /**
  25351. * @hidden Index of this particle in the global "indices" array (Internal use)
  25352. */
  25353. _ind: number;
  25354. /**
  25355. * @hidden ModelShape of this particle (Internal use)
  25356. */
  25357. _model: ModelShape;
  25358. /**
  25359. * ModelShape id of this particle
  25360. */
  25361. shapeId: number;
  25362. /**
  25363. * Index of the particle in its shape id
  25364. */
  25365. idxInShape: number;
  25366. /**
  25367. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25368. */
  25369. _modelBoundingInfo: BoundingInfo;
  25370. /**
  25371. * @hidden Particle BoundingInfo object (Internal use)
  25372. */
  25373. _boundingInfo: BoundingInfo;
  25374. /**
  25375. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25376. */
  25377. _sps: SolidParticleSystem;
  25378. /**
  25379. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25380. */
  25381. _stillInvisible: boolean;
  25382. /**
  25383. * @hidden Last computed particle rotation matrix
  25384. */
  25385. _rotationMatrix: number[];
  25386. /**
  25387. * Parent particle Id, if any.
  25388. * Default null.
  25389. */
  25390. parentId: Nullable<number>;
  25391. /**
  25392. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25393. * The possible values are :
  25394. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25395. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25396. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25397. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25398. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25399. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25400. * */
  25401. cullingStrategy: number;
  25402. /**
  25403. * @hidden Internal global position in the SPS.
  25404. */
  25405. _globalPosition: Vector3;
  25406. /**
  25407. * Creates a Solid Particle object.
  25408. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25409. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25410. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25411. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25412. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25413. * @param shapeId (integer) is the model shape identifier in the SPS.
  25414. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25415. * @param sps defines the sps it is associated to
  25416. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25417. */
  25418. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25419. /**
  25420. * Legacy support, changed scale to scaling
  25421. */
  25422. /**
  25423. * Legacy support, changed scale to scaling
  25424. */
  25425. scale: Vector3;
  25426. /**
  25427. * Legacy support, changed quaternion to rotationQuaternion
  25428. */
  25429. /**
  25430. * Legacy support, changed quaternion to rotationQuaternion
  25431. */
  25432. quaternion: Nullable<Quaternion>;
  25433. /**
  25434. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25435. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25436. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25437. * @returns true if it intersects
  25438. */
  25439. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25440. /**
  25441. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25442. * A particle is in the frustum if its bounding box intersects the frustum
  25443. * @param frustumPlanes defines the frustum to test
  25444. * @returns true if the particle is in the frustum planes
  25445. */
  25446. isInFrustum(frustumPlanes: Plane[]): boolean;
  25447. /**
  25448. * get the rotation matrix of the particle
  25449. * @hidden
  25450. */
  25451. getRotationMatrix(m: Matrix): void;
  25452. }
  25453. /**
  25454. * Represents the shape of the model used by one particle of a solid particle system.
  25455. * SPS internal tool, don't use it manually.
  25456. */
  25457. export class ModelShape {
  25458. /**
  25459. * The shape id
  25460. * @hidden
  25461. */
  25462. shapeID: number;
  25463. /**
  25464. * flat array of model positions (internal use)
  25465. * @hidden
  25466. */
  25467. _shape: Vector3[];
  25468. /**
  25469. * flat array of model UVs (internal use)
  25470. * @hidden
  25471. */
  25472. _shapeUV: number[];
  25473. /**
  25474. * length of the shape in the model indices array (internal use)
  25475. * @hidden
  25476. */
  25477. _indicesLength: number;
  25478. /**
  25479. * Custom position function (internal use)
  25480. * @hidden
  25481. */
  25482. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25483. /**
  25484. * Custom vertex function (internal use)
  25485. * @hidden
  25486. */
  25487. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25488. /**
  25489. * 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.
  25490. * SPS internal tool, don't use it manually.
  25491. * @hidden
  25492. */
  25493. 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>);
  25494. }
  25495. /**
  25496. * Represents a Depth Sorted Particle in the solid particle system.
  25497. */
  25498. export class DepthSortedParticle {
  25499. /**
  25500. * Index of the particle in the "indices" array
  25501. */
  25502. ind: number;
  25503. /**
  25504. * Length of the particle shape in the "indices" array
  25505. */
  25506. indicesLength: number;
  25507. /**
  25508. * Squared distance from the particle to the camera
  25509. */
  25510. sqDistance: number;
  25511. }
  25512. }
  25513. declare module BABYLON {
  25514. /**
  25515. * @hidden
  25516. */
  25517. export class _MeshCollisionData {
  25518. _checkCollisions: boolean;
  25519. _collisionMask: number;
  25520. _collisionGroup: number;
  25521. _collider: Nullable<Collider>;
  25522. _oldPositionForCollisions: Vector3;
  25523. _diffPositionForCollisions: Vector3;
  25524. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25525. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25526. }
  25527. }
  25528. declare module BABYLON {
  25529. /** @hidden */
  25530. class _FacetDataStorage {
  25531. facetPositions: Vector3[];
  25532. facetNormals: Vector3[];
  25533. facetPartitioning: number[][];
  25534. facetNb: number;
  25535. partitioningSubdivisions: number;
  25536. partitioningBBoxRatio: number;
  25537. facetDataEnabled: boolean;
  25538. facetParameters: any;
  25539. bbSize: Vector3;
  25540. subDiv: {
  25541. max: number;
  25542. X: number;
  25543. Y: number;
  25544. Z: number;
  25545. };
  25546. facetDepthSort: boolean;
  25547. facetDepthSortEnabled: boolean;
  25548. depthSortedIndices: IndicesArray;
  25549. depthSortedFacets: {
  25550. ind: number;
  25551. sqDistance: number;
  25552. }[];
  25553. facetDepthSortFunction: (f1: {
  25554. ind: number;
  25555. sqDistance: number;
  25556. }, f2: {
  25557. ind: number;
  25558. sqDistance: number;
  25559. }) => number;
  25560. facetDepthSortFrom: Vector3;
  25561. facetDepthSortOrigin: Vector3;
  25562. invertedMatrix: Matrix;
  25563. }
  25564. /**
  25565. * @hidden
  25566. **/
  25567. class _InternalAbstractMeshDataInfo {
  25568. _hasVertexAlpha: boolean;
  25569. _useVertexColors: boolean;
  25570. _numBoneInfluencers: number;
  25571. _applyFog: boolean;
  25572. _receiveShadows: boolean;
  25573. _facetData: _FacetDataStorage;
  25574. _visibility: number;
  25575. _skeleton: Nullable<Skeleton>;
  25576. _layerMask: number;
  25577. _computeBonesUsingShaders: boolean;
  25578. _isActive: boolean;
  25579. _onlyForInstances: boolean;
  25580. _isActiveIntermediate: boolean;
  25581. _onlyForInstancesIntermediate: boolean;
  25582. }
  25583. /**
  25584. * Class used to store all common mesh properties
  25585. */
  25586. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25587. /** No occlusion */
  25588. static OCCLUSION_TYPE_NONE: number;
  25589. /** Occlusion set to optimisitic */
  25590. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25591. /** Occlusion set to strict */
  25592. static OCCLUSION_TYPE_STRICT: number;
  25593. /** Use an accurante occlusion algorithm */
  25594. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25595. /** Use a conservative occlusion algorithm */
  25596. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25597. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25598. * Test order :
  25599. * Is the bounding sphere outside the frustum ?
  25600. * If not, are the bounding box vertices outside the frustum ?
  25601. * It not, then the cullable object is in the frustum.
  25602. */
  25603. static readonly CULLINGSTRATEGY_STANDARD: number;
  25604. /** Culling strategy : Bounding Sphere Only.
  25605. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25606. * It's also less accurate than the standard because some not visible objects can still be selected.
  25607. * Test : is the bounding sphere outside the frustum ?
  25608. * If not, then the cullable object is in the frustum.
  25609. */
  25610. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25611. /** Culling strategy : Optimistic Inclusion.
  25612. * This in an inclusion test first, then the standard exclusion test.
  25613. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25614. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  25615. * Anyway, it's as accurate as the standard strategy.
  25616. * Test :
  25617. * Is the cullable object bounding sphere center in the frustum ?
  25618. * If not, apply the default culling strategy.
  25619. */
  25620. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25621. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25622. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25623. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25624. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  25625. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25626. * Test :
  25627. * Is the cullable object bounding sphere center in the frustum ?
  25628. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25629. */
  25630. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25631. /**
  25632. * No billboard
  25633. */
  25634. static readonly BILLBOARDMODE_NONE: number;
  25635. /** Billboard on X axis */
  25636. static readonly BILLBOARDMODE_X: number;
  25637. /** Billboard on Y axis */
  25638. static readonly BILLBOARDMODE_Y: number;
  25639. /** Billboard on Z axis */
  25640. static readonly BILLBOARDMODE_Z: number;
  25641. /** Billboard on all axes */
  25642. static readonly BILLBOARDMODE_ALL: number;
  25643. /** Billboard on using position instead of orientation */
  25644. static readonly BILLBOARDMODE_USE_POSITION: number;
  25645. /** @hidden */
  25646. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25647. /**
  25648. * The culling strategy to use to check whether the mesh must be rendered or not.
  25649. * This value can be changed at any time and will be used on the next render mesh selection.
  25650. * The possible values are :
  25651. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25652. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25653. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25654. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25655. * Please read each static variable documentation to get details about the culling process.
  25656. * */
  25657. cullingStrategy: number;
  25658. /**
  25659. * Gets the number of facets in the mesh
  25660. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25661. */
  25662. readonly facetNb: number;
  25663. /**
  25664. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25665. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25666. */
  25667. partitioningSubdivisions: number;
  25668. /**
  25669. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25670. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25671. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25672. */
  25673. partitioningBBoxRatio: number;
  25674. /**
  25675. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25676. * Works only for updatable meshes.
  25677. * Doesn't work with multi-materials
  25678. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25679. */
  25680. mustDepthSortFacets: boolean;
  25681. /**
  25682. * The location (Vector3) where the facet depth sort must be computed from.
  25683. * By default, the active camera position.
  25684. * Used only when facet depth sort is enabled
  25685. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25686. */
  25687. facetDepthSortFrom: Vector3;
  25688. /**
  25689. * gets a boolean indicating if facetData is enabled
  25690. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25691. */
  25692. readonly isFacetDataEnabled: boolean;
  25693. /** @hidden */
  25694. _updateNonUniformScalingState(value: boolean): boolean;
  25695. /**
  25696. * An event triggered when this mesh collides with another one
  25697. */
  25698. onCollideObservable: Observable<AbstractMesh>;
  25699. /** Set a function to call when this mesh collides with another one */
  25700. onCollide: () => void;
  25701. /**
  25702. * An event triggered when the collision's position changes
  25703. */
  25704. onCollisionPositionChangeObservable: Observable<Vector3>;
  25705. /** Set a function to call when the collision's position changes */
  25706. onCollisionPositionChange: () => void;
  25707. /**
  25708. * An event triggered when material is changed
  25709. */
  25710. onMaterialChangedObservable: Observable<AbstractMesh>;
  25711. /**
  25712. * Gets or sets the orientation for POV movement & rotation
  25713. */
  25714. definedFacingForward: boolean;
  25715. /** @hidden */
  25716. _occlusionQuery: Nullable<WebGLQuery>;
  25717. /** @hidden */
  25718. _renderingGroup: Nullable<RenderingGroup>;
  25719. /**
  25720. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25721. */
  25722. /**
  25723. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25724. */
  25725. visibility: number;
  25726. /** Gets or sets the alpha index used to sort transparent meshes
  25727. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25728. */
  25729. alphaIndex: number;
  25730. /**
  25731. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25732. */
  25733. isVisible: boolean;
  25734. /**
  25735. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25736. */
  25737. isPickable: boolean;
  25738. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25739. showSubMeshesBoundingBox: boolean;
  25740. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25741. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25742. */
  25743. isBlocker: boolean;
  25744. /**
  25745. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25746. */
  25747. enablePointerMoveEvents: boolean;
  25748. /**
  25749. * Specifies the rendering group id for this mesh (0 by default)
  25750. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25751. */
  25752. renderingGroupId: number;
  25753. private _material;
  25754. /** Gets or sets current material */
  25755. material: Nullable<Material>;
  25756. /**
  25757. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25758. * @see http://doc.babylonjs.com/babylon101/shadows
  25759. */
  25760. receiveShadows: boolean;
  25761. /** Defines color to use when rendering outline */
  25762. outlineColor: Color3;
  25763. /** Define width to use when rendering outline */
  25764. outlineWidth: number;
  25765. /** Defines color to use when rendering overlay */
  25766. overlayColor: Color3;
  25767. /** Defines alpha to use when rendering overlay */
  25768. overlayAlpha: number;
  25769. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25770. hasVertexAlpha: boolean;
  25771. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  25772. useVertexColors: boolean;
  25773. /**
  25774. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25775. */
  25776. computeBonesUsingShaders: boolean;
  25777. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25778. numBoneInfluencers: number;
  25779. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25780. applyFog: boolean;
  25781. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25782. useOctreeForRenderingSelection: boolean;
  25783. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25784. useOctreeForPicking: boolean;
  25785. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25786. useOctreeForCollisions: boolean;
  25787. /**
  25788. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25789. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25790. */
  25791. layerMask: number;
  25792. /**
  25793. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25794. */
  25795. alwaysSelectAsActiveMesh: boolean;
  25796. /**
  25797. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25798. */
  25799. doNotSyncBoundingInfo: boolean;
  25800. /**
  25801. * Gets or sets the current action manager
  25802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25803. */
  25804. actionManager: Nullable<AbstractActionManager>;
  25805. private _meshCollisionData;
  25806. /**
  25807. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25808. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25809. */
  25810. ellipsoid: Vector3;
  25811. /**
  25812. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25813. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25814. */
  25815. ellipsoidOffset: Vector3;
  25816. /**
  25817. * Gets or sets a collision mask used to mask collisions (default is -1).
  25818. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25819. */
  25820. collisionMask: number;
  25821. /**
  25822. * Gets or sets the current collision group mask (-1 by default).
  25823. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25824. */
  25825. collisionGroup: number;
  25826. /**
  25827. * Defines edge width used when edgesRenderer is enabled
  25828. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25829. */
  25830. edgesWidth: number;
  25831. /**
  25832. * Defines edge color used when edgesRenderer is enabled
  25833. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25834. */
  25835. edgesColor: Color4;
  25836. /** @hidden */
  25837. _edgesRenderer: Nullable<IEdgesRenderer>;
  25838. /** @hidden */
  25839. _masterMesh: Nullable<AbstractMesh>;
  25840. /** @hidden */
  25841. _boundingInfo: Nullable<BoundingInfo>;
  25842. /** @hidden */
  25843. _renderId: number;
  25844. /**
  25845. * Gets or sets the list of subMeshes
  25846. * @see http://doc.babylonjs.com/how_to/multi_materials
  25847. */
  25848. subMeshes: SubMesh[];
  25849. /** @hidden */
  25850. _intersectionsInProgress: AbstractMesh[];
  25851. /** @hidden */
  25852. _unIndexed: boolean;
  25853. /** @hidden */
  25854. _lightSources: Light[];
  25855. /** Gets the list of lights affecting that mesh */
  25856. readonly lightSources: Light[];
  25857. /** @hidden */
  25858. readonly _positions: Nullable<Vector3[]>;
  25859. /** @hidden */
  25860. _waitingData: {
  25861. lods: Nullable<any>;
  25862. actions: Nullable<any>;
  25863. freezeWorldMatrix: Nullable<boolean>;
  25864. };
  25865. /** @hidden */
  25866. _bonesTransformMatrices: Nullable<Float32Array>;
  25867. /** @hidden */
  25868. _transformMatrixTexture: Nullable<RawTexture>;
  25869. /**
  25870. * Gets or sets a skeleton to apply skining transformations
  25871. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25872. */
  25873. skeleton: Nullable<Skeleton>;
  25874. /**
  25875. * An event triggered when the mesh is rebuilt.
  25876. */
  25877. onRebuildObservable: Observable<AbstractMesh>;
  25878. /**
  25879. * Creates a new AbstractMesh
  25880. * @param name defines the name of the mesh
  25881. * @param scene defines the hosting scene
  25882. */
  25883. constructor(name: string, scene?: Nullable<Scene>);
  25884. /**
  25885. * Returns the string "AbstractMesh"
  25886. * @returns "AbstractMesh"
  25887. */
  25888. getClassName(): string;
  25889. /**
  25890. * Gets a string representation of the current mesh
  25891. * @param fullDetails defines a boolean indicating if full details must be included
  25892. * @returns a string representation of the current mesh
  25893. */
  25894. toString(fullDetails?: boolean): string;
  25895. /**
  25896. * @hidden
  25897. */
  25898. protected _getEffectiveParent(): Nullable<Node>;
  25899. /** @hidden */
  25900. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25901. /** @hidden */
  25902. _rebuild(): void;
  25903. /** @hidden */
  25904. _resyncLightSources(): void;
  25905. /** @hidden */
  25906. _resyncLighSource(light: Light): void;
  25907. /** @hidden */
  25908. _unBindEffect(): void;
  25909. /** @hidden */
  25910. _removeLightSource(light: Light): void;
  25911. private _markSubMeshesAsDirty;
  25912. /** @hidden */
  25913. _markSubMeshesAsLightDirty(): void;
  25914. /** @hidden */
  25915. _markSubMeshesAsAttributesDirty(): void;
  25916. /** @hidden */
  25917. _markSubMeshesAsMiscDirty(): void;
  25918. /**
  25919. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25920. */
  25921. scaling: Vector3;
  25922. /**
  25923. * Returns true if the mesh is blocked. Implemented by child classes
  25924. */
  25925. readonly isBlocked: boolean;
  25926. /**
  25927. * Returns the mesh itself by default. Implemented by child classes
  25928. * @param camera defines the camera to use to pick the right LOD level
  25929. * @returns the currentAbstractMesh
  25930. */
  25931. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25932. /**
  25933. * Returns 0 by default. Implemented by child classes
  25934. * @returns an integer
  25935. */
  25936. getTotalVertices(): number;
  25937. /**
  25938. * Returns a positive integer : the total number of indices in this mesh geometry.
  25939. * @returns the numner of indices or zero if the mesh has no geometry.
  25940. */
  25941. getTotalIndices(): number;
  25942. /**
  25943. * Returns null by default. Implemented by child classes
  25944. * @returns null
  25945. */
  25946. getIndices(): Nullable<IndicesArray>;
  25947. /**
  25948. * Returns the array of the requested vertex data kind. Implemented by child classes
  25949. * @param kind defines the vertex data kind to use
  25950. * @returns null
  25951. */
  25952. getVerticesData(kind: string): Nullable<FloatArray>;
  25953. /**
  25954. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25955. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25956. * Note that a new underlying VertexBuffer object is created each call.
  25957. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25958. * @param kind defines vertex data kind:
  25959. * * VertexBuffer.PositionKind
  25960. * * VertexBuffer.UVKind
  25961. * * VertexBuffer.UV2Kind
  25962. * * VertexBuffer.UV3Kind
  25963. * * VertexBuffer.UV4Kind
  25964. * * VertexBuffer.UV5Kind
  25965. * * VertexBuffer.UV6Kind
  25966. * * VertexBuffer.ColorKind
  25967. * * VertexBuffer.MatricesIndicesKind
  25968. * * VertexBuffer.MatricesIndicesExtraKind
  25969. * * VertexBuffer.MatricesWeightsKind
  25970. * * VertexBuffer.MatricesWeightsExtraKind
  25971. * @param data defines the data source
  25972. * @param updatable defines if the data must be flagged as updatable (or static)
  25973. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  25974. * @returns the current mesh
  25975. */
  25976. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25977. /**
  25978. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25979. * If the mesh has no geometry, it is simply returned as it is.
  25980. * @param kind defines vertex data kind:
  25981. * * VertexBuffer.PositionKind
  25982. * * VertexBuffer.UVKind
  25983. * * VertexBuffer.UV2Kind
  25984. * * VertexBuffer.UV3Kind
  25985. * * VertexBuffer.UV4Kind
  25986. * * VertexBuffer.UV5Kind
  25987. * * VertexBuffer.UV6Kind
  25988. * * VertexBuffer.ColorKind
  25989. * * VertexBuffer.MatricesIndicesKind
  25990. * * VertexBuffer.MatricesIndicesExtraKind
  25991. * * VertexBuffer.MatricesWeightsKind
  25992. * * VertexBuffer.MatricesWeightsExtraKind
  25993. * @param data defines the data source
  25994. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  25995. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25996. * @returns the current mesh
  25997. */
  25998. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25999. /**
  26000. * Sets the mesh indices,
  26001. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26002. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26003. * @param totalVertices Defines the total number of vertices
  26004. * @returns the current mesh
  26005. */
  26006. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26007. /**
  26008. * Gets a boolean indicating if specific vertex data is present
  26009. * @param kind defines the vertex data kind to use
  26010. * @returns true is data kind is present
  26011. */
  26012. isVerticesDataPresent(kind: string): boolean;
  26013. /**
  26014. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26015. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26016. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26017. * @returns a BoundingInfo
  26018. */
  26019. getBoundingInfo(): BoundingInfo;
  26020. /**
  26021. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26022. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26023. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26024. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26025. * @returns the current mesh
  26026. */
  26027. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26028. /**
  26029. * Overwrite the current bounding info
  26030. * @param boundingInfo defines the new bounding info
  26031. * @returns the current mesh
  26032. */
  26033. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26034. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26035. readonly useBones: boolean;
  26036. /** @hidden */
  26037. _preActivate(): void;
  26038. /** @hidden */
  26039. _preActivateForIntermediateRendering(renderId: number): void;
  26040. /** @hidden */
  26041. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26042. /** @hidden */
  26043. _postActivate(): void;
  26044. /** @hidden */
  26045. _freeze(): void;
  26046. /** @hidden */
  26047. _unFreeze(): void;
  26048. /**
  26049. * Gets the current world matrix
  26050. * @returns a Matrix
  26051. */
  26052. getWorldMatrix(): Matrix;
  26053. /** @hidden */
  26054. _getWorldMatrixDeterminant(): number;
  26055. /**
  26056. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26057. */
  26058. readonly isAnInstance: boolean;
  26059. /**
  26060. * Gets a boolean indicating if this mesh has instances
  26061. */
  26062. readonly hasInstances: boolean;
  26063. /**
  26064. * Perform relative position change from the point of view of behind the front of the mesh.
  26065. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26066. * Supports definition of mesh facing forward or backward
  26067. * @param amountRight defines the distance on the right axis
  26068. * @param amountUp defines the distance on the up axis
  26069. * @param amountForward defines the distance on the forward axis
  26070. * @returns the current mesh
  26071. */
  26072. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26073. /**
  26074. * Calculate relative position change from the point of view of behind the front of the mesh.
  26075. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26076. * Supports definition of mesh facing forward or backward
  26077. * @param amountRight defines the distance on the right axis
  26078. * @param amountUp defines the distance on the up axis
  26079. * @param amountForward defines the distance on the forward axis
  26080. * @returns the new displacement vector
  26081. */
  26082. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26083. /**
  26084. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26085. * Supports definition of mesh facing forward or backward
  26086. * @param flipBack defines the flip
  26087. * @param twirlClockwise defines the twirl
  26088. * @param tiltRight defines the tilt
  26089. * @returns the current mesh
  26090. */
  26091. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26092. /**
  26093. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26094. * Supports definition of mesh facing forward or backward.
  26095. * @param flipBack defines the flip
  26096. * @param twirlClockwise defines the twirl
  26097. * @param tiltRight defines the tilt
  26098. * @returns the new rotation vector
  26099. */
  26100. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26101. /**
  26102. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26103. * This means the mesh underlying bounding box and sphere are recomputed.
  26104. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26105. * @returns the current mesh
  26106. */
  26107. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26108. /** @hidden */
  26109. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26110. /** @hidden */
  26111. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26112. /** @hidden */
  26113. _updateBoundingInfo(): AbstractMesh;
  26114. /** @hidden */
  26115. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26116. /** @hidden */
  26117. protected _afterComputeWorldMatrix(): void;
  26118. /** @hidden */
  26119. readonly _effectiveMesh: AbstractMesh;
  26120. /**
  26121. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26122. * A mesh is in the frustum if its bounding box intersects the frustum
  26123. * @param frustumPlanes defines the frustum to test
  26124. * @returns true if the mesh is in the frustum planes
  26125. */
  26126. isInFrustum(frustumPlanes: Plane[]): boolean;
  26127. /**
  26128. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26129. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26130. * @param frustumPlanes defines the frustum to test
  26131. * @returns true if the mesh is completely in the frustum planes
  26132. */
  26133. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26134. /**
  26135. * True if the mesh intersects another mesh or a SolidParticle object
  26136. * @param mesh defines a target mesh or SolidParticle to test
  26137. * @param precise 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)
  26138. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26139. * @returns true if there is an intersection
  26140. */
  26141. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26142. /**
  26143. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26144. * @param point defines the point to test
  26145. * @returns true if there is an intersection
  26146. */
  26147. intersectsPoint(point: Vector3): boolean;
  26148. /**
  26149. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26150. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26151. */
  26152. checkCollisions: boolean;
  26153. /**
  26154. * Gets Collider object used to compute collisions (not physics)
  26155. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26156. */
  26157. readonly collider: Nullable<Collider>;
  26158. /**
  26159. * Move the mesh using collision engine
  26160. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26161. * @param displacement defines the requested displacement vector
  26162. * @returns the current mesh
  26163. */
  26164. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26165. private _onCollisionPositionChange;
  26166. /** @hidden */
  26167. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26168. /** @hidden */
  26169. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26170. /** @hidden */
  26171. _checkCollision(collider: Collider): AbstractMesh;
  26172. /** @hidden */
  26173. _generatePointsArray(): boolean;
  26174. /**
  26175. * Checks if the passed Ray intersects with the mesh
  26176. * @param ray defines the ray to use
  26177. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26178. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26179. * @returns the picking info
  26180. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26181. */
  26182. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26183. /**
  26184. * Clones the current mesh
  26185. * @param name defines the mesh name
  26186. * @param newParent defines the new mesh parent
  26187. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26188. * @returns the new mesh
  26189. */
  26190. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26191. /**
  26192. * Disposes all the submeshes of the current meshnp
  26193. * @returns the current mesh
  26194. */
  26195. releaseSubMeshes(): AbstractMesh;
  26196. /**
  26197. * Releases resources associated with this abstract mesh.
  26198. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26199. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26200. */
  26201. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26202. /**
  26203. * Adds the passed mesh as a child to the current mesh
  26204. * @param mesh defines the child mesh
  26205. * @returns the current mesh
  26206. */
  26207. addChild(mesh: AbstractMesh): AbstractMesh;
  26208. /**
  26209. * Removes the passed mesh from the current mesh children list
  26210. * @param mesh defines the child mesh
  26211. * @returns the current mesh
  26212. */
  26213. removeChild(mesh: AbstractMesh): AbstractMesh;
  26214. /** @hidden */
  26215. private _initFacetData;
  26216. /**
  26217. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26218. * This method can be called within the render loop.
  26219. * 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
  26220. * @returns the current mesh
  26221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26222. */
  26223. updateFacetData(): AbstractMesh;
  26224. /**
  26225. * Returns the facetLocalNormals array.
  26226. * The normals are expressed in the mesh local spac
  26227. * @returns an array of Vector3
  26228. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26229. */
  26230. getFacetLocalNormals(): Vector3[];
  26231. /**
  26232. * Returns the facetLocalPositions array.
  26233. * The facet positions are expressed in the mesh local space
  26234. * @returns an array of Vector3
  26235. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26236. */
  26237. getFacetLocalPositions(): Vector3[];
  26238. /**
  26239. * Returns the facetLocalPartioning array
  26240. * @returns an array of array of numbers
  26241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26242. */
  26243. getFacetLocalPartitioning(): number[][];
  26244. /**
  26245. * Returns the i-th facet position in the world system.
  26246. * This method allocates a new Vector3 per call
  26247. * @param i defines the facet index
  26248. * @returns a new Vector3
  26249. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26250. */
  26251. getFacetPosition(i: number): Vector3;
  26252. /**
  26253. * Sets the reference Vector3 with the i-th facet position in the world system
  26254. * @param i defines the facet index
  26255. * @param ref defines the target vector
  26256. * @returns the current mesh
  26257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26258. */
  26259. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26260. /**
  26261. * Returns the i-th facet normal in the world system.
  26262. * This method allocates a new Vector3 per call
  26263. * @param i defines the facet index
  26264. * @returns a new Vector3
  26265. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26266. */
  26267. getFacetNormal(i: number): Vector3;
  26268. /**
  26269. * Sets the reference Vector3 with the i-th facet normal in the world system
  26270. * @param i defines the facet index
  26271. * @param ref defines the target vector
  26272. * @returns the current mesh
  26273. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26274. */
  26275. getFacetNormalToRef(i: number, ref: Vector3): this;
  26276. /**
  26277. * 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)
  26278. * @param x defines x coordinate
  26279. * @param y defines y coordinate
  26280. * @param z defines z coordinate
  26281. * @returns the array of facet indexes
  26282. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26283. */
  26284. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26285. /**
  26286. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26287. * @param projected sets as the (x,y,z) world projection on the facet
  26288. * @param checkFace if 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
  26289. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. 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
  26290. * @param x defines x coordinate
  26291. * @param y defines y coordinate
  26292. * @param z defines z coordinate
  26293. * @returns the face index if found (or null instead)
  26294. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26295. */
  26296. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26297. /**
  26298. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26299. * @param projected sets as the (x,y,z) local projection on the facet
  26300. * @param checkFace if 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
  26301. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. 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
  26302. * @param x defines x coordinate
  26303. * @param y defines y coordinate
  26304. * @param z defines z coordinate
  26305. * @returns the face index if found (or null instead)
  26306. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26307. */
  26308. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26309. /**
  26310. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26311. * @returns the parameters
  26312. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26313. */
  26314. getFacetDataParameters(): any;
  26315. /**
  26316. * Disables the feature FacetData and frees the related memory
  26317. * @returns the current mesh
  26318. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26319. */
  26320. disableFacetData(): AbstractMesh;
  26321. /**
  26322. * Updates the AbstractMesh indices array
  26323. * @param indices defines the data source
  26324. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26325. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  26326. * @returns the current mesh
  26327. */
  26328. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26329. /**
  26330. * Creates new normals data for the mesh
  26331. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26332. * @returns the current mesh
  26333. */
  26334. createNormals(updatable: boolean): AbstractMesh;
  26335. /**
  26336. * Align the mesh with a normal
  26337. * @param normal defines the normal to use
  26338. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26339. * @returns the current mesh
  26340. */
  26341. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26342. /** @hidden */
  26343. _checkOcclusionQuery(): boolean;
  26344. /**
  26345. * Disables the mesh edge rendering mode
  26346. * @returns the currentAbstractMesh
  26347. */
  26348. disableEdgesRendering(): AbstractMesh;
  26349. /**
  26350. * Enables the edge rendering mode on the mesh.
  26351. * This mode makes the mesh edges visible
  26352. * @param epsilon defines the maximal distance between two angles to detect a face
  26353. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26354. * @returns the currentAbstractMesh
  26355. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26356. */
  26357. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26358. }
  26359. }
  26360. declare module BABYLON {
  26361. /**
  26362. * Interface used to define ActionEvent
  26363. */
  26364. export interface IActionEvent {
  26365. /** The mesh or sprite that triggered the action */
  26366. source: any;
  26367. /** The X mouse cursor position at the time of the event */
  26368. pointerX: number;
  26369. /** The Y mouse cursor position at the time of the event */
  26370. pointerY: number;
  26371. /** The mesh that is currently pointed at (can be null) */
  26372. meshUnderPointer: Nullable<AbstractMesh>;
  26373. /** the original (browser) event that triggered the ActionEvent */
  26374. sourceEvent?: any;
  26375. /** additional data for the event */
  26376. additionalData?: any;
  26377. }
  26378. /**
  26379. * ActionEvent is the event being sent when an action is triggered.
  26380. */
  26381. export class ActionEvent implements IActionEvent {
  26382. /** The mesh or sprite that triggered the action */
  26383. source: any;
  26384. /** The X mouse cursor position at the time of the event */
  26385. pointerX: number;
  26386. /** The Y mouse cursor position at the time of the event */
  26387. pointerY: number;
  26388. /** The mesh that is currently pointed at (can be null) */
  26389. meshUnderPointer: Nullable<AbstractMesh>;
  26390. /** the original (browser) event that triggered the ActionEvent */
  26391. sourceEvent?: any;
  26392. /** additional data for the event */
  26393. additionalData?: any;
  26394. /**
  26395. * Creates a new ActionEvent
  26396. * @param source The mesh or sprite that triggered the action
  26397. * @param pointerX The X mouse cursor position at the time of the event
  26398. * @param pointerY The Y mouse cursor position at the time of the event
  26399. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26400. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26401. * @param additionalData additional data for the event
  26402. */
  26403. constructor(
  26404. /** The mesh or sprite that triggered the action */
  26405. source: any,
  26406. /** The X mouse cursor position at the time of the event */
  26407. pointerX: number,
  26408. /** The Y mouse cursor position at the time of the event */
  26409. pointerY: number,
  26410. /** The mesh that is currently pointed at (can be null) */
  26411. meshUnderPointer: Nullable<AbstractMesh>,
  26412. /** the original (browser) event that triggered the ActionEvent */
  26413. sourceEvent?: any,
  26414. /** additional data for the event */
  26415. additionalData?: any);
  26416. /**
  26417. * Helper function to auto-create an ActionEvent from a source mesh.
  26418. * @param source The source mesh that triggered the event
  26419. * @param evt The original (browser) event
  26420. * @param additionalData additional data for the event
  26421. * @returns the new ActionEvent
  26422. */
  26423. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26424. /**
  26425. * Helper function to auto-create an ActionEvent from a source sprite
  26426. * @param source The source sprite that triggered the event
  26427. * @param scene Scene associated with the sprite
  26428. * @param evt The original (browser) event
  26429. * @param additionalData additional data for the event
  26430. * @returns the new ActionEvent
  26431. */
  26432. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26433. /**
  26434. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26435. * @param scene the scene where the event occurred
  26436. * @param evt The original (browser) event
  26437. * @returns the new ActionEvent
  26438. */
  26439. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26440. /**
  26441. * Helper function to auto-create an ActionEvent from a primitive
  26442. * @param prim defines the target primitive
  26443. * @param pointerPos defines the pointer position
  26444. * @param evt The original (browser) event
  26445. * @param additionalData additional data for the event
  26446. * @returns the new ActionEvent
  26447. */
  26448. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26449. }
  26450. }
  26451. declare module BABYLON {
  26452. /**
  26453. * Abstract class used to decouple action Manager from scene and meshes.
  26454. * Do not instantiate.
  26455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26456. */
  26457. export abstract class AbstractActionManager implements IDisposable {
  26458. /** Gets the list of active triggers */
  26459. static Triggers: {
  26460. [key: string]: number;
  26461. };
  26462. /** Gets the cursor to use when hovering items */
  26463. hoverCursor: string;
  26464. /** Gets the list of actions */
  26465. actions: IAction[];
  26466. /**
  26467. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26468. */
  26469. isRecursive: boolean;
  26470. /**
  26471. * Releases all associated resources
  26472. */
  26473. abstract dispose(): void;
  26474. /**
  26475. * Does this action manager has pointer triggers
  26476. */
  26477. abstract readonly hasPointerTriggers: boolean;
  26478. /**
  26479. * Does this action manager has pick triggers
  26480. */
  26481. abstract readonly hasPickTriggers: boolean;
  26482. /**
  26483. * Process a specific trigger
  26484. * @param trigger defines the trigger to process
  26485. * @param evt defines the event details to be processed
  26486. */
  26487. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26488. /**
  26489. * Does this action manager handles actions of any of the given triggers
  26490. * @param triggers defines the triggers to be tested
  26491. * @return a boolean indicating whether one (or more) of the triggers is handled
  26492. */
  26493. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26494. /**
  26495. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26496. * speed.
  26497. * @param triggerA defines the trigger to be tested
  26498. * @param triggerB defines the trigger to be tested
  26499. * @return a boolean indicating whether one (or more) of the triggers is handled
  26500. */
  26501. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26502. /**
  26503. * Does this action manager handles actions of a given trigger
  26504. * @param trigger defines the trigger to be tested
  26505. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26506. * @return whether the trigger is handled
  26507. */
  26508. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26509. /**
  26510. * Serialize this manager to a JSON object
  26511. * @param name defines the property name to store this manager
  26512. * @returns a JSON representation of this manager
  26513. */
  26514. abstract serialize(name: string): any;
  26515. /**
  26516. * Registers an action to this action manager
  26517. * @param action defines the action to be registered
  26518. * @return the action amended (prepared) after registration
  26519. */
  26520. abstract registerAction(action: IAction): Nullable<IAction>;
  26521. /**
  26522. * Unregisters an action to this action manager
  26523. * @param action defines the action to be unregistered
  26524. * @return a boolean indicating whether the action has been unregistered
  26525. */
  26526. abstract unregisterAction(action: IAction): Boolean;
  26527. /**
  26528. * Does exist one action manager with at least one trigger
  26529. **/
  26530. static readonly HasTriggers: boolean;
  26531. /**
  26532. * Does exist one action manager with at least one pick trigger
  26533. **/
  26534. static readonly HasPickTriggers: boolean;
  26535. /**
  26536. * Does exist one action manager that handles actions of a given trigger
  26537. * @param trigger defines the trigger to be tested
  26538. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26539. **/
  26540. static HasSpecificTrigger(trigger: number): boolean;
  26541. }
  26542. }
  26543. declare module BABYLON {
  26544. /**
  26545. * Defines how a node can be built from a string name.
  26546. */
  26547. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26548. /**
  26549. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26550. */
  26551. export class Node implements IBehaviorAware<Node> {
  26552. /** @hidden */
  26553. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26554. private static _NodeConstructors;
  26555. /**
  26556. * Add a new node constructor
  26557. * @param type defines the type name of the node to construct
  26558. * @param constructorFunc defines the constructor function
  26559. */
  26560. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26561. /**
  26562. * Returns a node constructor based on type name
  26563. * @param type defines the type name
  26564. * @param name defines the new node name
  26565. * @param scene defines the hosting scene
  26566. * @param options defines optional options to transmit to constructors
  26567. * @returns the new constructor or null
  26568. */
  26569. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26570. /**
  26571. * Gets or sets the name of the node
  26572. */
  26573. name: string;
  26574. /**
  26575. * Gets or sets the id of the node
  26576. */
  26577. id: string;
  26578. /**
  26579. * Gets or sets the unique id of the node
  26580. */
  26581. uniqueId: number;
  26582. /**
  26583. * Gets or sets a string used to store user defined state for the node
  26584. */
  26585. state: string;
  26586. /**
  26587. * Gets or sets an object used to store user defined information for the node
  26588. */
  26589. metadata: any;
  26590. /**
  26591. * For internal use only. Please do not use.
  26592. */
  26593. reservedDataStore: any;
  26594. /**
  26595. * List of inspectable custom properties (used by the Inspector)
  26596. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26597. */
  26598. inspectableCustomProperties: IInspectable[];
  26599. /**
  26600. * Gets or sets a boolean used to define if the node must be serialized
  26601. */
  26602. doNotSerialize: boolean;
  26603. /** @hidden */
  26604. _isDisposed: boolean;
  26605. /**
  26606. * Gets a list of Animations associated with the node
  26607. */
  26608. animations: Animation[];
  26609. protected _ranges: {
  26610. [name: string]: Nullable<AnimationRange>;
  26611. };
  26612. /**
  26613. * Callback raised when the node is ready to be used
  26614. */
  26615. onReady: Nullable<(node: Node) => void>;
  26616. private _isEnabled;
  26617. private _isParentEnabled;
  26618. private _isReady;
  26619. /** @hidden */
  26620. _currentRenderId: number;
  26621. private _parentUpdateId;
  26622. /** @hidden */
  26623. _childUpdateId: number;
  26624. /** @hidden */
  26625. _waitingParentId: Nullable<string>;
  26626. /** @hidden */
  26627. _scene: Scene;
  26628. /** @hidden */
  26629. _cache: any;
  26630. private _parentNode;
  26631. private _children;
  26632. /** @hidden */
  26633. _worldMatrix: Matrix;
  26634. /** @hidden */
  26635. _worldMatrixDeterminant: number;
  26636. /** @hidden */
  26637. _worldMatrixDeterminantIsDirty: boolean;
  26638. /** @hidden */
  26639. private _sceneRootNodesIndex;
  26640. /**
  26641. * Gets a boolean indicating if the node has been disposed
  26642. * @returns true if the node was disposed
  26643. */
  26644. isDisposed(): boolean;
  26645. /**
  26646. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26647. * @see https://doc.babylonjs.com/how_to/parenting
  26648. */
  26649. parent: Nullable<Node>;
  26650. private addToSceneRootNodes;
  26651. private removeFromSceneRootNodes;
  26652. private _animationPropertiesOverride;
  26653. /**
  26654. * Gets or sets the animation properties override
  26655. */
  26656. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26657. /**
  26658. * Gets a string idenfifying the name of the class
  26659. * @returns "Node" string
  26660. */
  26661. getClassName(): string;
  26662. /** @hidden */
  26663. readonly _isNode: boolean;
  26664. /**
  26665. * An event triggered when the mesh is disposed
  26666. */
  26667. onDisposeObservable: Observable<Node>;
  26668. private _onDisposeObserver;
  26669. /**
  26670. * Sets a callback that will be raised when the node will be disposed
  26671. */
  26672. onDispose: () => void;
  26673. /**
  26674. * Creates a new Node
  26675. * @param name the name and id to be given to this node
  26676. * @param scene the scene this node will be added to
  26677. * @param addToRootNodes the node will be added to scene.rootNodes
  26678. */
  26679. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26680. /**
  26681. * Gets the scene of the node
  26682. * @returns a scene
  26683. */
  26684. getScene(): Scene;
  26685. /**
  26686. * Gets the engine of the node
  26687. * @returns a Engine
  26688. */
  26689. getEngine(): Engine;
  26690. private _behaviors;
  26691. /**
  26692. * Attach a behavior to the node
  26693. * @see http://doc.babylonjs.com/features/behaviour
  26694. * @param behavior defines the behavior to attach
  26695. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26696. * @returns the current Node
  26697. */
  26698. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26699. /**
  26700. * Remove an attached behavior
  26701. * @see http://doc.babylonjs.com/features/behaviour
  26702. * @param behavior defines the behavior to attach
  26703. * @returns the current Node
  26704. */
  26705. removeBehavior(behavior: Behavior<Node>): Node;
  26706. /**
  26707. * Gets the list of attached behaviors
  26708. * @see http://doc.babylonjs.com/features/behaviour
  26709. */
  26710. readonly behaviors: Behavior<Node>[];
  26711. /**
  26712. * Gets an attached behavior by name
  26713. * @param name defines the name of the behavior to look for
  26714. * @see http://doc.babylonjs.com/features/behaviour
  26715. * @returns null if behavior was not found else the requested behavior
  26716. */
  26717. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26718. /**
  26719. * Returns the latest update of the World matrix
  26720. * @returns a Matrix
  26721. */
  26722. getWorldMatrix(): Matrix;
  26723. /** @hidden */
  26724. _getWorldMatrixDeterminant(): number;
  26725. /**
  26726. * Returns directly the latest state of the mesh World matrix.
  26727. * A Matrix is returned.
  26728. */
  26729. readonly worldMatrixFromCache: Matrix;
  26730. /** @hidden */
  26731. _initCache(): void;
  26732. /** @hidden */
  26733. updateCache(force?: boolean): void;
  26734. /** @hidden */
  26735. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26736. /** @hidden */
  26737. _updateCache(ignoreParentClass?: boolean): void;
  26738. /** @hidden */
  26739. _isSynchronized(): boolean;
  26740. /** @hidden */
  26741. _markSyncedWithParent(): void;
  26742. /** @hidden */
  26743. isSynchronizedWithParent(): boolean;
  26744. /** @hidden */
  26745. isSynchronized(): boolean;
  26746. /**
  26747. * Is this node ready to be used/rendered
  26748. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26749. * @return true if the node is ready
  26750. */
  26751. isReady(completeCheck?: boolean): boolean;
  26752. /**
  26753. * Is this node enabled?
  26754. * 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
  26755. * @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
  26756. * @return whether this node (and its parent) is enabled
  26757. */
  26758. isEnabled(checkAncestors?: boolean): boolean;
  26759. /** @hidden */
  26760. protected _syncParentEnabledState(): void;
  26761. /**
  26762. * Set the enabled state of this node
  26763. * @param value defines the new enabled state
  26764. */
  26765. setEnabled(value: boolean): void;
  26766. /**
  26767. * Is this node a descendant of the given node?
  26768. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26769. * @param ancestor defines the parent node to inspect
  26770. * @returns a boolean indicating if this node is a descendant of the given node
  26771. */
  26772. isDescendantOf(ancestor: Node): boolean;
  26773. /** @hidden */
  26774. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26775. /**
  26776. * Will return all nodes that have this node as ascendant
  26777. * @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
  26778. * @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
  26779. * @return all children nodes of all types
  26780. */
  26781. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26782. /**
  26783. * Get all child-meshes of this node
  26784. * @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 (Default: false)
  26785. * @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
  26786. * @returns an array of AbstractMesh
  26787. */
  26788. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26789. /**
  26790. * Get all direct children of this node
  26791. * @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
  26792. * @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 (Default: true)
  26793. * @returns an array of Node
  26794. */
  26795. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26796. /** @hidden */
  26797. _setReady(state: boolean): void;
  26798. /**
  26799. * Get an animation by name
  26800. * @param name defines the name of the animation to look for
  26801. * @returns null if not found else the requested animation
  26802. */
  26803. getAnimationByName(name: string): Nullable<Animation>;
  26804. /**
  26805. * Creates an animation range for this node
  26806. * @param name defines the name of the range
  26807. * @param from defines the starting key
  26808. * @param to defines the end key
  26809. */
  26810. createAnimationRange(name: string, from: number, to: number): void;
  26811. /**
  26812. * Delete a specific animation range
  26813. * @param name defines the name of the range to delete
  26814. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26815. */
  26816. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26817. /**
  26818. * Get an animation range by name
  26819. * @param name defines the name of the animation range to look for
  26820. * @returns null if not found else the requested animation range
  26821. */
  26822. getAnimationRange(name: string): Nullable<AnimationRange>;
  26823. /**
  26824. * Gets the list of all animation ranges defined on this node
  26825. * @returns an array
  26826. */
  26827. getAnimationRanges(): Nullable<AnimationRange>[];
  26828. /**
  26829. * Will start the animation sequence
  26830. * @param name defines the range frames for animation sequence
  26831. * @param loop defines if the animation should loop (false by default)
  26832. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26833. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26834. * @returns the object created for this animation. If range does not exist, it will return null
  26835. */
  26836. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26837. /**
  26838. * Serialize animation ranges into a JSON compatible object
  26839. * @returns serialization object
  26840. */
  26841. serializeAnimationRanges(): any;
  26842. /**
  26843. * Computes the world matrix of the node
  26844. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26845. * @returns the world matrix
  26846. */
  26847. computeWorldMatrix(force?: boolean): Matrix;
  26848. /**
  26849. * Releases resources associated with this node.
  26850. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26851. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26852. */
  26853. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26854. /**
  26855. * Parse animation range data from a serialization object and store them into a given node
  26856. * @param node defines where to store the animation ranges
  26857. * @param parsedNode defines the serialization object to read data from
  26858. * @param scene defines the hosting scene
  26859. */
  26860. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26861. /**
  26862. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26863. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26864. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  26865. * @returns the new bounding vectors
  26866. */
  26867. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26868. min: Vector3;
  26869. max: Vector3;
  26870. };
  26871. }
  26872. }
  26873. declare module BABYLON {
  26874. /**
  26875. * @hidden
  26876. */
  26877. export class _IAnimationState {
  26878. key: number;
  26879. repeatCount: number;
  26880. workValue?: any;
  26881. loopMode?: number;
  26882. offsetValue?: any;
  26883. highLimitValue?: any;
  26884. }
  26885. /**
  26886. * Class used to store any kind of animation
  26887. */
  26888. export class Animation {
  26889. /**Name of the animation */
  26890. name: string;
  26891. /**Property to animate */
  26892. targetProperty: string;
  26893. /**The frames per second of the animation */
  26894. framePerSecond: number;
  26895. /**The data type of the animation */
  26896. dataType: number;
  26897. /**The loop mode of the animation */
  26898. loopMode?: number | undefined;
  26899. /**Specifies if blending should be enabled */
  26900. enableBlending?: boolean | undefined;
  26901. /**
  26902. * Use matrix interpolation instead of using direct key value when animating matrices
  26903. */
  26904. static AllowMatricesInterpolation: boolean;
  26905. /**
  26906. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26907. */
  26908. static AllowMatrixDecomposeForInterpolation: boolean;
  26909. /**
  26910. * Stores the key frames of the animation
  26911. */
  26912. private _keys;
  26913. /**
  26914. * Stores the easing function of the animation
  26915. */
  26916. private _easingFunction;
  26917. /**
  26918. * @hidden Internal use only
  26919. */
  26920. _runtimeAnimations: RuntimeAnimation[];
  26921. /**
  26922. * The set of event that will be linked to this animation
  26923. */
  26924. private _events;
  26925. /**
  26926. * Stores an array of target property paths
  26927. */
  26928. targetPropertyPath: string[];
  26929. /**
  26930. * Stores the blending speed of the animation
  26931. */
  26932. blendingSpeed: number;
  26933. /**
  26934. * Stores the animation ranges for the animation
  26935. */
  26936. private _ranges;
  26937. /**
  26938. * @hidden Internal use
  26939. */
  26940. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26941. /**
  26942. * Sets up an animation
  26943. * @param property The property to animate
  26944. * @param animationType The animation type to apply
  26945. * @param framePerSecond The frames per second of the animation
  26946. * @param easingFunction The easing function used in the animation
  26947. * @returns The created animation
  26948. */
  26949. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26950. /**
  26951. * Create and start an animation on a node
  26952. * @param name defines the name of the global animation that will be run on all nodes
  26953. * @param node defines the root node where the animation will take place
  26954. * @param targetProperty defines property to animate
  26955. * @param framePerSecond defines the number of frame per second yo use
  26956. * @param totalFrame defines the number of frames in total
  26957. * @param from defines the initial value
  26958. * @param to defines the final value
  26959. * @param loopMode defines which loop mode you want to use (off by default)
  26960. * @param easingFunction defines the easing function to use (linear by default)
  26961. * @param onAnimationEnd defines the callback to call when animation end
  26962. * @returns the animatable created for this animation
  26963. */
  26964. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26965. /**
  26966. * Create and start an animation on a node and its descendants
  26967. * @param name defines the name of the global animation that will be run on all nodes
  26968. * @param node defines the root node where the animation will take place
  26969. * @param 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
  26970. * @param targetProperty defines property to animate
  26971. * @param framePerSecond defines the number of frame per second to use
  26972. * @param totalFrame defines the number of frames in total
  26973. * @param from defines the initial value
  26974. * @param to defines the final value
  26975. * @param loopMode defines which loop mode you want to use (off by default)
  26976. * @param easingFunction defines the easing function to use (linear by default)
  26977. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26978. * @returns the list of animatables created for all nodes
  26979. * @example https://www.babylonjs-playground.com/#MH0VLI
  26980. */
  26981. 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[]>;
  26982. /**
  26983. * Creates a new animation, merges it with the existing animations and starts it
  26984. * @param name Name of the animation
  26985. * @param node Node which contains the scene that begins the animations
  26986. * @param targetProperty Specifies which property to animate
  26987. * @param framePerSecond The frames per second of the animation
  26988. * @param totalFrame The total number of frames
  26989. * @param from The frame at the beginning of the animation
  26990. * @param to The frame at the end of the animation
  26991. * @param loopMode Specifies the loop mode of the animation
  26992. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26993. * @param onAnimationEnd Callback to run once the animation is complete
  26994. * @returns Nullable animation
  26995. */
  26996. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26997. /**
  26998. * Transition property of an host to the target Value
  26999. * @param property The property to transition
  27000. * @param targetValue The target Value of the property
  27001. * @param host The object where the property to animate belongs
  27002. * @param scene Scene used to run the animation
  27003. * @param frameRate Framerate (in frame/s) to use
  27004. * @param transition The transition type we want to use
  27005. * @param duration The duration of the animation, in milliseconds
  27006. * @param onAnimationEnd Callback trigger at the end of the animation
  27007. * @returns Nullable animation
  27008. */
  27009. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27010. /**
  27011. * Return the array of runtime animations currently using this animation
  27012. */
  27013. readonly runtimeAnimations: RuntimeAnimation[];
  27014. /**
  27015. * Specifies if any of the runtime animations are currently running
  27016. */
  27017. readonly hasRunningRuntimeAnimations: boolean;
  27018. /**
  27019. * Initializes the animation
  27020. * @param name Name of the animation
  27021. * @param targetProperty Property to animate
  27022. * @param framePerSecond The frames per second of the animation
  27023. * @param dataType The data type of the animation
  27024. * @param loopMode The loop mode of the animation
  27025. * @param enableBlending Specifies if blending should be enabled
  27026. */
  27027. constructor(
  27028. /**Name of the animation */
  27029. name: string,
  27030. /**Property to animate */
  27031. targetProperty: string,
  27032. /**The frames per second of the animation */
  27033. framePerSecond: number,
  27034. /**The data type of the animation */
  27035. dataType: number,
  27036. /**The loop mode of the animation */
  27037. loopMode?: number | undefined,
  27038. /**Specifies if blending should be enabled */
  27039. enableBlending?: boolean | undefined);
  27040. /**
  27041. * Converts the animation to a string
  27042. * @param fullDetails support for multiple levels of logging within scene loading
  27043. * @returns String form of the animation
  27044. */
  27045. toString(fullDetails?: boolean): string;
  27046. /**
  27047. * Add an event to this animation
  27048. * @param event Event to add
  27049. */
  27050. addEvent(event: AnimationEvent): void;
  27051. /**
  27052. * Remove all events found at the given frame
  27053. * @param frame The frame to remove events from
  27054. */
  27055. removeEvents(frame: number): void;
  27056. /**
  27057. * Retrieves all the events from the animation
  27058. * @returns Events from the animation
  27059. */
  27060. getEvents(): AnimationEvent[];
  27061. /**
  27062. * Creates an animation range
  27063. * @param name Name of the animation range
  27064. * @param from Starting frame of the animation range
  27065. * @param to Ending frame of the animation
  27066. */
  27067. createRange(name: string, from: number, to: number): void;
  27068. /**
  27069. * Deletes an animation range by name
  27070. * @param name Name of the animation range to delete
  27071. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27072. */
  27073. deleteRange(name: string, deleteFrames?: boolean): void;
  27074. /**
  27075. * Gets the animation range by name, or null if not defined
  27076. * @param name Name of the animation range
  27077. * @returns Nullable animation range
  27078. */
  27079. getRange(name: string): Nullable<AnimationRange>;
  27080. /**
  27081. * Gets the key frames from the animation
  27082. * @returns The key frames of the animation
  27083. */
  27084. getKeys(): Array<IAnimationKey>;
  27085. /**
  27086. * Gets the highest frame rate of the animation
  27087. * @returns Highest frame rate of the animation
  27088. */
  27089. getHighestFrame(): number;
  27090. /**
  27091. * Gets the easing function of the animation
  27092. * @returns Easing function of the animation
  27093. */
  27094. getEasingFunction(): IEasingFunction;
  27095. /**
  27096. * Sets the easing function of the animation
  27097. * @param easingFunction A custom mathematical formula for animation
  27098. */
  27099. setEasingFunction(easingFunction: EasingFunction): void;
  27100. /**
  27101. * Interpolates a scalar linearly
  27102. * @param startValue Start value of the animation curve
  27103. * @param endValue End value of the animation curve
  27104. * @param gradient Scalar amount to interpolate
  27105. * @returns Interpolated scalar value
  27106. */
  27107. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27108. /**
  27109. * Interpolates a scalar cubically
  27110. * @param startValue Start value of the animation curve
  27111. * @param outTangent End tangent of the animation
  27112. * @param endValue End value of the animation curve
  27113. * @param inTangent Start tangent of the animation curve
  27114. * @param gradient Scalar amount to interpolate
  27115. * @returns Interpolated scalar value
  27116. */
  27117. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27118. /**
  27119. * Interpolates a quaternion using a spherical linear interpolation
  27120. * @param startValue Start value of the animation curve
  27121. * @param endValue End value of the animation curve
  27122. * @param gradient Scalar amount to interpolate
  27123. * @returns Interpolated quaternion value
  27124. */
  27125. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27126. /**
  27127. * Interpolates a quaternion cubically
  27128. * @param startValue Start value of the animation curve
  27129. * @param outTangent End tangent of the animation curve
  27130. * @param endValue End value of the animation curve
  27131. * @param inTangent Start tangent of the animation curve
  27132. * @param gradient Scalar amount to interpolate
  27133. * @returns Interpolated quaternion value
  27134. */
  27135. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27136. /**
  27137. * Interpolates a Vector3 linearl
  27138. * @param startValue Start value of the animation curve
  27139. * @param endValue End value of the animation curve
  27140. * @param gradient Scalar amount to interpolate
  27141. * @returns Interpolated scalar value
  27142. */
  27143. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27144. /**
  27145. * Interpolates a Vector3 cubically
  27146. * @param startValue Start value of the animation curve
  27147. * @param outTangent End tangent of the animation
  27148. * @param endValue End value of the animation curve
  27149. * @param inTangent Start tangent of the animation curve
  27150. * @param gradient Scalar amount to interpolate
  27151. * @returns InterpolatedVector3 value
  27152. */
  27153. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27154. /**
  27155. * Interpolates a Vector2 linearly
  27156. * @param startValue Start value of the animation curve
  27157. * @param endValue End value of the animation curve
  27158. * @param gradient Scalar amount to interpolate
  27159. * @returns Interpolated Vector2 value
  27160. */
  27161. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27162. /**
  27163. * Interpolates a Vector2 cubically
  27164. * @param startValue Start value of the animation curve
  27165. * @param outTangent End tangent of the animation
  27166. * @param endValue End value of the animation curve
  27167. * @param inTangent Start tangent of the animation curve
  27168. * @param gradient Scalar amount to interpolate
  27169. * @returns Interpolated Vector2 value
  27170. */
  27171. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27172. /**
  27173. * Interpolates a size linearly
  27174. * @param startValue Start value of the animation curve
  27175. * @param endValue End value of the animation curve
  27176. * @param gradient Scalar amount to interpolate
  27177. * @returns Interpolated Size value
  27178. */
  27179. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27180. /**
  27181. * Interpolates a Color3 linearly
  27182. * @param startValue Start value of the animation curve
  27183. * @param endValue End value of the animation curve
  27184. * @param gradient Scalar amount to interpolate
  27185. * @returns Interpolated Color3 value
  27186. */
  27187. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27188. /**
  27189. * @hidden Internal use only
  27190. */
  27191. _getKeyValue(value: any): any;
  27192. /**
  27193. * @hidden Internal use only
  27194. */
  27195. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27196. /**
  27197. * Defines the function to use to interpolate matrices
  27198. * @param startValue defines the start matrix
  27199. * @param endValue defines the end matrix
  27200. * @param gradient defines the gradient between both matrices
  27201. * @param result defines an optional target matrix where to store the interpolation
  27202. * @returns the interpolated matrix
  27203. */
  27204. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27205. /**
  27206. * Makes a copy of the animation
  27207. * @returns Cloned animation
  27208. */
  27209. clone(): Animation;
  27210. /**
  27211. * Sets the key frames of the animation
  27212. * @param values The animation key frames to set
  27213. */
  27214. setKeys(values: Array<IAnimationKey>): void;
  27215. /**
  27216. * Serializes the animation to an object
  27217. * @returns Serialized object
  27218. */
  27219. serialize(): any;
  27220. /**
  27221. * Float animation type
  27222. */
  27223. private static _ANIMATIONTYPE_FLOAT;
  27224. /**
  27225. * Vector3 animation type
  27226. */
  27227. private static _ANIMATIONTYPE_VECTOR3;
  27228. /**
  27229. * Quaternion animation type
  27230. */
  27231. private static _ANIMATIONTYPE_QUATERNION;
  27232. /**
  27233. * Matrix animation type
  27234. */
  27235. private static _ANIMATIONTYPE_MATRIX;
  27236. /**
  27237. * Color3 animation type
  27238. */
  27239. private static _ANIMATIONTYPE_COLOR3;
  27240. /**
  27241. * Vector2 animation type
  27242. */
  27243. private static _ANIMATIONTYPE_VECTOR2;
  27244. /**
  27245. * Size animation type
  27246. */
  27247. private static _ANIMATIONTYPE_SIZE;
  27248. /**
  27249. * Relative Loop Mode
  27250. */
  27251. private static _ANIMATIONLOOPMODE_RELATIVE;
  27252. /**
  27253. * Cycle Loop Mode
  27254. */
  27255. private static _ANIMATIONLOOPMODE_CYCLE;
  27256. /**
  27257. * Constant Loop Mode
  27258. */
  27259. private static _ANIMATIONLOOPMODE_CONSTANT;
  27260. /**
  27261. * Get the float animation type
  27262. */
  27263. static readonly ANIMATIONTYPE_FLOAT: number;
  27264. /**
  27265. * Get the Vector3 animation type
  27266. */
  27267. static readonly ANIMATIONTYPE_VECTOR3: number;
  27268. /**
  27269. * Get the Vector2 animation type
  27270. */
  27271. static readonly ANIMATIONTYPE_VECTOR2: number;
  27272. /**
  27273. * Get the Size animation type
  27274. */
  27275. static readonly ANIMATIONTYPE_SIZE: number;
  27276. /**
  27277. * Get the Quaternion animation type
  27278. */
  27279. static readonly ANIMATIONTYPE_QUATERNION: number;
  27280. /**
  27281. * Get the Matrix animation type
  27282. */
  27283. static readonly ANIMATIONTYPE_MATRIX: number;
  27284. /**
  27285. * Get the Color3 animation type
  27286. */
  27287. static readonly ANIMATIONTYPE_COLOR3: number;
  27288. /**
  27289. * Get the Relative Loop Mode
  27290. */
  27291. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27292. /**
  27293. * Get the Cycle Loop Mode
  27294. */
  27295. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27296. /**
  27297. * Get the Constant Loop Mode
  27298. */
  27299. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27300. /** @hidden */
  27301. static _UniversalLerp(left: any, right: any, amount: number): any;
  27302. /**
  27303. * Parses an animation object and creates an animation
  27304. * @param parsedAnimation Parsed animation object
  27305. * @returns Animation object
  27306. */
  27307. static Parse(parsedAnimation: any): Animation;
  27308. /**
  27309. * Appends the serialized animations from the source animations
  27310. * @param source Source containing the animations
  27311. * @param destination Target to store the animations
  27312. */
  27313. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27314. }
  27315. }
  27316. declare module BABYLON {
  27317. /**
  27318. * Interface containing an array of animations
  27319. */
  27320. export interface IAnimatable {
  27321. /**
  27322. * Array of animations
  27323. */
  27324. animations: Nullable<Array<Animation>>;
  27325. }
  27326. }
  27327. declare module BABYLON {
  27328. /**
  27329. * This represents all the required information to add a fresnel effect on a material:
  27330. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27331. */
  27332. export class FresnelParameters {
  27333. private _isEnabled;
  27334. /**
  27335. * Define if the fresnel effect is enable or not.
  27336. */
  27337. isEnabled: boolean;
  27338. /**
  27339. * Define the color used on edges (grazing angle)
  27340. */
  27341. leftColor: Color3;
  27342. /**
  27343. * Define the color used on center
  27344. */
  27345. rightColor: Color3;
  27346. /**
  27347. * Define bias applied to computed fresnel term
  27348. */
  27349. bias: number;
  27350. /**
  27351. * Defined the power exponent applied to fresnel term
  27352. */
  27353. power: number;
  27354. /**
  27355. * Clones the current fresnel and its valuues
  27356. * @returns a clone fresnel configuration
  27357. */
  27358. clone(): FresnelParameters;
  27359. /**
  27360. * Serializes the current fresnel parameters to a JSON representation.
  27361. * @return the JSON serialization
  27362. */
  27363. serialize(): any;
  27364. /**
  27365. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27366. * @param parsedFresnelParameters Define the JSON representation
  27367. * @returns the parsed parameters
  27368. */
  27369. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27370. }
  27371. }
  27372. declare module BABYLON {
  27373. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27374. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27375. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27376. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27377. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27378. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27379. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27380. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27381. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27382. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27383. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27384. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27385. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27386. /**
  27387. * Decorator used to define property that can be serialized as reference to a camera
  27388. * @param sourceName defines the name of the property to decorate
  27389. */
  27390. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27391. /**
  27392. * Class used to help serialization objects
  27393. */
  27394. export class SerializationHelper {
  27395. /** @hidden */
  27396. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27397. /** @hidden */
  27398. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27399. /** @hidden */
  27400. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27401. /** @hidden */
  27402. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27403. /**
  27404. * Appends the serialized animations from the source animations
  27405. * @param source Source containing the animations
  27406. * @param destination Target to store the animations
  27407. */
  27408. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27409. /**
  27410. * Static function used to serialized a specific entity
  27411. * @param entity defines the entity to serialize
  27412. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27413. * @returns a JSON compatible object representing the serialization of the entity
  27414. */
  27415. static Serialize<T>(entity: T, serializationObject?: any): any;
  27416. /**
  27417. * Creates a new entity from a serialization data object
  27418. * @param creationFunction defines a function used to instanciated the new entity
  27419. * @param source defines the source serialization data
  27420. * @param scene defines the hosting scene
  27421. * @param rootUrl defines the root url for resources
  27422. * @returns a new entity
  27423. */
  27424. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27425. /**
  27426. * Clones an object
  27427. * @param creationFunction defines the function used to instanciate the new object
  27428. * @param source defines the source object
  27429. * @returns the cloned object
  27430. */
  27431. static Clone<T>(creationFunction: () => T, source: T): T;
  27432. /**
  27433. * Instanciates a new object based on a source one (some data will be shared between both object)
  27434. * @param creationFunction defines the function used to instanciate the new object
  27435. * @param source defines the source object
  27436. * @returns the new object
  27437. */
  27438. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27439. }
  27440. }
  27441. declare module BABYLON {
  27442. /**
  27443. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27444. */
  27445. export interface CubeMapInfo {
  27446. /**
  27447. * The pixel array for the front face.
  27448. * This is stored in format, left to right, up to down format.
  27449. */
  27450. front: Nullable<ArrayBufferView>;
  27451. /**
  27452. * The pixel array for the back face.
  27453. * This is stored in format, left to right, up to down format.
  27454. */
  27455. back: Nullable<ArrayBufferView>;
  27456. /**
  27457. * The pixel array for the left face.
  27458. * This is stored in format, left to right, up to down format.
  27459. */
  27460. left: Nullable<ArrayBufferView>;
  27461. /**
  27462. * The pixel array for the right face.
  27463. * This is stored in format, left to right, up to down format.
  27464. */
  27465. right: Nullable<ArrayBufferView>;
  27466. /**
  27467. * The pixel array for the up face.
  27468. * This is stored in format, left to right, up to down format.
  27469. */
  27470. up: Nullable<ArrayBufferView>;
  27471. /**
  27472. * The pixel array for the down face.
  27473. * This is stored in format, left to right, up to down format.
  27474. */
  27475. down: Nullable<ArrayBufferView>;
  27476. /**
  27477. * The size of the cubemap stored.
  27478. *
  27479. * Each faces will be size * size pixels.
  27480. */
  27481. size: number;
  27482. /**
  27483. * The format of the texture.
  27484. *
  27485. * RGBA, RGB.
  27486. */
  27487. format: number;
  27488. /**
  27489. * The type of the texture data.
  27490. *
  27491. * UNSIGNED_INT, FLOAT.
  27492. */
  27493. type: number;
  27494. /**
  27495. * Specifies whether the texture is in gamma space.
  27496. */
  27497. gammaSpace: boolean;
  27498. }
  27499. /**
  27500. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27501. */
  27502. export class PanoramaToCubeMapTools {
  27503. private static FACE_FRONT;
  27504. private static FACE_BACK;
  27505. private static FACE_RIGHT;
  27506. private static FACE_LEFT;
  27507. private static FACE_DOWN;
  27508. private static FACE_UP;
  27509. /**
  27510. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27511. *
  27512. * @param float32Array The source data.
  27513. * @param inputWidth The width of the input panorama.
  27514. * @param inputHeight The height of the input panorama.
  27515. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27516. * @return The cubemap data
  27517. */
  27518. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27519. private static CreateCubemapTexture;
  27520. private static CalcProjectionSpherical;
  27521. }
  27522. }
  27523. declare module BABYLON {
  27524. /**
  27525. * Helper class dealing with the extraction of spherical polynomial dataArray
  27526. * from a cube map.
  27527. */
  27528. export class CubeMapToSphericalPolynomialTools {
  27529. private static FileFaces;
  27530. /**
  27531. * Converts a texture to the according Spherical Polynomial data.
  27532. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27533. *
  27534. * @param texture The texture to extract the information from.
  27535. * @return The Spherical Polynomial data.
  27536. */
  27537. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27538. /**
  27539. * Converts a cubemap to the according Spherical Polynomial data.
  27540. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27541. *
  27542. * @param cubeInfo The Cube map to extract the information from.
  27543. * @return The Spherical Polynomial data.
  27544. */
  27545. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27546. }
  27547. }
  27548. declare module BABYLON {
  27549. /**
  27550. * Class used to manipulate GUIDs
  27551. */
  27552. export class GUID {
  27553. /**
  27554. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27555. * Be aware Math.random() could cause collisions, but:
  27556. * "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"
  27557. * @returns a pseudo random id
  27558. */
  27559. static RandomId(): string;
  27560. }
  27561. }
  27562. declare module BABYLON {
  27563. /**
  27564. * Base class of all the textures in babylon.
  27565. * It groups all the common properties the materials, post process, lights... might need
  27566. * in order to make a correct use of the texture.
  27567. */
  27568. export class BaseTexture implements IAnimatable {
  27569. /**
  27570. * Default anisotropic filtering level for the application.
  27571. * It is set to 4 as a good tradeoff between perf and quality.
  27572. */
  27573. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27574. /**
  27575. * Gets or sets the unique id of the texture
  27576. */
  27577. uniqueId: number;
  27578. /**
  27579. * Define the name of the texture.
  27580. */
  27581. name: string;
  27582. /**
  27583. * Gets or sets an object used to store user defined information.
  27584. */
  27585. metadata: any;
  27586. /**
  27587. * For internal use only. Please do not use.
  27588. */
  27589. reservedDataStore: any;
  27590. private _hasAlpha;
  27591. /**
  27592. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27593. */
  27594. hasAlpha: boolean;
  27595. /**
  27596. * Defines if the alpha value should be determined via the rgb values.
  27597. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27598. */
  27599. getAlphaFromRGB: boolean;
  27600. /**
  27601. * Intensity or strength of the texture.
  27602. * It is commonly used by materials to fine tune the intensity of the texture
  27603. */
  27604. level: number;
  27605. /**
  27606. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27607. * This is part of the texture as textures usually maps to one uv set.
  27608. */
  27609. coordinatesIndex: number;
  27610. private _coordinatesMode;
  27611. /**
  27612. * How a texture is mapped.
  27613. *
  27614. * | Value | Type | Description |
  27615. * | ----- | ----------------------------------- | ----------- |
  27616. * | 0 | EXPLICIT_MODE | |
  27617. * | 1 | SPHERICAL_MODE | |
  27618. * | 2 | PLANAR_MODE | |
  27619. * | 3 | CUBIC_MODE | |
  27620. * | 4 | PROJECTION_MODE | |
  27621. * | 5 | SKYBOX_MODE | |
  27622. * | 6 | INVCUBIC_MODE | |
  27623. * | 7 | EQUIRECTANGULAR_MODE | |
  27624. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27625. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27626. */
  27627. coordinatesMode: number;
  27628. /**
  27629. * | Value | Type | Description |
  27630. * | ----- | ------------------ | ----------- |
  27631. * | 0 | CLAMP_ADDRESSMODE | |
  27632. * | 1 | WRAP_ADDRESSMODE | |
  27633. * | 2 | MIRROR_ADDRESSMODE | |
  27634. */
  27635. wrapU: number;
  27636. /**
  27637. * | Value | Type | Description |
  27638. * | ----- | ------------------ | ----------- |
  27639. * | 0 | CLAMP_ADDRESSMODE | |
  27640. * | 1 | WRAP_ADDRESSMODE | |
  27641. * | 2 | MIRROR_ADDRESSMODE | |
  27642. */
  27643. wrapV: number;
  27644. /**
  27645. * | Value | Type | Description |
  27646. * | ----- | ------------------ | ----------- |
  27647. * | 0 | CLAMP_ADDRESSMODE | |
  27648. * | 1 | WRAP_ADDRESSMODE | |
  27649. * | 2 | MIRROR_ADDRESSMODE | |
  27650. */
  27651. wrapR: number;
  27652. /**
  27653. * With compliant hardware and browser (supporting anisotropic filtering)
  27654. * this defines the level of anisotropic filtering in the texture.
  27655. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27656. */
  27657. anisotropicFilteringLevel: number;
  27658. /**
  27659. * Define if the texture is a cube texture or if false a 2d texture.
  27660. */
  27661. isCube: boolean;
  27662. /**
  27663. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27664. */
  27665. is3D: boolean;
  27666. /**
  27667. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27668. * HDR texture are usually stored in linear space.
  27669. * This only impacts the PBR and Background materials
  27670. */
  27671. gammaSpace: boolean;
  27672. /**
  27673. * Gets whether or not the texture contains RGBD data.
  27674. */
  27675. readonly isRGBD: boolean;
  27676. /**
  27677. * Is Z inverted in the texture (useful in a cube texture).
  27678. */
  27679. invertZ: boolean;
  27680. /**
  27681. * Are mip maps generated for this texture or not.
  27682. */
  27683. readonly noMipmap: boolean;
  27684. /**
  27685. * @hidden
  27686. */
  27687. lodLevelInAlpha: boolean;
  27688. /**
  27689. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27690. */
  27691. lodGenerationOffset: number;
  27692. /**
  27693. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27694. */
  27695. lodGenerationScale: number;
  27696. /**
  27697. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27698. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27699. * average roughness values.
  27700. */
  27701. linearSpecularLOD: boolean;
  27702. /**
  27703. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27704. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27705. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27706. */
  27707. irradianceTexture: Nullable<BaseTexture>;
  27708. /**
  27709. * Define if the texture is a render target.
  27710. */
  27711. isRenderTarget: boolean;
  27712. /**
  27713. * Define the unique id of the texture in the scene.
  27714. */
  27715. readonly uid: string;
  27716. /**
  27717. * Return a string representation of the texture.
  27718. * @returns the texture as a string
  27719. */
  27720. toString(): string;
  27721. /**
  27722. * Get the class name of the texture.
  27723. * @returns "BaseTexture"
  27724. */
  27725. getClassName(): string;
  27726. /**
  27727. * Define the list of animation attached to the texture.
  27728. */
  27729. animations: Animation[];
  27730. /**
  27731. * An event triggered when the texture is disposed.
  27732. */
  27733. onDisposeObservable: Observable<BaseTexture>;
  27734. private _onDisposeObserver;
  27735. /**
  27736. * Callback triggered when the texture has been disposed.
  27737. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27738. */
  27739. onDispose: () => void;
  27740. /**
  27741. * Define the current state of the loading sequence when in delayed load mode.
  27742. */
  27743. delayLoadState: number;
  27744. private _scene;
  27745. /** @hidden */
  27746. _texture: Nullable<InternalTexture>;
  27747. private _uid;
  27748. /**
  27749. * Define if the texture is preventinga material to render or not.
  27750. * If not and the texture is not ready, the engine will use a default black texture instead.
  27751. */
  27752. readonly isBlocking: boolean;
  27753. /**
  27754. * Instantiates a new BaseTexture.
  27755. * Base class of all the textures in babylon.
  27756. * It groups all the common properties the materials, post process, lights... might need
  27757. * in order to make a correct use of the texture.
  27758. * @param scene Define the scene the texture blongs to
  27759. */
  27760. constructor(scene: Nullable<Scene>);
  27761. /**
  27762. * Get the scene the texture belongs to.
  27763. * @returns the scene or null if undefined
  27764. */
  27765. getScene(): Nullable<Scene>;
  27766. /**
  27767. * Get the texture transform matrix used to offset tile the texture for istance.
  27768. * @returns the transformation matrix
  27769. */
  27770. getTextureMatrix(): Matrix;
  27771. /**
  27772. * Get the texture reflection matrix used to rotate/transform the reflection.
  27773. * @returns the reflection matrix
  27774. */
  27775. getReflectionTextureMatrix(): Matrix;
  27776. /**
  27777. * Get the underlying lower level texture from Babylon.
  27778. * @returns the insternal texture
  27779. */
  27780. getInternalTexture(): Nullable<InternalTexture>;
  27781. /**
  27782. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27783. * @returns true if ready or not blocking
  27784. */
  27785. isReadyOrNotBlocking(): boolean;
  27786. /**
  27787. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27788. * @returns true if fully ready
  27789. */
  27790. isReady(): boolean;
  27791. private _cachedSize;
  27792. /**
  27793. * Get the size of the texture.
  27794. * @returns the texture size.
  27795. */
  27796. getSize(): ISize;
  27797. /**
  27798. * Get the base size of the texture.
  27799. * It can be different from the size if the texture has been resized for POT for instance
  27800. * @returns the base size
  27801. */
  27802. getBaseSize(): ISize;
  27803. /**
  27804. * Update the sampling mode of the texture.
  27805. * Default is Trilinear mode.
  27806. *
  27807. * | Value | Type | Description |
  27808. * | ----- | ------------------ | ----------- |
  27809. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27810. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27811. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27812. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27813. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27814. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27815. * | 7 | NEAREST_LINEAR | |
  27816. * | 8 | NEAREST_NEAREST | |
  27817. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27818. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27819. * | 11 | LINEAR_LINEAR | |
  27820. * | 12 | LINEAR_NEAREST | |
  27821. *
  27822. * > _mag_: magnification filter (close to the viewer)
  27823. * > _min_: minification filter (far from the viewer)
  27824. * > _mip_: filter used between mip map levels
  27825. *@param samplingMode Define the new sampling mode of the texture
  27826. */
  27827. updateSamplingMode(samplingMode: number): void;
  27828. /**
  27829. * Scales the texture if is `canRescale()`
  27830. * @param ratio the resize factor we want to use to rescale
  27831. */
  27832. scale(ratio: number): void;
  27833. /**
  27834. * Get if the texture can rescale.
  27835. */
  27836. readonly canRescale: boolean;
  27837. /** @hidden */
  27838. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27839. /** @hidden */
  27840. _rebuild(): void;
  27841. /**
  27842. * Triggers the load sequence in delayed load mode.
  27843. */
  27844. delayLoad(): void;
  27845. /**
  27846. * Clones the texture.
  27847. * @returns the cloned texture
  27848. */
  27849. clone(): Nullable<BaseTexture>;
  27850. /**
  27851. * Get the texture underlying type (INT, FLOAT...)
  27852. */
  27853. readonly textureType: number;
  27854. /**
  27855. * Get the texture underlying format (RGB, RGBA...)
  27856. */
  27857. readonly textureFormat: number;
  27858. /**
  27859. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27860. * This will returns an RGBA array buffer containing either in values (0-255) or
  27861. * float values (0-1) depending of the underlying buffer type.
  27862. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27863. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27864. * @param buffer defines a user defined buffer to fill with data (can be null)
  27865. * @returns The Array buffer containing the pixels data.
  27866. */
  27867. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27868. /**
  27869. * Release and destroy the underlying lower level texture aka internalTexture.
  27870. */
  27871. releaseInternalTexture(): void;
  27872. /**
  27873. * Get the polynomial representation of the texture data.
  27874. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27875. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27876. */
  27877. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27878. /** @hidden */
  27879. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27880. /** @hidden */
  27881. readonly _lodTextureMid: Nullable<BaseTexture>;
  27882. /** @hidden */
  27883. readonly _lodTextureLow: Nullable<BaseTexture>;
  27884. /**
  27885. * Dispose the texture and release its associated resources.
  27886. */
  27887. dispose(): void;
  27888. /**
  27889. * Serialize the texture into a JSON representation that can be parsed later on.
  27890. * @returns the JSON representation of the texture
  27891. */
  27892. serialize(): any;
  27893. /**
  27894. * Helper function to be called back once a list of texture contains only ready textures.
  27895. * @param textures Define the list of textures to wait for
  27896. * @param callback Define the callback triggered once the entire list will be ready
  27897. */
  27898. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27899. }
  27900. }
  27901. declare module BABYLON {
  27902. /**
  27903. * Class used to store data associated with WebGL texture data for the engine
  27904. * This class should not be used directly
  27905. */
  27906. export class InternalTexture {
  27907. /** @hidden */
  27908. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27909. /**
  27910. * The source of the texture data is unknown
  27911. */
  27912. static DATASOURCE_UNKNOWN: number;
  27913. /**
  27914. * Texture data comes from an URL
  27915. */
  27916. static DATASOURCE_URL: number;
  27917. /**
  27918. * Texture data is only used for temporary storage
  27919. */
  27920. static DATASOURCE_TEMP: number;
  27921. /**
  27922. * Texture data comes from raw data (ArrayBuffer)
  27923. */
  27924. static DATASOURCE_RAW: number;
  27925. /**
  27926. * Texture content is dynamic (video or dynamic texture)
  27927. */
  27928. static DATASOURCE_DYNAMIC: number;
  27929. /**
  27930. * Texture content is generated by rendering to it
  27931. */
  27932. static DATASOURCE_RENDERTARGET: number;
  27933. /**
  27934. * Texture content is part of a multi render target process
  27935. */
  27936. static DATASOURCE_MULTIRENDERTARGET: number;
  27937. /**
  27938. * Texture data comes from a cube data file
  27939. */
  27940. static DATASOURCE_CUBE: number;
  27941. /**
  27942. * Texture data comes from a raw cube data
  27943. */
  27944. static DATASOURCE_CUBERAW: number;
  27945. /**
  27946. * Texture data come from a prefiltered cube data file
  27947. */
  27948. static DATASOURCE_CUBEPREFILTERED: number;
  27949. /**
  27950. * Texture content is raw 3D data
  27951. */
  27952. static DATASOURCE_RAW3D: number;
  27953. /**
  27954. * Texture content is a depth texture
  27955. */
  27956. static DATASOURCE_DEPTHTEXTURE: number;
  27957. /**
  27958. * Texture data comes from a raw cube data encoded with RGBD
  27959. */
  27960. static DATASOURCE_CUBERAW_RGBD: number;
  27961. /**
  27962. * Defines if the texture is ready
  27963. */
  27964. isReady: boolean;
  27965. /**
  27966. * Defines if the texture is a cube texture
  27967. */
  27968. isCube: boolean;
  27969. /**
  27970. * Defines if the texture contains 3D data
  27971. */
  27972. is3D: boolean;
  27973. /**
  27974. * Defines if the texture contains multiview data
  27975. */
  27976. isMultiview: boolean;
  27977. /**
  27978. * Gets the URL used to load this texture
  27979. */
  27980. url: string;
  27981. /**
  27982. * Gets the sampling mode of the texture
  27983. */
  27984. samplingMode: number;
  27985. /**
  27986. * Gets a boolean indicating if the texture needs mipmaps generation
  27987. */
  27988. generateMipMaps: boolean;
  27989. /**
  27990. * Gets the number of samples used by the texture (WebGL2+ only)
  27991. */
  27992. samples: number;
  27993. /**
  27994. * Gets the type of the texture (int, float...)
  27995. */
  27996. type: number;
  27997. /**
  27998. * Gets the format of the texture (RGB, RGBA...)
  27999. */
  28000. format: number;
  28001. /**
  28002. * Observable called when the texture is loaded
  28003. */
  28004. onLoadedObservable: Observable<InternalTexture>;
  28005. /**
  28006. * Gets the width of the texture
  28007. */
  28008. width: number;
  28009. /**
  28010. * Gets the height of the texture
  28011. */
  28012. height: number;
  28013. /**
  28014. * Gets the depth of the texture
  28015. */
  28016. depth: number;
  28017. /**
  28018. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28019. */
  28020. baseWidth: number;
  28021. /**
  28022. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28023. */
  28024. baseHeight: number;
  28025. /**
  28026. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28027. */
  28028. baseDepth: number;
  28029. /**
  28030. * Gets a boolean indicating if the texture is inverted on Y axis
  28031. */
  28032. invertY: boolean;
  28033. /** @hidden */
  28034. _invertVScale: boolean;
  28035. /** @hidden */
  28036. _associatedChannel: number;
  28037. /** @hidden */
  28038. _dataSource: number;
  28039. /** @hidden */
  28040. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28041. /** @hidden */
  28042. _bufferView: Nullable<ArrayBufferView>;
  28043. /** @hidden */
  28044. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28045. /** @hidden */
  28046. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28047. /** @hidden */
  28048. _size: number;
  28049. /** @hidden */
  28050. _extension: string;
  28051. /** @hidden */
  28052. _files: Nullable<string[]>;
  28053. /** @hidden */
  28054. _workingCanvas: Nullable<HTMLCanvasElement>;
  28055. /** @hidden */
  28056. _workingContext: Nullable<CanvasRenderingContext2D>;
  28057. /** @hidden */
  28058. _framebuffer: Nullable<WebGLFramebuffer>;
  28059. /** @hidden */
  28060. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28061. /** @hidden */
  28062. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28063. /** @hidden */
  28064. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28065. /** @hidden */
  28066. _attachments: Nullable<number[]>;
  28067. /** @hidden */
  28068. _cachedCoordinatesMode: Nullable<number>;
  28069. /** @hidden */
  28070. _cachedWrapU: Nullable<number>;
  28071. /** @hidden */
  28072. _cachedWrapV: Nullable<number>;
  28073. /** @hidden */
  28074. _cachedWrapR: Nullable<number>;
  28075. /** @hidden */
  28076. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28077. /** @hidden */
  28078. _isDisabled: boolean;
  28079. /** @hidden */
  28080. _compression: Nullable<string>;
  28081. /** @hidden */
  28082. _generateStencilBuffer: boolean;
  28083. /** @hidden */
  28084. _generateDepthBuffer: boolean;
  28085. /** @hidden */
  28086. _comparisonFunction: number;
  28087. /** @hidden */
  28088. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28089. /** @hidden */
  28090. _lodGenerationScale: number;
  28091. /** @hidden */
  28092. _lodGenerationOffset: number;
  28093. /** @hidden */
  28094. _colorTextureArray: Nullable<WebGLTexture>;
  28095. /** @hidden */
  28096. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28097. /** @hidden */
  28098. _lodTextureHigh: Nullable<BaseTexture>;
  28099. /** @hidden */
  28100. _lodTextureMid: Nullable<BaseTexture>;
  28101. /** @hidden */
  28102. _lodTextureLow: Nullable<BaseTexture>;
  28103. /** @hidden */
  28104. _isRGBD: boolean;
  28105. /** @hidden */
  28106. _linearSpecularLOD: boolean;
  28107. /** @hidden */
  28108. _irradianceTexture: Nullable<BaseTexture>;
  28109. /** @hidden */
  28110. _webGLTexture: Nullable<WebGLTexture>;
  28111. /** @hidden */
  28112. _references: number;
  28113. private _engine;
  28114. /**
  28115. * Gets the Engine the texture belongs to.
  28116. * @returns The babylon engine
  28117. */
  28118. getEngine(): Engine;
  28119. /**
  28120. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28121. */
  28122. readonly dataSource: number;
  28123. /**
  28124. * Creates a new InternalTexture
  28125. * @param engine defines the engine to use
  28126. * @param dataSource defines the type of data that will be used
  28127. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28128. */
  28129. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28130. /**
  28131. * Increments the number of references (ie. the number of Texture that point to it)
  28132. */
  28133. incrementReferences(): void;
  28134. /**
  28135. * Change the size of the texture (not the size of the content)
  28136. * @param width defines the new width
  28137. * @param height defines the new height
  28138. * @param depth defines the new depth (1 by default)
  28139. */
  28140. updateSize(width: int, height: int, depth?: int): void;
  28141. /** @hidden */
  28142. _rebuild(): void;
  28143. /** @hidden */
  28144. _swapAndDie(target: InternalTexture): void;
  28145. /**
  28146. * Dispose the current allocated resources
  28147. */
  28148. dispose(): void;
  28149. }
  28150. }
  28151. declare module BABYLON {
  28152. /**
  28153. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28154. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28155. */
  28156. export class EffectFallbacks {
  28157. private _defines;
  28158. private _currentRank;
  28159. private _maxRank;
  28160. private _mesh;
  28161. /**
  28162. * Removes the fallback from the bound mesh.
  28163. */
  28164. unBindMesh(): void;
  28165. /**
  28166. * Adds a fallback on the specified property.
  28167. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28168. * @param define The name of the define in the shader
  28169. */
  28170. addFallback(rank: number, define: string): void;
  28171. /**
  28172. * Sets the mesh to use CPU skinning when needing to fallback.
  28173. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28174. * @param mesh The mesh to use the fallbacks.
  28175. */
  28176. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28177. /**
  28178. * Checks to see if more fallbacks are still availible.
  28179. */
  28180. readonly hasMoreFallbacks: boolean;
  28181. /**
  28182. * Removes the defines that should be removed when falling back.
  28183. * @param currentDefines defines the current define statements for the shader.
  28184. * @param effect defines the current effect we try to compile
  28185. * @returns The resulting defines with defines of the current rank removed.
  28186. */
  28187. reduce(currentDefines: string, effect: Effect): string;
  28188. }
  28189. /**
  28190. * Options to be used when creating an effect.
  28191. */
  28192. export class EffectCreationOptions {
  28193. /**
  28194. * Atrributes that will be used in the shader.
  28195. */
  28196. attributes: string[];
  28197. /**
  28198. * Uniform varible names that will be set in the shader.
  28199. */
  28200. uniformsNames: string[];
  28201. /**
  28202. * Uniform buffer varible names that will be set in the shader.
  28203. */
  28204. uniformBuffersNames: string[];
  28205. /**
  28206. * Sampler texture variable names that will be set in the shader.
  28207. */
  28208. samplers: string[];
  28209. /**
  28210. * Define statements that will be set in the shader.
  28211. */
  28212. defines: any;
  28213. /**
  28214. * Possible fallbacks for this effect to improve performance when needed.
  28215. */
  28216. fallbacks: Nullable<EffectFallbacks>;
  28217. /**
  28218. * Callback that will be called when the shader is compiled.
  28219. */
  28220. onCompiled: Nullable<(effect: Effect) => void>;
  28221. /**
  28222. * Callback that will be called if an error occurs during shader compilation.
  28223. */
  28224. onError: Nullable<(effect: Effect, errors: string) => void>;
  28225. /**
  28226. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28227. */
  28228. indexParameters: any;
  28229. /**
  28230. * Max number of lights that can be used in the shader.
  28231. */
  28232. maxSimultaneousLights: number;
  28233. /**
  28234. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28235. */
  28236. transformFeedbackVaryings: Nullable<string[]>;
  28237. }
  28238. /**
  28239. * Effect containing vertex and fragment shader that can be executed on an object.
  28240. */
  28241. export class Effect implements IDisposable {
  28242. /**
  28243. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28244. */
  28245. static ShadersRepository: string;
  28246. /**
  28247. * Name of the effect.
  28248. */
  28249. name: any;
  28250. /**
  28251. * String container all the define statements that should be set on the shader.
  28252. */
  28253. defines: string;
  28254. /**
  28255. * Callback that will be called when the shader is compiled.
  28256. */
  28257. onCompiled: Nullable<(effect: Effect) => void>;
  28258. /**
  28259. * Callback that will be called if an error occurs during shader compilation.
  28260. */
  28261. onError: Nullable<(effect: Effect, errors: string) => void>;
  28262. /**
  28263. * Callback that will be called when effect is bound.
  28264. */
  28265. onBind: Nullable<(effect: Effect) => void>;
  28266. /**
  28267. * Unique ID of the effect.
  28268. */
  28269. uniqueId: number;
  28270. /**
  28271. * Observable that will be called when the shader is compiled.
  28272. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28273. */
  28274. onCompileObservable: Observable<Effect>;
  28275. /**
  28276. * Observable that will be called if an error occurs during shader compilation.
  28277. */
  28278. onErrorObservable: Observable<Effect>;
  28279. /** @hidden */
  28280. _onBindObservable: Nullable<Observable<Effect>>;
  28281. /**
  28282. * Observable that will be called when effect is bound.
  28283. */
  28284. readonly onBindObservable: Observable<Effect>;
  28285. /** @hidden */
  28286. _bonesComputationForcedToCPU: boolean;
  28287. private static _uniqueIdSeed;
  28288. private _engine;
  28289. private _uniformBuffersNames;
  28290. private _uniformsNames;
  28291. private _samplerList;
  28292. private _samplers;
  28293. private _isReady;
  28294. private _compilationError;
  28295. private _attributesNames;
  28296. private _attributes;
  28297. private _uniforms;
  28298. /**
  28299. * Key for the effect.
  28300. * @hidden
  28301. */
  28302. _key: string;
  28303. private _indexParameters;
  28304. private _fallbacks;
  28305. private _vertexSourceCode;
  28306. private _fragmentSourceCode;
  28307. private _vertexSourceCodeOverride;
  28308. private _fragmentSourceCodeOverride;
  28309. private _transformFeedbackVaryings;
  28310. /**
  28311. * Compiled shader to webGL program.
  28312. * @hidden
  28313. */
  28314. _pipelineContext: Nullable<IPipelineContext>;
  28315. private _valueCache;
  28316. private static _baseCache;
  28317. /**
  28318. * Instantiates an effect.
  28319. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28320. * @param baseName Name of the effect.
  28321. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28322. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28323. * @param samplers List of sampler variables that will be passed to the shader.
  28324. * @param engine Engine to be used to render the effect
  28325. * @param defines Define statements to be added to the shader.
  28326. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28327. * @param onCompiled Callback that will be called when the shader is compiled.
  28328. * @param onError Callback that will be called if an error occurs during shader compilation.
  28329. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28330. */
  28331. 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);
  28332. private _useFinalCode;
  28333. /**
  28334. * Unique key for this effect
  28335. */
  28336. readonly key: string;
  28337. /**
  28338. * If the effect has been compiled and prepared.
  28339. * @returns if the effect is compiled and prepared.
  28340. */
  28341. isReady(): boolean;
  28342. private _isReadyInternal;
  28343. /**
  28344. * The engine the effect was initialized with.
  28345. * @returns the engine.
  28346. */
  28347. getEngine(): Engine;
  28348. /**
  28349. * The pipeline context for this effect
  28350. * @returns the associated pipeline context
  28351. */
  28352. getPipelineContext(): Nullable<IPipelineContext>;
  28353. /**
  28354. * The set of names of attribute variables for the shader.
  28355. * @returns An array of attribute names.
  28356. */
  28357. getAttributesNames(): string[];
  28358. /**
  28359. * Returns the attribute at the given index.
  28360. * @param index The index of the attribute.
  28361. * @returns The location of the attribute.
  28362. */
  28363. getAttributeLocation(index: number): number;
  28364. /**
  28365. * Returns the attribute based on the name of the variable.
  28366. * @param name of the attribute to look up.
  28367. * @returns the attribute location.
  28368. */
  28369. getAttributeLocationByName(name: string): number;
  28370. /**
  28371. * The number of attributes.
  28372. * @returns the numnber of attributes.
  28373. */
  28374. getAttributesCount(): number;
  28375. /**
  28376. * Gets the index of a uniform variable.
  28377. * @param uniformName of the uniform to look up.
  28378. * @returns the index.
  28379. */
  28380. getUniformIndex(uniformName: string): number;
  28381. /**
  28382. * Returns the attribute based on the name of the variable.
  28383. * @param uniformName of the uniform to look up.
  28384. * @returns the location of the uniform.
  28385. */
  28386. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28387. /**
  28388. * Returns an array of sampler variable names
  28389. * @returns The array of sampler variable neames.
  28390. */
  28391. getSamplers(): string[];
  28392. /**
  28393. * The error from the last compilation.
  28394. * @returns the error string.
  28395. */
  28396. getCompilationError(): string;
  28397. /**
  28398. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28399. * @param func The callback to be used.
  28400. */
  28401. executeWhenCompiled(func: (effect: Effect) => void): void;
  28402. private _checkIsReady;
  28403. /** @hidden */
  28404. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28405. /** @hidden */
  28406. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28407. /** @hidden */
  28408. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28409. /**
  28410. * Recompiles the webGL program
  28411. * @param vertexSourceCode The source code for the vertex shader.
  28412. * @param fragmentSourceCode The source code for the fragment shader.
  28413. * @param onCompiled Callback called when completed.
  28414. * @param onError Callback called on error.
  28415. * @hidden
  28416. */
  28417. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28418. /**
  28419. * Prepares the effect
  28420. * @hidden
  28421. */
  28422. _prepareEffect(): void;
  28423. private _processCompilationErrors;
  28424. /**
  28425. * Checks if the effect is supported. (Must be called after compilation)
  28426. */
  28427. readonly isSupported: boolean;
  28428. /**
  28429. * Binds a texture to the engine to be used as output of the shader.
  28430. * @param channel Name of the output variable.
  28431. * @param texture Texture to bind.
  28432. * @hidden
  28433. */
  28434. _bindTexture(channel: string, texture: InternalTexture): void;
  28435. /**
  28436. * Sets a texture on the engine to be used in the shader.
  28437. * @param channel Name of the sampler variable.
  28438. * @param texture Texture to set.
  28439. */
  28440. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28441. /**
  28442. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28443. * @param channel Name of the sampler variable.
  28444. * @param texture Texture to set.
  28445. */
  28446. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28447. /**
  28448. * Sets an array of textures on the engine to be used in the shader.
  28449. * @param channel Name of the variable.
  28450. * @param textures Textures to set.
  28451. */
  28452. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28453. /**
  28454. * 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)
  28455. * @param channel Name of the sampler variable.
  28456. * @param postProcess Post process to get the input texture from.
  28457. */
  28458. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28459. /**
  28460. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28461. * 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)
  28462. * @param channel Name of the sampler variable.
  28463. * @param postProcess Post process to get the output texture from.
  28464. */
  28465. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28466. /** @hidden */
  28467. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28468. /** @hidden */
  28469. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28470. /** @hidden */
  28471. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28472. /** @hidden */
  28473. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28474. /**
  28475. * Binds a buffer to a uniform.
  28476. * @param buffer Buffer to bind.
  28477. * @param name Name of the uniform variable to bind to.
  28478. */
  28479. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28480. /**
  28481. * Binds block to a uniform.
  28482. * @param blockName Name of the block to bind.
  28483. * @param index Index to bind.
  28484. */
  28485. bindUniformBlock(blockName: string, index: number): void;
  28486. /**
  28487. * Sets an interger value on a uniform variable.
  28488. * @param uniformName Name of the variable.
  28489. * @param value Value to be set.
  28490. * @returns this effect.
  28491. */
  28492. setInt(uniformName: string, value: number): Effect;
  28493. /**
  28494. * Sets an int array on a uniform variable.
  28495. * @param uniformName Name of the variable.
  28496. * @param array array to be set.
  28497. * @returns this effect.
  28498. */
  28499. setIntArray(uniformName: string, array: Int32Array): Effect;
  28500. /**
  28501. * 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)
  28502. * @param uniformName Name of the variable.
  28503. * @param array array to be set.
  28504. * @returns this effect.
  28505. */
  28506. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28507. /**
  28508. * 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)
  28509. * @param uniformName Name of the variable.
  28510. * @param array array to be set.
  28511. * @returns this effect.
  28512. */
  28513. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28514. /**
  28515. * 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)
  28516. * @param uniformName Name of the variable.
  28517. * @param array array to be set.
  28518. * @returns this effect.
  28519. */
  28520. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28521. /**
  28522. * Sets an float array on a uniform variable.
  28523. * @param uniformName Name of the variable.
  28524. * @param array array to be set.
  28525. * @returns this effect.
  28526. */
  28527. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28528. /**
  28529. * 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)
  28530. * @param uniformName Name of the variable.
  28531. * @param array array to be set.
  28532. * @returns this effect.
  28533. */
  28534. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28535. /**
  28536. * 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)
  28537. * @param uniformName Name of the variable.
  28538. * @param array array to be set.
  28539. * @returns this effect.
  28540. */
  28541. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28542. /**
  28543. * 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)
  28544. * @param uniformName Name of the variable.
  28545. * @param array array to be set.
  28546. * @returns this effect.
  28547. */
  28548. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28549. /**
  28550. * Sets an array on a uniform variable.
  28551. * @param uniformName Name of the variable.
  28552. * @param array array to be set.
  28553. * @returns this effect.
  28554. */
  28555. setArray(uniformName: string, array: number[]): Effect;
  28556. /**
  28557. * 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)
  28558. * @param uniformName Name of the variable.
  28559. * @param array array to be set.
  28560. * @returns this effect.
  28561. */
  28562. setArray2(uniformName: string, array: number[]): Effect;
  28563. /**
  28564. * 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)
  28565. * @param uniformName Name of the variable.
  28566. * @param array array to be set.
  28567. * @returns this effect.
  28568. */
  28569. setArray3(uniformName: string, array: number[]): Effect;
  28570. /**
  28571. * 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)
  28572. * @param uniformName Name of the variable.
  28573. * @param array array to be set.
  28574. * @returns this effect.
  28575. */
  28576. setArray4(uniformName: string, array: number[]): Effect;
  28577. /**
  28578. * Sets matrices on a uniform variable.
  28579. * @param uniformName Name of the variable.
  28580. * @param matrices matrices to be set.
  28581. * @returns this effect.
  28582. */
  28583. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28584. /**
  28585. * Sets matrix on a uniform variable.
  28586. * @param uniformName Name of the variable.
  28587. * @param matrix matrix to be set.
  28588. * @returns this effect.
  28589. */
  28590. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28591. /**
  28592. * 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)
  28593. * @param uniformName Name of the variable.
  28594. * @param matrix matrix to be set.
  28595. * @returns this effect.
  28596. */
  28597. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28598. /**
  28599. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28600. * @param uniformName Name of the variable.
  28601. * @param matrix matrix to be set.
  28602. * @returns this effect.
  28603. */
  28604. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28605. /**
  28606. * Sets a float on a uniform variable.
  28607. * @param uniformName Name of the variable.
  28608. * @param value value to be set.
  28609. * @returns this effect.
  28610. */
  28611. setFloat(uniformName: string, value: number): Effect;
  28612. /**
  28613. * Sets a boolean on a uniform variable.
  28614. * @param uniformName Name of the variable.
  28615. * @param bool value to be set.
  28616. * @returns this effect.
  28617. */
  28618. setBool(uniformName: string, bool: boolean): Effect;
  28619. /**
  28620. * Sets a Vector2 on a uniform variable.
  28621. * @param uniformName Name of the variable.
  28622. * @param vector2 vector2 to be set.
  28623. * @returns this effect.
  28624. */
  28625. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28626. /**
  28627. * Sets a float2 on a uniform variable.
  28628. * @param uniformName Name of the variable.
  28629. * @param x First float in float2.
  28630. * @param y Second float in float2.
  28631. * @returns this effect.
  28632. */
  28633. setFloat2(uniformName: string, x: number, y: number): Effect;
  28634. /**
  28635. * Sets a Vector3 on a uniform variable.
  28636. * @param uniformName Name of the variable.
  28637. * @param vector3 Value to be set.
  28638. * @returns this effect.
  28639. */
  28640. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28641. /**
  28642. * Sets a float3 on a uniform variable.
  28643. * @param uniformName Name of the variable.
  28644. * @param x First float in float3.
  28645. * @param y Second float in float3.
  28646. * @param z Third float in float3.
  28647. * @returns this effect.
  28648. */
  28649. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28650. /**
  28651. * Sets a Vector4 on a uniform variable.
  28652. * @param uniformName Name of the variable.
  28653. * @param vector4 Value to be set.
  28654. * @returns this effect.
  28655. */
  28656. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28657. /**
  28658. * Sets a float4 on a uniform variable.
  28659. * @param uniformName Name of the variable.
  28660. * @param x First float in float4.
  28661. * @param y Second float in float4.
  28662. * @param z Third float in float4.
  28663. * @param w Fourth float in float4.
  28664. * @returns this effect.
  28665. */
  28666. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28667. /**
  28668. * Sets a Color3 on a uniform variable.
  28669. * @param uniformName Name of the variable.
  28670. * @param color3 Value to be set.
  28671. * @returns this effect.
  28672. */
  28673. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28674. /**
  28675. * Sets a Color4 on a uniform variable.
  28676. * @param uniformName Name of the variable.
  28677. * @param color3 Value to be set.
  28678. * @param alpha Alpha value to be set.
  28679. * @returns this effect.
  28680. */
  28681. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28682. /**
  28683. * Sets a Color4 on a uniform variable
  28684. * @param uniformName defines the name of the variable
  28685. * @param color4 defines the value to be set
  28686. * @returns this effect.
  28687. */
  28688. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28689. /** Release all associated resources */
  28690. dispose(): void;
  28691. /**
  28692. * This function will add a new shader to the shader store
  28693. * @param name the name of the shader
  28694. * @param pixelShader optional pixel shader content
  28695. * @param vertexShader optional vertex shader content
  28696. */
  28697. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28698. /**
  28699. * Store of each shader (The can be looked up using effect.key)
  28700. */
  28701. static ShadersStore: {
  28702. [key: string]: string;
  28703. };
  28704. /**
  28705. * Store of each included file for a shader (The can be looked up using effect.key)
  28706. */
  28707. static IncludesShadersStore: {
  28708. [key: string]: string;
  28709. };
  28710. /**
  28711. * Resets the cache of effects.
  28712. */
  28713. static ResetCache(): void;
  28714. }
  28715. }
  28716. declare module BABYLON {
  28717. /**
  28718. * Uniform buffer objects.
  28719. *
  28720. * Handles blocks of uniform on the GPU.
  28721. *
  28722. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28723. *
  28724. * For more information, please refer to :
  28725. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28726. */
  28727. export class UniformBuffer {
  28728. private _engine;
  28729. private _buffer;
  28730. private _data;
  28731. private _bufferData;
  28732. private _dynamic?;
  28733. private _uniformLocations;
  28734. private _uniformSizes;
  28735. private _uniformLocationPointer;
  28736. private _needSync;
  28737. private _noUBO;
  28738. private _currentEffect;
  28739. private static _MAX_UNIFORM_SIZE;
  28740. private static _tempBuffer;
  28741. /**
  28742. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28743. * This is dynamic to allow compat with webgl 1 and 2.
  28744. * You will need to pass the name of the uniform as well as the value.
  28745. */
  28746. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28747. /**
  28748. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28749. * This is dynamic to allow compat with webgl 1 and 2.
  28750. * You will need to pass the name of the uniform as well as the value.
  28751. */
  28752. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28753. /**
  28754. * Lambda to Update a single float in a uniform buffer.
  28755. * This is dynamic to allow compat with webgl 1 and 2.
  28756. * You will need to pass the name of the uniform as well as the value.
  28757. */
  28758. updateFloat: (name: string, x: number) => void;
  28759. /**
  28760. * Lambda to Update a vec2 of float in a uniform buffer.
  28761. * This is dynamic to allow compat with webgl 1 and 2.
  28762. * You will need to pass the name of the uniform as well as the value.
  28763. */
  28764. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28765. /**
  28766. * Lambda to Update a vec3 of float in a uniform buffer.
  28767. * This is dynamic to allow compat with webgl 1 and 2.
  28768. * You will need to pass the name of the uniform as well as the value.
  28769. */
  28770. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28771. /**
  28772. * Lambda to Update a vec4 of float in a uniform buffer.
  28773. * This is dynamic to allow compat with webgl 1 and 2.
  28774. * You will need to pass the name of the uniform as well as the value.
  28775. */
  28776. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28777. /**
  28778. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28779. * This is dynamic to allow compat with webgl 1 and 2.
  28780. * You will need to pass the name of the uniform as well as the value.
  28781. */
  28782. updateMatrix: (name: string, mat: Matrix) => void;
  28783. /**
  28784. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28785. * This is dynamic to allow compat with webgl 1 and 2.
  28786. * You will need to pass the name of the uniform as well as the value.
  28787. */
  28788. updateVector3: (name: string, vector: Vector3) => void;
  28789. /**
  28790. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28791. * This is dynamic to allow compat with webgl 1 and 2.
  28792. * You will need to pass the name of the uniform as well as the value.
  28793. */
  28794. updateVector4: (name: string, vector: Vector4) => void;
  28795. /**
  28796. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28797. * This is dynamic to allow compat with webgl 1 and 2.
  28798. * You will need to pass the name of the uniform as well as the value.
  28799. */
  28800. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28801. /**
  28802. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28803. * This is dynamic to allow compat with webgl 1 and 2.
  28804. * You will need to pass the name of the uniform as well as the value.
  28805. */
  28806. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28807. /**
  28808. * Instantiates a new Uniform buffer objects.
  28809. *
  28810. * Handles blocks of uniform on the GPU.
  28811. *
  28812. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28813. *
  28814. * For more information, please refer to :
  28815. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28816. * @param engine Define the engine the buffer is associated with
  28817. * @param data Define the data contained in the buffer
  28818. * @param dynamic Define if the buffer is updatable
  28819. */
  28820. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28821. /**
  28822. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28823. * or just falling back on setUniformXXX calls.
  28824. */
  28825. readonly useUbo: boolean;
  28826. /**
  28827. * Indicates if the WebGL underlying uniform buffer is in sync
  28828. * with the javascript cache data.
  28829. */
  28830. readonly isSync: boolean;
  28831. /**
  28832. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28833. * Also, a dynamic UniformBuffer will disable cache verification and always
  28834. * update the underlying WebGL uniform buffer to the GPU.
  28835. * @returns if Dynamic, otherwise false
  28836. */
  28837. isDynamic(): boolean;
  28838. /**
  28839. * The data cache on JS side.
  28840. * @returns the underlying data as a float array
  28841. */
  28842. getData(): Float32Array;
  28843. /**
  28844. * The underlying WebGL Uniform buffer.
  28845. * @returns the webgl buffer
  28846. */
  28847. getBuffer(): Nullable<DataBuffer>;
  28848. /**
  28849. * std140 layout specifies how to align data within an UBO structure.
  28850. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28851. * for specs.
  28852. */
  28853. private _fillAlignment;
  28854. /**
  28855. * Adds an uniform in the buffer.
  28856. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28857. * for the layout to be correct !
  28858. * @param name Name of the uniform, as used in the uniform block in the shader.
  28859. * @param size Data size, or data directly.
  28860. */
  28861. addUniform(name: string, size: number | number[]): void;
  28862. /**
  28863. * Adds a Matrix 4x4 to the uniform buffer.
  28864. * @param name Name of the uniform, as used in the uniform block in the shader.
  28865. * @param mat A 4x4 matrix.
  28866. */
  28867. addMatrix(name: string, mat: Matrix): void;
  28868. /**
  28869. * Adds a vec2 to the uniform buffer.
  28870. * @param name Name of the uniform, as used in the uniform block in the shader.
  28871. * @param x Define the x component value of the vec2
  28872. * @param y Define the y component value of the vec2
  28873. */
  28874. addFloat2(name: string, x: number, y: number): void;
  28875. /**
  28876. * Adds a vec3 to the uniform buffer.
  28877. * @param name Name of the uniform, as used in the uniform block in the shader.
  28878. * @param x Define the x component value of the vec3
  28879. * @param y Define the y component value of the vec3
  28880. * @param z Define the z component value of the vec3
  28881. */
  28882. addFloat3(name: string, x: number, y: number, z: number): void;
  28883. /**
  28884. * Adds a vec3 to the uniform buffer.
  28885. * @param name Name of the uniform, as used in the uniform block in the shader.
  28886. * @param color Define the vec3 from a Color
  28887. */
  28888. addColor3(name: string, color: Color3): void;
  28889. /**
  28890. * Adds a vec4 to the uniform buffer.
  28891. * @param name Name of the uniform, as used in the uniform block in the shader.
  28892. * @param color Define the rgb components from a Color
  28893. * @param alpha Define the a component of the vec4
  28894. */
  28895. addColor4(name: string, color: Color3, alpha: number): void;
  28896. /**
  28897. * Adds a vec3 to the uniform buffer.
  28898. * @param name Name of the uniform, as used in the uniform block in the shader.
  28899. * @param vector Define the vec3 components from a Vector
  28900. */
  28901. addVector3(name: string, vector: Vector3): void;
  28902. /**
  28903. * Adds a Matrix 3x3 to the uniform buffer.
  28904. * @param name Name of the uniform, as used in the uniform block in the shader.
  28905. */
  28906. addMatrix3x3(name: string): void;
  28907. /**
  28908. * Adds a Matrix 2x2 to the uniform buffer.
  28909. * @param name Name of the uniform, as used in the uniform block in the shader.
  28910. */
  28911. addMatrix2x2(name: string): void;
  28912. /**
  28913. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28914. */
  28915. create(): void;
  28916. /** @hidden */
  28917. _rebuild(): void;
  28918. /**
  28919. * Updates the WebGL Uniform Buffer on the GPU.
  28920. * If the `dynamic` flag is set to true, no cache comparison is done.
  28921. * Otherwise, the buffer will be updated only if the cache differs.
  28922. */
  28923. update(): void;
  28924. /**
  28925. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28926. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28927. * @param data Define the flattened data
  28928. * @param size Define the size of the data.
  28929. */
  28930. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28931. private _valueCache;
  28932. private _cacheMatrix;
  28933. private _updateMatrix3x3ForUniform;
  28934. private _updateMatrix3x3ForEffect;
  28935. private _updateMatrix2x2ForEffect;
  28936. private _updateMatrix2x2ForUniform;
  28937. private _updateFloatForEffect;
  28938. private _updateFloatForUniform;
  28939. private _updateFloat2ForEffect;
  28940. private _updateFloat2ForUniform;
  28941. private _updateFloat3ForEffect;
  28942. private _updateFloat3ForUniform;
  28943. private _updateFloat4ForEffect;
  28944. private _updateFloat4ForUniform;
  28945. private _updateMatrixForEffect;
  28946. private _updateMatrixForUniform;
  28947. private _updateVector3ForEffect;
  28948. private _updateVector3ForUniform;
  28949. private _updateVector4ForEffect;
  28950. private _updateVector4ForUniform;
  28951. private _updateColor3ForEffect;
  28952. private _updateColor3ForUniform;
  28953. private _updateColor4ForEffect;
  28954. private _updateColor4ForUniform;
  28955. /**
  28956. * Sets a sampler uniform on the effect.
  28957. * @param name Define the name of the sampler.
  28958. * @param texture Define the texture to set in the sampler
  28959. */
  28960. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28961. /**
  28962. * Directly updates the value of the uniform in the cache AND on the GPU.
  28963. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28964. * @param data Define the flattened data
  28965. */
  28966. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28967. /**
  28968. * Binds this uniform buffer to an effect.
  28969. * @param effect Define the effect to bind the buffer to
  28970. * @param name Name of the uniform block in the shader.
  28971. */
  28972. bindToEffect(effect: Effect, name: string): void;
  28973. /**
  28974. * Disposes the uniform buffer.
  28975. */
  28976. dispose(): void;
  28977. }
  28978. }
  28979. declare module BABYLON {
  28980. /**
  28981. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28983. */
  28984. export class Analyser {
  28985. /**
  28986. * Gets or sets the smoothing
  28987. * @ignorenaming
  28988. */
  28989. SMOOTHING: number;
  28990. /**
  28991. * Gets or sets the FFT table size
  28992. * @ignorenaming
  28993. */
  28994. FFT_SIZE: number;
  28995. /**
  28996. * Gets or sets the bar graph amplitude
  28997. * @ignorenaming
  28998. */
  28999. BARGRAPHAMPLITUDE: number;
  29000. /**
  29001. * Gets or sets the position of the debug canvas
  29002. * @ignorenaming
  29003. */
  29004. DEBUGCANVASPOS: {
  29005. x: number;
  29006. y: number;
  29007. };
  29008. /**
  29009. * Gets or sets the debug canvas size
  29010. * @ignorenaming
  29011. */
  29012. DEBUGCANVASSIZE: {
  29013. width: number;
  29014. height: number;
  29015. };
  29016. private _byteFreqs;
  29017. private _byteTime;
  29018. private _floatFreqs;
  29019. private _webAudioAnalyser;
  29020. private _debugCanvas;
  29021. private _debugCanvasContext;
  29022. private _scene;
  29023. private _registerFunc;
  29024. private _audioEngine;
  29025. /**
  29026. * Creates a new analyser
  29027. * @param scene defines hosting scene
  29028. */
  29029. constructor(scene: Scene);
  29030. /**
  29031. * Get the number of data values you will have to play with for the visualization
  29032. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29033. * @returns a number
  29034. */
  29035. getFrequencyBinCount(): number;
  29036. /**
  29037. * Gets the current frequency data as a byte array
  29038. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29039. * @returns a Uint8Array
  29040. */
  29041. getByteFrequencyData(): Uint8Array;
  29042. /**
  29043. * Gets the current waveform as a byte array
  29044. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29045. * @returns a Uint8Array
  29046. */
  29047. getByteTimeDomainData(): Uint8Array;
  29048. /**
  29049. * Gets the current frequency data as a float array
  29050. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29051. * @returns a Float32Array
  29052. */
  29053. getFloatFrequencyData(): Float32Array;
  29054. /**
  29055. * Renders the debug canvas
  29056. */
  29057. drawDebugCanvas(): void;
  29058. /**
  29059. * Stops rendering the debug canvas and removes it
  29060. */
  29061. stopDebugCanvas(): void;
  29062. /**
  29063. * Connects two audio nodes
  29064. * @param inputAudioNode defines first node to connect
  29065. * @param outputAudioNode defines second node to connect
  29066. */
  29067. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29068. /**
  29069. * Releases all associated resources
  29070. */
  29071. dispose(): void;
  29072. }
  29073. }
  29074. declare module BABYLON {
  29075. /**
  29076. * This represents an audio engine and it is responsible
  29077. * to play, synchronize and analyse sounds throughout the application.
  29078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29079. */
  29080. export interface IAudioEngine extends IDisposable {
  29081. /**
  29082. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29083. */
  29084. readonly canUseWebAudio: boolean;
  29085. /**
  29086. * Gets the current AudioContext if available.
  29087. */
  29088. readonly audioContext: Nullable<AudioContext>;
  29089. /**
  29090. * The master gain node defines the global audio volume of your audio engine.
  29091. */
  29092. readonly masterGain: GainNode;
  29093. /**
  29094. * Gets whether or not mp3 are supported by your browser.
  29095. */
  29096. readonly isMP3supported: boolean;
  29097. /**
  29098. * Gets whether or not ogg are supported by your browser.
  29099. */
  29100. readonly isOGGsupported: boolean;
  29101. /**
  29102. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29103. * @ignoreNaming
  29104. */
  29105. WarnedWebAudioUnsupported: boolean;
  29106. /**
  29107. * Defines if the audio engine relies on a custom unlocked button.
  29108. * In this case, the embedded button will not be displayed.
  29109. */
  29110. useCustomUnlockedButton: boolean;
  29111. /**
  29112. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29113. */
  29114. readonly unlocked: boolean;
  29115. /**
  29116. * Event raised when audio has been unlocked on the browser.
  29117. */
  29118. onAudioUnlockedObservable: Observable<AudioEngine>;
  29119. /**
  29120. * Event raised when audio has been locked on the browser.
  29121. */
  29122. onAudioLockedObservable: Observable<AudioEngine>;
  29123. /**
  29124. * Flags the audio engine in Locked state.
  29125. * This happens due to new browser policies preventing audio to autoplay.
  29126. */
  29127. lock(): void;
  29128. /**
  29129. * Unlocks the audio engine once a user action has been done on the dom.
  29130. * This is helpful to resume play once browser policies have been satisfied.
  29131. */
  29132. unlock(): void;
  29133. }
  29134. /**
  29135. * This represents the default audio engine used in babylon.
  29136. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29138. */
  29139. export class AudioEngine implements IAudioEngine {
  29140. private _audioContext;
  29141. private _audioContextInitialized;
  29142. private _muteButton;
  29143. private _hostElement;
  29144. /**
  29145. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29146. */
  29147. canUseWebAudio: boolean;
  29148. /**
  29149. * The master gain node defines the global audio volume of your audio engine.
  29150. */
  29151. masterGain: GainNode;
  29152. /**
  29153. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29154. * @ignoreNaming
  29155. */
  29156. WarnedWebAudioUnsupported: boolean;
  29157. /**
  29158. * Gets whether or not mp3 are supported by your browser.
  29159. */
  29160. isMP3supported: boolean;
  29161. /**
  29162. * Gets whether or not ogg are supported by your browser.
  29163. */
  29164. isOGGsupported: boolean;
  29165. /**
  29166. * Gets whether audio has been unlocked on the device.
  29167. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29168. * a user interaction has happened.
  29169. */
  29170. unlocked: boolean;
  29171. /**
  29172. * Defines if the audio engine relies on a custom unlocked button.
  29173. * In this case, the embedded button will not be displayed.
  29174. */
  29175. useCustomUnlockedButton: boolean;
  29176. /**
  29177. * Event raised when audio has been unlocked on the browser.
  29178. */
  29179. onAudioUnlockedObservable: Observable<AudioEngine>;
  29180. /**
  29181. * Event raised when audio has been locked on the browser.
  29182. */
  29183. onAudioLockedObservable: Observable<AudioEngine>;
  29184. /**
  29185. * Gets the current AudioContext if available.
  29186. */
  29187. readonly audioContext: Nullable<AudioContext>;
  29188. private _connectedAnalyser;
  29189. /**
  29190. * Instantiates a new audio engine.
  29191. *
  29192. * There should be only one per page as some browsers restrict the number
  29193. * of audio contexts you can create.
  29194. * @param hostElement defines the host element where to display the mute icon if necessary
  29195. */
  29196. constructor(hostElement?: Nullable<HTMLElement>);
  29197. /**
  29198. * Flags the audio engine in Locked state.
  29199. * This happens due to new browser policies preventing audio to autoplay.
  29200. */
  29201. lock(): void;
  29202. /**
  29203. * Unlocks the audio engine once a user action has been done on the dom.
  29204. * This is helpful to resume play once browser policies have been satisfied.
  29205. */
  29206. unlock(): void;
  29207. private _resumeAudioContext;
  29208. private _initializeAudioContext;
  29209. private _tryToRun;
  29210. private _triggerRunningState;
  29211. private _triggerSuspendedState;
  29212. private _displayMuteButton;
  29213. private _moveButtonToTopLeft;
  29214. private _onResize;
  29215. private _hideMuteButton;
  29216. /**
  29217. * Destroy and release the resources associated with the audio ccontext.
  29218. */
  29219. dispose(): void;
  29220. /**
  29221. * Gets the global volume sets on the master gain.
  29222. * @returns the global volume if set or -1 otherwise
  29223. */
  29224. getGlobalVolume(): number;
  29225. /**
  29226. * Sets the global volume of your experience (sets on the master gain).
  29227. * @param newVolume Defines the new global volume of the application
  29228. */
  29229. setGlobalVolume(newVolume: number): void;
  29230. /**
  29231. * Connect the audio engine to an audio analyser allowing some amazing
  29232. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29234. * @param analyser The analyser to connect to the engine
  29235. */
  29236. connectToAnalyser(analyser: Analyser): void;
  29237. }
  29238. }
  29239. declare module BABYLON {
  29240. /**
  29241. * Interface used to present a loading screen while loading a scene
  29242. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29243. */
  29244. export interface ILoadingScreen {
  29245. /**
  29246. * Function called to display the loading screen
  29247. */
  29248. displayLoadingUI: () => void;
  29249. /**
  29250. * Function called to hide the loading screen
  29251. */
  29252. hideLoadingUI: () => void;
  29253. /**
  29254. * Gets or sets the color to use for the background
  29255. */
  29256. loadingUIBackgroundColor: string;
  29257. /**
  29258. * Gets or sets the text to display while loading
  29259. */
  29260. loadingUIText: string;
  29261. }
  29262. /**
  29263. * Class used for the default loading screen
  29264. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29265. */
  29266. export class DefaultLoadingScreen implements ILoadingScreen {
  29267. private _renderingCanvas;
  29268. private _loadingText;
  29269. private _loadingDivBackgroundColor;
  29270. private _loadingDiv;
  29271. private _loadingTextDiv;
  29272. /** Gets or sets the logo url to use for the default loading screen */
  29273. static DefaultLogoUrl: string;
  29274. /** Gets or sets the spinner url to use for the default loading screen */
  29275. static DefaultSpinnerUrl: string;
  29276. /**
  29277. * Creates a new default loading screen
  29278. * @param _renderingCanvas defines the canvas used to render the scene
  29279. * @param _loadingText defines the default text to display
  29280. * @param _loadingDivBackgroundColor defines the default background color
  29281. */
  29282. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29283. /**
  29284. * Function called to display the loading screen
  29285. */
  29286. displayLoadingUI(): void;
  29287. /**
  29288. * Function called to hide the loading screen
  29289. */
  29290. hideLoadingUI(): void;
  29291. /**
  29292. * Gets or sets the text to display while loading
  29293. */
  29294. loadingUIText: string;
  29295. /**
  29296. * Gets or sets the color to use for the background
  29297. */
  29298. loadingUIBackgroundColor: string;
  29299. private _resizeLoadingUI;
  29300. }
  29301. }
  29302. declare module BABYLON {
  29303. /** @hidden */
  29304. export class WebGLPipelineContext implements IPipelineContext {
  29305. engine: Engine;
  29306. program: Nullable<WebGLProgram>;
  29307. context?: WebGLRenderingContext;
  29308. vertexShader?: WebGLShader;
  29309. fragmentShader?: WebGLShader;
  29310. isParallelCompiled: boolean;
  29311. onCompiled?: () => void;
  29312. transformFeedback?: WebGLTransformFeedback | null;
  29313. readonly isAsync: boolean;
  29314. readonly isReady: boolean;
  29315. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29316. }
  29317. }
  29318. declare module BABYLON {
  29319. /** @hidden */
  29320. export class WebGLDataBuffer extends DataBuffer {
  29321. private _buffer;
  29322. constructor(resource: WebGLBuffer);
  29323. readonly underlyingResource: any;
  29324. }
  29325. }
  29326. declare module BABYLON {
  29327. /** @hidden */
  29328. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29329. attributeProcessor(attribute: string): string;
  29330. varyingProcessor(varying: string, isFragment: boolean): string;
  29331. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29332. }
  29333. }
  29334. declare module BABYLON {
  29335. /**
  29336. * This class is used to track a performance counter which is number based.
  29337. * The user has access to many properties which give statistics of different nature.
  29338. *
  29339. * The implementer can track two kinds of Performance Counter: time and count.
  29340. * 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.
  29341. * 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.
  29342. */
  29343. export class PerfCounter {
  29344. /**
  29345. * Gets or sets a global boolean to turn on and off all the counters
  29346. */
  29347. static Enabled: boolean;
  29348. /**
  29349. * Returns the smallest value ever
  29350. */
  29351. readonly min: number;
  29352. /**
  29353. * Returns the biggest value ever
  29354. */
  29355. readonly max: number;
  29356. /**
  29357. * Returns the average value since the performance counter is running
  29358. */
  29359. readonly average: number;
  29360. /**
  29361. * Returns the average value of the last second the counter was monitored
  29362. */
  29363. readonly lastSecAverage: number;
  29364. /**
  29365. * Returns the current value
  29366. */
  29367. readonly current: number;
  29368. /**
  29369. * Gets the accumulated total
  29370. */
  29371. readonly total: number;
  29372. /**
  29373. * Gets the total value count
  29374. */
  29375. readonly count: number;
  29376. /**
  29377. * Creates a new counter
  29378. */
  29379. constructor();
  29380. /**
  29381. * Call this method to start monitoring a new frame.
  29382. * 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.
  29383. */
  29384. fetchNewFrame(): void;
  29385. /**
  29386. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29387. * @param newCount the count value to add to the monitored count
  29388. * @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.
  29389. */
  29390. addCount(newCount: number, fetchResult: boolean): void;
  29391. /**
  29392. * Start monitoring this performance counter
  29393. */
  29394. beginMonitoring(): void;
  29395. /**
  29396. * Compute the time lapsed since the previous beginMonitoring() call.
  29397. * @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
  29398. */
  29399. endMonitoring(newFrame?: boolean): void;
  29400. private _fetchResult;
  29401. private _startMonitoringTime;
  29402. private _min;
  29403. private _max;
  29404. private _average;
  29405. private _current;
  29406. private _totalValueCount;
  29407. private _totalAccumulated;
  29408. private _lastSecAverage;
  29409. private _lastSecAccumulated;
  29410. private _lastSecTime;
  29411. private _lastSecValueCount;
  29412. }
  29413. }
  29414. declare module BABYLON {
  29415. /**
  29416. * Interface for any object that can request an animation frame
  29417. */
  29418. export interface ICustomAnimationFrameRequester {
  29419. /**
  29420. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29421. */
  29422. renderFunction?: Function;
  29423. /**
  29424. * Called to request the next frame to render to
  29425. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29426. */
  29427. requestAnimationFrame: Function;
  29428. /**
  29429. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29430. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29431. */
  29432. requestID?: number;
  29433. }
  29434. }
  29435. declare module BABYLON {
  29436. /**
  29437. * Settings for finer control over video usage
  29438. */
  29439. export interface VideoTextureSettings {
  29440. /**
  29441. * Applies `autoplay` to video, if specified
  29442. */
  29443. autoPlay?: boolean;
  29444. /**
  29445. * Applies `loop` to video, if specified
  29446. */
  29447. loop?: boolean;
  29448. /**
  29449. * Automatically updates internal texture from video at every frame in the render loop
  29450. */
  29451. autoUpdateTexture: boolean;
  29452. /**
  29453. * Image src displayed during the video loading or until the user interacts with the video.
  29454. */
  29455. poster?: string;
  29456. }
  29457. /**
  29458. * If you want to display a video in your scene, this is the special texture for that.
  29459. * This special texture works similar to other textures, with the exception of a few parameters.
  29460. * @see https://doc.babylonjs.com/how_to/video_texture
  29461. */
  29462. export class VideoTexture extends Texture {
  29463. /**
  29464. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29465. */
  29466. readonly autoUpdateTexture: boolean;
  29467. /**
  29468. * The video instance used by the texture internally
  29469. */
  29470. readonly video: HTMLVideoElement;
  29471. private _onUserActionRequestedObservable;
  29472. /**
  29473. * Event triggerd when a dom action is required by the user to play the video.
  29474. * This happens due to recent changes in browser policies preventing video to auto start.
  29475. */
  29476. readonly onUserActionRequestedObservable: Observable<Texture>;
  29477. private _generateMipMaps;
  29478. private _engine;
  29479. private _stillImageCaptured;
  29480. private _displayingPosterTexture;
  29481. private _settings;
  29482. private _createInternalTextureOnEvent;
  29483. /**
  29484. * Creates a video texture.
  29485. * If you want to display a video in your scene, this is the special texture for that.
  29486. * This special texture works similar to other textures, with the exception of a few parameters.
  29487. * @see https://doc.babylonjs.com/how_to/video_texture
  29488. * @param name optional name, will detect from video source, if not defined
  29489. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29490. * @param scene is obviously the current scene.
  29491. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29492. * @param invertY is false by default but can be used to invert video on Y axis
  29493. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29494. * @param settings allows finer control over video usage
  29495. */
  29496. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29497. private _getName;
  29498. private _getVideo;
  29499. private _createInternalTexture;
  29500. private reset;
  29501. /**
  29502. * @hidden Internal method to initiate `update`.
  29503. */
  29504. _rebuild(): void;
  29505. /**
  29506. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29507. */
  29508. update(): void;
  29509. /**
  29510. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29511. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29512. */
  29513. updateTexture(isVisible: boolean): void;
  29514. protected _updateInternalTexture: () => void;
  29515. /**
  29516. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29517. * @param url New url.
  29518. */
  29519. updateURL(url: string): void;
  29520. /**
  29521. * Dispose the texture and release its associated resources.
  29522. */
  29523. dispose(): void;
  29524. /**
  29525. * Creates a video texture straight from a stream.
  29526. * @param scene Define the scene the texture should be created in
  29527. * @param stream Define the stream the texture should be created from
  29528. * @returns The created video texture as a promise
  29529. */
  29530. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29531. /**
  29532. * Creates a video texture straight from your WebCam video feed.
  29533. * @param scene Define the scene the texture should be created in
  29534. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29535. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29536. * @returns The created video texture as a promise
  29537. */
  29538. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29539. minWidth: number;
  29540. maxWidth: number;
  29541. minHeight: number;
  29542. maxHeight: number;
  29543. deviceId: string;
  29544. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29545. /**
  29546. * Creates a video texture straight from your WebCam video feed.
  29547. * @param scene Define the scene the texture should be created in
  29548. * @param onReady Define a callback to triggered once the texture will be ready
  29549. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29550. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29551. */
  29552. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29553. minWidth: number;
  29554. maxWidth: number;
  29555. minHeight: number;
  29556. maxHeight: number;
  29557. deviceId: string;
  29558. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29559. }
  29560. }
  29561. declare module BABYLON {
  29562. /**
  29563. * Defines the interface used by objects containing a viewport (like a camera)
  29564. */
  29565. interface IViewportOwnerLike {
  29566. /**
  29567. * Gets or sets the viewport
  29568. */
  29569. viewport: IViewportLike;
  29570. }
  29571. /**
  29572. * Interface for attribute information associated with buffer instanciation
  29573. */
  29574. export class InstancingAttributeInfo {
  29575. /**
  29576. * Index/offset of the attribute in the vertex shader
  29577. */
  29578. index: number;
  29579. /**
  29580. * size of the attribute, 1, 2, 3 or 4
  29581. */
  29582. attributeSize: number;
  29583. /**
  29584. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29585. * default is FLOAT
  29586. */
  29587. attribyteType: number;
  29588. /**
  29589. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29590. */
  29591. normalized: boolean;
  29592. /**
  29593. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29594. */
  29595. offset: number;
  29596. /**
  29597. * Name of the GLSL attribute, for debugging purpose only
  29598. */
  29599. attributeName: string;
  29600. }
  29601. /**
  29602. * Define options used to create a depth texture
  29603. */
  29604. export class DepthTextureCreationOptions {
  29605. /** Specifies whether or not a stencil should be allocated in the texture */
  29606. generateStencil?: boolean;
  29607. /** Specifies whether or not bilinear filtering is enable on the texture */
  29608. bilinearFiltering?: boolean;
  29609. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29610. comparisonFunction?: number;
  29611. /** Specifies if the created texture is a cube texture */
  29612. isCube?: boolean;
  29613. }
  29614. /**
  29615. * Class used to describe the capabilities of the engine relatively to the current browser
  29616. */
  29617. export class EngineCapabilities {
  29618. /** Maximum textures units per fragment shader */
  29619. maxTexturesImageUnits: number;
  29620. /** Maximum texture units per vertex shader */
  29621. maxVertexTextureImageUnits: number;
  29622. /** Maximum textures units in the entire pipeline */
  29623. maxCombinedTexturesImageUnits: number;
  29624. /** Maximum texture size */
  29625. maxTextureSize: number;
  29626. /** Maximum cube texture size */
  29627. maxCubemapTextureSize: number;
  29628. /** Maximum render texture size */
  29629. maxRenderTextureSize: number;
  29630. /** Maximum number of vertex attributes */
  29631. maxVertexAttribs: number;
  29632. /** Maximum number of varyings */
  29633. maxVaryingVectors: number;
  29634. /** Maximum number of uniforms per vertex shader */
  29635. maxVertexUniformVectors: number;
  29636. /** Maximum number of uniforms per fragment shader */
  29637. maxFragmentUniformVectors: number;
  29638. /** Defines if standard derivates (dx/dy) are supported */
  29639. standardDerivatives: boolean;
  29640. /** Defines if s3tc texture compression is supported */
  29641. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29642. /** Defines if pvrtc texture compression is supported */
  29643. pvrtc: any;
  29644. /** Defines if etc1 texture compression is supported */
  29645. etc1: any;
  29646. /** Defines if etc2 texture compression is supported */
  29647. etc2: any;
  29648. /** Defines if astc texture compression is supported */
  29649. astc: any;
  29650. /** Defines if float textures are supported */
  29651. textureFloat: boolean;
  29652. /** Defines if vertex array objects are supported */
  29653. vertexArrayObject: boolean;
  29654. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29655. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29656. /** Gets the maximum level of anisotropy supported */
  29657. maxAnisotropy: number;
  29658. /** Defines if instancing is supported */
  29659. instancedArrays: boolean;
  29660. /** Defines if 32 bits indices are supported */
  29661. uintIndices: boolean;
  29662. /** Defines if high precision shaders are supported */
  29663. highPrecisionShaderSupported: boolean;
  29664. /** Defines if depth reading in the fragment shader is supported */
  29665. fragmentDepthSupported: boolean;
  29666. /** Defines if float texture linear filtering is supported*/
  29667. textureFloatLinearFiltering: boolean;
  29668. /** Defines if rendering to float textures is supported */
  29669. textureFloatRender: boolean;
  29670. /** Defines if half float textures are supported*/
  29671. textureHalfFloat: boolean;
  29672. /** Defines if half float texture linear filtering is supported*/
  29673. textureHalfFloatLinearFiltering: boolean;
  29674. /** Defines if rendering to half float textures is supported */
  29675. textureHalfFloatRender: boolean;
  29676. /** Defines if textureLOD shader command is supported */
  29677. textureLOD: boolean;
  29678. /** Defines if draw buffers extension is supported */
  29679. drawBuffersExtension: boolean;
  29680. /** Defines if depth textures are supported */
  29681. depthTextureExtension: boolean;
  29682. /** Defines if float color buffer are supported */
  29683. colorBufferFloat: boolean;
  29684. /** Gets disjoint timer query extension (null if not supported) */
  29685. timerQuery: EXT_disjoint_timer_query;
  29686. /** Defines if timestamp can be used with timer query */
  29687. canUseTimestampForTimerQuery: boolean;
  29688. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29689. multiview: any;
  29690. /** Function used to let the system compiles shaders in background */
  29691. parallelShaderCompile: {
  29692. COMPLETION_STATUS_KHR: number;
  29693. };
  29694. /** Max number of texture samples for MSAA */
  29695. maxMSAASamples: number;
  29696. }
  29697. /** Interface defining initialization parameters for Engine class */
  29698. export interface EngineOptions extends WebGLContextAttributes {
  29699. /**
  29700. * Defines if the engine should no exceed a specified device ratio
  29701. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29702. */
  29703. limitDeviceRatio?: number;
  29704. /**
  29705. * Defines if webvr should be enabled automatically
  29706. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29707. */
  29708. autoEnableWebVR?: boolean;
  29709. /**
  29710. * Defines if webgl2 should be turned off even if supported
  29711. * @see http://doc.babylonjs.com/features/webgl2
  29712. */
  29713. disableWebGL2Support?: boolean;
  29714. /**
  29715. * Defines if webaudio should be initialized as well
  29716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29717. */
  29718. audioEngine?: boolean;
  29719. /**
  29720. * Defines if animations should run using a deterministic lock step
  29721. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29722. */
  29723. deterministicLockstep?: boolean;
  29724. /** Defines the maximum steps to use with deterministic lock step mode */
  29725. lockstepMaxSteps?: number;
  29726. /**
  29727. * Defines that engine should ignore context lost events
  29728. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29729. */
  29730. doNotHandleContextLost?: boolean;
  29731. /**
  29732. * Defines that engine should ignore modifying touch action attribute and style
  29733. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29734. */
  29735. doNotHandleTouchAction?: boolean;
  29736. /**
  29737. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29738. */
  29739. useHighPrecisionFloats?: boolean;
  29740. }
  29741. /**
  29742. * Defines the interface used by display changed events
  29743. */
  29744. export interface IDisplayChangedEventArgs {
  29745. /** Gets the vrDisplay object (if any) */
  29746. vrDisplay: Nullable<any>;
  29747. /** Gets a boolean indicating if webVR is supported */
  29748. vrSupported: boolean;
  29749. }
  29750. /**
  29751. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29752. */
  29753. export class Engine {
  29754. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29755. static ExceptionList: ({
  29756. key: string;
  29757. capture: string;
  29758. captureConstraint: number;
  29759. targets: string[];
  29760. } | {
  29761. key: string;
  29762. capture: null;
  29763. captureConstraint: null;
  29764. targets: string[];
  29765. })[];
  29766. /** Gets the list of created engines */
  29767. static readonly Instances: Engine[];
  29768. /**
  29769. * Gets the latest created engine
  29770. */
  29771. static readonly LastCreatedEngine: Nullable<Engine>;
  29772. /**
  29773. * Gets the latest created scene
  29774. */
  29775. static readonly LastCreatedScene: Nullable<Scene>;
  29776. /**
  29777. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29778. * @param flag defines which part of the materials must be marked as dirty
  29779. * @param predicate defines a predicate used to filter which materials should be affected
  29780. */
  29781. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29782. /** @hidden */
  29783. static _TextureLoaders: IInternalTextureLoader[];
  29784. /** Defines that alpha blending is disabled */
  29785. static readonly ALPHA_DISABLE: number;
  29786. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29787. static readonly ALPHA_ADD: number;
  29788. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29789. static readonly ALPHA_COMBINE: number;
  29790. /** Defines that alpha blending to DEST - SRC * DEST */
  29791. static readonly ALPHA_SUBTRACT: number;
  29792. /** Defines that alpha blending to SRC * DEST */
  29793. static readonly ALPHA_MULTIPLY: number;
  29794. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29795. static readonly ALPHA_MAXIMIZED: number;
  29796. /** Defines that alpha blending to SRC + DEST */
  29797. static readonly ALPHA_ONEONE: number;
  29798. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29799. static readonly ALPHA_PREMULTIPLIED: number;
  29800. /**
  29801. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29802. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29803. */
  29804. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29805. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29806. static readonly ALPHA_INTERPOLATE: number;
  29807. /**
  29808. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29809. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29810. */
  29811. static readonly ALPHA_SCREENMODE: number;
  29812. /** Defines that the ressource is not delayed*/
  29813. static readonly DELAYLOADSTATE_NONE: number;
  29814. /** Defines that the ressource was successfully delay loaded */
  29815. static readonly DELAYLOADSTATE_LOADED: number;
  29816. /** Defines that the ressource is currently delay loading */
  29817. static readonly DELAYLOADSTATE_LOADING: number;
  29818. /** Defines that the ressource is delayed and has not started loading */
  29819. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29820. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29821. static readonly NEVER: number;
  29822. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  29823. static readonly ALWAYS: number;
  29824. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29825. static readonly LESS: number;
  29826. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29827. static readonly EQUAL: number;
  29828. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  29829. static readonly LEQUAL: number;
  29830. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29831. static readonly GREATER: number;
  29832. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  29833. static readonly GEQUAL: number;
  29834. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  29835. static readonly NOTEQUAL: number;
  29836. /** Passed to stencilOperation to specify that stencil value must be kept */
  29837. static readonly KEEP: number;
  29838. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29839. static readonly REPLACE: number;
  29840. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29841. static readonly INCR: number;
  29842. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29843. static readonly DECR: number;
  29844. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29845. static readonly INVERT: number;
  29846. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29847. static readonly INCR_WRAP: number;
  29848. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29849. static readonly DECR_WRAP: number;
  29850. /** Texture is not repeating outside of 0..1 UVs */
  29851. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29852. /** Texture is repeating outside of 0..1 UVs */
  29853. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29854. /** Texture is repeating and mirrored */
  29855. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29856. /** ALPHA */
  29857. static readonly TEXTUREFORMAT_ALPHA: number;
  29858. /** LUMINANCE */
  29859. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29860. /** LUMINANCE_ALPHA */
  29861. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29862. /** RGB */
  29863. static readonly TEXTUREFORMAT_RGB: number;
  29864. /** RGBA */
  29865. static readonly TEXTUREFORMAT_RGBA: number;
  29866. /** RED */
  29867. static readonly TEXTUREFORMAT_RED: number;
  29868. /** RED (2nd reference) */
  29869. static readonly TEXTUREFORMAT_R: number;
  29870. /** RG */
  29871. static readonly TEXTUREFORMAT_RG: number;
  29872. /** RED_INTEGER */
  29873. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29874. /** RED_INTEGER (2nd reference) */
  29875. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29876. /** RG_INTEGER */
  29877. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29878. /** RGB_INTEGER */
  29879. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29880. /** RGBA_INTEGER */
  29881. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29882. /** UNSIGNED_BYTE */
  29883. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29884. /** UNSIGNED_BYTE (2nd reference) */
  29885. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29886. /** FLOAT */
  29887. static readonly TEXTURETYPE_FLOAT: number;
  29888. /** HALF_FLOAT */
  29889. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29890. /** BYTE */
  29891. static readonly TEXTURETYPE_BYTE: number;
  29892. /** SHORT */
  29893. static readonly TEXTURETYPE_SHORT: number;
  29894. /** UNSIGNED_SHORT */
  29895. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29896. /** INT */
  29897. static readonly TEXTURETYPE_INT: number;
  29898. /** UNSIGNED_INT */
  29899. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29900. /** UNSIGNED_SHORT_4_4_4_4 */
  29901. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29902. /** UNSIGNED_SHORT_5_5_5_1 */
  29903. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29904. /** UNSIGNED_SHORT_5_6_5 */
  29905. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29906. /** UNSIGNED_INT_2_10_10_10_REV */
  29907. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29908. /** UNSIGNED_INT_24_8 */
  29909. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29910. /** UNSIGNED_INT_10F_11F_11F_REV */
  29911. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29912. /** UNSIGNED_INT_5_9_9_9_REV */
  29913. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29914. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29915. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29916. /** nearest is mag = nearest and min = nearest and mip = linear */
  29917. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29918. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29919. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29920. /** Trilinear is mag = linear and min = linear and mip = linear */
  29921. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29922. /** nearest is mag = nearest and min = nearest and mip = linear */
  29923. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29924. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29925. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29926. /** Trilinear is mag = linear and min = linear and mip = linear */
  29927. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29928. /** mag = nearest and min = nearest and mip = nearest */
  29929. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29930. /** mag = nearest and min = linear and mip = nearest */
  29931. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29932. /** mag = nearest and min = linear and mip = linear */
  29933. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29934. /** mag = nearest and min = linear and mip = none */
  29935. static readonly TEXTURE_NEAREST_LINEAR: number;
  29936. /** mag = nearest and min = nearest and mip = none */
  29937. static readonly TEXTURE_NEAREST_NEAREST: number;
  29938. /** mag = linear and min = nearest and mip = nearest */
  29939. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29940. /** mag = linear and min = nearest and mip = linear */
  29941. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29942. /** mag = linear and min = linear and mip = none */
  29943. static readonly TEXTURE_LINEAR_LINEAR: number;
  29944. /** mag = linear and min = nearest and mip = none */
  29945. static readonly TEXTURE_LINEAR_NEAREST: number;
  29946. /** Explicit coordinates mode */
  29947. static readonly TEXTURE_EXPLICIT_MODE: number;
  29948. /** Spherical coordinates mode */
  29949. static readonly TEXTURE_SPHERICAL_MODE: number;
  29950. /** Planar coordinates mode */
  29951. static readonly TEXTURE_PLANAR_MODE: number;
  29952. /** Cubic coordinates mode */
  29953. static readonly TEXTURE_CUBIC_MODE: number;
  29954. /** Projection coordinates mode */
  29955. static readonly TEXTURE_PROJECTION_MODE: number;
  29956. /** Skybox coordinates mode */
  29957. static readonly TEXTURE_SKYBOX_MODE: number;
  29958. /** Inverse Cubic coordinates mode */
  29959. static readonly TEXTURE_INVCUBIC_MODE: number;
  29960. /** Equirectangular coordinates mode */
  29961. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29962. /** Equirectangular Fixed coordinates mode */
  29963. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29964. /** Equirectangular Fixed Mirrored coordinates mode */
  29965. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29966. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29967. static readonly SCALEMODE_FLOOR: number;
  29968. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29969. static readonly SCALEMODE_NEAREST: number;
  29970. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29971. static readonly SCALEMODE_CEILING: number;
  29972. /**
  29973. * Returns the current npm package of the sdk
  29974. */
  29975. static readonly NpmPackage: string;
  29976. /**
  29977. * Returns the current version of the framework
  29978. */
  29979. static readonly Version: string;
  29980. /**
  29981. * Returns a string describing the current engine
  29982. */
  29983. readonly description: string;
  29984. /**
  29985. * Gets or sets the epsilon value used by collision engine
  29986. */
  29987. static CollisionsEpsilon: number;
  29988. /**
  29989. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29990. */
  29991. static ShadersRepository: string;
  29992. /**
  29993. * Method called to create the default loading screen.
  29994. * This can be overriden in your own app.
  29995. * @param canvas The rendering canvas element
  29996. * @returns The loading screen
  29997. */
  29998. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  29999. /**
  30000. * Method called to create the default rescale post process on each engine.
  30001. */
  30002. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30003. /** @hidden */
  30004. _shaderProcessor: IShaderProcessor;
  30005. /**
  30006. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30007. */
  30008. forcePOTTextures: boolean;
  30009. /**
  30010. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30011. */
  30012. isFullscreen: boolean;
  30013. /**
  30014. * Gets a boolean indicating if the pointer is currently locked
  30015. */
  30016. isPointerLock: boolean;
  30017. /**
  30018. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30019. */
  30020. cullBackFaces: boolean;
  30021. /**
  30022. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30023. */
  30024. renderEvenInBackground: boolean;
  30025. /**
  30026. * Gets or sets a boolean indicating that cache can be kept between frames
  30027. */
  30028. preventCacheWipeBetweenFrames: boolean;
  30029. /**
  30030. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30031. **/
  30032. enableOfflineSupport: boolean;
  30033. /**
  30034. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  30035. **/
  30036. disableManifestCheck: boolean;
  30037. /**
  30038. * Gets the list of created scenes
  30039. */
  30040. scenes: Scene[];
  30041. /**
  30042. * Event raised when a new scene is created
  30043. */
  30044. onNewSceneAddedObservable: Observable<Scene>;
  30045. /**
  30046. * Gets the list of created postprocesses
  30047. */
  30048. postProcesses: PostProcess[];
  30049. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30050. validateShaderPrograms: boolean;
  30051. /**
  30052. * Observable event triggered each time the rendering canvas is resized
  30053. */
  30054. onResizeObservable: Observable<Engine>;
  30055. /**
  30056. * Observable event triggered each time the canvas loses focus
  30057. */
  30058. onCanvasBlurObservable: Observable<Engine>;
  30059. /**
  30060. * Observable event triggered each time the canvas gains focus
  30061. */
  30062. onCanvasFocusObservable: Observable<Engine>;
  30063. /**
  30064. * Observable event triggered each time the canvas receives pointerout event
  30065. */
  30066. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30067. /**
  30068. * Observable event triggered before each texture is initialized
  30069. */
  30070. onBeforeTextureInitObservable: Observable<Texture>;
  30071. /**
  30072. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30073. */
  30074. disableUniformBuffers: boolean;
  30075. /** @hidden */
  30076. _uniformBuffers: UniformBuffer[];
  30077. /**
  30078. * Gets a boolean indicating that the engine supports uniform buffers
  30079. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30080. */
  30081. readonly supportsUniformBuffers: boolean;
  30082. /**
  30083. * Observable raised when the engine begins a new frame
  30084. */
  30085. onBeginFrameObservable: Observable<Engine>;
  30086. /**
  30087. * If set, will be used to request the next animation frame for the render loop
  30088. */
  30089. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30090. /**
  30091. * Observable raised when the engine ends the current frame
  30092. */
  30093. onEndFrameObservable: Observable<Engine>;
  30094. /**
  30095. * Observable raised when the engine is about to compile a shader
  30096. */
  30097. onBeforeShaderCompilationObservable: Observable<Engine>;
  30098. /**
  30099. * Observable raised when the engine has jsut compiled a shader
  30100. */
  30101. onAfterShaderCompilationObservable: Observable<Engine>;
  30102. /** @hidden */
  30103. _gl: WebGLRenderingContext;
  30104. private _renderingCanvas;
  30105. private _windowIsBackground;
  30106. private _webGLVersion;
  30107. protected _highPrecisionShadersAllowed: boolean;
  30108. /** @hidden */
  30109. readonly _shouldUseHighPrecisionShader: boolean;
  30110. /**
  30111. * Gets a boolean indicating that only power of 2 textures are supported
  30112. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30113. */
  30114. readonly needPOTTextures: boolean;
  30115. /** @hidden */
  30116. _badOS: boolean;
  30117. /** @hidden */
  30118. _badDesktopOS: boolean;
  30119. /**
  30120. * Gets the audio engine
  30121. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30122. * @ignorenaming
  30123. */
  30124. static audioEngine: IAudioEngine;
  30125. /**
  30126. * Default AudioEngine factory responsible of creating the Audio Engine.
  30127. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30128. */
  30129. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30130. /**
  30131. * Default offline support factory responsible of creating a tool used to store data locally.
  30132. * By default, this will create a Database object if the workload has been embedded.
  30133. */
  30134. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30135. private _onFocus;
  30136. private _onBlur;
  30137. private _onCanvasPointerOut;
  30138. private _onCanvasBlur;
  30139. private _onCanvasFocus;
  30140. private _onFullscreenChange;
  30141. private _onPointerLockChange;
  30142. private _hardwareScalingLevel;
  30143. /** @hidden */
  30144. _caps: EngineCapabilities;
  30145. private _pointerLockRequested;
  30146. private _isStencilEnable;
  30147. private _colorWrite;
  30148. private _loadingScreen;
  30149. /** @hidden */
  30150. _drawCalls: PerfCounter;
  30151. private _glVersion;
  30152. private _glRenderer;
  30153. private _glVendor;
  30154. private _videoTextureSupported;
  30155. private _renderingQueueLaunched;
  30156. private _activeRenderLoops;
  30157. private _deterministicLockstep;
  30158. private _lockstepMaxSteps;
  30159. /**
  30160. * Observable signaled when a context lost event is raised
  30161. */
  30162. onContextLostObservable: Observable<Engine>;
  30163. /**
  30164. * Observable signaled when a context restored event is raised
  30165. */
  30166. onContextRestoredObservable: Observable<Engine>;
  30167. private _onContextLost;
  30168. private _onContextRestored;
  30169. private _contextWasLost;
  30170. /** @hidden */
  30171. _doNotHandleContextLost: boolean;
  30172. /**
  30173. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30174. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30175. */
  30176. doNotHandleContextLost: boolean;
  30177. private _performanceMonitor;
  30178. private _fps;
  30179. private _deltaTime;
  30180. /**
  30181. * Turn this value on if you want to pause FPS computation when in background
  30182. */
  30183. disablePerformanceMonitorInBackground: boolean;
  30184. /**
  30185. * Gets the performance monitor attached to this engine
  30186. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30187. */
  30188. readonly performanceMonitor: PerformanceMonitor;
  30189. /**
  30190. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30191. */
  30192. disableVertexArrayObjects: boolean;
  30193. /** @hidden */
  30194. protected _depthCullingState: _DepthCullingState;
  30195. /** @hidden */
  30196. protected _stencilState: _StencilState;
  30197. /** @hidden */
  30198. protected _alphaState: _AlphaState;
  30199. /** @hidden */
  30200. protected _alphaMode: number;
  30201. /** @hidden */
  30202. _internalTexturesCache: InternalTexture[];
  30203. /** @hidden */
  30204. protected _activeChannel: number;
  30205. private _currentTextureChannel;
  30206. /** @hidden */
  30207. protected _boundTexturesCache: {
  30208. [key: string]: Nullable<InternalTexture>;
  30209. };
  30210. /** @hidden */
  30211. protected _currentEffect: Nullable<Effect>;
  30212. /** @hidden */
  30213. protected _currentProgram: Nullable<WebGLProgram>;
  30214. private _compiledEffects;
  30215. private _vertexAttribArraysEnabled;
  30216. /** @hidden */
  30217. protected _cachedViewport: Nullable<IViewportLike>;
  30218. private _cachedVertexArrayObject;
  30219. /** @hidden */
  30220. protected _cachedVertexBuffers: any;
  30221. /** @hidden */
  30222. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30223. /** @hidden */
  30224. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30225. /** @hidden */
  30226. _currentRenderTarget: Nullable<InternalTexture>;
  30227. private _uintIndicesCurrentlySet;
  30228. private _currentBoundBuffer;
  30229. /** @hidden */
  30230. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30231. private _currentBufferPointers;
  30232. private _currentInstanceLocations;
  30233. private _currentInstanceBuffers;
  30234. private _textureUnits;
  30235. /** @hidden */
  30236. _workingCanvas: Nullable<HTMLCanvasElement>;
  30237. /** @hidden */
  30238. _workingContext: Nullable<CanvasRenderingContext2D>;
  30239. private _rescalePostProcess;
  30240. private _dummyFramebuffer;
  30241. private _externalData;
  30242. /** @hidden */
  30243. _bindedRenderFunction: any;
  30244. private _vaoRecordInProgress;
  30245. private _mustWipeVertexAttributes;
  30246. private _emptyTexture;
  30247. private _emptyCubeTexture;
  30248. private _emptyTexture3D;
  30249. /** @hidden */
  30250. _frameHandler: number;
  30251. private _nextFreeTextureSlots;
  30252. private _maxSimultaneousTextures;
  30253. private _activeRequests;
  30254. private _texturesSupported;
  30255. /** @hidden */
  30256. _textureFormatInUse: Nullable<string>;
  30257. /**
  30258. * Gets the list of texture formats supported
  30259. */
  30260. readonly texturesSupported: Array<string>;
  30261. /**
  30262. * Gets the list of texture formats in use
  30263. */
  30264. readonly textureFormatInUse: Nullable<string>;
  30265. /**
  30266. * Gets the current viewport
  30267. */
  30268. readonly currentViewport: Nullable<IViewportLike>;
  30269. /**
  30270. * Gets the default empty texture
  30271. */
  30272. readonly emptyTexture: InternalTexture;
  30273. /**
  30274. * Gets the default empty 3D texture
  30275. */
  30276. readonly emptyTexture3D: InternalTexture;
  30277. /**
  30278. * Gets the default empty cube texture
  30279. */
  30280. readonly emptyCubeTexture: InternalTexture;
  30281. /**
  30282. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30283. */
  30284. readonly premultipliedAlpha: boolean;
  30285. /**
  30286. * Creates a new engine
  30287. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  30288. * @param antialias defines enable antialiasing (default: false)
  30289. * @param options defines further options to be sent to the getContext() function
  30290. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30291. */
  30292. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30293. /**
  30294. * Initializes a webVR display and starts listening to display change events
  30295. * The onVRDisplayChangedObservable will be notified upon these changes
  30296. * @returns The onVRDisplayChangedObservable
  30297. */
  30298. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30299. /** @hidden */
  30300. _prepareVRComponent(): void;
  30301. /** @hidden */
  30302. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30303. /** @hidden */
  30304. _submitVRFrame(): void;
  30305. /**
  30306. * Call this function to leave webVR mode
  30307. * Will do nothing if webVR is not supported or if there is no webVR device
  30308. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30309. */
  30310. disableVR(): void;
  30311. /**
  30312. * Gets a boolean indicating that the system is in VR mode and is presenting
  30313. * @returns true if VR mode is engaged
  30314. */
  30315. isVRPresenting(): boolean;
  30316. /** @hidden */
  30317. _requestVRFrame(): void;
  30318. private _disableTouchAction;
  30319. private _rebuildInternalTextures;
  30320. private _rebuildEffects;
  30321. /**
  30322. * Gets a boolean indicating if all created effects are ready
  30323. * @returns true if all effects are ready
  30324. */
  30325. areAllEffectsReady(): boolean;
  30326. private _rebuildBuffers;
  30327. private _initGLContext;
  30328. /**
  30329. * Gets version of the current webGL context
  30330. */
  30331. readonly webGLVersion: number;
  30332. /**
  30333. * Gets a string idenfifying the name of the class
  30334. * @returns "Engine" string
  30335. */
  30336. getClassName(): string;
  30337. /**
  30338. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30339. */
  30340. readonly isStencilEnable: boolean;
  30341. /** @hidden */
  30342. _prepareWorkingCanvas(): void;
  30343. /**
  30344. * Reset the texture cache to empty state
  30345. */
  30346. resetTextureCache(): void;
  30347. /**
  30348. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30349. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30350. * @returns true if engine is in deterministic lock step mode
  30351. */
  30352. isDeterministicLockStep(): boolean;
  30353. /**
  30354. * Gets the max steps when engine is running in deterministic lock step
  30355. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30356. * @returns the max steps
  30357. */
  30358. getLockstepMaxSteps(): number;
  30359. /**
  30360. * Gets an object containing information about the current webGL context
  30361. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30362. */
  30363. getGlInfo(): {
  30364. vendor: string;
  30365. renderer: string;
  30366. version: string;
  30367. };
  30368. /**
  30369. * Gets current aspect ratio
  30370. * @param viewportOwner defines the camera to use to get the aspect ratio
  30371. * @param useScreen defines if screen size must be used (or the current render target if any)
  30372. * @returns a number defining the aspect ratio
  30373. */
  30374. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30375. /**
  30376. * Gets current screen aspect ratio
  30377. * @returns a number defining the aspect ratio
  30378. */
  30379. getScreenAspectRatio(): number;
  30380. /**
  30381. * Gets the current render width
  30382. * @param useScreen defines if screen size must be used (or the current render target if any)
  30383. * @returns a number defining the current render width
  30384. */
  30385. getRenderWidth(useScreen?: boolean): number;
  30386. /**
  30387. * Gets the current render height
  30388. * @param useScreen defines if screen size must be used (or the current render target if any)
  30389. * @returns a number defining the current render height
  30390. */
  30391. getRenderHeight(useScreen?: boolean): number;
  30392. /**
  30393. * Gets the HTML canvas attached with the current webGL context
  30394. * @returns a HTML canvas
  30395. */
  30396. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30397. /**
  30398. * Gets host window
  30399. * @returns the host window object
  30400. */
  30401. getHostWindow(): Window;
  30402. /**
  30403. * Gets host document
  30404. * @returns the host document object
  30405. */
  30406. getHostDocument(): Document;
  30407. /**
  30408. * Gets the client rect of the HTML canvas attached with the current webGL context
  30409. * @returns a client rectanglee
  30410. */
  30411. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30412. /**
  30413. * Defines the hardware scaling level.
  30414. * By default the hardware scaling level is computed from the window device ratio.
  30415. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  30416. * @param level defines the level to use
  30417. */
  30418. setHardwareScalingLevel(level: number): void;
  30419. /**
  30420. * Gets the current hardware scaling level.
  30421. * By default the hardware scaling level is computed from the window device ratio.
  30422. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  30423. * @returns a number indicating the current hardware scaling level
  30424. */
  30425. getHardwareScalingLevel(): number;
  30426. /**
  30427. * Gets the list of loaded textures
  30428. * @returns an array containing all loaded textures
  30429. */
  30430. getLoadedTexturesCache(): InternalTexture[];
  30431. /**
  30432. * Gets the object containing all engine capabilities
  30433. * @returns the EngineCapabilities object
  30434. */
  30435. getCaps(): EngineCapabilities;
  30436. /**
  30437. * Gets the current depth function
  30438. * @returns a number defining the depth function
  30439. */
  30440. getDepthFunction(): Nullable<number>;
  30441. /**
  30442. * Sets the current depth function
  30443. * @param depthFunc defines the function to use
  30444. */
  30445. setDepthFunction(depthFunc: number): void;
  30446. /**
  30447. * Sets the current depth function to GREATER
  30448. */
  30449. setDepthFunctionToGreater(): void;
  30450. /**
  30451. * Sets the current depth function to GEQUAL
  30452. */
  30453. setDepthFunctionToGreaterOrEqual(): void;
  30454. /**
  30455. * Sets the current depth function to LESS
  30456. */
  30457. setDepthFunctionToLess(): void;
  30458. private _cachedStencilBuffer;
  30459. private _cachedStencilFunction;
  30460. private _cachedStencilMask;
  30461. private _cachedStencilOperationPass;
  30462. private _cachedStencilOperationFail;
  30463. private _cachedStencilOperationDepthFail;
  30464. private _cachedStencilReference;
  30465. /**
  30466. * Caches the the state of the stencil buffer
  30467. */
  30468. cacheStencilState(): void;
  30469. /**
  30470. * Restores the state of the stencil buffer
  30471. */
  30472. restoreStencilState(): void;
  30473. /**
  30474. * Sets the current depth function to LEQUAL
  30475. */
  30476. setDepthFunctionToLessOrEqual(): void;
  30477. /**
  30478. * Gets a boolean indicating if stencil buffer is enabled
  30479. * @returns the current stencil buffer state
  30480. */
  30481. getStencilBuffer(): boolean;
  30482. /**
  30483. * Enable or disable the stencil buffer
  30484. * @param enable defines if the stencil buffer must be enabled or disabled
  30485. */
  30486. setStencilBuffer(enable: boolean): void;
  30487. /**
  30488. * Gets the current stencil mask
  30489. * @returns a number defining the new stencil mask to use
  30490. */
  30491. getStencilMask(): number;
  30492. /**
  30493. * Sets the current stencil mask
  30494. * @param mask defines the new stencil mask to use
  30495. */
  30496. setStencilMask(mask: number): void;
  30497. /**
  30498. * Gets the current stencil function
  30499. * @returns a number defining the stencil function to use
  30500. */
  30501. getStencilFunction(): number;
  30502. /**
  30503. * Gets the current stencil reference value
  30504. * @returns a number defining the stencil reference value to use
  30505. */
  30506. getStencilFunctionReference(): number;
  30507. /**
  30508. * Gets the current stencil mask
  30509. * @returns a number defining the stencil mask to use
  30510. */
  30511. getStencilFunctionMask(): number;
  30512. /**
  30513. * Sets the current stencil function
  30514. * @param stencilFunc defines the new stencil function to use
  30515. */
  30516. setStencilFunction(stencilFunc: number): void;
  30517. /**
  30518. * Sets the current stencil reference
  30519. * @param reference defines the new stencil reference to use
  30520. */
  30521. setStencilFunctionReference(reference: number): void;
  30522. /**
  30523. * Sets the current stencil mask
  30524. * @param mask defines the new stencil mask to use
  30525. */
  30526. setStencilFunctionMask(mask: number): void;
  30527. /**
  30528. * Gets the current stencil operation when stencil fails
  30529. * @returns a number defining stencil operation to use when stencil fails
  30530. */
  30531. getStencilOperationFail(): number;
  30532. /**
  30533. * Gets the current stencil operation when depth fails
  30534. * @returns a number defining stencil operation to use when depth fails
  30535. */
  30536. getStencilOperationDepthFail(): number;
  30537. /**
  30538. * Gets the current stencil operation when stencil passes
  30539. * @returns a number defining stencil operation to use when stencil passes
  30540. */
  30541. getStencilOperationPass(): number;
  30542. /**
  30543. * Sets the stencil operation to use when stencil fails
  30544. * @param operation defines the stencil operation to use when stencil fails
  30545. */
  30546. setStencilOperationFail(operation: number): void;
  30547. /**
  30548. * Sets the stencil operation to use when depth fails
  30549. * @param operation defines the stencil operation to use when depth fails
  30550. */
  30551. setStencilOperationDepthFail(operation: number): void;
  30552. /**
  30553. * Sets the stencil operation to use when stencil passes
  30554. * @param operation defines the stencil operation to use when stencil passes
  30555. */
  30556. setStencilOperationPass(operation: number): void;
  30557. /**
  30558. * Sets a boolean indicating if the dithering state is enabled or disabled
  30559. * @param value defines the dithering state
  30560. */
  30561. setDitheringState(value: boolean): void;
  30562. /**
  30563. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30564. * @param value defines the rasterizer state
  30565. */
  30566. setRasterizerState(value: boolean): void;
  30567. /**
  30568. * stop executing a render loop function and remove it from the execution array
  30569. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30570. */
  30571. stopRenderLoop(renderFunction?: () => void): void;
  30572. /** @hidden */
  30573. _renderLoop(): void;
  30574. /**
  30575. * Register and execute a render loop. The engine can have more than one render function
  30576. * @param renderFunction defines the function to continuously execute
  30577. */
  30578. runRenderLoop(renderFunction: () => void): void;
  30579. /**
  30580. * Toggle full screen mode
  30581. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30582. */
  30583. switchFullscreen(requestPointerLock: boolean): void;
  30584. /**
  30585. * Enters full screen mode
  30586. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30587. */
  30588. enterFullscreen(requestPointerLock: boolean): void;
  30589. /**
  30590. * Exits full screen mode
  30591. */
  30592. exitFullscreen(): void;
  30593. /**
  30594. * Enters Pointerlock mode
  30595. */
  30596. enterPointerlock(): void;
  30597. /**
  30598. * Exits Pointerlock mode
  30599. */
  30600. exitPointerlock(): void;
  30601. /**
  30602. * Clear the current render buffer or the current render target (if any is set up)
  30603. * @param color defines the color to use
  30604. * @param backBuffer defines if the back buffer must be cleared
  30605. * @param depth defines if the depth buffer must be cleared
  30606. * @param stencil defines if the stencil buffer must be cleared
  30607. */
  30608. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30609. /**
  30610. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30611. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30612. * @param y defines the y-coordinate of the corner of the clear rectangle
  30613. * @param width defines the width of the clear rectangle
  30614. * @param height defines the height of the clear rectangle
  30615. * @param clearColor defines the clear color
  30616. */
  30617. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30618. /**
  30619. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30620. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30621. * @param y defines the y-coordinate of the corner of the clear rectangle
  30622. * @param width defines the width of the clear rectangle
  30623. * @param height defines the height of the clear rectangle
  30624. */
  30625. enableScissor(x: number, y: number, width: number, height: number): void;
  30626. /**
  30627. * Disable previously set scissor test rectangle
  30628. */
  30629. disableScissor(): void;
  30630. private _viewportCached;
  30631. /** @hidden */
  30632. _viewport(x: number, y: number, width: number, height: number): void;
  30633. /**
  30634. * Set the WebGL's viewport
  30635. * @param viewport defines the viewport element to be used
  30636. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30637. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30638. */
  30639. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30640. /**
  30641. * Directly set the WebGL Viewport
  30642. * @param x defines the x coordinate of the viewport (in screen space)
  30643. * @param y defines the y coordinate of the viewport (in screen space)
  30644. * @param width defines the width of the viewport (in screen space)
  30645. * @param height defines the height of the viewport (in screen space)
  30646. * @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
  30647. */
  30648. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30649. /**
  30650. * Begin a new frame
  30651. */
  30652. beginFrame(): void;
  30653. /**
  30654. * Enf the current frame
  30655. */
  30656. endFrame(): void;
  30657. /**
  30658. * Resize the view according to the canvas' size
  30659. */
  30660. resize(): void;
  30661. /**
  30662. * Force a specific size of the canvas
  30663. * @param width defines the new canvas' width
  30664. * @param height defines the new canvas' height
  30665. */
  30666. setSize(width: number, height: number): void;
  30667. /**
  30668. * Binds the frame buffer to the specified texture.
  30669. * @param texture The texture to render to or null for the default canvas
  30670. * @param faceIndex The face of the texture to render to in case of cube texture
  30671. * @param requiredWidth The width of the target to render to
  30672. * @param requiredHeight The height of the target to render to
  30673. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30674. * @param depthStencilTexture The depth stencil texture to use to render
  30675. * @param lodLevel defines le lod level to bind to the frame buffer
  30676. */
  30677. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30678. /** @hidden */
  30679. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30680. /**
  30681. * Unbind the current render target texture from the webGL context
  30682. * @param texture defines the render target texture to unbind
  30683. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30684. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30685. */
  30686. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30687. /**
  30688. * Force the mipmap generation for the given render target texture
  30689. * @param texture defines the render target texture to use
  30690. */
  30691. generateMipMapsForCubemap(texture: InternalTexture): void;
  30692. /**
  30693. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30694. */
  30695. flushFramebuffer(): void;
  30696. /**
  30697. * Unbind the current render target and bind the default framebuffer
  30698. */
  30699. restoreDefaultFramebuffer(): void;
  30700. /**
  30701. * Create an uniform buffer
  30702. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30703. * @param elements defines the content of the uniform buffer
  30704. * @returns the webGL uniform buffer
  30705. */
  30706. createUniformBuffer(elements: FloatArray): DataBuffer;
  30707. /**
  30708. * Create a dynamic uniform buffer
  30709. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30710. * @param elements defines the content of the uniform buffer
  30711. * @returns the webGL uniform buffer
  30712. */
  30713. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30714. /**
  30715. * Update an existing uniform buffer
  30716. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30717. * @param uniformBuffer defines the target uniform buffer
  30718. * @param elements defines the content to update
  30719. * @param offset defines the offset in the uniform buffer where update should start
  30720. * @param count defines the size of the data to update
  30721. */
  30722. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30723. private _resetVertexBufferBinding;
  30724. /**
  30725. * Creates a vertex buffer
  30726. * @param data the data for the vertex buffer
  30727. * @returns the new WebGL static buffer
  30728. */
  30729. createVertexBuffer(data: DataArray): DataBuffer;
  30730. /**
  30731. * Creates a dynamic vertex buffer
  30732. * @param data the data for the dynamic vertex buffer
  30733. * @returns the new WebGL dynamic buffer
  30734. */
  30735. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30736. /**
  30737. * Update a dynamic index buffer
  30738. * @param indexBuffer defines the target index buffer
  30739. * @param indices defines the data to update
  30740. * @param offset defines the offset in the target index buffer where update should start
  30741. */
  30742. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30743. /**
  30744. * Updates a dynamic vertex buffer.
  30745. * @param vertexBuffer the vertex buffer to update
  30746. * @param data the data used to update the vertex buffer
  30747. * @param byteOffset the byte offset of the data
  30748. * @param byteLength the byte length of the data
  30749. */
  30750. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30751. private _resetIndexBufferBinding;
  30752. /**
  30753. * Creates a new index buffer
  30754. * @param indices defines the content of the index buffer
  30755. * @param updatable defines if the index buffer must be updatable
  30756. * @returns a new webGL buffer
  30757. */
  30758. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30759. /**
  30760. * Bind a webGL buffer to the webGL context
  30761. * @param buffer defines the buffer to bind
  30762. */
  30763. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30764. /**
  30765. * Bind an uniform buffer to the current webGL context
  30766. * @param buffer defines the buffer to bind
  30767. */
  30768. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30769. /**
  30770. * Bind a buffer to the current webGL context at a given location
  30771. * @param buffer defines the buffer to bind
  30772. * @param location defines the index where to bind the buffer
  30773. */
  30774. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30775. /**
  30776. * Bind a specific block at a given index in a specific shader program
  30777. * @param pipelineContext defines the pipeline context to use
  30778. * @param blockName defines the block name
  30779. * @param index defines the index where to bind the block
  30780. */
  30781. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30782. private bindIndexBuffer;
  30783. private bindBuffer;
  30784. /**
  30785. * update the bound buffer with the given data
  30786. * @param data defines the data to update
  30787. */
  30788. updateArrayBuffer(data: Float32Array): void;
  30789. private _vertexAttribPointer;
  30790. private _bindIndexBufferWithCache;
  30791. private _bindVertexBuffersAttributes;
  30792. /**
  30793. * Records a vertex array object
  30794. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30795. * @param vertexBuffers defines the list of vertex buffers to store
  30796. * @param indexBuffer defines the index buffer to store
  30797. * @param effect defines the effect to store
  30798. * @returns the new vertex array object
  30799. */
  30800. recordVertexArrayObject(vertexBuffers: {
  30801. [key: string]: VertexBuffer;
  30802. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30803. /**
  30804. * Bind a specific vertex array object
  30805. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30806. * @param vertexArrayObject defines the vertex array object to bind
  30807. * @param indexBuffer defines the index buffer to bind
  30808. */
  30809. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30810. /**
  30811. * Bind webGl buffers directly to the webGL context
  30812. * @param vertexBuffer defines the vertex buffer to bind
  30813. * @param indexBuffer defines the index buffer to bind
  30814. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30815. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30816. * @param effect defines the effect associated with the vertex buffer
  30817. */
  30818. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30819. private _unbindVertexArrayObject;
  30820. /**
  30821. * Bind a list of vertex buffers to the webGL context
  30822. * @param vertexBuffers defines the list of vertex buffers to bind
  30823. * @param indexBuffer defines the index buffer to bind
  30824. * @param effect defines the effect associated with the vertex buffers
  30825. */
  30826. bindBuffers(vertexBuffers: {
  30827. [key: string]: Nullable<VertexBuffer>;
  30828. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30829. /**
  30830. * Unbind all instance attributes
  30831. */
  30832. unbindInstanceAttributes(): void;
  30833. /**
  30834. * Release and free the memory of a vertex array object
  30835. * @param vao defines the vertex array object to delete
  30836. */
  30837. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30838. /** @hidden */
  30839. _releaseBuffer(buffer: DataBuffer): boolean;
  30840. /**
  30841. * Creates a webGL buffer to use with instanciation
  30842. * @param capacity defines the size of the buffer
  30843. * @returns the webGL buffer
  30844. */
  30845. createInstancesBuffer(capacity: number): DataBuffer;
  30846. /**
  30847. * Delete a webGL buffer used with instanciation
  30848. * @param buffer defines the webGL buffer to delete
  30849. */
  30850. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30851. /**
  30852. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30853. * @param instancesBuffer defines the webGL buffer to update and bind
  30854. * @param data defines the data to store in the buffer
  30855. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30856. */
  30857. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30858. /**
  30859. * Apply all cached states (depth, culling, stencil and alpha)
  30860. */
  30861. applyStates(): void;
  30862. /**
  30863. * Send a draw order
  30864. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30865. * @param indexStart defines the starting index
  30866. * @param indexCount defines the number of index to draw
  30867. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30868. */
  30869. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30870. /**
  30871. * Draw a list of points
  30872. * @param verticesStart defines the index of first vertex to draw
  30873. * @param verticesCount defines the count of vertices to draw
  30874. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30875. */
  30876. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30877. /**
  30878. * Draw a list of unindexed primitives
  30879. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30880. * @param verticesStart defines the index of first vertex to draw
  30881. * @param verticesCount defines the count of vertices to draw
  30882. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30883. */
  30884. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30885. /**
  30886. * Draw a list of indexed primitives
  30887. * @param fillMode defines the primitive to use
  30888. * @param indexStart defines the starting index
  30889. * @param indexCount defines the number of index to draw
  30890. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30891. */
  30892. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30893. /**
  30894. * Draw a list of unindexed primitives
  30895. * @param fillMode defines the primitive to use
  30896. * @param verticesStart defines the index of first vertex to draw
  30897. * @param verticesCount defines the count of vertices to draw
  30898. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30899. */
  30900. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30901. private _drawMode;
  30902. /** @hidden */
  30903. _releaseEffect(effect: Effect): void;
  30904. /** @hidden */
  30905. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30906. /**
  30907. * Create a new effect (used to store vertex/fragment shaders)
  30908. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30909. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30910. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30911. * @param samplers defines an array of string used to represent textures
  30912. * @param defines defines the string containing the defines to use to compile the shaders
  30913. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30914. * @param onCompiled defines a function to call when the effect creation is successful
  30915. * @param onError defines a function to call when the effect creation has failed
  30916. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30917. * @returns the new Effect
  30918. */
  30919. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30920. private _compileShader;
  30921. private _compileRawShader;
  30922. /**
  30923. * Directly creates a webGL program
  30924. * @param pipelineContext defines the pipeline context to attach to
  30925. * @param vertexCode defines the vertex shader code to use
  30926. * @param fragmentCode defines the fragment shader code to use
  30927. * @param context defines the webGL context to use (if not set, the current one will be used)
  30928. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30929. * @returns the new webGL program
  30930. */
  30931. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30932. /**
  30933. * Creates a webGL program
  30934. * @param pipelineContext defines the pipeline context to attach to
  30935. * @param vertexCode defines the vertex shader code to use
  30936. * @param fragmentCode defines the fragment shader code to use
  30937. * @param defines defines the string containing the defines to use to compile the shaders
  30938. * @param context defines the webGL context to use (if not set, the current one will be used)
  30939. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30940. * @returns the new webGL program
  30941. */
  30942. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30943. /**
  30944. * Creates a new pipeline context
  30945. * @returns the new pipeline
  30946. */
  30947. createPipelineContext(): WebGLPipelineContext;
  30948. private _createShaderProgram;
  30949. private _finalizePipelineContext;
  30950. /** @hidden */
  30951. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30952. /** @hidden */
  30953. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30954. /** @hidden */
  30955. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30956. /**
  30957. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30958. * @param pipelineContext defines the pipeline context to use
  30959. * @param uniformsNames defines the list of uniform names
  30960. * @returns an array of webGL uniform locations
  30961. */
  30962. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30963. /**
  30964. * Gets the lsit of active attributes for a given webGL program
  30965. * @param pipelineContext defines the pipeline context to use
  30966. * @param attributesNames defines the list of attribute names to get
  30967. * @returns an array of indices indicating the offset of each attribute
  30968. */
  30969. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30970. /**
  30971. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30972. * @param effect defines the effect to activate
  30973. */
  30974. enableEffect(effect: Nullable<Effect>): void;
  30975. /**
  30976. * Set the value of an uniform to an array of int32
  30977. * @param uniform defines the webGL uniform location where to store the value
  30978. * @param array defines the array of int32 to store
  30979. */
  30980. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30981. /**
  30982. * Set the value of an uniform to an array of int32 (stored as vec2)
  30983. * @param uniform defines the webGL uniform location where to store the value
  30984. * @param array defines the array of int32 to store
  30985. */
  30986. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30987. /**
  30988. * Set the value of an uniform to an array of int32 (stored as vec3)
  30989. * @param uniform defines the webGL uniform location where to store the value
  30990. * @param array defines the array of int32 to store
  30991. */
  30992. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30993. /**
  30994. * Set the value of an uniform to an array of int32 (stored as vec4)
  30995. * @param uniform defines the webGL uniform location where to store the value
  30996. * @param array defines the array of int32 to store
  30997. */
  30998. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30999. /**
  31000. * Set the value of an uniform to an array of float32
  31001. * @param uniform defines the webGL uniform location where to store the value
  31002. * @param array defines the array of float32 to store
  31003. */
  31004. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31005. /**
  31006. * Set the value of an uniform to an array of float32 (stored as vec2)
  31007. * @param uniform defines the webGL uniform location where to store the value
  31008. * @param array defines the array of float32 to store
  31009. */
  31010. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31011. /**
  31012. * Set the value of an uniform to an array of float32 (stored as vec3)
  31013. * @param uniform defines the webGL uniform location where to store the value
  31014. * @param array defines the array of float32 to store
  31015. */
  31016. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31017. /**
  31018. * Set the value of an uniform to an array of float32 (stored as vec4)
  31019. * @param uniform defines the webGL uniform location where to store the value
  31020. * @param array defines the array of float32 to store
  31021. */
  31022. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31023. /**
  31024. * Set the value of an uniform to an array of number
  31025. * @param uniform defines the webGL uniform location where to store the value
  31026. * @param array defines the array of number to store
  31027. */
  31028. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31029. /**
  31030. * Set the value of an uniform to an array of number (stored as vec2)
  31031. * @param uniform defines the webGL uniform location where to store the value
  31032. * @param array defines the array of number to store
  31033. */
  31034. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31035. /**
  31036. * Set the value of an uniform to an array of number (stored as vec3)
  31037. * @param uniform defines the webGL uniform location where to store the value
  31038. * @param array defines the array of number to store
  31039. */
  31040. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31041. /**
  31042. * Set the value of an uniform to an array of number (stored as vec4)
  31043. * @param uniform defines the webGL uniform location where to store the value
  31044. * @param array defines the array of number to store
  31045. */
  31046. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31047. /**
  31048. * Set the value of an uniform to an array of float32 (stored as matrices)
  31049. * @param uniform defines the webGL uniform location where to store the value
  31050. * @param matrices defines the array of float32 to store
  31051. */
  31052. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31053. /**
  31054. * Set the value of an uniform to a matrix (3x3)
  31055. * @param uniform defines the webGL uniform location where to store the value
  31056. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31057. */
  31058. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31059. /**
  31060. * Set the value of an uniform to a matrix (2x2)
  31061. * @param uniform defines the webGL uniform location where to store the value
  31062. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31063. */
  31064. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31065. /**
  31066. * Set the value of an uniform to a number (int)
  31067. * @param uniform defines the webGL uniform location where to store the value
  31068. * @param value defines the int number to store
  31069. */
  31070. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31071. /**
  31072. * Set the value of an uniform to a number (float)
  31073. * @param uniform defines the webGL uniform location where to store the value
  31074. * @param value defines the float number to store
  31075. */
  31076. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31077. /**
  31078. * Set the value of an uniform to a vec2
  31079. * @param uniform defines the webGL uniform location where to store the value
  31080. * @param x defines the 1st component of the value
  31081. * @param y defines the 2nd component of the value
  31082. */
  31083. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31084. /**
  31085. * Set the value of an uniform to a vec3
  31086. * @param uniform defines the webGL uniform location where to store the value
  31087. * @param x defines the 1st component of the value
  31088. * @param y defines the 2nd component of the value
  31089. * @param z defines the 3rd component of the value
  31090. */
  31091. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31092. /**
  31093. * Set the value of an uniform to a boolean
  31094. * @param uniform defines the webGL uniform location where to store the value
  31095. * @param bool defines the boolean to store
  31096. */
  31097. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31098. /**
  31099. * Set the value of an uniform to a vec4
  31100. * @param uniform defines the webGL uniform location where to store the value
  31101. * @param x defines the 1st component of the value
  31102. * @param y defines the 2nd component of the value
  31103. * @param z defines the 3rd component of the value
  31104. * @param w defines the 4th component of the value
  31105. */
  31106. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31107. /**
  31108. * Sets a Color4 on a uniform variable
  31109. * @param uniform defines the uniform location
  31110. * @param color4 defines the value to be set
  31111. */
  31112. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31113. /**
  31114. * Set various states to the webGL context
  31115. * @param culling defines backface culling state
  31116. * @param zOffset defines the value to apply to zOffset (0 by default)
  31117. * @param force defines if states must be applied even if cache is up to date
  31118. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31119. */
  31120. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31121. /**
  31122. * Set the z offset to apply to current rendering
  31123. * @param value defines the offset to apply
  31124. */
  31125. setZOffset(value: number): void;
  31126. /**
  31127. * Gets the current value of the zOffset
  31128. * @returns the current zOffset state
  31129. */
  31130. getZOffset(): number;
  31131. /**
  31132. * Enable or disable depth buffering
  31133. * @param enable defines the state to set
  31134. */
  31135. setDepthBuffer(enable: boolean): void;
  31136. /**
  31137. * Gets a boolean indicating if depth writing is enabled
  31138. * @returns the current depth writing state
  31139. */
  31140. getDepthWrite(): boolean;
  31141. /**
  31142. * Enable or disable depth writing
  31143. * @param enable defines the state to set
  31144. */
  31145. setDepthWrite(enable: boolean): void;
  31146. /**
  31147. * Enable or disable color writing
  31148. * @param enable defines the state to set
  31149. */
  31150. setColorWrite(enable: boolean): void;
  31151. /**
  31152. * Gets a boolean indicating if color writing is enabled
  31153. * @returns the current color writing state
  31154. */
  31155. getColorWrite(): boolean;
  31156. /**
  31157. * Sets alpha constants used by some alpha blending modes
  31158. * @param r defines the red component
  31159. * @param g defines the green component
  31160. * @param b defines the blue component
  31161. * @param a defines the alpha component
  31162. */
  31163. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31164. /**
  31165. * Sets the current alpha mode
  31166. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31167. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31168. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31169. */
  31170. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31171. /**
  31172. * Gets the current alpha mode
  31173. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31174. * @returns the current alpha mode
  31175. */
  31176. getAlphaMode(): number;
  31177. /**
  31178. * Clears the list of texture accessible through engine.
  31179. * This can help preventing texture load conflict due to name collision.
  31180. */
  31181. clearInternalTexturesCache(): void;
  31182. /**
  31183. * Force the entire cache to be cleared
  31184. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31185. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31186. */
  31187. wipeCaches(bruteForce?: boolean): void;
  31188. /**
  31189. * Set the compressed texture format to use, based on the formats you have, and the formats
  31190. * supported by the hardware / browser.
  31191. *
  31192. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31193. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31194. * to API arguments needed to compressed textures. This puts the burden on the container
  31195. * generator to house the arcane code for determining these for current & future formats.
  31196. *
  31197. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31198. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31199. *
  31200. * Note: The result of this call is not taken into account when a texture is base64.
  31201. *
  31202. * @param formatsAvailable defines the list of those format families you have created
  31203. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31204. *
  31205. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31206. * @returns The extension selected.
  31207. */
  31208. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31209. /** @hidden */
  31210. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31211. min: number;
  31212. mag: number;
  31213. };
  31214. /** @hidden */
  31215. _createTexture(): WebGLTexture;
  31216. /**
  31217. * Usually called from Texture.ts.
  31218. * Passed information to create a WebGLTexture
  31219. * @param urlArg defines a value which contains one of the following:
  31220. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31221. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31222. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31223. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31224. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  31225. * @param scene needed for loading to the correct scene
  31226. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31227. * @param onLoad optional callback to be called upon successful completion
  31228. * @param onError optional callback to be called upon failure
  31229. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  31230. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31231. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31232. * @param forcedExtension defines the extension to use to pick the right loader
  31233. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31234. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31235. */
  31236. 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<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31237. /**
  31238. * @hidden
  31239. * Rescales a texture
  31240. * @param source input texutre
  31241. * @param destination destination texture
  31242. * @param scene scene to use to render the resize
  31243. * @param internalFormat format to use when resizing
  31244. * @param onComplete callback to be called when resize has completed
  31245. */
  31246. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31247. private _unpackFlipYCached;
  31248. /**
  31249. * In case you are sharing the context with other applications, it might
  31250. * be interested to not cache the unpack flip y state to ensure a consistent
  31251. * value would be set.
  31252. */
  31253. enableUnpackFlipYCached: boolean;
  31254. /** @hidden */
  31255. _unpackFlipY(value: boolean): void;
  31256. /** @hidden */
  31257. _getUnpackAlignement(): number;
  31258. /**
  31259. * Creates a dynamic texture
  31260. * @param width defines the width of the texture
  31261. * @param height defines the height of the texture
  31262. * @param generateMipMaps defines if the engine should generate the mip levels
  31263. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31264. * @returns the dynamic texture inside an InternalTexture
  31265. */
  31266. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31267. /**
  31268. * Update the sampling mode of a given texture
  31269. * @param samplingMode defines the required sampling mode
  31270. * @param texture defines the texture to update
  31271. */
  31272. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31273. /**
  31274. * Update the content of a dynamic texture
  31275. * @param texture defines the texture to update
  31276. * @param canvas defines the canvas containing the source
  31277. * @param invertY defines if data must be stored with Y axis inverted
  31278. * @param premulAlpha defines if alpha is stored as premultiplied
  31279. * @param format defines the format of the data
  31280. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31281. */
  31282. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31283. /**
  31284. * Update a video texture
  31285. * @param texture defines the texture to update
  31286. * @param video defines the video element to use
  31287. * @param invertY defines if data must be stored with Y axis inverted
  31288. */
  31289. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31290. /**
  31291. * Updates a depth texture Comparison Mode and Function.
  31292. * If the comparison Function is equal to 0, the mode will be set to none.
  31293. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31294. * @param texture The texture to set the comparison function for
  31295. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31296. */
  31297. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31298. /** @hidden */
  31299. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31300. width: number;
  31301. height: number;
  31302. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31303. /**
  31304. * Creates a depth stencil texture.
  31305. * This is only available in WebGL 2 or with the depth texture extension available.
  31306. * @param size The size of face edge in the texture.
  31307. * @param options The options defining the texture.
  31308. * @returns The texture
  31309. */
  31310. createDepthStencilTexture(size: number | {
  31311. width: number;
  31312. height: number;
  31313. }, options: DepthTextureCreationOptions): InternalTexture;
  31314. /**
  31315. * Creates a depth stencil texture.
  31316. * This is only available in WebGL 2 or with the depth texture extension available.
  31317. * @param size The size of face edge in the texture.
  31318. * @param options The options defining the texture.
  31319. * @returns The texture
  31320. */
  31321. private _createDepthStencilTexture;
  31322. /**
  31323. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31324. * @param renderTarget The render target to set the frame buffer for
  31325. */
  31326. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31327. /**
  31328. * Creates a new render target texture
  31329. * @param size defines the size of the texture
  31330. * @param options defines the options used to create the texture
  31331. * @returns a new render target texture stored in an InternalTexture
  31332. */
  31333. createRenderTargetTexture(size: number | {
  31334. width: number;
  31335. height: number;
  31336. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31337. /** @hidden */
  31338. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31339. /**
  31340. * Updates the sample count of a render target texture
  31341. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31342. * @param texture defines the texture to update
  31343. * @param samples defines the sample count to set
  31344. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31345. */
  31346. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31347. /** @hidden */
  31348. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31349. /** @hidden */
  31350. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31351. /** @hidden */
  31352. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31353. /** @hidden */
  31354. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31355. /**
  31356. * @hidden
  31357. */
  31358. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31359. private _prepareWebGLTextureContinuation;
  31360. private _prepareWebGLTexture;
  31361. /** @hidden */
  31362. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31363. /** @hidden */
  31364. _releaseFramebufferObjects(texture: InternalTexture): void;
  31365. /** @hidden */
  31366. _releaseTexture(texture: InternalTexture): void;
  31367. private setProgram;
  31368. private _boundUniforms;
  31369. /**
  31370. * Binds an effect to the webGL context
  31371. * @param effect defines the effect to bind
  31372. */
  31373. bindSamplers(effect: Effect): void;
  31374. private _activateCurrentTexture;
  31375. /** @hidden */
  31376. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31377. /** @hidden */
  31378. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31379. /**
  31380. * Sets a texture to the webGL context from a postprocess
  31381. * @param channel defines the channel to use
  31382. * @param postProcess defines the source postprocess
  31383. */
  31384. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31385. /**
  31386. * Binds the output of the passed in post process to the texture channel specified
  31387. * @param channel The channel the texture should be bound to
  31388. * @param postProcess The post process which's output should be bound
  31389. */
  31390. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31391. /**
  31392. * Unbind all textures from the webGL context
  31393. */
  31394. unbindAllTextures(): void;
  31395. /**
  31396. * Sets a texture to the according uniform.
  31397. * @param channel The texture channel
  31398. * @param uniform The uniform to set
  31399. * @param texture The texture to apply
  31400. */
  31401. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31402. /**
  31403. * Sets a depth stencil texture from a render target to the according uniform.
  31404. * @param channel The texture channel
  31405. * @param uniform The uniform to set
  31406. * @param texture The render target texture containing the depth stencil texture to apply
  31407. */
  31408. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31409. private _bindSamplerUniformToChannel;
  31410. private _getTextureWrapMode;
  31411. private _setTexture;
  31412. /**
  31413. * Sets an array of texture to the webGL context
  31414. * @param channel defines the channel where the texture array must be set
  31415. * @param uniform defines the associated uniform location
  31416. * @param textures defines the array of textures to bind
  31417. */
  31418. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31419. /** @hidden */
  31420. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31421. private _setTextureParameterFloat;
  31422. private _setTextureParameterInteger;
  31423. /**
  31424. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31425. * @param x defines the x coordinate of the rectangle where pixels must be read
  31426. * @param y defines the y coordinate of the rectangle where pixels must be read
  31427. * @param width defines the width of the rectangle where pixels must be read
  31428. * @param height defines the height of the rectangle where pixels must be read
  31429. * @returns a Uint8Array containing RGBA colors
  31430. */
  31431. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31432. /**
  31433. * Add an externaly attached data from its key.
  31434. * This method call will fail and return false, if such key already exists.
  31435. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31436. * @param key the unique key that identifies the data
  31437. * @param data the data object to associate to the key for this Engine instance
  31438. * @return true if no such key were already present and the data was added successfully, false otherwise
  31439. */
  31440. addExternalData<T>(key: string, data: T): boolean;
  31441. /**
  31442. * Get an externaly attached data from its key
  31443. * @param key the unique key that identifies the data
  31444. * @return the associated data, if present (can be null), or undefined if not present
  31445. */
  31446. getExternalData<T>(key: string): T;
  31447. /**
  31448. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31449. * @param key the unique key that identifies the data
  31450. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31451. * @return the associated data, can be null if the factory returned null.
  31452. */
  31453. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31454. /**
  31455. * Remove an externaly attached data from the Engine instance
  31456. * @param key the unique key that identifies the data
  31457. * @return true if the data was successfully removed, false if it doesn't exist
  31458. */
  31459. removeExternalData(key: string): boolean;
  31460. /**
  31461. * Unbind all vertex attributes from the webGL context
  31462. */
  31463. unbindAllAttributes(): void;
  31464. /**
  31465. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  31466. */
  31467. releaseEffects(): void;
  31468. /**
  31469. * Dispose and release all associated resources
  31470. */
  31471. dispose(): void;
  31472. /**
  31473. * Display the loading screen
  31474. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31475. */
  31476. displayLoadingUI(): void;
  31477. /**
  31478. * Hide the loading screen
  31479. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31480. */
  31481. hideLoadingUI(): void;
  31482. /**
  31483. * Gets the current loading screen object
  31484. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31485. */
  31486. /**
  31487. * Sets the current loading screen object
  31488. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31489. */
  31490. loadingScreen: ILoadingScreen;
  31491. /**
  31492. * Sets the current loading screen text
  31493. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31494. */
  31495. loadingUIText: string;
  31496. /**
  31497. * Sets the current loading screen background color
  31498. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31499. */
  31500. loadingUIBackgroundColor: string;
  31501. /**
  31502. * Attach a new callback raised when context lost event is fired
  31503. * @param callback defines the callback to call
  31504. */
  31505. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31506. /**
  31507. * Attach a new callback raised when context restored event is fired
  31508. * @param callback defines the callback to call
  31509. */
  31510. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31511. /**
  31512. * Gets the source code of the vertex shader associated with a specific webGL program
  31513. * @param program defines the program to use
  31514. * @returns a string containing the source code of the vertex shader associated with the program
  31515. */
  31516. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31517. /**
  31518. * Gets the source code of the fragment shader associated with a specific webGL program
  31519. * @param program defines the program to use
  31520. * @returns a string containing the source code of the fragment shader associated with the program
  31521. */
  31522. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31523. /**
  31524. * Get the current error code of the webGL context
  31525. * @returns the error code
  31526. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31527. */
  31528. getError(): number;
  31529. /**
  31530. * Gets the current framerate
  31531. * @returns a number representing the framerate
  31532. */
  31533. getFps(): number;
  31534. /**
  31535. * Gets the time spent between current and previous frame
  31536. * @returns a number representing the delta time in ms
  31537. */
  31538. getDeltaTime(): number;
  31539. private _measureFps;
  31540. /** @hidden */
  31541. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31542. private _canRenderToFloatFramebuffer;
  31543. private _canRenderToHalfFloatFramebuffer;
  31544. private _canRenderToFramebuffer;
  31545. /** @hidden */
  31546. _getWebGLTextureType(type: number): number;
  31547. /** @hidden */
  31548. _getInternalFormat(format: number): number;
  31549. /** @hidden */
  31550. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31551. /** @hidden */
  31552. _getRGBAMultiSampleBufferFormat(type: number): number;
  31553. /** @hidden */
  31554. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  31555. /** @hidden */
  31556. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31557. /**
  31558. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31559. * @returns true if the engine can be created
  31560. * @ignorenaming
  31561. */
  31562. static isSupported(): boolean;
  31563. /**
  31564. * Find the next highest power of two.
  31565. * @param x Number to start search from.
  31566. * @return Next highest power of two.
  31567. */
  31568. static CeilingPOT(x: number): number;
  31569. /**
  31570. * Find the next lowest power of two.
  31571. * @param x Number to start search from.
  31572. * @return Next lowest power of two.
  31573. */
  31574. static FloorPOT(x: number): number;
  31575. /**
  31576. * Find the nearest power of two.
  31577. * @param x Number to start search from.
  31578. * @return Next nearest power of two.
  31579. */
  31580. static NearestPOT(x: number): number;
  31581. /**
  31582. * Get the closest exponent of two
  31583. * @param value defines the value to approximate
  31584. * @param max defines the maximum value to return
  31585. * @param mode defines how to define the closest value
  31586. * @returns closest exponent of two of the given value
  31587. */
  31588. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31589. /**
  31590. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31591. * @param func - the function to be called
  31592. * @param requester - the object that will request the next frame. Falls back to window.
  31593. * @returns frame number
  31594. */
  31595. static QueueNewFrame(func: () => void, requester?: any): number;
  31596. /**
  31597. * Ask the browser to promote the current element to pointerlock mode
  31598. * @param element defines the DOM element to promote
  31599. */
  31600. static _RequestPointerlock(element: HTMLElement): void;
  31601. /**
  31602. * Asks the browser to exit pointerlock mode
  31603. */
  31604. static _ExitPointerlock(): void;
  31605. /**
  31606. * Ask the browser to promote the current element to fullscreen rendering mode
  31607. * @param element defines the DOM element to promote
  31608. */
  31609. static _RequestFullscreen(element: HTMLElement): void;
  31610. /**
  31611. * Asks the browser to exit fullscreen mode
  31612. */
  31613. static _ExitFullscreen(): void;
  31614. }
  31615. }
  31616. declare module BABYLON {
  31617. /**
  31618. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31619. * during the life time of the application.
  31620. */
  31621. export class EngineStore {
  31622. /** Gets the list of created engines */
  31623. static Instances: Engine[];
  31624. /** @hidden */
  31625. static _LastCreatedScene: Nullable<Scene>;
  31626. /**
  31627. * Gets the latest created engine
  31628. */
  31629. static readonly LastCreatedEngine: Nullable<Engine>;
  31630. /**
  31631. * Gets the latest created scene
  31632. */
  31633. static readonly LastCreatedScene: Nullable<Scene>;
  31634. /**
  31635. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31636. * @ignorenaming
  31637. */
  31638. static UseFallbackTexture: boolean;
  31639. /**
  31640. * Texture content used if a texture cannot loaded
  31641. * @ignorenaming
  31642. */
  31643. static FallbackTexture: string;
  31644. }
  31645. }
  31646. declare module BABYLON {
  31647. /**
  31648. * Helper class that provides a small promise polyfill
  31649. */
  31650. export class PromisePolyfill {
  31651. /**
  31652. * Static function used to check if the polyfill is required
  31653. * If this is the case then the function will inject the polyfill to window.Promise
  31654. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31655. */
  31656. static Apply(force?: boolean): void;
  31657. }
  31658. }
  31659. declare module BABYLON {
  31660. /**
  31661. * Interface for screenshot methods with describe argument called `size` as object with options
  31662. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31663. */
  31664. export interface IScreenshotSize {
  31665. /**
  31666. * number in pixels for canvas height
  31667. */
  31668. height?: number;
  31669. /**
  31670. * multiplier allowing render at a higher or lower resolution
  31671. * If value is defined then height and width will be ignored and taken from camera
  31672. */
  31673. precision?: number;
  31674. /**
  31675. * number in pixels for canvas width
  31676. */
  31677. width?: number;
  31678. }
  31679. }
  31680. declare module BABYLON {
  31681. interface IColor4Like {
  31682. r: float;
  31683. g: float;
  31684. b: float;
  31685. a: float;
  31686. }
  31687. /**
  31688. * Class containing a set of static utilities functions
  31689. */
  31690. export class Tools {
  31691. /**
  31692. * Gets or sets the base URL to use to load assets
  31693. */
  31694. static BaseUrl: string;
  31695. /**
  31696. * Enable/Disable Custom HTTP Request Headers globally.
  31697. * default = false
  31698. * @see CustomRequestHeaders
  31699. */
  31700. static UseCustomRequestHeaders: boolean;
  31701. /**
  31702. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31703. * i.e. when loading files, where the server/service expects an Authorization header
  31704. */
  31705. static CustomRequestHeaders: {
  31706. [key: string]: string;
  31707. };
  31708. /**
  31709. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31710. */
  31711. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31712. /**
  31713. * Default behaviour for cors in the application.
  31714. * It can be a string if the expected behavior is identical in the entire app.
  31715. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31716. */
  31717. static CorsBehavior: string | ((url: string | string[]) => string);
  31718. /**
  31719. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31720. * @ignorenaming
  31721. */
  31722. static UseFallbackTexture: boolean;
  31723. /**
  31724. * Use this object to register external classes like custom textures or material
  31725. * to allow the laoders to instantiate them
  31726. */
  31727. static RegisteredExternalClasses: {
  31728. [key: string]: Object;
  31729. };
  31730. /**
  31731. * Texture content used if a texture cannot loaded
  31732. * @ignorenaming
  31733. */
  31734. static fallbackTexture: string;
  31735. /**
  31736. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31737. * @param u defines the coordinate on X axis
  31738. * @param v defines the coordinate on Y axis
  31739. * @param width defines the width of the source data
  31740. * @param height defines the height of the source data
  31741. * @param pixels defines the source byte array
  31742. * @param color defines the output color
  31743. */
  31744. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31745. /**
  31746. * Interpolates between a and b via alpha
  31747. * @param a The lower value (returned when alpha = 0)
  31748. * @param b The upper value (returned when alpha = 1)
  31749. * @param alpha The interpolation-factor
  31750. * @return The mixed value
  31751. */
  31752. static Mix(a: number, b: number, alpha: number): number;
  31753. /**
  31754. * Tries to instantiate a new object from a given class name
  31755. * @param className defines the class name to instantiate
  31756. * @returns the new object or null if the system was not able to do the instantiation
  31757. */
  31758. static Instantiate(className: string): any;
  31759. /**
  31760. * Provides a slice function that will work even on IE
  31761. * @param data defines the array to slice
  31762. * @param start defines the start of the data (optional)
  31763. * @param end defines the end of the data (optional)
  31764. * @returns the new sliced array
  31765. */
  31766. static Slice<T>(data: T, start?: number, end?: number): T;
  31767. /**
  31768. * Polyfill for setImmediate
  31769. * @param action defines the action to execute after the current execution block
  31770. */
  31771. static SetImmediate(action: () => void): void;
  31772. /**
  31773. * Function indicating if a number is an exponent of 2
  31774. * @param value defines the value to test
  31775. * @returns true if the value is an exponent of 2
  31776. */
  31777. static IsExponentOfTwo(value: number): boolean;
  31778. private static _tmpFloatArray;
  31779. /**
  31780. * Returns the nearest 32-bit single precision float representation of a Number
  31781. * @param value A Number. If the parameter is of a different type, it will get converted
  31782. * to a number or to NaN if it cannot be converted
  31783. * @returns number
  31784. */
  31785. static FloatRound(value: number): number;
  31786. /**
  31787. * Extracts the filename from a path
  31788. * @param path defines the path to use
  31789. * @returns the filename
  31790. */
  31791. static GetFilename(path: string): string;
  31792. /**
  31793. * Extracts the "folder" part of a path (everything before the filename).
  31794. * @param uri The URI to extract the info from
  31795. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31796. * @returns The "folder" part of the path
  31797. */
  31798. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31799. /**
  31800. * Extracts text content from a DOM element hierarchy
  31801. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31802. */
  31803. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31804. /**
  31805. * Convert an angle in radians to degrees
  31806. * @param angle defines the angle to convert
  31807. * @returns the angle in degrees
  31808. */
  31809. static ToDegrees(angle: number): number;
  31810. /**
  31811. * Convert an angle in degrees to radians
  31812. * @param angle defines the angle to convert
  31813. * @returns the angle in radians
  31814. */
  31815. static ToRadians(angle: number): number;
  31816. /**
  31817. * Encode a buffer to a base64 string
  31818. * @param buffer defines the buffer to encode
  31819. * @returns the encoded string
  31820. */
  31821. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31822. /**
  31823. * Returns an array if obj is not an array
  31824. * @param obj defines the object to evaluate as an array
  31825. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31826. * @returns either obj directly if obj is an array or a new array containing obj
  31827. */
  31828. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31829. /**
  31830. * Gets the pointer prefix to use
  31831. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31832. */
  31833. static GetPointerPrefix(): string;
  31834. /**
  31835. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31836. * @param url define the url we are trying
  31837. * @param element define the dom element where to configure the cors policy
  31838. */
  31839. static SetCorsBehavior(url: string | string[], element: {
  31840. crossOrigin: string | null;
  31841. }): void;
  31842. /**
  31843. * Removes unwanted characters from an url
  31844. * @param url defines the url to clean
  31845. * @returns the cleaned url
  31846. */
  31847. static CleanUrl(url: string): string;
  31848. /**
  31849. * Gets or sets a function used to pre-process url before using them to load assets
  31850. */
  31851. static PreprocessUrl: (url: string) => string;
  31852. /**
  31853. * Loads an image as an HTMLImageElement.
  31854. * @param input url string, ArrayBuffer, or Blob to load
  31855. * @param onLoad callback called when the image successfully loads
  31856. * @param onError callback called when the image fails to load
  31857. * @param offlineProvider offline provider for caching
  31858. * @returns the HTMLImageElement of the loaded image
  31859. */
  31860. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31861. /**
  31862. * Loads a file
  31863. * @param url url string, ArrayBuffer, or Blob to load
  31864. * @param onSuccess callback called when the file successfully loads
  31865. * @param onProgress callback called while file is loading (if the server supports this mode)
  31866. * @param offlineProvider defines the offline provider for caching
  31867. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31868. * @param onError callback called when the file fails to load
  31869. * @returns a file request object
  31870. */
  31871. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  31872. /**
  31873. * Loads a file from a url
  31874. * @param url the file url to load
  31875. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31876. */
  31877. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31878. /**
  31879. * Load a script (identified by an url). When the url returns, the
  31880. * content of this file is added into a new script element, attached to the DOM (body element)
  31881. * @param scriptUrl defines the url of the script to laod
  31882. * @param onSuccess defines the callback called when the script is loaded
  31883. * @param onError defines the callback to call if an error occurs
  31884. * @param scriptId defines the id of the script element
  31885. */
  31886. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31887. /**
  31888. * Load an asynchronous script (identified by an url). When the url returns, the
  31889. * content of this file is added into a new script element, attached to the DOM (body element)
  31890. * @param scriptUrl defines the url of the script to laod
  31891. * @param scriptId defines the id of the script element
  31892. * @returns a promise request object
  31893. */
  31894. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31895. /**
  31896. * Loads a file from a blob
  31897. * @param fileToLoad defines the blob to use
  31898. * @param callback defines the callback to call when data is loaded
  31899. * @param progressCallback defines the callback to call during loading process
  31900. * @returns a file request object
  31901. */
  31902. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31903. /**
  31904. * Loads a file
  31905. * @param fileToLoad defines the file to load
  31906. * @param callback defines the callback to call when data is loaded
  31907. * @param progressCallBack defines the callback to call during loading process
  31908. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31909. * @returns a file request object
  31910. */
  31911. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31912. /**
  31913. * Creates a data url from a given string content
  31914. * @param content defines the content to convert
  31915. * @returns the new data url link
  31916. */
  31917. static FileAsURL(content: string): string;
  31918. /**
  31919. * Format the given number to a specific decimal format
  31920. * @param value defines the number to format
  31921. * @param decimals defines the number of decimals to use
  31922. * @returns the formatted string
  31923. */
  31924. static Format(value: number, decimals?: number): string;
  31925. /**
  31926. * Tries to copy an object by duplicating every property
  31927. * @param source defines the source object
  31928. * @param destination defines the target object
  31929. * @param doNotCopyList defines a list of properties to avoid
  31930. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31931. */
  31932. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31933. /**
  31934. * Gets a boolean indicating if the given object has no own property
  31935. * @param obj defines the object to test
  31936. * @returns true if object has no own property
  31937. */
  31938. static IsEmpty(obj: any): boolean;
  31939. /**
  31940. * Function used to register events at window level
  31941. * @param windowElement defines the Window object to use
  31942. * @param events defines the events to register
  31943. */
  31944. static RegisterTopRootEvents(windowElement: Window, events: {
  31945. name: string;
  31946. handler: Nullable<(e: FocusEvent) => any>;
  31947. }[]): void;
  31948. /**
  31949. * Function used to unregister events from window level
  31950. * @param windowElement defines the Window object to use
  31951. * @param events defines the events to unregister
  31952. */
  31953. static UnregisterTopRootEvents(windowElement: Window, events: {
  31954. name: string;
  31955. handler: Nullable<(e: FocusEvent) => any>;
  31956. }[]): void;
  31957. /**
  31958. * @ignore
  31959. */
  31960. static _ScreenshotCanvas: HTMLCanvasElement;
  31961. /**
  31962. * Dumps the current bound framebuffer
  31963. * @param width defines the rendering width
  31964. * @param height defines the rendering height
  31965. * @param engine defines the hosting engine
  31966. * @param successCallback defines the callback triggered once the data are available
  31967. * @param mimeType defines the mime type of the result
  31968. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31969. */
  31970. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31971. /**
  31972. * Converts the canvas data to blob.
  31973. * This acts as a polyfill for browsers not supporting the to blob function.
  31974. * @param canvas Defines the canvas to extract the data from
  31975. * @param successCallback Defines the callback triggered once the data are available
  31976. * @param mimeType Defines the mime type of the result
  31977. */
  31978. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31979. /**
  31980. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31981. * @param successCallback defines the callback triggered once the data are available
  31982. * @param mimeType defines the mime type of the result
  31983. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31984. */
  31985. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31986. /**
  31987. * Downloads a blob in the browser
  31988. * @param blob defines the blob to download
  31989. * @param fileName defines the name of the downloaded file
  31990. */
  31991. static Download(blob: Blob, fileName: string): void;
  31992. /**
  31993. * Captures a screenshot of the current rendering
  31994. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31995. * @param engine defines the rendering engine
  31996. * @param camera defines the source camera
  31997. * @param size This parameter can be set to a single number or to an object with the
  31998. * following (optional) properties: precision, width, height. If a single number is passed,
  31999. * it will be used for both width and height. If an object is passed, the screenshot size
  32000. * will be derived from the parameters. The precision property is a multiplier allowing
  32001. * rendering at a higher or lower resolution
  32002. * @param successCallback defines the callback receives a single parameter which contains the
  32003. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32004. * src parameter of an <img> to display it
  32005. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32006. * Check your browser for supported MIME types
  32007. */
  32008. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32009. /**
  32010. * Captures a screenshot of the current rendering
  32011. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32012. * @param engine defines the rendering engine
  32013. * @param camera defines the source camera
  32014. * @param size This parameter can be set to a single number or to an object with the
  32015. * following (optional) properties: precision, width, height. If a single number is passed,
  32016. * it will be used for both width and height. If an object is passed, the screenshot size
  32017. * will be derived from the parameters. The precision property is a multiplier allowing
  32018. * rendering at a higher or lower resolution
  32019. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32020. * Check your browser for supported MIME types
  32021. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32022. * to the src parameter of an <img> to display it
  32023. */
  32024. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32025. /**
  32026. * Generates an image screenshot from the specified camera.
  32027. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32028. * @param engine The engine to use for rendering
  32029. * @param camera The camera to use for rendering
  32030. * @param size This parameter can be set to a single number or to an object with the
  32031. * following (optional) properties: precision, width, height. If a single number is passed,
  32032. * it will be used for both width and height. If an object is passed, the screenshot size
  32033. * will be derived from the parameters. The precision property is a multiplier allowing
  32034. * rendering at a higher or lower resolution
  32035. * @param successCallback The callback receives a single parameter which contains the
  32036. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32037. * src parameter of an <img> to display it
  32038. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32039. * Check your browser for supported MIME types
  32040. * @param samples Texture samples (default: 1)
  32041. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32042. * @param fileName A name for for the downloaded file.
  32043. */
  32044. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32045. /**
  32046. * Generates an image screenshot from the specified camera.
  32047. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32048. * @param engine The engine to use for rendering
  32049. * @param camera The camera to use for rendering
  32050. * @param size This parameter can be set to a single number or to an object with the
  32051. * following (optional) properties: precision, width, height. If a single number is passed,
  32052. * it will be used for both width and height. If an object is passed, the screenshot size
  32053. * will be derived from the parameters. The precision property is a multiplier allowing
  32054. * rendering at a higher or lower resolution
  32055. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32056. * Check your browser for supported MIME types
  32057. * @param samples Texture samples (default: 1)
  32058. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32059. * @param fileName A name for for the downloaded file.
  32060. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32061. * to the src parameter of an <img> to display it
  32062. */
  32063. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32064. /**
  32065. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32066. * Be aware Math.random() could cause collisions, but:
  32067. * "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"
  32068. * @returns a pseudo random id
  32069. */
  32070. static RandomId(): string;
  32071. /**
  32072. * Test if the given uri is a base64 string
  32073. * @param uri The uri to test
  32074. * @return True if the uri is a base64 string or false otherwise
  32075. */
  32076. static IsBase64(uri: string): boolean;
  32077. /**
  32078. * Decode the given base64 uri.
  32079. * @param uri The uri to decode
  32080. * @return The decoded base64 data.
  32081. */
  32082. static DecodeBase64(uri: string): ArrayBuffer;
  32083. /**
  32084. * Gets the absolute url.
  32085. * @param url the input url
  32086. * @return the absolute url
  32087. */
  32088. static GetAbsoluteUrl(url: string): string;
  32089. /**
  32090. * No log
  32091. */
  32092. static readonly NoneLogLevel: number;
  32093. /**
  32094. * Only message logs
  32095. */
  32096. static readonly MessageLogLevel: number;
  32097. /**
  32098. * Only warning logs
  32099. */
  32100. static readonly WarningLogLevel: number;
  32101. /**
  32102. * Only error logs
  32103. */
  32104. static readonly ErrorLogLevel: number;
  32105. /**
  32106. * All logs
  32107. */
  32108. static readonly AllLogLevel: number;
  32109. /**
  32110. * Gets a value indicating the number of loading errors
  32111. * @ignorenaming
  32112. */
  32113. static readonly errorsCount: number;
  32114. /**
  32115. * Callback called when a new log is added
  32116. */
  32117. static OnNewCacheEntry: (entry: string) => void;
  32118. /**
  32119. * Log a message to the console
  32120. * @param message defines the message to log
  32121. */
  32122. static Log(message: string): void;
  32123. /**
  32124. * Write a warning message to the console
  32125. * @param message defines the message to log
  32126. */
  32127. static Warn(message: string): void;
  32128. /**
  32129. * Write an error message to the console
  32130. * @param message defines the message to log
  32131. */
  32132. static Error(message: string): void;
  32133. /**
  32134. * Gets current log cache (list of logs)
  32135. */
  32136. static readonly LogCache: string;
  32137. /**
  32138. * Clears the log cache
  32139. */
  32140. static ClearLogCache(): void;
  32141. /**
  32142. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32143. */
  32144. static LogLevels: number;
  32145. /**
  32146. * Checks if the window object exists
  32147. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32148. */
  32149. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32150. /**
  32151. * No performance log
  32152. */
  32153. static readonly PerformanceNoneLogLevel: number;
  32154. /**
  32155. * Use user marks to log performance
  32156. */
  32157. static readonly PerformanceUserMarkLogLevel: number;
  32158. /**
  32159. * Log performance to the console
  32160. */
  32161. static readonly PerformanceConsoleLogLevel: number;
  32162. private static _performance;
  32163. /**
  32164. * Sets the current performance log level
  32165. */
  32166. static PerformanceLogLevel: number;
  32167. private static _StartPerformanceCounterDisabled;
  32168. private static _EndPerformanceCounterDisabled;
  32169. private static _StartUserMark;
  32170. private static _EndUserMark;
  32171. private static _StartPerformanceConsole;
  32172. private static _EndPerformanceConsole;
  32173. /**
  32174. * Starts a performance counter
  32175. */
  32176. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32177. /**
  32178. * Ends a specific performance coutner
  32179. */
  32180. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32181. /**
  32182. * Gets either window.performance.now() if supported or Date.now() else
  32183. */
  32184. static readonly Now: number;
  32185. /**
  32186. * This method will return the name of the class used to create the instance of the given object.
  32187. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32188. * @param object the object to get the class name from
  32189. * @param isType defines if the object is actually a type
  32190. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32191. */
  32192. static GetClassName(object: any, isType?: boolean): string;
  32193. /**
  32194. * Gets the first element of an array satisfying a given predicate
  32195. * @param array defines the array to browse
  32196. * @param predicate defines the predicate to use
  32197. * @returns null if not found or the element
  32198. */
  32199. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32200. /**
  32201. * This method will return the name of the full name of the class, including its owning module (if any).
  32202. * 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).
  32203. * @param object the object to get the class name from
  32204. * @param isType defines if the object is actually a type
  32205. * @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.
  32206. * @ignorenaming
  32207. */
  32208. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32209. /**
  32210. * Returns a promise that resolves after the given amount of time.
  32211. * @param delay Number of milliseconds to delay
  32212. * @returns Promise that resolves after the given amount of time
  32213. */
  32214. static DelayAsync(delay: number): Promise<void>;
  32215. }
  32216. /**
  32217. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32218. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32219. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32220. * @param name The name of the class, case should be preserved
  32221. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32222. */
  32223. export function className(name: string, module?: string): (target: Object) => void;
  32224. /**
  32225. * An implementation of a loop for asynchronous functions.
  32226. */
  32227. export class AsyncLoop {
  32228. /**
  32229. * Defines the number of iterations for the loop
  32230. */
  32231. iterations: number;
  32232. /**
  32233. * Defines the current index of the loop.
  32234. */
  32235. index: number;
  32236. private _done;
  32237. private _fn;
  32238. private _successCallback;
  32239. /**
  32240. * Constructor.
  32241. * @param iterations the number of iterations.
  32242. * @param func the function to run each iteration
  32243. * @param successCallback the callback that will be called upon succesful execution
  32244. * @param offset starting offset.
  32245. */
  32246. constructor(
  32247. /**
  32248. * Defines the number of iterations for the loop
  32249. */
  32250. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32251. /**
  32252. * Execute the next iteration. Must be called after the last iteration was finished.
  32253. */
  32254. executeNext(): void;
  32255. /**
  32256. * Break the loop and run the success callback.
  32257. */
  32258. breakLoop(): void;
  32259. /**
  32260. * Create and run an async loop.
  32261. * @param iterations the number of iterations.
  32262. * @param fn the function to run each iteration
  32263. * @param successCallback the callback that will be called upon succesful execution
  32264. * @param offset starting offset.
  32265. * @returns the created async loop object
  32266. */
  32267. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32268. /**
  32269. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32270. * @param iterations total number of iterations
  32271. * @param syncedIterations number of synchronous iterations in each async iteration.
  32272. * @param fn the function to call each iteration.
  32273. * @param callback a success call back that will be called when iterating stops.
  32274. * @param breakFunction a break condition (optional)
  32275. * @param timeout timeout settings for the setTimeout function. default - 0.
  32276. * @returns the created async loop object
  32277. */
  32278. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32279. }
  32280. }
  32281. declare module BABYLON {
  32282. /** @hidden */
  32283. export interface ICollisionCoordinator {
  32284. createCollider(): Collider;
  32285. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32286. init(scene: Scene): void;
  32287. }
  32288. /** @hidden */
  32289. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32290. private _scene;
  32291. private _scaledPosition;
  32292. private _scaledVelocity;
  32293. private _finalPosition;
  32294. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32295. createCollider(): Collider;
  32296. init(scene: Scene): void;
  32297. private _collideWithWorld;
  32298. }
  32299. }
  32300. declare module BABYLON {
  32301. /**
  32302. * Class used to manage all inputs for the scene.
  32303. */
  32304. export class InputManager {
  32305. /** The distance in pixel that you have to move to prevent some events */
  32306. static DragMovementThreshold: number;
  32307. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32308. static LongPressDelay: number;
  32309. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32310. static DoubleClickDelay: number;
  32311. /** If you need to check double click without raising a single click at first click, enable this flag */
  32312. static ExclusiveDoubleClickMode: boolean;
  32313. private _wheelEventName;
  32314. private _onPointerMove;
  32315. private _onPointerDown;
  32316. private _onPointerUp;
  32317. private _initClickEvent;
  32318. private _initActionManager;
  32319. private _delayedSimpleClick;
  32320. private _delayedSimpleClickTimeout;
  32321. private _previousDelayedSimpleClickTimeout;
  32322. private _meshPickProceed;
  32323. private _previousButtonPressed;
  32324. private _currentPickResult;
  32325. private _previousPickResult;
  32326. private _totalPointersPressed;
  32327. private _doubleClickOccured;
  32328. private _pointerOverMesh;
  32329. private _pickedDownMesh;
  32330. private _pickedUpMesh;
  32331. private _pointerX;
  32332. private _pointerY;
  32333. private _unTranslatedPointerX;
  32334. private _unTranslatedPointerY;
  32335. private _startingPointerPosition;
  32336. private _previousStartingPointerPosition;
  32337. private _startingPointerTime;
  32338. private _previousStartingPointerTime;
  32339. private _pointerCaptures;
  32340. private _onKeyDown;
  32341. private _onKeyUp;
  32342. private _onCanvasFocusObserver;
  32343. private _onCanvasBlurObserver;
  32344. private _scene;
  32345. /**
  32346. * Creates a new InputManager
  32347. * @param scene defines the hosting scene
  32348. */
  32349. constructor(scene: Scene);
  32350. /**
  32351. * Gets the mesh that is currently under the pointer
  32352. */
  32353. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32354. /**
  32355. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32356. */
  32357. readonly unTranslatedPointer: Vector2;
  32358. /**
  32359. * Gets or sets the current on-screen X position of the pointer
  32360. */
  32361. pointerX: number;
  32362. /**
  32363. * Gets or sets the current on-screen Y position of the pointer
  32364. */
  32365. pointerY: number;
  32366. private _updatePointerPosition;
  32367. private _processPointerMove;
  32368. private _setRayOnPointerInfo;
  32369. private _checkPrePointerObservable;
  32370. /**
  32371. * Use this method to simulate a pointer move on a mesh
  32372. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32373. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32374. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32375. */
  32376. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32377. /**
  32378. * Use this method to simulate a pointer down on a mesh
  32379. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32380. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32381. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32382. */
  32383. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32384. private _processPointerDown;
  32385. /** @hidden */
  32386. _isPointerSwiping(): boolean;
  32387. /**
  32388. * Use this method to simulate a pointer up on a mesh
  32389. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32390. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32391. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32392. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32393. */
  32394. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32395. private _processPointerUp;
  32396. /**
  32397. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32398. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32399. * @returns true if the pointer was captured
  32400. */
  32401. isPointerCaptured(pointerId?: number): boolean;
  32402. /**
  32403. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32404. * @param attachUp defines if you want to attach events to pointerup
  32405. * @param attachDown defines if you want to attach events to pointerdown
  32406. * @param attachMove defines if you want to attach events to pointermove
  32407. */
  32408. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32409. /**
  32410. * Detaches all event handlers
  32411. */
  32412. detachControl(): void;
  32413. /**
  32414. * Force the value of meshUnderPointer
  32415. * @param mesh defines the mesh to use
  32416. */
  32417. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32418. /**
  32419. * Gets the mesh under the pointer
  32420. * @returns a Mesh or null if no mesh is under the pointer
  32421. */
  32422. getPointerOverMesh(): Nullable<AbstractMesh>;
  32423. }
  32424. }
  32425. declare module BABYLON {
  32426. /**
  32427. * Helper class used to generate session unique ID
  32428. */
  32429. export class UniqueIdGenerator {
  32430. private static _UniqueIdCounter;
  32431. /**
  32432. * Gets an unique (relatively to the current scene) Id
  32433. */
  32434. static readonly UniqueId: number;
  32435. }
  32436. }
  32437. declare module BABYLON {
  32438. /**
  32439. * This class defines the direct association between an animation and a target
  32440. */
  32441. export class TargetedAnimation {
  32442. /**
  32443. * Animation to perform
  32444. */
  32445. animation: Animation;
  32446. /**
  32447. * Target to animate
  32448. */
  32449. target: any;
  32450. /**
  32451. * Serialize the object
  32452. * @returns the JSON object representing the current entity
  32453. */
  32454. serialize(): any;
  32455. }
  32456. /**
  32457. * Use this class to create coordinated animations on multiple targets
  32458. */
  32459. export class AnimationGroup implements IDisposable {
  32460. /** The name of the animation group */
  32461. name: string;
  32462. private _scene;
  32463. private _targetedAnimations;
  32464. private _animatables;
  32465. private _from;
  32466. private _to;
  32467. private _isStarted;
  32468. private _isPaused;
  32469. private _speedRatio;
  32470. private _loopAnimation;
  32471. /**
  32472. * Gets or sets the unique id of the node
  32473. */
  32474. uniqueId: number;
  32475. /**
  32476. * This observable will notify when one animation have ended
  32477. */
  32478. onAnimationEndObservable: Observable<TargetedAnimation>;
  32479. /**
  32480. * Observer raised when one animation loops
  32481. */
  32482. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32483. /**
  32484. * This observable will notify when all animations have ended.
  32485. */
  32486. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32487. /**
  32488. * This observable will notify when all animations have paused.
  32489. */
  32490. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32491. /**
  32492. * This observable will notify when all animations are playing.
  32493. */
  32494. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32495. /**
  32496. * Gets the first frame
  32497. */
  32498. readonly from: number;
  32499. /**
  32500. * Gets the last frame
  32501. */
  32502. readonly to: number;
  32503. /**
  32504. * Define if the animations are started
  32505. */
  32506. readonly isStarted: boolean;
  32507. /**
  32508. * Gets a value indicating that the current group is playing
  32509. */
  32510. readonly isPlaying: boolean;
  32511. /**
  32512. * Gets or sets the speed ratio to use for all animations
  32513. */
  32514. /**
  32515. * Gets or sets the speed ratio to use for all animations
  32516. */
  32517. speedRatio: number;
  32518. /**
  32519. * Gets or sets if all animations should loop or not
  32520. */
  32521. loopAnimation: boolean;
  32522. /**
  32523. * Gets the targeted animations for this animation group
  32524. */
  32525. readonly targetedAnimations: Array<TargetedAnimation>;
  32526. /**
  32527. * returning the list of animatables controlled by this animation group.
  32528. */
  32529. readonly animatables: Array<Animatable>;
  32530. /**
  32531. * Instantiates a new Animation Group.
  32532. * This helps managing several animations at once.
  32533. * @see http://doc.babylonjs.com/how_to/group
  32534. * @param name Defines the name of the group
  32535. * @param scene Defines the scene the group belongs to
  32536. */
  32537. constructor(
  32538. /** The name of the animation group */
  32539. name: string, scene?: Nullable<Scene>);
  32540. /**
  32541. * Add an animation (with its target) in the group
  32542. * @param animation defines the animation we want to add
  32543. * @param target defines the target of the animation
  32544. * @returns the TargetedAnimation object
  32545. */
  32546. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32547. /**
  32548. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32549. * It can add constant keys at begin or end
  32550. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32551. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32552. * @returns the animation group
  32553. */
  32554. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32555. /**
  32556. * Start all animations on given targets
  32557. * @param loop defines if animations must loop
  32558. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32559. * @param from defines the from key (optional)
  32560. * @param to defines the to key (optional)
  32561. * @returns the current animation group
  32562. */
  32563. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32564. /**
  32565. * Pause all animations
  32566. * @returns the animation group
  32567. */
  32568. pause(): AnimationGroup;
  32569. /**
  32570. * Play all animations to initial state
  32571. * This function will start() the animations if they were not started or will restart() them if they were paused
  32572. * @param loop defines if animations must loop
  32573. * @returns the animation group
  32574. */
  32575. play(loop?: boolean): AnimationGroup;
  32576. /**
  32577. * Reset all animations to initial state
  32578. * @returns the animation group
  32579. */
  32580. reset(): AnimationGroup;
  32581. /**
  32582. * Restart animations from key 0
  32583. * @returns the animation group
  32584. */
  32585. restart(): AnimationGroup;
  32586. /**
  32587. * Stop all animations
  32588. * @returns the animation group
  32589. */
  32590. stop(): AnimationGroup;
  32591. /**
  32592. * Set animation weight for all animatables
  32593. * @param weight defines the weight to use
  32594. * @return the animationGroup
  32595. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32596. */
  32597. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32598. /**
  32599. * Synchronize and normalize all animatables with a source animatable
  32600. * @param root defines the root animatable to synchronize with
  32601. * @return the animationGroup
  32602. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32603. */
  32604. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32605. /**
  32606. * Goes to a specific frame in this animation group
  32607. * @param frame the frame number to go to
  32608. * @return the animationGroup
  32609. */
  32610. goToFrame(frame: number): AnimationGroup;
  32611. /**
  32612. * Dispose all associated resources
  32613. */
  32614. dispose(): void;
  32615. private _checkAnimationGroupEnded;
  32616. /**
  32617. * Clone the current animation group and returns a copy
  32618. * @param newName defines the name of the new group
  32619. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32620. * @returns the new aniamtion group
  32621. */
  32622. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32623. /**
  32624. * Serializes the animationGroup to an object
  32625. * @returns Serialized object
  32626. */
  32627. serialize(): any;
  32628. /**
  32629. * Returns a new AnimationGroup object parsed from the source provided.
  32630. * @param parsedAnimationGroup defines the source
  32631. * @param scene defines the scene that will receive the animationGroup
  32632. * @returns a new AnimationGroup
  32633. */
  32634. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32635. /**
  32636. * Returns the string "AnimationGroup"
  32637. * @returns "AnimationGroup"
  32638. */
  32639. getClassName(): string;
  32640. /**
  32641. * Creates a detailled string about the object
  32642. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32643. * @returns a string representing the object
  32644. */
  32645. toString(fullDetails?: boolean): string;
  32646. }
  32647. }
  32648. declare module BABYLON {
  32649. /**
  32650. * Define an interface for all classes that will hold resources
  32651. */
  32652. export interface IDisposable {
  32653. /**
  32654. * Releases all held resources
  32655. */
  32656. dispose(): void;
  32657. }
  32658. /** Interface defining initialization parameters for Scene class */
  32659. export interface SceneOptions {
  32660. /**
  32661. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32662. * It will improve performance when the number of geometries becomes important.
  32663. */
  32664. useGeometryUniqueIdsMap?: boolean;
  32665. /**
  32666. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32667. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32668. */
  32669. useMaterialMeshMap?: boolean;
  32670. /**
  32671. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32672. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32673. */
  32674. useClonedMeshhMap?: boolean;
  32675. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32676. virtual?: boolean;
  32677. }
  32678. /**
  32679. * Represents a scene to be rendered by the engine.
  32680. * @see http://doc.babylonjs.com/features/scene
  32681. */
  32682. export class Scene extends AbstractScene implements IAnimatable {
  32683. /** The fog is deactivated */
  32684. static readonly FOGMODE_NONE: number;
  32685. /** The fog density is following an exponential function */
  32686. static readonly FOGMODE_EXP: number;
  32687. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32688. static readonly FOGMODE_EXP2: number;
  32689. /** The fog density is following a linear function. */
  32690. static readonly FOGMODE_LINEAR: number;
  32691. /**
  32692. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32693. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32694. */
  32695. static MinDeltaTime: number;
  32696. /**
  32697. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32698. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32699. */
  32700. static MaxDeltaTime: number;
  32701. /**
  32702. * Factory used to create the default material.
  32703. * @param name The name of the material to create
  32704. * @param scene The scene to create the material for
  32705. * @returns The default material
  32706. */
  32707. static DefaultMaterialFactory(scene: Scene): Material;
  32708. /**
  32709. * Factory used to create the a collision coordinator.
  32710. * @returns The collision coordinator
  32711. */
  32712. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32713. /** @hidden */
  32714. _inputManager: InputManager;
  32715. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32716. cameraToUseForPointers: Nullable<Camera>;
  32717. /** @hidden */
  32718. readonly _isScene: boolean;
  32719. /**
  32720. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32721. */
  32722. autoClear: boolean;
  32723. /**
  32724. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32725. */
  32726. autoClearDepthAndStencil: boolean;
  32727. /**
  32728. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32729. */
  32730. clearColor: Color4;
  32731. /**
  32732. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32733. */
  32734. ambientColor: Color3;
  32735. /**
  32736. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32737. * It should only be one of the following (if not the default embedded one):
  32738. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32739. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32740. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32741. * The material properties need to be setup according to the type of texture in use.
  32742. */
  32743. environmentBRDFTexture: BaseTexture;
  32744. /** @hidden */
  32745. protected _environmentTexture: Nullable<BaseTexture>;
  32746. /**
  32747. * Texture used in all pbr material as the reflection texture.
  32748. * As in the majority of the scene they are the same (exception for multi room and so on),
  32749. * this is easier to reference from here than from all the materials.
  32750. */
  32751. /**
  32752. * Texture used in all pbr material as the reflection texture.
  32753. * As in the majority of the scene they are the same (exception for multi room and so on),
  32754. * this is easier to set here than in all the materials.
  32755. */
  32756. environmentTexture: Nullable<BaseTexture>;
  32757. /** @hidden */
  32758. protected _environmentIntensity: number;
  32759. /**
  32760. * Intensity of the environment in all pbr material.
  32761. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32762. * As in the majority of the scene they are the same (exception for multi room and so on),
  32763. * this is easier to reference from here than from all the materials.
  32764. */
  32765. /**
  32766. * Intensity of the environment in all pbr material.
  32767. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32768. * As in the majority of the scene they are the same (exception for multi room and so on),
  32769. * this is easier to set here than in all the materials.
  32770. */
  32771. environmentIntensity: number;
  32772. /** @hidden */
  32773. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32774. /**
  32775. * Default image processing configuration used either in the rendering
  32776. * Forward main pass or through the imageProcessingPostProcess if present.
  32777. * As in the majority of the scene they are the same (exception for multi camera),
  32778. * this is easier to reference from here than from all the materials and post process.
  32779. *
  32780. * No setter as we it is a shared configuration, you can set the values instead.
  32781. */
  32782. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32783. private _forceWireframe;
  32784. /**
  32785. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32786. */
  32787. forceWireframe: boolean;
  32788. private _forcePointsCloud;
  32789. /**
  32790. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32791. */
  32792. forcePointsCloud: boolean;
  32793. /**
  32794. * Gets or sets the active clipplane 1
  32795. */
  32796. clipPlane: Nullable<Plane>;
  32797. /**
  32798. * Gets or sets the active clipplane 2
  32799. */
  32800. clipPlane2: Nullable<Plane>;
  32801. /**
  32802. * Gets or sets the active clipplane 3
  32803. */
  32804. clipPlane3: Nullable<Plane>;
  32805. /**
  32806. * Gets or sets the active clipplane 4
  32807. */
  32808. clipPlane4: Nullable<Plane>;
  32809. /**
  32810. * Gets or sets a boolean indicating if animations are enabled
  32811. */
  32812. animationsEnabled: boolean;
  32813. private _animationPropertiesOverride;
  32814. /**
  32815. * Gets or sets the animation properties override
  32816. */
  32817. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32818. /**
  32819. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32820. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32821. */
  32822. useConstantAnimationDeltaTime: boolean;
  32823. /**
  32824. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32825. * Please note that it requires to run a ray cast through the scene on every frame
  32826. */
  32827. constantlyUpdateMeshUnderPointer: boolean;
  32828. /**
  32829. * Defines the HTML cursor to use when hovering over interactive elements
  32830. */
  32831. hoverCursor: string;
  32832. /**
  32833. * Defines the HTML default cursor to use (empty by default)
  32834. */
  32835. defaultCursor: string;
  32836. /**
  32837. * This is used to call preventDefault() on pointer down
  32838. * in order to block unwanted artifacts like system double clicks
  32839. */
  32840. preventDefaultOnPointerDown: boolean;
  32841. /**
  32842. * This is used to call preventDefault() on pointer up
  32843. * in order to block unwanted artifacts like system double clicks
  32844. */
  32845. preventDefaultOnPointerUp: boolean;
  32846. /**
  32847. * Gets or sets user defined metadata
  32848. */
  32849. metadata: any;
  32850. /**
  32851. * For internal use only. Please do not use.
  32852. */
  32853. reservedDataStore: any;
  32854. /**
  32855. * Gets the name of the plugin used to load this scene (null by default)
  32856. */
  32857. loadingPluginName: string;
  32858. /**
  32859. * Use this array to add regular expressions used to disable offline support for specific urls
  32860. */
  32861. disableOfflineSupportExceptionRules: RegExp[];
  32862. /**
  32863. * An event triggered when the scene is disposed.
  32864. */
  32865. onDisposeObservable: Observable<Scene>;
  32866. private _onDisposeObserver;
  32867. /** Sets a function to be executed when this scene is disposed. */
  32868. onDispose: () => void;
  32869. /**
  32870. * An event triggered before rendering the scene (right after animations and physics)
  32871. */
  32872. onBeforeRenderObservable: Observable<Scene>;
  32873. private _onBeforeRenderObserver;
  32874. /** Sets a function to be executed before rendering this scene */
  32875. beforeRender: Nullable<() => void>;
  32876. /**
  32877. * An event triggered after rendering the scene
  32878. */
  32879. onAfterRenderObservable: Observable<Scene>;
  32880. /**
  32881. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32882. */
  32883. onAfterRenderCameraObservable: Observable<Camera>;
  32884. private _onAfterRenderObserver;
  32885. /** Sets a function to be executed after rendering this scene */
  32886. afterRender: Nullable<() => void>;
  32887. /**
  32888. * An event triggered before animating the scene
  32889. */
  32890. onBeforeAnimationsObservable: Observable<Scene>;
  32891. /**
  32892. * An event triggered after animations processing
  32893. */
  32894. onAfterAnimationsObservable: Observable<Scene>;
  32895. /**
  32896. * An event triggered before draw calls are ready to be sent
  32897. */
  32898. onBeforeDrawPhaseObservable: Observable<Scene>;
  32899. /**
  32900. * An event triggered after draw calls have been sent
  32901. */
  32902. onAfterDrawPhaseObservable: Observable<Scene>;
  32903. /**
  32904. * An event triggered when the scene is ready
  32905. */
  32906. onReadyObservable: Observable<Scene>;
  32907. /**
  32908. * An event triggered before rendering a camera
  32909. */
  32910. onBeforeCameraRenderObservable: Observable<Camera>;
  32911. private _onBeforeCameraRenderObserver;
  32912. /** Sets a function to be executed before rendering a camera*/
  32913. beforeCameraRender: () => void;
  32914. /**
  32915. * An event triggered after rendering a camera
  32916. */
  32917. onAfterCameraRenderObservable: Observable<Camera>;
  32918. private _onAfterCameraRenderObserver;
  32919. /** Sets a function to be executed after rendering a camera*/
  32920. afterCameraRender: () => void;
  32921. /**
  32922. * An event triggered when active meshes evaluation is about to start
  32923. */
  32924. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32925. /**
  32926. * An event triggered when active meshes evaluation is done
  32927. */
  32928. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32929. /**
  32930. * An event triggered when particles rendering is about to start
  32931. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32932. */
  32933. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32934. /**
  32935. * An event triggered when particles rendering is done
  32936. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32937. */
  32938. onAfterParticlesRenderingObservable: Observable<Scene>;
  32939. /**
  32940. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32941. */
  32942. onDataLoadedObservable: Observable<Scene>;
  32943. /**
  32944. * An event triggered when a camera is created
  32945. */
  32946. onNewCameraAddedObservable: Observable<Camera>;
  32947. /**
  32948. * An event triggered when a camera is removed
  32949. */
  32950. onCameraRemovedObservable: Observable<Camera>;
  32951. /**
  32952. * An event triggered when a light is created
  32953. */
  32954. onNewLightAddedObservable: Observable<Light>;
  32955. /**
  32956. * An event triggered when a light is removed
  32957. */
  32958. onLightRemovedObservable: Observable<Light>;
  32959. /**
  32960. * An event triggered when a geometry is created
  32961. */
  32962. onNewGeometryAddedObservable: Observable<Geometry>;
  32963. /**
  32964. * An event triggered when a geometry is removed
  32965. */
  32966. onGeometryRemovedObservable: Observable<Geometry>;
  32967. /**
  32968. * An event triggered when a transform node is created
  32969. */
  32970. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32971. /**
  32972. * An event triggered when a transform node is removed
  32973. */
  32974. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32975. /**
  32976. * An event triggered when a mesh is created
  32977. */
  32978. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32979. /**
  32980. * An event triggered when a mesh is removed
  32981. */
  32982. onMeshRemovedObservable: Observable<AbstractMesh>;
  32983. /**
  32984. * An event triggered when a skeleton is created
  32985. */
  32986. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32987. /**
  32988. * An event triggered when a skeleton is removed
  32989. */
  32990. onSkeletonRemovedObservable: Observable<Skeleton>;
  32991. /**
  32992. * An event triggered when a material is created
  32993. */
  32994. onNewMaterialAddedObservable: Observable<Material>;
  32995. /**
  32996. * An event triggered when a material is removed
  32997. */
  32998. onMaterialRemovedObservable: Observable<Material>;
  32999. /**
  33000. * An event triggered when a texture is created
  33001. */
  33002. onNewTextureAddedObservable: Observable<BaseTexture>;
  33003. /**
  33004. * An event triggered when a texture is removed
  33005. */
  33006. onTextureRemovedObservable: Observable<BaseTexture>;
  33007. /**
  33008. * An event triggered when render targets are about to be rendered
  33009. * Can happen multiple times per frame.
  33010. */
  33011. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33012. /**
  33013. * An event triggered when render targets were rendered.
  33014. * Can happen multiple times per frame.
  33015. */
  33016. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33017. /**
  33018. * An event triggered before calculating deterministic simulation step
  33019. */
  33020. onBeforeStepObservable: Observable<Scene>;
  33021. /**
  33022. * An event triggered after calculating deterministic simulation step
  33023. */
  33024. onAfterStepObservable: Observable<Scene>;
  33025. /**
  33026. * An event triggered when the activeCamera property is updated
  33027. */
  33028. onActiveCameraChanged: Observable<Scene>;
  33029. /**
  33030. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33031. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33032. * 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)
  33033. */
  33034. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33035. /**
  33036. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33037. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33038. * 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)
  33039. */
  33040. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33041. /**
  33042. * This Observable will when a mesh has been imported into the scene.
  33043. */
  33044. onMeshImportedObservable: Observable<AbstractMesh>;
  33045. /**
  33046. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33047. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33048. */
  33049. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33050. /** @hidden */
  33051. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33052. /**
  33053. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33054. */
  33055. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33056. /**
  33057. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33058. */
  33059. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33060. /**
  33061. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33062. */
  33063. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33064. /** Callback called when a pointer move is detected */
  33065. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33066. /** Callback called when a pointer down is detected */
  33067. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33068. /** Callback called when a pointer up is detected */
  33069. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33070. /** Callback called when a pointer pick is detected */
  33071. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33072. /**
  33073. * 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).
  33074. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33075. */
  33076. onPrePointerObservable: Observable<PointerInfoPre>;
  33077. /**
  33078. * Observable event triggered each time an input event is received from the rendering canvas
  33079. */
  33080. onPointerObservable: Observable<PointerInfo>;
  33081. /**
  33082. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33083. */
  33084. readonly unTranslatedPointer: Vector2;
  33085. /**
  33086. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33087. */
  33088. static DragMovementThreshold: number;
  33089. /**
  33090. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33091. */
  33092. static LongPressDelay: number;
  33093. /**
  33094. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33095. */
  33096. static DoubleClickDelay: number;
  33097. /** If you need to check double click without raising a single click at first click, enable this flag */
  33098. static ExclusiveDoubleClickMode: boolean;
  33099. /** @hidden */
  33100. _mirroredCameraPosition: Nullable<Vector3>;
  33101. /**
  33102. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33103. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33104. */
  33105. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33106. /**
  33107. * Observable event triggered each time an keyboard event is received from the hosting window
  33108. */
  33109. onKeyboardObservable: Observable<KeyboardInfo>;
  33110. private _useRightHandedSystem;
  33111. /**
  33112. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33113. */
  33114. useRightHandedSystem: boolean;
  33115. private _timeAccumulator;
  33116. private _currentStepId;
  33117. private _currentInternalStep;
  33118. /**
  33119. * Sets the step Id used by deterministic lock step
  33120. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33121. * @param newStepId defines the step Id
  33122. */
  33123. setStepId(newStepId: number): void;
  33124. /**
  33125. * Gets the step Id used by deterministic lock step
  33126. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33127. * @returns the step Id
  33128. */
  33129. getStepId(): number;
  33130. /**
  33131. * Gets the internal step used by deterministic lock step
  33132. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33133. * @returns the internal step
  33134. */
  33135. getInternalStep(): number;
  33136. private _fogEnabled;
  33137. /**
  33138. * Gets or sets a boolean indicating if fog is enabled on this scene
  33139. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33140. * (Default is true)
  33141. */
  33142. fogEnabled: boolean;
  33143. private _fogMode;
  33144. /**
  33145. * Gets or sets the fog mode to use
  33146. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33147. * | mode | value |
  33148. * | --- | --- |
  33149. * | FOGMODE_NONE | 0 |
  33150. * | FOGMODE_EXP | 1 |
  33151. * | FOGMODE_EXP2 | 2 |
  33152. * | FOGMODE_LINEAR | 3 |
  33153. */
  33154. fogMode: number;
  33155. /**
  33156. * Gets or sets the fog color to use
  33157. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33158. * (Default is Color3(0.2, 0.2, 0.3))
  33159. */
  33160. fogColor: Color3;
  33161. /**
  33162. * Gets or sets the fog density to use
  33163. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33164. * (Default is 0.1)
  33165. */
  33166. fogDensity: number;
  33167. /**
  33168. * Gets or sets the fog start distance to use
  33169. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33170. * (Default is 0)
  33171. */
  33172. fogStart: number;
  33173. /**
  33174. * Gets or sets the fog end distance to use
  33175. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33176. * (Default is 1000)
  33177. */
  33178. fogEnd: number;
  33179. private _shadowsEnabled;
  33180. /**
  33181. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33182. */
  33183. shadowsEnabled: boolean;
  33184. private _lightsEnabled;
  33185. /**
  33186. * Gets or sets a boolean indicating if lights are enabled on this scene
  33187. */
  33188. lightsEnabled: boolean;
  33189. /** All of the active cameras added to this scene. */
  33190. activeCameras: Camera[];
  33191. /** @hidden */
  33192. _activeCamera: Nullable<Camera>;
  33193. /** Gets or sets the current active camera */
  33194. activeCamera: Nullable<Camera>;
  33195. private _defaultMaterial;
  33196. /** The default material used on meshes when no material is affected */
  33197. /** The default material used on meshes when no material is affected */
  33198. defaultMaterial: Material;
  33199. private _texturesEnabled;
  33200. /**
  33201. * Gets or sets a boolean indicating if textures are enabled on this scene
  33202. */
  33203. texturesEnabled: boolean;
  33204. /**
  33205. * Gets or sets a boolean indicating if particles are enabled on this scene
  33206. */
  33207. particlesEnabled: boolean;
  33208. /**
  33209. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33210. */
  33211. spritesEnabled: boolean;
  33212. private _skeletonsEnabled;
  33213. /**
  33214. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33215. */
  33216. skeletonsEnabled: boolean;
  33217. /**
  33218. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33219. */
  33220. lensFlaresEnabled: boolean;
  33221. /**
  33222. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33223. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33224. */
  33225. collisionsEnabled: boolean;
  33226. private _collisionCoordinator;
  33227. /** @hidden */
  33228. readonly collisionCoordinator: ICollisionCoordinator;
  33229. /**
  33230. * Defines the gravity applied to this scene (used only for collisions)
  33231. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33232. */
  33233. gravity: Vector3;
  33234. /**
  33235. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33236. */
  33237. postProcessesEnabled: boolean;
  33238. /**
  33239. * The list of postprocesses added to the scene
  33240. */
  33241. postProcesses: PostProcess[];
  33242. /**
  33243. * Gets the current postprocess manager
  33244. */
  33245. postProcessManager: PostProcessManager;
  33246. /**
  33247. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33248. */
  33249. renderTargetsEnabled: boolean;
  33250. /**
  33251. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33252. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33253. */
  33254. dumpNextRenderTargets: boolean;
  33255. /**
  33256. * The list of user defined render targets added to the scene
  33257. */
  33258. customRenderTargets: RenderTargetTexture[];
  33259. /**
  33260. * Defines if texture loading must be delayed
  33261. * If true, textures will only be loaded when they need to be rendered
  33262. */
  33263. useDelayedTextureLoading: boolean;
  33264. /**
  33265. * Gets the list of meshes imported to the scene through SceneLoader
  33266. */
  33267. importedMeshesFiles: String[];
  33268. /**
  33269. * Gets or sets a boolean indicating if probes are enabled on this scene
  33270. */
  33271. probesEnabled: boolean;
  33272. /**
  33273. * Gets or sets the current offline provider to use to store scene data
  33274. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33275. */
  33276. offlineProvider: IOfflineProvider;
  33277. /**
  33278. * Gets or sets the action manager associated with the scene
  33279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33280. */
  33281. actionManager: AbstractActionManager;
  33282. private _meshesForIntersections;
  33283. /**
  33284. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33285. */
  33286. proceduralTexturesEnabled: boolean;
  33287. private _engine;
  33288. private _totalVertices;
  33289. /** @hidden */
  33290. _activeIndices: PerfCounter;
  33291. /** @hidden */
  33292. _activeParticles: PerfCounter;
  33293. /** @hidden */
  33294. _activeBones: PerfCounter;
  33295. private _animationRatio;
  33296. /** @hidden */
  33297. _animationTimeLast: number;
  33298. /** @hidden */
  33299. _animationTime: number;
  33300. /**
  33301. * Gets or sets a general scale for animation speed
  33302. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33303. */
  33304. animationTimeScale: number;
  33305. /** @hidden */
  33306. _cachedMaterial: Nullable<Material>;
  33307. /** @hidden */
  33308. _cachedEffect: Nullable<Effect>;
  33309. /** @hidden */
  33310. _cachedVisibility: Nullable<number>;
  33311. private _renderId;
  33312. private _frameId;
  33313. private _executeWhenReadyTimeoutId;
  33314. private _intermediateRendering;
  33315. private _viewUpdateFlag;
  33316. private _projectionUpdateFlag;
  33317. /** @hidden */
  33318. _toBeDisposed: Nullable<IDisposable>[];
  33319. private _activeRequests;
  33320. /** @hidden */
  33321. _pendingData: any[];
  33322. private _isDisposed;
  33323. /**
  33324. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33325. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33326. */
  33327. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33328. private _activeMeshes;
  33329. private _processedMaterials;
  33330. private _renderTargets;
  33331. /** @hidden */
  33332. _activeParticleSystems: SmartArray<IParticleSystem>;
  33333. private _activeSkeletons;
  33334. private _softwareSkinnedMeshes;
  33335. private _renderingManager;
  33336. /** @hidden */
  33337. _activeAnimatables: Animatable[];
  33338. private _transformMatrix;
  33339. private _sceneUbo;
  33340. /** @hidden */
  33341. _viewMatrix: Matrix;
  33342. private _projectionMatrix;
  33343. /** @hidden */
  33344. _forcedViewPosition: Nullable<Vector3>;
  33345. /** @hidden */
  33346. _frustumPlanes: Plane[];
  33347. /**
  33348. * Gets the list of frustum planes (built from the active camera)
  33349. */
  33350. readonly frustumPlanes: Plane[];
  33351. /**
  33352. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33353. * This is useful if there are more lights that the maximum simulteanous authorized
  33354. */
  33355. requireLightSorting: boolean;
  33356. /** @hidden */
  33357. readonly useMaterialMeshMap: boolean;
  33358. /** @hidden */
  33359. readonly useClonedMeshhMap: boolean;
  33360. private _externalData;
  33361. private _uid;
  33362. /**
  33363. * @hidden
  33364. * Backing store of defined scene components.
  33365. */
  33366. _components: ISceneComponent[];
  33367. /**
  33368. * @hidden
  33369. * Backing store of defined scene components.
  33370. */
  33371. _serializableComponents: ISceneSerializableComponent[];
  33372. /**
  33373. * List of components to register on the next registration step.
  33374. */
  33375. private _transientComponents;
  33376. /**
  33377. * Registers the transient components if needed.
  33378. */
  33379. private _registerTransientComponents;
  33380. /**
  33381. * @hidden
  33382. * Add a component to the scene.
  33383. * Note that the ccomponent could be registered on th next frame if this is called after
  33384. * the register component stage.
  33385. * @param component Defines the component to add to the scene
  33386. */
  33387. _addComponent(component: ISceneComponent): void;
  33388. /**
  33389. * @hidden
  33390. * Gets a component from the scene.
  33391. * @param name defines the name of the component to retrieve
  33392. * @returns the component or null if not present
  33393. */
  33394. _getComponent(name: string): Nullable<ISceneComponent>;
  33395. /**
  33396. * @hidden
  33397. * Defines the actions happening before camera updates.
  33398. */
  33399. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33400. /**
  33401. * @hidden
  33402. * Defines the actions happening before clear the canvas.
  33403. */
  33404. _beforeClearStage: Stage<SimpleStageAction>;
  33405. /**
  33406. * @hidden
  33407. * Defines the actions when collecting render targets for the frame.
  33408. */
  33409. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33410. /**
  33411. * @hidden
  33412. * Defines the actions happening for one camera in the frame.
  33413. */
  33414. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33415. /**
  33416. * @hidden
  33417. * Defines the actions happening during the per mesh ready checks.
  33418. */
  33419. _isReadyForMeshStage: Stage<MeshStageAction>;
  33420. /**
  33421. * @hidden
  33422. * Defines the actions happening before evaluate active mesh checks.
  33423. */
  33424. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33425. /**
  33426. * @hidden
  33427. * Defines the actions happening during the evaluate sub mesh checks.
  33428. */
  33429. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33430. /**
  33431. * @hidden
  33432. * Defines the actions happening during the active mesh stage.
  33433. */
  33434. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33435. /**
  33436. * @hidden
  33437. * Defines the actions happening during the per camera render target step.
  33438. */
  33439. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33440. /**
  33441. * @hidden
  33442. * Defines the actions happening just before the active camera is drawing.
  33443. */
  33444. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33445. /**
  33446. * @hidden
  33447. * Defines the actions happening just before a render target is drawing.
  33448. */
  33449. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33450. /**
  33451. * @hidden
  33452. * Defines the actions happening just before a rendering group is drawing.
  33453. */
  33454. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33455. /**
  33456. * @hidden
  33457. * Defines the actions happening just before a mesh is drawing.
  33458. */
  33459. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33460. /**
  33461. * @hidden
  33462. * Defines the actions happening just after a mesh has been drawn.
  33463. */
  33464. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33465. /**
  33466. * @hidden
  33467. * Defines the actions happening just after a rendering group has been drawn.
  33468. */
  33469. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33470. /**
  33471. * @hidden
  33472. * Defines the actions happening just after the active camera has been drawn.
  33473. */
  33474. _afterCameraDrawStage: Stage<CameraStageAction>;
  33475. /**
  33476. * @hidden
  33477. * Defines the actions happening just after a render target has been drawn.
  33478. */
  33479. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33480. /**
  33481. * @hidden
  33482. * Defines the actions happening just after rendering all cameras and computing intersections.
  33483. */
  33484. _afterRenderStage: Stage<SimpleStageAction>;
  33485. /**
  33486. * @hidden
  33487. * Defines the actions happening when a pointer move event happens.
  33488. */
  33489. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33490. /**
  33491. * @hidden
  33492. * Defines the actions happening when a pointer down event happens.
  33493. */
  33494. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33495. /**
  33496. * @hidden
  33497. * Defines the actions happening when a pointer up event happens.
  33498. */
  33499. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33500. /**
  33501. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33502. */
  33503. private geometriesByUniqueId;
  33504. /**
  33505. * Creates a new Scene
  33506. * @param engine defines the engine to use to render this scene
  33507. * @param options defines the scene options
  33508. */
  33509. constructor(engine: Engine, options?: SceneOptions);
  33510. /**
  33511. * Gets a string idenfifying the name of the class
  33512. * @returns "Scene" string
  33513. */
  33514. getClassName(): string;
  33515. private _defaultMeshCandidates;
  33516. /**
  33517. * @hidden
  33518. */
  33519. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33520. private _defaultSubMeshCandidates;
  33521. /**
  33522. * @hidden
  33523. */
  33524. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33525. /**
  33526. * Sets the default candidate providers for the scene.
  33527. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33528. * and getCollidingSubMeshCandidates to their default function
  33529. */
  33530. setDefaultCandidateProviders(): void;
  33531. /**
  33532. * Gets the mesh that is currently under the pointer
  33533. */
  33534. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33535. /**
  33536. * Gets or sets the current on-screen X position of the pointer
  33537. */
  33538. pointerX: number;
  33539. /**
  33540. * Gets or sets the current on-screen Y position of the pointer
  33541. */
  33542. pointerY: number;
  33543. /**
  33544. * Gets the cached material (ie. the latest rendered one)
  33545. * @returns the cached material
  33546. */
  33547. getCachedMaterial(): Nullable<Material>;
  33548. /**
  33549. * Gets the cached effect (ie. the latest rendered one)
  33550. * @returns the cached effect
  33551. */
  33552. getCachedEffect(): Nullable<Effect>;
  33553. /**
  33554. * Gets the cached visibility state (ie. the latest rendered one)
  33555. * @returns the cached visibility state
  33556. */
  33557. getCachedVisibility(): Nullable<number>;
  33558. /**
  33559. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33560. * @param material defines the current material
  33561. * @param effect defines the current effect
  33562. * @param visibility defines the current visibility state
  33563. * @returns true if one parameter is not cached
  33564. */
  33565. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33566. /**
  33567. * Gets the engine associated with the scene
  33568. * @returns an Engine
  33569. */
  33570. getEngine(): Engine;
  33571. /**
  33572. * Gets the total number of vertices rendered per frame
  33573. * @returns the total number of vertices rendered per frame
  33574. */
  33575. getTotalVertices(): number;
  33576. /**
  33577. * Gets the performance counter for total vertices
  33578. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33579. */
  33580. readonly totalVerticesPerfCounter: PerfCounter;
  33581. /**
  33582. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33583. * @returns the total number of active indices rendered per frame
  33584. */
  33585. getActiveIndices(): number;
  33586. /**
  33587. * Gets the performance counter for active indices
  33588. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33589. */
  33590. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33591. /**
  33592. * Gets the total number of active particles rendered per frame
  33593. * @returns the total number of active particles rendered per frame
  33594. */
  33595. getActiveParticles(): number;
  33596. /**
  33597. * Gets the performance counter for active particles
  33598. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33599. */
  33600. readonly activeParticlesPerfCounter: PerfCounter;
  33601. /**
  33602. * Gets the total number of active bones rendered per frame
  33603. * @returns the total number of active bones rendered per frame
  33604. */
  33605. getActiveBones(): number;
  33606. /**
  33607. * Gets the performance counter for active bones
  33608. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33609. */
  33610. readonly activeBonesPerfCounter: PerfCounter;
  33611. /**
  33612. * Gets the array of active meshes
  33613. * @returns an array of AbstractMesh
  33614. */
  33615. getActiveMeshes(): SmartArray<AbstractMesh>;
  33616. /**
  33617. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33618. * @returns a number
  33619. */
  33620. getAnimationRatio(): number;
  33621. /**
  33622. * Gets an unique Id for the current render phase
  33623. * @returns a number
  33624. */
  33625. getRenderId(): number;
  33626. /**
  33627. * Gets an unique Id for the current frame
  33628. * @returns a number
  33629. */
  33630. getFrameId(): number;
  33631. /** Call this function if you want to manually increment the render Id*/
  33632. incrementRenderId(): void;
  33633. private _createUbo;
  33634. /**
  33635. * Use this method to simulate a pointer move on a mesh
  33636. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33637. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33638. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33639. * @returns the current scene
  33640. */
  33641. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33642. /**
  33643. * Use this method to simulate a pointer down on a mesh
  33644. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33645. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33646. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33647. * @returns the current scene
  33648. */
  33649. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33650. /**
  33651. * Use this method to simulate a pointer up on a mesh
  33652. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33653. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33654. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33655. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33656. * @returns the current scene
  33657. */
  33658. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33659. /**
  33660. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33661. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33662. * @returns true if the pointer was captured
  33663. */
  33664. isPointerCaptured(pointerId?: number): boolean;
  33665. /**
  33666. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33667. * @param attachUp defines if you want to attach events to pointerup
  33668. * @param attachDown defines if you want to attach events to pointerdown
  33669. * @param attachMove defines if you want to attach events to pointermove
  33670. */
  33671. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33672. /** Detaches all event handlers*/
  33673. detachControl(): void;
  33674. /**
  33675. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33676. * Delay loaded resources are not taking in account
  33677. * @return true if all required resources are ready
  33678. */
  33679. isReady(): boolean;
  33680. /** Resets all cached information relative to material (including effect and visibility) */
  33681. resetCachedMaterial(): void;
  33682. /**
  33683. * Registers a function to be called before every frame render
  33684. * @param func defines the function to register
  33685. */
  33686. registerBeforeRender(func: () => void): void;
  33687. /**
  33688. * Unregisters a function called before every frame render
  33689. * @param func defines the function to unregister
  33690. */
  33691. unregisterBeforeRender(func: () => void): void;
  33692. /**
  33693. * Registers a function to be called after every frame render
  33694. * @param func defines the function to register
  33695. */
  33696. registerAfterRender(func: () => void): void;
  33697. /**
  33698. * Unregisters a function called after every frame render
  33699. * @param func defines the function to unregister
  33700. */
  33701. unregisterAfterRender(func: () => void): void;
  33702. private _executeOnceBeforeRender;
  33703. /**
  33704. * The provided function will run before render once and will be disposed afterwards.
  33705. * A timeout delay can be provided so that the function will be executed in N ms.
  33706. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33707. * @param func The function to be executed.
  33708. * @param timeout optional delay in ms
  33709. */
  33710. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33711. /** @hidden */
  33712. _addPendingData(data: any): void;
  33713. /** @hidden */
  33714. _removePendingData(data: any): void;
  33715. /**
  33716. * Returns the number of items waiting to be loaded
  33717. * @returns the number of items waiting to be loaded
  33718. */
  33719. getWaitingItemsCount(): number;
  33720. /**
  33721. * Returns a boolean indicating if the scene is still loading data
  33722. */
  33723. readonly isLoading: boolean;
  33724. /**
  33725. * Registers a function to be executed when the scene is ready
  33726. * @param {Function} func - the function to be executed
  33727. */
  33728. executeWhenReady(func: () => void): void;
  33729. /**
  33730. * Returns a promise that resolves when the scene is ready
  33731. * @returns A promise that resolves when the scene is ready
  33732. */
  33733. whenReadyAsync(): Promise<void>;
  33734. /** @hidden */
  33735. _checkIsReady(): void;
  33736. /**
  33737. * Gets all animatable attached to the scene
  33738. */
  33739. readonly animatables: Animatable[];
  33740. /**
  33741. * Resets the last animation time frame.
  33742. * Useful to override when animations start running when loading a scene for the first time.
  33743. */
  33744. resetLastAnimationTimeFrame(): void;
  33745. /**
  33746. * Gets the current view matrix
  33747. * @returns a Matrix
  33748. */
  33749. getViewMatrix(): Matrix;
  33750. /**
  33751. * Gets the current projection matrix
  33752. * @returns a Matrix
  33753. */
  33754. getProjectionMatrix(): Matrix;
  33755. /**
  33756. * Gets the current transform matrix
  33757. * @returns a Matrix made of View * Projection
  33758. */
  33759. getTransformMatrix(): Matrix;
  33760. /**
  33761. * Sets the current transform matrix
  33762. * @param viewL defines the View matrix to use
  33763. * @param projectionL defines the Projection matrix to use
  33764. * @param viewR defines the right View matrix to use (if provided)
  33765. * @param projectionR defines the right Projection matrix to use (if provided)
  33766. */
  33767. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33768. /**
  33769. * Gets the uniform buffer used to store scene data
  33770. * @returns a UniformBuffer
  33771. */
  33772. getSceneUniformBuffer(): UniformBuffer;
  33773. /**
  33774. * Gets an unique (relatively to the current scene) Id
  33775. * @returns an unique number for the scene
  33776. */
  33777. getUniqueId(): number;
  33778. /**
  33779. * Add a mesh to the list of scene's meshes
  33780. * @param newMesh defines the mesh to add
  33781. * @param recursive if all child meshes should also be added to the scene
  33782. */
  33783. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33784. /**
  33785. * Remove a mesh for the list of scene's meshes
  33786. * @param toRemove defines the mesh to remove
  33787. * @param recursive if all child meshes should also be removed from the scene
  33788. * @returns the index where the mesh was in the mesh list
  33789. */
  33790. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33791. /**
  33792. * Add a transform node to the list of scene's transform nodes
  33793. * @param newTransformNode defines the transform node to add
  33794. */
  33795. addTransformNode(newTransformNode: TransformNode): void;
  33796. /**
  33797. * Remove a transform node for the list of scene's transform nodes
  33798. * @param toRemove defines the transform node to remove
  33799. * @returns the index where the transform node was in the transform node list
  33800. */
  33801. removeTransformNode(toRemove: TransformNode): number;
  33802. /**
  33803. * Remove a skeleton for the list of scene's skeletons
  33804. * @param toRemove defines the skeleton to remove
  33805. * @returns the index where the skeleton was in the skeleton list
  33806. */
  33807. removeSkeleton(toRemove: Skeleton): number;
  33808. /**
  33809. * Remove a morph target for the list of scene's morph targets
  33810. * @param toRemove defines the morph target to remove
  33811. * @returns the index where the morph target was in the morph target list
  33812. */
  33813. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33814. /**
  33815. * Remove a light for the list of scene's lights
  33816. * @param toRemove defines the light to remove
  33817. * @returns the index where the light was in the light list
  33818. */
  33819. removeLight(toRemove: Light): number;
  33820. /**
  33821. * Remove a camera for the list of scene's cameras
  33822. * @param toRemove defines the camera to remove
  33823. * @returns the index where the camera was in the camera list
  33824. */
  33825. removeCamera(toRemove: Camera): number;
  33826. /**
  33827. * Remove a particle system for the list of scene's particle systems
  33828. * @param toRemove defines the particle system to remove
  33829. * @returns the index where the particle system was in the particle system list
  33830. */
  33831. removeParticleSystem(toRemove: IParticleSystem): number;
  33832. /**
  33833. * Remove a animation for the list of scene's animations
  33834. * @param toRemove defines the animation to remove
  33835. * @returns the index where the animation was in the animation list
  33836. */
  33837. removeAnimation(toRemove: Animation): number;
  33838. /**
  33839. * Will stop the animation of the given target
  33840. * @param target - the target
  33841. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33842. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  33843. */
  33844. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33845. /**
  33846. * Removes the given animation group from this scene.
  33847. * @param toRemove The animation group to remove
  33848. * @returns The index of the removed animation group
  33849. */
  33850. removeAnimationGroup(toRemove: AnimationGroup): number;
  33851. /**
  33852. * Removes the given multi-material from this scene.
  33853. * @param toRemove The multi-material to remove
  33854. * @returns The index of the removed multi-material
  33855. */
  33856. removeMultiMaterial(toRemove: MultiMaterial): number;
  33857. /**
  33858. * Removes the given material from this scene.
  33859. * @param toRemove The material to remove
  33860. * @returns The index of the removed material
  33861. */
  33862. removeMaterial(toRemove: Material): number;
  33863. /**
  33864. * Removes the given action manager from this scene.
  33865. * @param toRemove The action manager to remove
  33866. * @returns The index of the removed action manager
  33867. */
  33868. removeActionManager(toRemove: AbstractActionManager): number;
  33869. /**
  33870. * Removes the given texture from this scene.
  33871. * @param toRemove The texture to remove
  33872. * @returns The index of the removed texture
  33873. */
  33874. removeTexture(toRemove: BaseTexture): number;
  33875. /**
  33876. * Adds the given light to this scene
  33877. * @param newLight The light to add
  33878. */
  33879. addLight(newLight: Light): void;
  33880. /**
  33881. * Sorts the list list based on light priorities
  33882. */
  33883. sortLightsByPriority(): void;
  33884. /**
  33885. * Adds the given camera to this scene
  33886. * @param newCamera The camera to add
  33887. */
  33888. addCamera(newCamera: Camera): void;
  33889. /**
  33890. * Adds the given skeleton to this scene
  33891. * @param newSkeleton The skeleton to add
  33892. */
  33893. addSkeleton(newSkeleton: Skeleton): void;
  33894. /**
  33895. * Adds the given particle system to this scene
  33896. * @param newParticleSystem The particle system to add
  33897. */
  33898. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33899. /**
  33900. * Adds the given animation to this scene
  33901. * @param newAnimation The animation to add
  33902. */
  33903. addAnimation(newAnimation: Animation): void;
  33904. /**
  33905. * Adds the given animation group to this scene.
  33906. * @param newAnimationGroup The animation group to add
  33907. */
  33908. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33909. /**
  33910. * Adds the given multi-material to this scene
  33911. * @param newMultiMaterial The multi-material to add
  33912. */
  33913. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33914. /**
  33915. * Adds the given material to this scene
  33916. * @param newMaterial The material to add
  33917. */
  33918. addMaterial(newMaterial: Material): void;
  33919. /**
  33920. * Adds the given morph target to this scene
  33921. * @param newMorphTargetManager The morph target to add
  33922. */
  33923. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33924. /**
  33925. * Adds the given geometry to this scene
  33926. * @param newGeometry The geometry to add
  33927. */
  33928. addGeometry(newGeometry: Geometry): void;
  33929. /**
  33930. * Adds the given action manager to this scene
  33931. * @param newActionManager The action manager to add
  33932. */
  33933. addActionManager(newActionManager: AbstractActionManager): void;
  33934. /**
  33935. * Adds the given texture to this scene.
  33936. * @param newTexture The texture to add
  33937. */
  33938. addTexture(newTexture: BaseTexture): void;
  33939. /**
  33940. * Switch active camera
  33941. * @param newCamera defines the new active camera
  33942. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33943. */
  33944. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33945. /**
  33946. * sets the active camera of the scene using its ID
  33947. * @param id defines the camera's ID
  33948. * @return the new active camera or null if none found.
  33949. */
  33950. setActiveCameraByID(id: string): Nullable<Camera>;
  33951. /**
  33952. * sets the active camera of the scene using its name
  33953. * @param name defines the camera's name
  33954. * @returns the new active camera or null if none found.
  33955. */
  33956. setActiveCameraByName(name: string): Nullable<Camera>;
  33957. /**
  33958. * get an animation group using its name
  33959. * @param name defines the material's name
  33960. * @return the animation group or null if none found.
  33961. */
  33962. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33963. /**
  33964. * Get a material using its unique id
  33965. * @param uniqueId defines the material's unique id
  33966. * @return the material or null if none found.
  33967. */
  33968. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33969. /**
  33970. * get a material using its id
  33971. * @param id defines the material's ID
  33972. * @return the material or null if none found.
  33973. */
  33974. getMaterialByID(id: string): Nullable<Material>;
  33975. /**
  33976. * Gets a the last added material using a given id
  33977. * @param id defines the material's ID
  33978. * @return the last material with the given id or null if none found.
  33979. */
  33980. getLastMaterialByID(id: string): Nullable<Material>;
  33981. /**
  33982. * Gets a material using its name
  33983. * @param name defines the material's name
  33984. * @return the material or null if none found.
  33985. */
  33986. getMaterialByName(name: string): Nullable<Material>;
  33987. /**
  33988. * Get a texture using its unique id
  33989. * @param uniqueId defines the texture's unique id
  33990. * @return the texture or null if none found.
  33991. */
  33992. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33993. /**
  33994. * Gets a camera using its id
  33995. * @param id defines the id to look for
  33996. * @returns the camera or null if not found
  33997. */
  33998. getCameraByID(id: string): Nullable<Camera>;
  33999. /**
  34000. * Gets a camera using its unique id
  34001. * @param uniqueId defines the unique id to look for
  34002. * @returns the camera or null if not found
  34003. */
  34004. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34005. /**
  34006. * Gets a camera using its name
  34007. * @param name defines the camera's name
  34008. * @return the camera or null if none found.
  34009. */
  34010. getCameraByName(name: string): Nullable<Camera>;
  34011. /**
  34012. * Gets a bone using its id
  34013. * @param id defines the bone's id
  34014. * @return the bone or null if not found
  34015. */
  34016. getBoneByID(id: string): Nullable<Bone>;
  34017. /**
  34018. * Gets a bone using its id
  34019. * @param name defines the bone's name
  34020. * @return the bone or null if not found
  34021. */
  34022. getBoneByName(name: string): Nullable<Bone>;
  34023. /**
  34024. * Gets a light node using its name
  34025. * @param name defines the the light's name
  34026. * @return the light or null if none found.
  34027. */
  34028. getLightByName(name: string): Nullable<Light>;
  34029. /**
  34030. * Gets a light node using its id
  34031. * @param id defines the light's id
  34032. * @return the light or null if none found.
  34033. */
  34034. getLightByID(id: string): Nullable<Light>;
  34035. /**
  34036. * Gets a light node using its scene-generated unique ID
  34037. * @param uniqueId defines the light's unique id
  34038. * @return the light or null if none found.
  34039. */
  34040. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34041. /**
  34042. * Gets a particle system by id
  34043. * @param id defines the particle system id
  34044. * @return the corresponding system or null if none found
  34045. */
  34046. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34047. /**
  34048. * Gets a geometry using its ID
  34049. * @param id defines the geometry's id
  34050. * @return the geometry or null if none found.
  34051. */
  34052. getGeometryByID(id: string): Nullable<Geometry>;
  34053. private _getGeometryByUniqueID;
  34054. /**
  34055. * Add a new geometry to this scene
  34056. * @param geometry defines the geometry to be added to the scene.
  34057. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34058. * @return a boolean defining if the geometry was added or not
  34059. */
  34060. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34061. /**
  34062. * Removes an existing geometry
  34063. * @param geometry defines the geometry to be removed from the scene
  34064. * @return a boolean defining if the geometry was removed or not
  34065. */
  34066. removeGeometry(geometry: Geometry): boolean;
  34067. /**
  34068. * Gets the list of geometries attached to the scene
  34069. * @returns an array of Geometry
  34070. */
  34071. getGeometries(): Geometry[];
  34072. /**
  34073. * Gets the first added mesh found of a given ID
  34074. * @param id defines the id to search for
  34075. * @return the mesh found or null if not found at all
  34076. */
  34077. getMeshByID(id: string): Nullable<AbstractMesh>;
  34078. /**
  34079. * Gets a list of meshes using their id
  34080. * @param id defines the id to search for
  34081. * @returns a list of meshes
  34082. */
  34083. getMeshesByID(id: string): Array<AbstractMesh>;
  34084. /**
  34085. * Gets the first added transform node found of a given ID
  34086. * @param id defines the id to search for
  34087. * @return the found transform node or null if not found at all.
  34088. */
  34089. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34090. /**
  34091. * Gets a transform node with its auto-generated unique id
  34092. * @param uniqueId efines the unique id to search for
  34093. * @return the found transform node or null if not found at all.
  34094. */
  34095. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34096. /**
  34097. * Gets a list of transform nodes using their id
  34098. * @param id defines the id to search for
  34099. * @returns a list of transform nodes
  34100. */
  34101. getTransformNodesByID(id: string): Array<TransformNode>;
  34102. /**
  34103. * Gets a mesh with its auto-generated unique id
  34104. * @param uniqueId defines the unique id to search for
  34105. * @return the found mesh or null if not found at all.
  34106. */
  34107. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34108. /**
  34109. * Gets a the last added mesh using a given id
  34110. * @param id defines the id to search for
  34111. * @return the found mesh or null if not found at all.
  34112. */
  34113. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34114. /**
  34115. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34116. * @param id defines the id to search for
  34117. * @return the found node or null if not found at all
  34118. */
  34119. getLastEntryByID(id: string): Nullable<Node>;
  34120. /**
  34121. * Gets a node (Mesh, Camera, Light) using a given id
  34122. * @param id defines the id to search for
  34123. * @return the found node or null if not found at all
  34124. */
  34125. getNodeByID(id: string): Nullable<Node>;
  34126. /**
  34127. * Gets a node (Mesh, Camera, Light) using a given name
  34128. * @param name defines the name to search for
  34129. * @return the found node or null if not found at all.
  34130. */
  34131. getNodeByName(name: string): Nullable<Node>;
  34132. /**
  34133. * Gets a mesh using a given name
  34134. * @param name defines the name to search for
  34135. * @return the found mesh or null if not found at all.
  34136. */
  34137. getMeshByName(name: string): Nullable<AbstractMesh>;
  34138. /**
  34139. * Gets a transform node using a given name
  34140. * @param name defines the name to search for
  34141. * @return the found transform node or null if not found at all.
  34142. */
  34143. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34144. /**
  34145. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34146. * @param id defines the id to search for
  34147. * @return the found skeleton or null if not found at all.
  34148. */
  34149. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34150. /**
  34151. * Gets a skeleton using a given auto generated unique id
  34152. * @param uniqueId defines the unique id to search for
  34153. * @return the found skeleton or null if not found at all.
  34154. */
  34155. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34156. /**
  34157. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34158. * @param id defines the id to search for
  34159. * @return the found skeleton or null if not found at all.
  34160. */
  34161. getSkeletonById(id: string): Nullable<Skeleton>;
  34162. /**
  34163. * Gets a skeleton using a given name
  34164. * @param name defines the name to search for
  34165. * @return the found skeleton or null if not found at all.
  34166. */
  34167. getSkeletonByName(name: string): Nullable<Skeleton>;
  34168. /**
  34169. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34170. * @param id defines the id to search for
  34171. * @return the found morph target manager or null if not found at all.
  34172. */
  34173. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34174. /**
  34175. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34176. * @param id defines the id to search for
  34177. * @return the found morph target or null if not found at all.
  34178. */
  34179. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34180. /**
  34181. * Gets a boolean indicating if the given mesh is active
  34182. * @param mesh defines the mesh to look for
  34183. * @returns true if the mesh is in the active list
  34184. */
  34185. isActiveMesh(mesh: AbstractMesh): boolean;
  34186. /**
  34187. * Return a unique id as a string which can serve as an identifier for the scene
  34188. */
  34189. readonly uid: string;
  34190. /**
  34191. * Add an externaly attached data from its key.
  34192. * This method call will fail and return false, if such key already exists.
  34193. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34194. * @param key the unique key that identifies the data
  34195. * @param data the data object to associate to the key for this Engine instance
  34196. * @return true if no such key were already present and the data was added successfully, false otherwise
  34197. */
  34198. addExternalData<T>(key: string, data: T): boolean;
  34199. /**
  34200. * Get an externaly attached data from its key
  34201. * @param key the unique key that identifies the data
  34202. * @return the associated data, if present (can be null), or undefined if not present
  34203. */
  34204. getExternalData<T>(key: string): Nullable<T>;
  34205. /**
  34206. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34207. * @param key the unique key that identifies the data
  34208. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34209. * @return the associated data, can be null if the factory returned null.
  34210. */
  34211. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34212. /**
  34213. * Remove an externaly attached data from the Engine instance
  34214. * @param key the unique key that identifies the data
  34215. * @return true if the data was successfully removed, false if it doesn't exist
  34216. */
  34217. removeExternalData(key: string): boolean;
  34218. private _evaluateSubMesh;
  34219. /**
  34220. * Clear the processed materials smart array preventing retention point in material dispose.
  34221. */
  34222. freeProcessedMaterials(): void;
  34223. private _preventFreeActiveMeshesAndRenderingGroups;
  34224. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34225. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34226. * when disposing several meshes in a row or a hierarchy of meshes.
  34227. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34228. */
  34229. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34230. /**
  34231. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34232. */
  34233. freeActiveMeshes(): void;
  34234. /**
  34235. * Clear the info related to rendering groups preventing retention points during dispose.
  34236. */
  34237. freeRenderingGroups(): void;
  34238. /** @hidden */
  34239. _isInIntermediateRendering(): boolean;
  34240. /**
  34241. * Lambda returning the list of potentially active meshes.
  34242. */
  34243. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34244. /**
  34245. * Lambda returning the list of potentially active sub meshes.
  34246. */
  34247. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34248. /**
  34249. * Lambda returning the list of potentially intersecting sub meshes.
  34250. */
  34251. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34252. /**
  34253. * Lambda returning the list of potentially colliding sub meshes.
  34254. */
  34255. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34256. private _activeMeshesFrozen;
  34257. /**
  34258. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34259. * @returns the current scene
  34260. */
  34261. freezeActiveMeshes(): Scene;
  34262. /**
  34263. * Use this function to restart evaluating active meshes on every frame
  34264. * @returns the current scene
  34265. */
  34266. unfreezeActiveMeshes(): Scene;
  34267. private _evaluateActiveMeshes;
  34268. private _activeMesh;
  34269. /**
  34270. * Update the transform matrix to update from the current active camera
  34271. * @param force defines a boolean used to force the update even if cache is up to date
  34272. */
  34273. updateTransformMatrix(force?: boolean): void;
  34274. private _bindFrameBuffer;
  34275. /** @hidden */
  34276. _allowPostProcessClearColor: boolean;
  34277. /** @hidden */
  34278. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34279. private _processSubCameras;
  34280. private _checkIntersections;
  34281. /** @hidden */
  34282. _advancePhysicsEngineStep(step: number): void;
  34283. /**
  34284. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34285. */
  34286. getDeterministicFrameTime: () => number;
  34287. /** @hidden */
  34288. _animate(): void;
  34289. /** Execute all animations (for a frame) */
  34290. animate(): void;
  34291. /**
  34292. * Render the scene
  34293. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34294. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34295. */
  34296. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34297. /**
  34298. * Freeze all materials
  34299. * A frozen material will not be updatable but should be faster to render
  34300. */
  34301. freezeMaterials(): void;
  34302. /**
  34303. * Unfreeze all materials
  34304. * A frozen material will not be updatable but should be faster to render
  34305. */
  34306. unfreezeMaterials(): void;
  34307. /**
  34308. * Releases all held ressources
  34309. */
  34310. dispose(): void;
  34311. /**
  34312. * Gets if the scene is already disposed
  34313. */
  34314. readonly isDisposed: boolean;
  34315. /**
  34316. * Call this function to reduce memory footprint of the scene.
  34317. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34318. */
  34319. clearCachedVertexData(): void;
  34320. /**
  34321. * This function will remove the local cached buffer data from texture.
  34322. * It will save memory but will prevent the texture from being rebuilt
  34323. */
  34324. cleanCachedTextureBuffer(): void;
  34325. /**
  34326. * Get the world extend vectors with an optional filter
  34327. *
  34328. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34329. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34330. */
  34331. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34332. min: Vector3;
  34333. max: Vector3;
  34334. };
  34335. /**
  34336. * Creates a ray that can be used to pick in the scene
  34337. * @param x defines the x coordinate of the origin (on-screen)
  34338. * @param y defines the y coordinate of the origin (on-screen)
  34339. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34340. * @param camera defines the camera to use for the picking
  34341. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34342. * @returns a Ray
  34343. */
  34344. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34345. /**
  34346. * Creates a ray that can be used to pick in the scene
  34347. * @param x defines the x coordinate of the origin (on-screen)
  34348. * @param y defines the y coordinate of the origin (on-screen)
  34349. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34350. * @param result defines the ray where to store the picking ray
  34351. * @param camera defines the camera to use for the picking
  34352. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34353. * @returns the current scene
  34354. */
  34355. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34356. /**
  34357. * Creates a ray that can be used to pick in the scene
  34358. * @param x defines the x coordinate of the origin (on-screen)
  34359. * @param y defines the y coordinate of the origin (on-screen)
  34360. * @param camera defines the camera to use for the picking
  34361. * @returns a Ray
  34362. */
  34363. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34364. /**
  34365. * Creates a ray that can be used to pick in the scene
  34366. * @param x defines the x coordinate of the origin (on-screen)
  34367. * @param y defines the y coordinate of the origin (on-screen)
  34368. * @param result defines the ray where to store the picking ray
  34369. * @param camera defines the camera to use for the picking
  34370. * @returns the current scene
  34371. */
  34372. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34373. /** Launch a ray to try to pick a mesh in the scene
  34374. * @param x position on screen
  34375. * @param y position on screen
  34376. * @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
  34377. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34378. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34379. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34380. * @returns a PickingInfo
  34381. */
  34382. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34383. /** Use the given ray to pick a mesh in the scene
  34384. * @param ray The ray to use to pick meshes
  34385. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  34386. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34387. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34388. * @returns a PickingInfo
  34389. */
  34390. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34391. /**
  34392. * Launch a ray to try to pick a mesh in the scene
  34393. * @param x X position on screen
  34394. * @param y Y position on screen
  34395. * @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
  34396. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34397. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34398. * @returns an array of PickingInfo
  34399. */
  34400. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34401. /**
  34402. * Launch a ray to try to pick a mesh in the scene
  34403. * @param ray Ray to use
  34404. * @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
  34405. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34406. * @returns an array of PickingInfo
  34407. */
  34408. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34409. /**
  34410. * Force the value of meshUnderPointer
  34411. * @param mesh defines the mesh to use
  34412. */
  34413. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34414. /**
  34415. * Gets the mesh under the pointer
  34416. * @returns a Mesh or null if no mesh is under the pointer
  34417. */
  34418. getPointerOverMesh(): Nullable<AbstractMesh>;
  34419. /** @hidden */
  34420. _rebuildGeometries(): void;
  34421. /** @hidden */
  34422. _rebuildTextures(): void;
  34423. private _getByTags;
  34424. /**
  34425. * Get a list of meshes by tags
  34426. * @param tagsQuery defines the tags query to use
  34427. * @param forEach defines a predicate used to filter results
  34428. * @returns an array of Mesh
  34429. */
  34430. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34431. /**
  34432. * Get a list of cameras by tags
  34433. * @param tagsQuery defines the tags query to use
  34434. * @param forEach defines a predicate used to filter results
  34435. * @returns an array of Camera
  34436. */
  34437. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34438. /**
  34439. * Get a list of lights by tags
  34440. * @param tagsQuery defines the tags query to use
  34441. * @param forEach defines a predicate used to filter results
  34442. * @returns an array of Light
  34443. */
  34444. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34445. /**
  34446. * Get a list of materials by tags
  34447. * @param tagsQuery defines the tags query to use
  34448. * @param forEach defines a predicate used to filter results
  34449. * @returns an array of Material
  34450. */
  34451. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34452. /**
  34453. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34454. * This allowed control for front to back rendering or reversly depending of the special needs.
  34455. *
  34456. * @param renderingGroupId The rendering group id corresponding to its index
  34457. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34458. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34459. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34460. */
  34461. 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;
  34462. /**
  34463. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34464. *
  34465. * @param renderingGroupId The rendering group id corresponding to its index
  34466. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34467. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34468. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34469. */
  34470. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34471. /**
  34472. * Gets the current auto clear configuration for one rendering group of the rendering
  34473. * manager.
  34474. * @param index the rendering group index to get the information for
  34475. * @returns The auto clear setup for the requested rendering group
  34476. */
  34477. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34478. private _blockMaterialDirtyMechanism;
  34479. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34480. blockMaterialDirtyMechanism: boolean;
  34481. /**
  34482. * Will flag all materials as dirty to trigger new shader compilation
  34483. * @param flag defines the flag used to specify which material part must be marked as dirty
  34484. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34485. */
  34486. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34487. /** @hidden */
  34488. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34489. /** @hidden */
  34490. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34491. }
  34492. }
  34493. declare module BABYLON {
  34494. /**
  34495. * Set of assets to keep when moving a scene into an asset container.
  34496. */
  34497. export class KeepAssets extends AbstractScene {
  34498. }
  34499. /**
  34500. * Container with a set of assets that can be added or removed from a scene.
  34501. */
  34502. export class AssetContainer extends AbstractScene {
  34503. /**
  34504. * The scene the AssetContainer belongs to.
  34505. */
  34506. scene: Scene;
  34507. /**
  34508. * Instantiates an AssetContainer.
  34509. * @param scene The scene the AssetContainer belongs to.
  34510. */
  34511. constructor(scene: Scene);
  34512. /**
  34513. * Adds all the assets from the container to the scene.
  34514. */
  34515. addAllToScene(): void;
  34516. /**
  34517. * Removes all the assets in the container from the scene
  34518. */
  34519. removeAllFromScene(): void;
  34520. /**
  34521. * Disposes all the assets in the container
  34522. */
  34523. dispose(): void;
  34524. private _moveAssets;
  34525. /**
  34526. * Removes all the assets contained in the scene and adds them to the container.
  34527. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34528. */
  34529. moveAllFromScene(keepAssets?: KeepAssets): void;
  34530. /**
  34531. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  34532. * @returns the root mesh
  34533. */
  34534. createRootMesh(): Mesh;
  34535. }
  34536. }
  34537. declare module BABYLON {
  34538. /**
  34539. * Defines how the parser contract is defined.
  34540. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34541. */
  34542. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34543. /**
  34544. * Defines how the individual parser contract is defined.
  34545. * These parser can parse an individual asset
  34546. */
  34547. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34548. /**
  34549. * Base class of the scene acting as a container for the different elements composing a scene.
  34550. * This class is dynamically extended by the different components of the scene increasing
  34551. * flexibility and reducing coupling
  34552. */
  34553. export abstract class AbstractScene {
  34554. /**
  34555. * Stores the list of available parsers in the application.
  34556. */
  34557. private static _BabylonFileParsers;
  34558. /**
  34559. * Stores the list of available individual parsers in the application.
  34560. */
  34561. private static _IndividualBabylonFileParsers;
  34562. /**
  34563. * Adds a parser in the list of available ones
  34564. * @param name Defines the name of the parser
  34565. * @param parser Defines the parser to add
  34566. */
  34567. static AddParser(name: string, parser: BabylonFileParser): void;
  34568. /**
  34569. * Gets a general parser from the list of avaialble ones
  34570. * @param name Defines the name of the parser
  34571. * @returns the requested parser or null
  34572. */
  34573. static GetParser(name: string): Nullable<BabylonFileParser>;
  34574. /**
  34575. * Adds n individual parser in the list of available ones
  34576. * @param name Defines the name of the parser
  34577. * @param parser Defines the parser to add
  34578. */
  34579. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34580. /**
  34581. * Gets an individual parser from the list of avaialble ones
  34582. * @param name Defines the name of the parser
  34583. * @returns the requested parser or null
  34584. */
  34585. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34586. /**
  34587. * Parser json data and populate both a scene and its associated container object
  34588. * @param jsonData Defines the data to parse
  34589. * @param scene Defines the scene to parse the data for
  34590. * @param container Defines the container attached to the parsing sequence
  34591. * @param rootUrl Defines the root url of the data
  34592. */
  34593. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34594. /**
  34595. * Gets the list of root nodes (ie. nodes with no parent)
  34596. */
  34597. rootNodes: Node[];
  34598. /** All of the cameras added to this scene
  34599. * @see http://doc.babylonjs.com/babylon101/cameras
  34600. */
  34601. cameras: Camera[];
  34602. /**
  34603. * All of the lights added to this scene
  34604. * @see http://doc.babylonjs.com/babylon101/lights
  34605. */
  34606. lights: Light[];
  34607. /**
  34608. * All of the (abstract) meshes added to this scene
  34609. */
  34610. meshes: AbstractMesh[];
  34611. /**
  34612. * The list of skeletons added to the scene
  34613. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34614. */
  34615. skeletons: Skeleton[];
  34616. /**
  34617. * All of the particle systems added to this scene
  34618. * @see http://doc.babylonjs.com/babylon101/particles
  34619. */
  34620. particleSystems: IParticleSystem[];
  34621. /**
  34622. * Gets a list of Animations associated with the scene
  34623. */
  34624. animations: Animation[];
  34625. /**
  34626. * All of the animation groups added to this scene
  34627. * @see http://doc.babylonjs.com/how_to/group
  34628. */
  34629. animationGroups: AnimationGroup[];
  34630. /**
  34631. * All of the multi-materials added to this scene
  34632. * @see http://doc.babylonjs.com/how_to/multi_materials
  34633. */
  34634. multiMaterials: MultiMaterial[];
  34635. /**
  34636. * All of the materials added to this scene
  34637. * In the context of a Scene, it is not supposed to be modified manually.
  34638. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34639. * Note also that the order of the Material wihin the array is not significant and might change.
  34640. * @see http://doc.babylonjs.com/babylon101/materials
  34641. */
  34642. materials: Material[];
  34643. /**
  34644. * The list of morph target managers added to the scene
  34645. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34646. */
  34647. morphTargetManagers: MorphTargetManager[];
  34648. /**
  34649. * The list of geometries used in the scene.
  34650. */
  34651. geometries: Geometry[];
  34652. /**
  34653. * All of the tranform nodes added to this scene
  34654. * In the context of a Scene, it is not supposed to be modified manually.
  34655. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34656. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34657. * @see http://doc.babylonjs.com/how_to/transformnode
  34658. */
  34659. transformNodes: TransformNode[];
  34660. /**
  34661. * ActionManagers available on the scene.
  34662. */
  34663. actionManagers: AbstractActionManager[];
  34664. /**
  34665. * Textures to keep.
  34666. */
  34667. textures: BaseTexture[];
  34668. /**
  34669. * Environment texture for the scene
  34670. */
  34671. environmentTexture: Nullable<BaseTexture>;
  34672. }
  34673. }
  34674. declare module BABYLON {
  34675. /**
  34676. * Interface used to define options for Sound class
  34677. */
  34678. export interface ISoundOptions {
  34679. /**
  34680. * Does the sound autoplay once loaded.
  34681. */
  34682. autoplay?: boolean;
  34683. /**
  34684. * Does the sound loop after it finishes playing once.
  34685. */
  34686. loop?: boolean;
  34687. /**
  34688. * Sound's volume
  34689. */
  34690. volume?: number;
  34691. /**
  34692. * Is it a spatial sound?
  34693. */
  34694. spatialSound?: boolean;
  34695. /**
  34696. * Maximum distance to hear that sound
  34697. */
  34698. maxDistance?: number;
  34699. /**
  34700. * Uses user defined attenuation function
  34701. */
  34702. useCustomAttenuation?: boolean;
  34703. /**
  34704. * Define the roll off factor of spatial sounds.
  34705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34706. */
  34707. rolloffFactor?: number;
  34708. /**
  34709. * Define the reference distance the sound should be heard perfectly.
  34710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34711. */
  34712. refDistance?: number;
  34713. /**
  34714. * Define the distance attenuation model the sound will follow.
  34715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34716. */
  34717. distanceModel?: string;
  34718. /**
  34719. * Defines the playback speed (1 by default)
  34720. */
  34721. playbackRate?: number;
  34722. /**
  34723. * Defines if the sound is from a streaming source
  34724. */
  34725. streaming?: boolean;
  34726. /**
  34727. * Defines an optional length (in seconds) inside the sound file
  34728. */
  34729. length?: number;
  34730. /**
  34731. * Defines an optional offset (in seconds) inside the sound file
  34732. */
  34733. offset?: number;
  34734. /**
  34735. * If true, URLs will not be required to state the audio file codec to use.
  34736. */
  34737. skipCodecCheck?: boolean;
  34738. }
  34739. /**
  34740. * Defines a sound that can be played in the application.
  34741. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34743. */
  34744. export class Sound {
  34745. /**
  34746. * The name of the sound in the scene.
  34747. */
  34748. name: string;
  34749. /**
  34750. * Does the sound autoplay once loaded.
  34751. */
  34752. autoplay: boolean;
  34753. /**
  34754. * Does the sound loop after it finishes playing once.
  34755. */
  34756. loop: boolean;
  34757. /**
  34758. * Does the sound use a custom attenuation curve to simulate the falloff
  34759. * happening when the source gets further away from the camera.
  34760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34761. */
  34762. useCustomAttenuation: boolean;
  34763. /**
  34764. * The sound track id this sound belongs to.
  34765. */
  34766. soundTrackId: number;
  34767. /**
  34768. * Is this sound currently played.
  34769. */
  34770. isPlaying: boolean;
  34771. /**
  34772. * Is this sound currently paused.
  34773. */
  34774. isPaused: boolean;
  34775. /**
  34776. * Does this sound enables spatial sound.
  34777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34778. */
  34779. spatialSound: boolean;
  34780. /**
  34781. * Define the reference distance the sound should be heard perfectly.
  34782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34783. */
  34784. refDistance: number;
  34785. /**
  34786. * Define the roll off factor of spatial sounds.
  34787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34788. */
  34789. rolloffFactor: number;
  34790. /**
  34791. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34793. */
  34794. maxDistance: number;
  34795. /**
  34796. * Define the distance attenuation model the sound will follow.
  34797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34798. */
  34799. distanceModel: string;
  34800. /**
  34801. * @hidden
  34802. * Back Compat
  34803. **/
  34804. onended: () => any;
  34805. /**
  34806. * Observable event when the current playing sound finishes.
  34807. */
  34808. onEndedObservable: Observable<Sound>;
  34809. private _panningModel;
  34810. private _playbackRate;
  34811. private _streaming;
  34812. private _startTime;
  34813. private _startOffset;
  34814. private _position;
  34815. /** @hidden */
  34816. _positionInEmitterSpace: boolean;
  34817. private _localDirection;
  34818. private _volume;
  34819. private _isReadyToPlay;
  34820. private _isDirectional;
  34821. private _readyToPlayCallback;
  34822. private _audioBuffer;
  34823. private _soundSource;
  34824. private _streamingSource;
  34825. private _soundPanner;
  34826. private _soundGain;
  34827. private _inputAudioNode;
  34828. private _outputAudioNode;
  34829. private _coneInnerAngle;
  34830. private _coneOuterAngle;
  34831. private _coneOuterGain;
  34832. private _scene;
  34833. private _connectedTransformNode;
  34834. private _customAttenuationFunction;
  34835. private _registerFunc;
  34836. private _isOutputConnected;
  34837. private _htmlAudioElement;
  34838. private _urlType;
  34839. private _length?;
  34840. private _offset?;
  34841. /** @hidden */
  34842. static _SceneComponentInitialization: (scene: Scene) => void;
  34843. /**
  34844. * Create a sound and attach it to a scene
  34845. * @param name Name of your sound
  34846. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34847. * @param scene defines the scene the sound belongs to
  34848. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34849. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34850. */
  34851. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34852. /**
  34853. * Release the sound and its associated resources
  34854. */
  34855. dispose(): void;
  34856. /**
  34857. * Gets if the sounds is ready to be played or not.
  34858. * @returns true if ready, otherwise false
  34859. */
  34860. isReady(): boolean;
  34861. private _soundLoaded;
  34862. /**
  34863. * Sets the data of the sound from an audiobuffer
  34864. * @param audioBuffer The audioBuffer containing the data
  34865. */
  34866. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34867. /**
  34868. * Updates the current sounds options such as maxdistance, loop...
  34869. * @param options A JSON object containing values named as the object properties
  34870. */
  34871. updateOptions(options: ISoundOptions): void;
  34872. private _createSpatialParameters;
  34873. private _updateSpatialParameters;
  34874. /**
  34875. * Switch the panning model to HRTF:
  34876. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34878. */
  34879. switchPanningModelToHRTF(): void;
  34880. /**
  34881. * Switch the panning model to Equal Power:
  34882. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34884. */
  34885. switchPanningModelToEqualPower(): void;
  34886. private _switchPanningModel;
  34887. /**
  34888. * Connect this sound to a sound track audio node like gain...
  34889. * @param soundTrackAudioNode the sound track audio node to connect to
  34890. */
  34891. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34892. /**
  34893. * Transform this sound into a directional source
  34894. * @param coneInnerAngle Size of the inner cone in degree
  34895. * @param coneOuterAngle Size of the outer cone in degree
  34896. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34897. */
  34898. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34899. /**
  34900. * Gets or sets the inner angle for the directional cone.
  34901. */
  34902. /**
  34903. * Gets or sets the inner angle for the directional cone.
  34904. */
  34905. directionalConeInnerAngle: number;
  34906. /**
  34907. * Gets or sets the outer angle for the directional cone.
  34908. */
  34909. /**
  34910. * Gets or sets the outer angle for the directional cone.
  34911. */
  34912. directionalConeOuterAngle: number;
  34913. /**
  34914. * Sets the position of the emitter if spatial sound is enabled
  34915. * @param newPosition Defines the new posisiton
  34916. */
  34917. setPosition(newPosition: Vector3): void;
  34918. /**
  34919. * Sets the local direction of the emitter if spatial sound is enabled
  34920. * @param newLocalDirection Defines the new local direction
  34921. */
  34922. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34923. private _updateDirection;
  34924. /** @hidden */
  34925. updateDistanceFromListener(): void;
  34926. /**
  34927. * Sets a new custom attenuation function for the sound.
  34928. * @param callback Defines the function used for the attenuation
  34929. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34930. */
  34931. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34932. /**
  34933. * Play the sound
  34934. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34935. * @param offset (optional) Start the sound at a specific time in seconds
  34936. * @param length (optional) Sound duration (in seconds)
  34937. */
  34938. play(time?: number, offset?: number, length?: number): void;
  34939. private _onended;
  34940. /**
  34941. * Stop the sound
  34942. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34943. */
  34944. stop(time?: number): void;
  34945. /**
  34946. * Put the sound in pause
  34947. */
  34948. pause(): void;
  34949. /**
  34950. * Sets a dedicated volume for this sounds
  34951. * @param newVolume Define the new volume of the sound
  34952. * @param time Define time for gradual change to new volume
  34953. */
  34954. setVolume(newVolume: number, time?: number): void;
  34955. /**
  34956. * Set the sound play back rate
  34957. * @param newPlaybackRate Define the playback rate the sound should be played at
  34958. */
  34959. setPlaybackRate(newPlaybackRate: number): void;
  34960. /**
  34961. * Gets the volume of the sound.
  34962. * @returns the volume of the sound
  34963. */
  34964. getVolume(): number;
  34965. /**
  34966. * Attach the sound to a dedicated mesh
  34967. * @param transformNode The transform node to connect the sound with
  34968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34969. */
  34970. attachToMesh(transformNode: TransformNode): void;
  34971. /**
  34972. * Detach the sound from the previously attached mesh
  34973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34974. */
  34975. detachFromMesh(): void;
  34976. private _onRegisterAfterWorldMatrixUpdate;
  34977. /**
  34978. * Clone the current sound in the scene.
  34979. * @returns the new sound clone
  34980. */
  34981. clone(): Nullable<Sound>;
  34982. /**
  34983. * Gets the current underlying audio buffer containing the data
  34984. * @returns the audio buffer
  34985. */
  34986. getAudioBuffer(): Nullable<AudioBuffer>;
  34987. /**
  34988. * Serializes the Sound in a JSON representation
  34989. * @returns the JSON representation of the sound
  34990. */
  34991. serialize(): any;
  34992. /**
  34993. * Parse a JSON representation of a sound to innstantiate in a given scene
  34994. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34995. * @param scene Define the scene the new parsed sound should be created in
  34996. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34997. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34998. * @returns the newly parsed sound
  34999. */
  35000. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35001. }
  35002. }
  35003. declare module BABYLON {
  35004. /**
  35005. * This defines an action helpful to play a defined sound on a triggered action.
  35006. */
  35007. export class PlaySoundAction extends Action {
  35008. private _sound;
  35009. /**
  35010. * Instantiate the action
  35011. * @param triggerOptions defines the trigger options
  35012. * @param sound defines the sound to play
  35013. * @param condition defines the trigger related conditions
  35014. */
  35015. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35016. /** @hidden */
  35017. _prepare(): void;
  35018. /**
  35019. * Execute the action and play the sound.
  35020. */
  35021. execute(): void;
  35022. /**
  35023. * Serializes the actions and its related information.
  35024. * @param parent defines the object to serialize in
  35025. * @returns the serialized object
  35026. */
  35027. serialize(parent: any): any;
  35028. }
  35029. /**
  35030. * This defines an action helpful to stop a defined sound on a triggered action.
  35031. */
  35032. export class StopSoundAction extends Action {
  35033. private _sound;
  35034. /**
  35035. * Instantiate the action
  35036. * @param triggerOptions defines the trigger options
  35037. * @param sound defines the sound to stop
  35038. * @param condition defines the trigger related conditions
  35039. */
  35040. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35041. /** @hidden */
  35042. _prepare(): void;
  35043. /**
  35044. * Execute the action and stop the sound.
  35045. */
  35046. execute(): void;
  35047. /**
  35048. * Serializes the actions and its related information.
  35049. * @param parent defines the object to serialize in
  35050. * @returns the serialized object
  35051. */
  35052. serialize(parent: any): any;
  35053. }
  35054. }
  35055. declare module BABYLON {
  35056. /**
  35057. * This defines an action responsible to change the value of a property
  35058. * by interpolating between its current value and the newly set one once triggered.
  35059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35060. */
  35061. export class InterpolateValueAction extends Action {
  35062. /**
  35063. * Defines the path of the property where the value should be interpolated
  35064. */
  35065. propertyPath: string;
  35066. /**
  35067. * Defines the target value at the end of the interpolation.
  35068. */
  35069. value: any;
  35070. /**
  35071. * Defines the time it will take for the property to interpolate to the value.
  35072. */
  35073. duration: number;
  35074. /**
  35075. * Defines if the other scene animations should be stopped when the action has been triggered
  35076. */
  35077. stopOtherAnimations?: boolean;
  35078. /**
  35079. * Defines a callback raised once the interpolation animation has been done.
  35080. */
  35081. onInterpolationDone?: () => void;
  35082. /**
  35083. * Observable triggered once the interpolation animation has been done.
  35084. */
  35085. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35086. private _target;
  35087. private _effectiveTarget;
  35088. private _property;
  35089. /**
  35090. * Instantiate the action
  35091. * @param triggerOptions defines the trigger options
  35092. * @param target defines the object containing the value to interpolate
  35093. * @param propertyPath defines the path to the property in the target object
  35094. * @param value defines the target value at the end of the interpolation
  35095. * @param duration deines the time it will take for the property to interpolate to the value.
  35096. * @param condition defines the trigger related conditions
  35097. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35098. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35099. */
  35100. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35101. /** @hidden */
  35102. _prepare(): void;
  35103. /**
  35104. * Execute the action starts the value interpolation.
  35105. */
  35106. execute(): void;
  35107. /**
  35108. * Serializes the actions and its related information.
  35109. * @param parent defines the object to serialize in
  35110. * @returns the serialized object
  35111. */
  35112. serialize(parent: any): any;
  35113. }
  35114. }
  35115. declare module BABYLON {
  35116. /**
  35117. * Options allowed during the creation of a sound track.
  35118. */
  35119. export interface ISoundTrackOptions {
  35120. /**
  35121. * The volume the sound track should take during creation
  35122. */
  35123. volume?: number;
  35124. /**
  35125. * Define if the sound track is the main sound track of the scene
  35126. */
  35127. mainTrack?: boolean;
  35128. }
  35129. /**
  35130. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35131. * It will be also used in a future release to apply effects on a specific track.
  35132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35133. */
  35134. export class SoundTrack {
  35135. /**
  35136. * The unique identifier of the sound track in the scene.
  35137. */
  35138. id: number;
  35139. /**
  35140. * The list of sounds included in the sound track.
  35141. */
  35142. soundCollection: Array<Sound>;
  35143. private _outputAudioNode;
  35144. private _scene;
  35145. private _isMainTrack;
  35146. private _connectedAnalyser;
  35147. private _options;
  35148. private _isInitialized;
  35149. /**
  35150. * Creates a new sound track.
  35151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35152. * @param scene Define the scene the sound track belongs to
  35153. * @param options
  35154. */
  35155. constructor(scene: Scene, options?: ISoundTrackOptions);
  35156. private _initializeSoundTrackAudioGraph;
  35157. /**
  35158. * Release the sound track and its associated resources
  35159. */
  35160. dispose(): void;
  35161. /**
  35162. * Adds a sound to this sound track
  35163. * @param sound define the cound to add
  35164. * @ignoreNaming
  35165. */
  35166. AddSound(sound: Sound): void;
  35167. /**
  35168. * Removes a sound to this sound track
  35169. * @param sound define the cound to remove
  35170. * @ignoreNaming
  35171. */
  35172. RemoveSound(sound: Sound): void;
  35173. /**
  35174. * Set a global volume for the full sound track.
  35175. * @param newVolume Define the new volume of the sound track
  35176. */
  35177. setVolume(newVolume: number): void;
  35178. /**
  35179. * Switch the panning model to HRTF:
  35180. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35182. */
  35183. switchPanningModelToHRTF(): void;
  35184. /**
  35185. * Switch the panning model to Equal Power:
  35186. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35187. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35188. */
  35189. switchPanningModelToEqualPower(): void;
  35190. /**
  35191. * Connect the sound track to an audio analyser allowing some amazing
  35192. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35194. * @param analyser The analyser to connect to the engine
  35195. */
  35196. connectToAnalyser(analyser: Analyser): void;
  35197. }
  35198. }
  35199. declare module BABYLON {
  35200. interface AbstractScene {
  35201. /**
  35202. * The list of sounds used in the scene.
  35203. */
  35204. sounds: Nullable<Array<Sound>>;
  35205. }
  35206. interface Scene {
  35207. /**
  35208. * @hidden
  35209. * Backing field
  35210. */
  35211. _mainSoundTrack: SoundTrack;
  35212. /**
  35213. * The main sound track played by the scene.
  35214. * It cotains your primary collection of sounds.
  35215. */
  35216. mainSoundTrack: SoundTrack;
  35217. /**
  35218. * The list of sound tracks added to the scene
  35219. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35220. */
  35221. soundTracks: Nullable<Array<SoundTrack>>;
  35222. /**
  35223. * Gets a sound using a given name
  35224. * @param name defines the name to search for
  35225. * @return the found sound or null if not found at all.
  35226. */
  35227. getSoundByName(name: string): Nullable<Sound>;
  35228. /**
  35229. * Gets or sets if audio support is enabled
  35230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35231. */
  35232. audioEnabled: boolean;
  35233. /**
  35234. * Gets or sets if audio will be output to headphones
  35235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35236. */
  35237. headphone: boolean;
  35238. /**
  35239. * Gets or sets custom audio listener position provider
  35240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35241. */
  35242. audioListenerPositionProvider: Nullable<() => Vector3>;
  35243. }
  35244. /**
  35245. * Defines the sound scene component responsible to manage any sounds
  35246. * in a given scene.
  35247. */
  35248. export class AudioSceneComponent implements ISceneSerializableComponent {
  35249. /**
  35250. * The component name helpfull to identify the component in the list of scene components.
  35251. */
  35252. readonly name: string;
  35253. /**
  35254. * The scene the component belongs to.
  35255. */
  35256. scene: Scene;
  35257. private _audioEnabled;
  35258. /**
  35259. * Gets whether audio is enabled or not.
  35260. * Please use related enable/disable method to switch state.
  35261. */
  35262. readonly audioEnabled: boolean;
  35263. private _headphone;
  35264. /**
  35265. * Gets whether audio is outputing to headphone or not.
  35266. * Please use the according Switch methods to change output.
  35267. */
  35268. readonly headphone: boolean;
  35269. private _audioListenerPositionProvider;
  35270. /**
  35271. * Gets the current audio listener position provider
  35272. */
  35273. /**
  35274. * Sets a custom listener position for all sounds in the scene
  35275. * By default, this is the position of the first active camera
  35276. */
  35277. audioListenerPositionProvider: Nullable<() => Vector3>;
  35278. /**
  35279. * Creates a new instance of the component for the given scene
  35280. * @param scene Defines the scene to register the component in
  35281. */
  35282. constructor(scene: Scene);
  35283. /**
  35284. * Registers the component in a given scene
  35285. */
  35286. register(): void;
  35287. /**
  35288. * Rebuilds the elements related to this component in case of
  35289. * context lost for instance.
  35290. */
  35291. rebuild(): void;
  35292. /**
  35293. * Serializes the component data to the specified json object
  35294. * @param serializationObject The object to serialize to
  35295. */
  35296. serialize(serializationObject: any): void;
  35297. /**
  35298. * Adds all the elements from the container to the scene
  35299. * @param container the container holding the elements
  35300. */
  35301. addFromContainer(container: AbstractScene): void;
  35302. /**
  35303. * Removes all the elements in the container from the scene
  35304. * @param container contains the elements to remove
  35305. * @param dispose if the removed element should be disposed (default: false)
  35306. */
  35307. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35308. /**
  35309. * Disposes the component and the associated ressources.
  35310. */
  35311. dispose(): void;
  35312. /**
  35313. * Disables audio in the associated scene.
  35314. */
  35315. disableAudio(): void;
  35316. /**
  35317. * Enables audio in the associated scene.
  35318. */
  35319. enableAudio(): void;
  35320. /**
  35321. * Switch audio to headphone output.
  35322. */
  35323. switchAudioModeForHeadphones(): void;
  35324. /**
  35325. * Switch audio to normal speakers.
  35326. */
  35327. switchAudioModeForNormalSpeakers(): void;
  35328. private _afterRender;
  35329. }
  35330. }
  35331. declare module BABYLON {
  35332. /**
  35333. * Wraps one or more Sound objects and selects one with random weight for playback.
  35334. */
  35335. export class WeightedSound {
  35336. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35337. loop: boolean;
  35338. private _coneInnerAngle;
  35339. private _coneOuterAngle;
  35340. private _volume;
  35341. /** A Sound is currently playing. */
  35342. isPlaying: boolean;
  35343. /** A Sound is currently paused. */
  35344. isPaused: boolean;
  35345. private _sounds;
  35346. private _weights;
  35347. private _currentIndex?;
  35348. /**
  35349. * Creates a new WeightedSound from the list of sounds given.
  35350. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35351. * @param sounds Array of Sounds that will be selected from.
  35352. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35353. */
  35354. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35355. /**
  35356. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35357. */
  35358. /**
  35359. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35360. */
  35361. directionalConeInnerAngle: number;
  35362. /**
  35363. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35364. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35365. */
  35366. /**
  35367. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35368. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35369. */
  35370. directionalConeOuterAngle: number;
  35371. /**
  35372. * Playback volume.
  35373. */
  35374. /**
  35375. * Playback volume.
  35376. */
  35377. volume: number;
  35378. private _onended;
  35379. /**
  35380. * Suspend playback
  35381. */
  35382. pause(): void;
  35383. /**
  35384. * Stop playback
  35385. */
  35386. stop(): void;
  35387. /**
  35388. * Start playback.
  35389. * @param startOffset Position the clip head at a specific time in seconds.
  35390. */
  35391. play(startOffset?: number): void;
  35392. }
  35393. }
  35394. declare module BABYLON {
  35395. /**
  35396. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35397. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35398. */
  35399. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35400. /**
  35401. * Gets the name of the behavior.
  35402. */
  35403. readonly name: string;
  35404. /**
  35405. * The easing function used by animations
  35406. */
  35407. static EasingFunction: BackEase;
  35408. /**
  35409. * The easing mode used by animations
  35410. */
  35411. static EasingMode: number;
  35412. /**
  35413. * The duration of the animation, in milliseconds
  35414. */
  35415. transitionDuration: number;
  35416. /**
  35417. * Length of the distance animated by the transition when lower radius is reached
  35418. */
  35419. lowerRadiusTransitionRange: number;
  35420. /**
  35421. * Length of the distance animated by the transition when upper radius is reached
  35422. */
  35423. upperRadiusTransitionRange: number;
  35424. private _autoTransitionRange;
  35425. /**
  35426. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35427. */
  35428. /**
  35429. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35430. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35431. */
  35432. autoTransitionRange: boolean;
  35433. private _attachedCamera;
  35434. private _onAfterCheckInputsObserver;
  35435. private _onMeshTargetChangedObserver;
  35436. /**
  35437. * Initializes the behavior.
  35438. */
  35439. init(): void;
  35440. /**
  35441. * Attaches the behavior to its arc rotate camera.
  35442. * @param camera Defines the camera to attach the behavior to
  35443. */
  35444. attach(camera: ArcRotateCamera): void;
  35445. /**
  35446. * Detaches the behavior from its current arc rotate camera.
  35447. */
  35448. detach(): void;
  35449. private _radiusIsAnimating;
  35450. private _radiusBounceTransition;
  35451. private _animatables;
  35452. private _cachedWheelPrecision;
  35453. /**
  35454. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35455. * @param radiusLimit The limit to check against.
  35456. * @return Bool to indicate if at limit.
  35457. */
  35458. private _isRadiusAtLimit;
  35459. /**
  35460. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35461. * @param radiusDelta The delta by which to animate to. Can be negative.
  35462. */
  35463. private _applyBoundRadiusAnimation;
  35464. /**
  35465. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35466. */
  35467. protected _clearAnimationLocks(): void;
  35468. /**
  35469. * Stops and removes all animations that have been applied to the camera
  35470. */
  35471. stopAllAnimations(): void;
  35472. }
  35473. }
  35474. declare module BABYLON {
  35475. /**
  35476. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  35477. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35478. */
  35479. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35480. /**
  35481. * Gets the name of the behavior.
  35482. */
  35483. readonly name: string;
  35484. private _mode;
  35485. private _radiusScale;
  35486. private _positionScale;
  35487. private _defaultElevation;
  35488. private _elevationReturnTime;
  35489. private _elevationReturnWaitTime;
  35490. private _zoomStopsAnimation;
  35491. private _framingTime;
  35492. /**
  35493. * The easing function used by animations
  35494. */
  35495. static EasingFunction: ExponentialEase;
  35496. /**
  35497. * The easing mode used by animations
  35498. */
  35499. static EasingMode: number;
  35500. /**
  35501. * Sets the current mode used by the behavior
  35502. */
  35503. /**
  35504. * Gets current mode used by the behavior.
  35505. */
  35506. mode: number;
  35507. /**
  35508. * Sets the scale applied to the radius (1 by default)
  35509. */
  35510. /**
  35511. * Gets the scale applied to the radius
  35512. */
  35513. radiusScale: number;
  35514. /**
  35515. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35516. */
  35517. /**
  35518. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35519. */
  35520. positionScale: number;
  35521. /**
  35522. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35523. * behaviour is triggered, in radians.
  35524. */
  35525. /**
  35526. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35527. * behaviour is triggered, in radians.
  35528. */
  35529. defaultElevation: number;
  35530. /**
  35531. * Sets the time (in milliseconds) taken to return to the default beta position.
  35532. * Negative value indicates camera should not return to default.
  35533. */
  35534. /**
  35535. * Gets the time (in milliseconds) taken to return to the default beta position.
  35536. * Negative value indicates camera should not return to default.
  35537. */
  35538. elevationReturnTime: number;
  35539. /**
  35540. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35541. */
  35542. /**
  35543. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35544. */
  35545. elevationReturnWaitTime: number;
  35546. /**
  35547. * Sets the flag that indicates if user zooming should stop animation.
  35548. */
  35549. /**
  35550. * Gets the flag that indicates if user zooming should stop animation.
  35551. */
  35552. zoomStopsAnimation: boolean;
  35553. /**
  35554. * Sets the transition time when framing the mesh, in milliseconds
  35555. */
  35556. /**
  35557. * Gets the transition time when framing the mesh, in milliseconds
  35558. */
  35559. framingTime: number;
  35560. /**
  35561. * Define if the behavior should automatically change the configured
  35562. * camera limits and sensibilities.
  35563. */
  35564. autoCorrectCameraLimitsAndSensibility: boolean;
  35565. private _onPrePointerObservableObserver;
  35566. private _onAfterCheckInputsObserver;
  35567. private _onMeshTargetChangedObserver;
  35568. private _attachedCamera;
  35569. private _isPointerDown;
  35570. private _lastInteractionTime;
  35571. /**
  35572. * Initializes the behavior.
  35573. */
  35574. init(): void;
  35575. /**
  35576. * Attaches the behavior to its arc rotate camera.
  35577. * @param camera Defines the camera to attach the behavior to
  35578. */
  35579. attach(camera: ArcRotateCamera): void;
  35580. /**
  35581. * Detaches the behavior from its current arc rotate camera.
  35582. */
  35583. detach(): void;
  35584. private _animatables;
  35585. private _betaIsAnimating;
  35586. private _betaTransition;
  35587. private _radiusTransition;
  35588. private _vectorTransition;
  35589. /**
  35590. * Targets the given mesh and updates zoom level accordingly.
  35591. * @param mesh The mesh to target.
  35592. * @param radius Optional. If a cached radius position already exists, overrides default.
  35593. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35594. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35595. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35596. */
  35597. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35598. /**
  35599. * Targets the given mesh with its children and updates zoom level accordingly.
  35600. * @param mesh The mesh to target.
  35601. * @param radius Optional. If a cached radius position already exists, overrides default.
  35602. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35603. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35604. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35605. */
  35606. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35607. /**
  35608. * Targets the given meshes with their children and updates zoom level accordingly.
  35609. * @param meshes The mesh to target.
  35610. * @param radius Optional. If a cached radius position already exists, overrides default.
  35611. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35612. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35613. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35614. */
  35615. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35616. /**
  35617. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35618. * @param minimumWorld Determines the smaller position of the bounding box extend
  35619. * @param maximumWorld Determines the bigger position of the bounding box extend
  35620. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35621. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35622. */
  35623. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35624. /**
  35625. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35626. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35627. * frustum width.
  35628. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35629. * to fully enclose the mesh in the viewing frustum.
  35630. */
  35631. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35632. /**
  35633. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35634. * is automatically returned to its default position (expected to be above ground plane).
  35635. */
  35636. private _maintainCameraAboveGround;
  35637. /**
  35638. * Returns the frustum slope based on the canvas ratio and camera FOV
  35639. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35640. */
  35641. private _getFrustumSlope;
  35642. /**
  35643. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35644. */
  35645. private _clearAnimationLocks;
  35646. /**
  35647. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35648. */
  35649. private _applyUserInteraction;
  35650. /**
  35651. * Stops and removes all animations that have been applied to the camera
  35652. */
  35653. stopAllAnimations(): void;
  35654. /**
  35655. * Gets a value indicating if the user is moving the camera
  35656. */
  35657. readonly isUserIsMoving: boolean;
  35658. /**
  35659. * The camera can move all the way towards the mesh.
  35660. */
  35661. static IgnoreBoundsSizeMode: number;
  35662. /**
  35663. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35664. */
  35665. static FitFrustumSidesMode: number;
  35666. }
  35667. }
  35668. declare module BABYLON {
  35669. /**
  35670. * Base class for Camera Pointer Inputs.
  35671. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35672. * for example usage.
  35673. */
  35674. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35675. /**
  35676. * Defines the camera the input is attached to.
  35677. */
  35678. abstract camera: Camera;
  35679. /**
  35680. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35681. */
  35682. protected _altKey: boolean;
  35683. protected _ctrlKey: boolean;
  35684. protected _metaKey: boolean;
  35685. protected _shiftKey: boolean;
  35686. /**
  35687. * Which mouse buttons were pressed at time of last mouse event.
  35688. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35689. */
  35690. protected _buttonsPressed: number;
  35691. /**
  35692. * Defines the buttons associated with the input to handle camera move.
  35693. */
  35694. buttons: number[];
  35695. /**
  35696. * Attach the input controls to a specific dom element to get the input from.
  35697. * @param element Defines the element the controls should be listened from
  35698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35699. */
  35700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35701. /**
  35702. * Detach the current controls from the specified dom element.
  35703. * @param element Defines the element to stop listening the inputs from
  35704. */
  35705. detachControl(element: Nullable<HTMLElement>): void;
  35706. /**
  35707. * Gets the class name of the current input.
  35708. * @returns the class name
  35709. */
  35710. getClassName(): string;
  35711. /**
  35712. * Get the friendly name associated with the input class.
  35713. * @returns the input friendly name
  35714. */
  35715. getSimpleName(): string;
  35716. /**
  35717. * Called on pointer POINTERDOUBLETAP event.
  35718. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35719. */
  35720. protected onDoubleTap(type: string): void;
  35721. /**
  35722. * Called on pointer POINTERMOVE event if only a single touch is active.
  35723. * Override this method to provide functionality.
  35724. */
  35725. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35726. /**
  35727. * Called on pointer POINTERMOVE event if multiple touches are active.
  35728. * Override this method to provide functionality.
  35729. */
  35730. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35731. /**
  35732. * Called on JS contextmenu event.
  35733. * Override this method to provide functionality.
  35734. */
  35735. protected onContextMenu(evt: PointerEvent): void;
  35736. /**
  35737. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35738. * press.
  35739. * Override this method to provide functionality.
  35740. */
  35741. protected onButtonDown(evt: PointerEvent): void;
  35742. /**
  35743. * Called each time a new POINTERUP event occurs. Ie, for each button
  35744. * release.
  35745. * Override this method to provide functionality.
  35746. */
  35747. protected onButtonUp(evt: PointerEvent): void;
  35748. /**
  35749. * Called when window becomes inactive.
  35750. * Override this method to provide functionality.
  35751. */
  35752. protected onLostFocus(): void;
  35753. private _pointerInput;
  35754. private _observer;
  35755. private _onLostFocus;
  35756. private pointA;
  35757. private pointB;
  35758. }
  35759. }
  35760. declare module BABYLON {
  35761. /**
  35762. * Manage the pointers inputs to control an arc rotate camera.
  35763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35764. */
  35765. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35766. /**
  35767. * Defines the camera the input is attached to.
  35768. */
  35769. camera: ArcRotateCamera;
  35770. /**
  35771. * Gets the class name of the current input.
  35772. * @returns the class name
  35773. */
  35774. getClassName(): string;
  35775. /**
  35776. * Defines the buttons associated with the input to handle camera move.
  35777. */
  35778. buttons: number[];
  35779. /**
  35780. * Defines the pointer angular sensibility along the X axis or how fast is
  35781. * the camera rotating.
  35782. */
  35783. angularSensibilityX: number;
  35784. /**
  35785. * Defines the pointer angular sensibility along the Y axis or how fast is
  35786. * the camera rotating.
  35787. */
  35788. angularSensibilityY: number;
  35789. /**
  35790. * Defines the pointer pinch precision or how fast is the camera zooming.
  35791. */
  35792. pinchPrecision: number;
  35793. /**
  35794. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35795. * from 0.
  35796. * It defines the percentage of current camera.radius to use as delta when
  35797. * pinch zoom is used.
  35798. */
  35799. pinchDeltaPercentage: number;
  35800. /**
  35801. * Defines the pointer panning sensibility or how fast is the camera moving.
  35802. */
  35803. panningSensibility: number;
  35804. /**
  35805. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35806. */
  35807. multiTouchPanning: boolean;
  35808. /**
  35809. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35810. * zoom (pinch) through multitouch.
  35811. */
  35812. multiTouchPanAndZoom: boolean;
  35813. /**
  35814. * Revers pinch action direction.
  35815. */
  35816. pinchInwards: boolean;
  35817. private _isPanClick;
  35818. private _twoFingerActivityCount;
  35819. private _isPinching;
  35820. /**
  35821. * Called on pointer POINTERMOVE event if only a single touch is active.
  35822. */
  35823. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35824. /**
  35825. * Called on pointer POINTERDOUBLETAP event.
  35826. */
  35827. protected onDoubleTap(type: string): void;
  35828. /**
  35829. * Called on pointer POINTERMOVE event if multiple touches are active.
  35830. */
  35831. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35832. /**
  35833. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35834. * press.
  35835. */
  35836. protected onButtonDown(evt: PointerEvent): void;
  35837. /**
  35838. * Called each time a new POINTERUP event occurs. Ie, for each button
  35839. * release.
  35840. */
  35841. protected onButtonUp(evt: PointerEvent): void;
  35842. /**
  35843. * Called when window becomes inactive.
  35844. */
  35845. protected onLostFocus(): void;
  35846. }
  35847. }
  35848. declare module BABYLON {
  35849. /**
  35850. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35851. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35852. */
  35853. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35854. /**
  35855. * Defines the camera the input is attached to.
  35856. */
  35857. camera: ArcRotateCamera;
  35858. /**
  35859. * Defines the list of key codes associated with the up action (increase alpha)
  35860. */
  35861. keysUp: number[];
  35862. /**
  35863. * Defines the list of key codes associated with the down action (decrease alpha)
  35864. */
  35865. keysDown: number[];
  35866. /**
  35867. * Defines the list of key codes associated with the left action (increase beta)
  35868. */
  35869. keysLeft: number[];
  35870. /**
  35871. * Defines the list of key codes associated with the right action (decrease beta)
  35872. */
  35873. keysRight: number[];
  35874. /**
  35875. * Defines the list of key codes associated with the reset action.
  35876. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35877. */
  35878. keysReset: number[];
  35879. /**
  35880. * Defines the panning sensibility of the inputs.
  35881. * (How fast is the camera paning)
  35882. */
  35883. panningSensibility: number;
  35884. /**
  35885. * Defines the zooming sensibility of the inputs.
  35886. * (How fast is the camera zooming)
  35887. */
  35888. zoomingSensibility: number;
  35889. /**
  35890. * Defines wether maintaining the alt key down switch the movement mode from
  35891. * orientation to zoom.
  35892. */
  35893. useAltToZoom: boolean;
  35894. /**
  35895. * Rotation speed of the camera
  35896. */
  35897. angularSpeed: number;
  35898. private _keys;
  35899. private _ctrlPressed;
  35900. private _altPressed;
  35901. private _onCanvasBlurObserver;
  35902. private _onKeyboardObserver;
  35903. private _engine;
  35904. private _scene;
  35905. /**
  35906. * Attach the input controls to a specific dom element to get the input from.
  35907. * @param element Defines the element the controls should be listened from
  35908. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35909. */
  35910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35911. /**
  35912. * Detach the current controls from the specified dom element.
  35913. * @param element Defines the element to stop listening the inputs from
  35914. */
  35915. detachControl(element: Nullable<HTMLElement>): void;
  35916. /**
  35917. * Update the current camera state depending on the inputs that have been used this frame.
  35918. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35919. */
  35920. checkInputs(): void;
  35921. /**
  35922. * Gets the class name of the current intput.
  35923. * @returns the class name
  35924. */
  35925. getClassName(): string;
  35926. /**
  35927. * Get the friendly name associated with the input class.
  35928. * @returns the input friendly name
  35929. */
  35930. getSimpleName(): string;
  35931. }
  35932. }
  35933. declare module BABYLON {
  35934. /**
  35935. * Manage the mouse wheel inputs to control an arc rotate camera.
  35936. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35937. */
  35938. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35939. /**
  35940. * Defines the camera the input is attached to.
  35941. */
  35942. camera: ArcRotateCamera;
  35943. /**
  35944. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35945. */
  35946. wheelPrecision: number;
  35947. /**
  35948. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35949. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35950. */
  35951. wheelDeltaPercentage: number;
  35952. private _wheel;
  35953. private _observer;
  35954. private computeDeltaFromMouseWheelLegacyEvent;
  35955. /**
  35956. * Attach the input controls to a specific dom element to get the input from.
  35957. * @param element Defines the element the controls should be listened from
  35958. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35959. */
  35960. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35961. /**
  35962. * Detach the current controls from the specified dom element.
  35963. * @param element Defines the element to stop listening the inputs from
  35964. */
  35965. detachControl(element: Nullable<HTMLElement>): void;
  35966. /**
  35967. * Gets the class name of the current intput.
  35968. * @returns the class name
  35969. */
  35970. getClassName(): string;
  35971. /**
  35972. * Get the friendly name associated with the input class.
  35973. * @returns the input friendly name
  35974. */
  35975. getSimpleName(): string;
  35976. }
  35977. }
  35978. declare module BABYLON {
  35979. /**
  35980. * Default Inputs manager for the ArcRotateCamera.
  35981. * It groups all the default supported inputs for ease of use.
  35982. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35983. */
  35984. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35985. /**
  35986. * Instantiates a new ArcRotateCameraInputsManager.
  35987. * @param camera Defines the camera the inputs belong to
  35988. */
  35989. constructor(camera: ArcRotateCamera);
  35990. /**
  35991. * Add mouse wheel input support to the input manager.
  35992. * @returns the current input manager
  35993. */
  35994. addMouseWheel(): ArcRotateCameraInputsManager;
  35995. /**
  35996. * Add pointers input support to the input manager.
  35997. * @returns the current input manager
  35998. */
  35999. addPointers(): ArcRotateCameraInputsManager;
  36000. /**
  36001. * Add keyboard input support to the input manager.
  36002. * @returns the current input manager
  36003. */
  36004. addKeyboard(): ArcRotateCameraInputsManager;
  36005. }
  36006. }
  36007. declare module BABYLON {
  36008. /**
  36009. * This represents an orbital type of camera.
  36010. *
  36011. * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events.
  36012. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position.
  36013. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36014. */
  36015. export class ArcRotateCamera extends TargetCamera {
  36016. /**
  36017. * Defines the rotation angle of the camera along the longitudinal axis.
  36018. */
  36019. alpha: number;
  36020. /**
  36021. * Defines the rotation angle of the camera along the latitudinal axis.
  36022. */
  36023. beta: number;
  36024. /**
  36025. * Defines the radius of the camera from it s target point.
  36026. */
  36027. radius: number;
  36028. protected _target: Vector3;
  36029. protected _targetHost: Nullable<AbstractMesh>;
  36030. /**
  36031. * Defines the target point of the camera.
  36032. * The camera looks towards it form the radius distance.
  36033. */
  36034. target: Vector3;
  36035. /**
  36036. * Define the current local position of the camera in the scene
  36037. */
  36038. position: Vector3;
  36039. protected _upVector: Vector3;
  36040. protected _upToYMatrix: Matrix;
  36041. protected _YToUpMatrix: Matrix;
  36042. /**
  36043. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36044. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36045. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36046. */
  36047. upVector: Vector3;
  36048. /**
  36049. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36050. */
  36051. setMatUp(): void;
  36052. /**
  36053. * Current inertia value on the longitudinal axis.
  36054. * The bigger this number the longer it will take for the camera to stop.
  36055. */
  36056. inertialAlphaOffset: number;
  36057. /**
  36058. * Current inertia value on the latitudinal axis.
  36059. * The bigger this number the longer it will take for the camera to stop.
  36060. */
  36061. inertialBetaOffset: number;
  36062. /**
  36063. * Current inertia value on the radius axis.
  36064. * The bigger this number the longer it will take for the camera to stop.
  36065. */
  36066. inertialRadiusOffset: number;
  36067. /**
  36068. * Minimum allowed angle on the longitudinal axis.
  36069. * This can help limiting how the Camera is able to move in the scene.
  36070. */
  36071. lowerAlphaLimit: Nullable<number>;
  36072. /**
  36073. * Maximum allowed angle on the longitudinal axis.
  36074. * This can help limiting how the Camera is able to move in the scene.
  36075. */
  36076. upperAlphaLimit: Nullable<number>;
  36077. /**
  36078. * Minimum allowed angle on the latitudinal axis.
  36079. * This can help limiting how the Camera is able to move in the scene.
  36080. */
  36081. lowerBetaLimit: number;
  36082. /**
  36083. * Maximum allowed angle on the latitudinal axis.
  36084. * This can help limiting how the Camera is able to move in the scene.
  36085. */
  36086. upperBetaLimit: number;
  36087. /**
  36088. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36089. * This can help limiting how the Camera is able to move in the scene.
  36090. */
  36091. lowerRadiusLimit: Nullable<number>;
  36092. /**
  36093. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36094. * This can help limiting how the Camera is able to move in the scene.
  36095. */
  36096. upperRadiusLimit: Nullable<number>;
  36097. /**
  36098. * Defines the current inertia value used during panning of the camera along the X axis.
  36099. */
  36100. inertialPanningX: number;
  36101. /**
  36102. * Defines the current inertia value used during panning of the camera along the Y axis.
  36103. */
  36104. inertialPanningY: number;
  36105. /**
  36106. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36107. * Basically if your fingers moves away from more than this distance you will be considered
  36108. * in pinch mode.
  36109. */
  36110. pinchToPanMaxDistance: number;
  36111. /**
  36112. * Defines the maximum distance the camera can pan.
  36113. * This could help keeping the cammera always in your scene.
  36114. */
  36115. panningDistanceLimit: Nullable<number>;
  36116. /**
  36117. * Defines the target of the camera before paning.
  36118. */
  36119. panningOriginTarget: Vector3;
  36120. /**
  36121. * Defines the value of the inertia used during panning.
  36122. * 0 would mean stop inertia and one would mean no decelleration at all.
  36123. */
  36124. panningInertia: number;
  36125. /**
  36126. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36127. */
  36128. angularSensibilityX: number;
  36129. /**
  36130. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36131. */
  36132. angularSensibilityY: number;
  36133. /**
  36134. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36135. */
  36136. pinchPrecision: number;
  36137. /**
  36138. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36139. * It will be used instead of pinchDeltaPrecision if different from 0.
  36140. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36141. */
  36142. pinchDeltaPercentage: number;
  36143. /**
  36144. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36145. */
  36146. panningSensibility: number;
  36147. /**
  36148. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36149. */
  36150. keysUp: number[];
  36151. /**
  36152. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36153. */
  36154. keysDown: number[];
  36155. /**
  36156. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36157. */
  36158. keysLeft: number[];
  36159. /**
  36160. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36161. */
  36162. keysRight: number[];
  36163. /**
  36164. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36165. */
  36166. wheelPrecision: number;
  36167. /**
  36168. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36169. * It will be used instead of pinchDeltaPrecision if different from 0.
  36170. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36171. */
  36172. wheelDeltaPercentage: number;
  36173. /**
  36174. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36175. */
  36176. zoomOnFactor: number;
  36177. /**
  36178. * Defines a screen offset for the camera position.
  36179. */
  36180. targetScreenOffset: Vector2;
  36181. /**
  36182. * Allows the camera to be completely reversed.
  36183. * If false the camera can not arrive upside down.
  36184. */
  36185. allowUpsideDown: boolean;
  36186. /**
  36187. * Define if double tap/click is used to restore the previously saved state of the camera.
  36188. */
  36189. useInputToRestoreState: boolean;
  36190. /** @hidden */
  36191. _viewMatrix: Matrix;
  36192. /** @hidden */
  36193. _useCtrlForPanning: boolean;
  36194. /** @hidden */
  36195. _panningMouseButton: number;
  36196. /**
  36197. * Defines the input associated to the camera.
  36198. */
  36199. inputs: ArcRotateCameraInputsManager;
  36200. /** @hidden */
  36201. _reset: () => void;
  36202. /**
  36203. * Defines the allowed panning axis.
  36204. */
  36205. panningAxis: Vector3;
  36206. protected _localDirection: Vector3;
  36207. protected _transformedDirection: Vector3;
  36208. private _bouncingBehavior;
  36209. /**
  36210. * Gets the bouncing behavior of the camera if it has been enabled.
  36211. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36212. */
  36213. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36214. /**
  36215. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36216. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36217. */
  36218. useBouncingBehavior: boolean;
  36219. private _framingBehavior;
  36220. /**
  36221. * Gets the framing behavior of the camera if it has been enabled.
  36222. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36223. */
  36224. readonly framingBehavior: Nullable<FramingBehavior>;
  36225. /**
  36226. * Defines if the framing behavior of the camera is enabled on the camera.
  36227. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36228. */
  36229. useFramingBehavior: boolean;
  36230. private _autoRotationBehavior;
  36231. /**
  36232. * Gets the auto rotation behavior of the camera if it has been enabled.
  36233. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36234. */
  36235. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36236. /**
  36237. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36238. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36239. */
  36240. useAutoRotationBehavior: boolean;
  36241. /**
  36242. * Observable triggered when the mesh target has been changed on the camera.
  36243. */
  36244. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36245. /**
  36246. * Event raised when the camera is colliding with a mesh.
  36247. */
  36248. onCollide: (collidedMesh: AbstractMesh) => void;
  36249. /**
  36250. * Defines whether the camera should check collision with the objects oh the scene.
  36251. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36252. */
  36253. checkCollisions: boolean;
  36254. /**
  36255. * Defines the collision radius of the camera.
  36256. * This simulates a sphere around the camera.
  36257. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36258. */
  36259. collisionRadius: Vector3;
  36260. protected _collider: Collider;
  36261. protected _previousPosition: Vector3;
  36262. protected _collisionVelocity: Vector3;
  36263. protected _newPosition: Vector3;
  36264. protected _previousAlpha: number;
  36265. protected _previousBeta: number;
  36266. protected _previousRadius: number;
  36267. protected _collisionTriggered: boolean;
  36268. protected _targetBoundingCenter: Nullable<Vector3>;
  36269. private _computationVector;
  36270. /**
  36271. * Instantiates a new ArcRotateCamera in a given scene
  36272. * @param name Defines the name of the camera
  36273. * @param alpha Defines the camera rotation along the logitudinal axis
  36274. * @param beta Defines the camera rotation along the latitudinal axis
  36275. * @param radius Defines the camera distance from its target
  36276. * @param target Defines the camera target
  36277. * @param scene Defines the scene the camera belongs to
  36278. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36279. */
  36280. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36281. /** @hidden */
  36282. _initCache(): void;
  36283. /** @hidden */
  36284. _updateCache(ignoreParentClass?: boolean): void;
  36285. protected _getTargetPosition(): Vector3;
  36286. private _storedAlpha;
  36287. private _storedBeta;
  36288. private _storedRadius;
  36289. private _storedTarget;
  36290. /**
  36291. * Stores the current state of the camera (alpha, beta, radius and target)
  36292. * @returns the camera itself
  36293. */
  36294. storeState(): Camera;
  36295. /**
  36296. * @hidden
  36297. * Restored camera state. You must call storeState() first
  36298. */
  36299. _restoreStateValues(): boolean;
  36300. /** @hidden */
  36301. _isSynchronizedViewMatrix(): boolean;
  36302. /**
  36303. * Attached controls to the current camera.
  36304. * @param element Defines the element the controls should be listened from
  36305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36306. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36307. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36308. */
  36309. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36310. /**
  36311. * Detach the current controls from the camera.
  36312. * The camera will stop reacting to inputs.
  36313. * @param element Defines the element to stop listening the inputs from
  36314. */
  36315. detachControl(element: HTMLElement): void;
  36316. /** @hidden */
  36317. _checkInputs(): void;
  36318. protected _checkLimits(): void;
  36319. /**
  36320. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36321. */
  36322. rebuildAnglesAndRadius(): void;
  36323. /**
  36324. * Use a position to define the current camera related information like aplha, beta and radius
  36325. * @param position Defines the position to set the camera at
  36326. */
  36327. setPosition(position: Vector3): void;
  36328. /**
  36329. * Defines the target the camera should look at.
  36330. * This will automatically adapt alpha beta and radius to fit within the new target.
  36331. * @param target Defines the new target as a Vector or a mesh
  36332. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36333. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36334. */
  36335. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36336. /** @hidden */
  36337. _getViewMatrix(): Matrix;
  36338. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36339. /**
  36340. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36341. * @param meshes Defines the mesh to zoom on
  36342. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  36343. */
  36344. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36345. /**
  36346. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36347. * The target will be changed but the radius
  36348. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36349. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  36350. */
  36351. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36352. min: Vector3;
  36353. max: Vector3;
  36354. distance: number;
  36355. }, doNotUpdateMaxZ?: boolean): void;
  36356. /**
  36357. * @override
  36358. * Override Camera.createRigCamera
  36359. */
  36360. createRigCamera(name: string, cameraIndex: number): Camera;
  36361. /**
  36362. * @hidden
  36363. * @override
  36364. * Override Camera._updateRigCameras
  36365. */
  36366. _updateRigCameras(): void;
  36367. /**
  36368. * Destroy the camera and release the current resources hold by it.
  36369. */
  36370. dispose(): void;
  36371. /**
  36372. * Gets the current object class name.
  36373. * @return the class name
  36374. */
  36375. getClassName(): string;
  36376. }
  36377. }
  36378. declare module BABYLON {
  36379. /**
  36380. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36381. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36382. */
  36383. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36384. /**
  36385. * Gets the name of the behavior.
  36386. */
  36387. readonly name: string;
  36388. private _zoomStopsAnimation;
  36389. private _idleRotationSpeed;
  36390. private _idleRotationWaitTime;
  36391. private _idleRotationSpinupTime;
  36392. /**
  36393. * Sets the flag that indicates if user zooming should stop animation.
  36394. */
  36395. /**
  36396. * Gets the flag that indicates if user zooming should stop animation.
  36397. */
  36398. zoomStopsAnimation: boolean;
  36399. /**
  36400. * Sets the default speed at which the camera rotates around the model.
  36401. */
  36402. /**
  36403. * Gets the default speed at which the camera rotates around the model.
  36404. */
  36405. idleRotationSpeed: number;
  36406. /**
  36407. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36408. */
  36409. /**
  36410. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36411. */
  36412. idleRotationWaitTime: number;
  36413. /**
  36414. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36415. */
  36416. /**
  36417. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36418. */
  36419. idleRotationSpinupTime: number;
  36420. /**
  36421. * Gets a value indicating if the camera is currently rotating because of this behavior
  36422. */
  36423. readonly rotationInProgress: boolean;
  36424. private _onPrePointerObservableObserver;
  36425. private _onAfterCheckInputsObserver;
  36426. private _attachedCamera;
  36427. private _isPointerDown;
  36428. private _lastFrameTime;
  36429. private _lastInteractionTime;
  36430. private _cameraRotationSpeed;
  36431. /**
  36432. * Initializes the behavior.
  36433. */
  36434. init(): void;
  36435. /**
  36436. * Attaches the behavior to its arc rotate camera.
  36437. * @param camera Defines the camera to attach the behavior to
  36438. */
  36439. attach(camera: ArcRotateCamera): void;
  36440. /**
  36441. * Detaches the behavior from its current arc rotate camera.
  36442. */
  36443. detach(): void;
  36444. /**
  36445. * Returns true if user is scrolling.
  36446. * @return true if user is scrolling.
  36447. */
  36448. private _userIsZooming;
  36449. private _lastFrameRadius;
  36450. private _shouldAnimationStopForInteraction;
  36451. /**
  36452. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36453. */
  36454. private _applyUserInteraction;
  36455. private _userIsMoving;
  36456. }
  36457. }
  36458. declare module BABYLON {
  36459. /**
  36460. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36461. */
  36462. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36463. private ui;
  36464. /**
  36465. * The name of the behavior
  36466. */
  36467. name: string;
  36468. /**
  36469. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36470. */
  36471. distanceAwayFromFace: number;
  36472. /**
  36473. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36474. */
  36475. distanceAwayFromBottomOfFace: number;
  36476. private _faceVectors;
  36477. private _target;
  36478. private _scene;
  36479. private _onRenderObserver;
  36480. private _tmpMatrix;
  36481. private _tmpVector;
  36482. /**
  36483. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36484. * @param ui The transform node that should be attched to the mesh
  36485. */
  36486. constructor(ui: TransformNode);
  36487. /**
  36488. * Initializes the behavior
  36489. */
  36490. init(): void;
  36491. private _closestFace;
  36492. private _zeroVector;
  36493. private _lookAtTmpMatrix;
  36494. private _lookAtToRef;
  36495. /**
  36496. * Attaches the AttachToBoxBehavior to the passed in mesh
  36497. * @param target The mesh that the specified node will be attached to
  36498. */
  36499. attach(target: Mesh): void;
  36500. /**
  36501. * Detaches the behavior from the mesh
  36502. */
  36503. detach(): void;
  36504. }
  36505. }
  36506. declare module BABYLON {
  36507. /**
  36508. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36509. */
  36510. export class FadeInOutBehavior implements Behavior<Mesh> {
  36511. /**
  36512. * Time in milliseconds to delay before fading in (Default: 0)
  36513. */
  36514. delay: number;
  36515. /**
  36516. * Time in milliseconds for the mesh to fade in (Default: 300)
  36517. */
  36518. fadeInTime: number;
  36519. private _millisecondsPerFrame;
  36520. private _hovered;
  36521. private _hoverValue;
  36522. private _ownerNode;
  36523. /**
  36524. * Instatiates the FadeInOutBehavior
  36525. */
  36526. constructor();
  36527. /**
  36528. * The name of the behavior
  36529. */
  36530. readonly name: string;
  36531. /**
  36532. * Initializes the behavior
  36533. */
  36534. init(): void;
  36535. /**
  36536. * Attaches the fade behavior on the passed in mesh
  36537. * @param ownerNode The mesh that will be faded in/out once attached
  36538. */
  36539. attach(ownerNode: Mesh): void;
  36540. /**
  36541. * Detaches the behavior from the mesh
  36542. */
  36543. detach(): void;
  36544. /**
  36545. * Triggers the mesh to begin fading in or out
  36546. * @param value if the object should fade in or out (true to fade in)
  36547. */
  36548. fadeIn(value: boolean): void;
  36549. private _update;
  36550. private _setAllVisibility;
  36551. }
  36552. }
  36553. declare module BABYLON {
  36554. /**
  36555. * Class containing a set of static utilities functions for managing Pivots
  36556. * @hidden
  36557. */
  36558. export class PivotTools {
  36559. private static _PivotCached;
  36560. private static _OldPivotPoint;
  36561. private static _PivotTranslation;
  36562. private static _PivotTmpVector;
  36563. /** @hidden */
  36564. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36565. /** @hidden */
  36566. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36567. }
  36568. }
  36569. declare module BABYLON {
  36570. /**
  36571. * Class containing static functions to help procedurally build meshes
  36572. */
  36573. export class PlaneBuilder {
  36574. /**
  36575. * Creates a plane mesh
  36576. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36577. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36578. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36580. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36582. * @param name defines the name of the mesh
  36583. * @param options defines the options used to create the mesh
  36584. * @param scene defines the hosting scene
  36585. * @returns the plane mesh
  36586. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36587. */
  36588. static CreatePlane(name: string, options: {
  36589. size?: number;
  36590. width?: number;
  36591. height?: number;
  36592. sideOrientation?: number;
  36593. frontUVs?: Vector4;
  36594. backUVs?: Vector4;
  36595. updatable?: boolean;
  36596. sourcePlane?: Plane;
  36597. }, scene?: Nullable<Scene>): Mesh;
  36598. }
  36599. }
  36600. declare module BABYLON {
  36601. /**
  36602. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36603. */
  36604. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36605. private static _AnyMouseID;
  36606. /**
  36607. * Abstract mesh the behavior is set on
  36608. */
  36609. attachedNode: AbstractMesh;
  36610. private _dragPlane;
  36611. private _scene;
  36612. private _pointerObserver;
  36613. private _beforeRenderObserver;
  36614. private static _planeScene;
  36615. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36616. /**
  36617. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  36618. */
  36619. maxDragAngle: number;
  36620. /**
  36621. * @hidden
  36622. */
  36623. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36624. /**
  36625. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36626. */
  36627. currentDraggingPointerID: number;
  36628. /**
  36629. * The last position where the pointer hit the drag plane in world space
  36630. */
  36631. lastDragPosition: Vector3;
  36632. /**
  36633. * If the behavior is currently in a dragging state
  36634. */
  36635. dragging: boolean;
  36636. /**
  36637. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  36638. */
  36639. dragDeltaRatio: number;
  36640. /**
  36641. * If the drag plane orientation should be updated during the dragging (Default: true)
  36642. */
  36643. updateDragPlane: boolean;
  36644. private _debugMode;
  36645. private _moving;
  36646. /**
  36647. * Fires each time the attached mesh is dragged with the pointer
  36648. * * delta between last drag position and current drag position in world space
  36649. * * dragDistance along the drag axis
  36650. * * dragPlaneNormal normal of the current drag plane used during the drag
  36651. * * dragPlanePoint in world space where the drag intersects the drag plane
  36652. */
  36653. onDragObservable: Observable<{
  36654. delta: Vector3;
  36655. dragPlanePoint: Vector3;
  36656. dragPlaneNormal: Vector3;
  36657. dragDistance: number;
  36658. pointerId: number;
  36659. }>;
  36660. /**
  36661. * Fires each time a drag begins (eg. mouse down on mesh)
  36662. */
  36663. onDragStartObservable: Observable<{
  36664. dragPlanePoint: Vector3;
  36665. pointerId: number;
  36666. }>;
  36667. /**
  36668. * Fires each time a drag ends (eg. mouse release after drag)
  36669. */
  36670. onDragEndObservable: Observable<{
  36671. dragPlanePoint: Vector3;
  36672. pointerId: number;
  36673. }>;
  36674. /**
  36675. * If the attached mesh should be moved when dragged
  36676. */
  36677. moveAttached: boolean;
  36678. /**
  36679. * If the drag behavior will react to drag events (Default: true)
  36680. */
  36681. enabled: boolean;
  36682. /**
  36683. * If pointer events should start and release the drag (Default: true)
  36684. */
  36685. startAndReleaseDragOnPointerEvents: boolean;
  36686. /**
  36687. * If camera controls should be detached during the drag
  36688. */
  36689. detachCameraControls: boolean;
  36690. /**
  36691. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36692. */
  36693. useObjectOrienationForDragging: boolean;
  36694. private _options;
  36695. /**
  36696. * Creates a pointer drag behavior that can be attached to a mesh
  36697. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  36698. */
  36699. constructor(options?: {
  36700. dragAxis?: Vector3;
  36701. dragPlaneNormal?: Vector3;
  36702. });
  36703. /**
  36704. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36705. */
  36706. validateDrag: (targetPosition: Vector3) => boolean;
  36707. /**
  36708. * The name of the behavior
  36709. */
  36710. readonly name: string;
  36711. /**
  36712. * Initializes the behavior
  36713. */
  36714. init(): void;
  36715. private _tmpVector;
  36716. private _alternatePickedPoint;
  36717. private _worldDragAxis;
  36718. private _targetPosition;
  36719. private _attachedElement;
  36720. /**
  36721. * Attaches the drag behavior the passed in mesh
  36722. * @param ownerNode The mesh that will be dragged around once attached
  36723. */
  36724. attach(ownerNode: AbstractMesh): void;
  36725. /**
  36726. * Force relase the drag action by code.
  36727. */
  36728. releaseDrag(): void;
  36729. private _startDragRay;
  36730. private _lastPointerRay;
  36731. /**
  36732. * Simulates the start of a pointer drag event on the behavior
  36733. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36734. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36735. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36736. */
  36737. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36738. private _startDrag;
  36739. private _dragDelta;
  36740. private _moveDrag;
  36741. private _pickWithRayOnDragPlane;
  36742. private _pointA;
  36743. private _pointB;
  36744. private _pointC;
  36745. private _lineA;
  36746. private _lineB;
  36747. private _localAxis;
  36748. private _lookAt;
  36749. private _updateDragPlanePosition;
  36750. /**
  36751. * Detaches the behavior from the mesh
  36752. */
  36753. detach(): void;
  36754. }
  36755. }
  36756. declare module BABYLON {
  36757. /**
  36758. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36759. */
  36760. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36761. private _dragBehaviorA;
  36762. private _dragBehaviorB;
  36763. private _startDistance;
  36764. private _initialScale;
  36765. private _targetScale;
  36766. private _ownerNode;
  36767. private _sceneRenderObserver;
  36768. /**
  36769. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36770. */
  36771. constructor();
  36772. /**
  36773. * The name of the behavior
  36774. */
  36775. readonly name: string;
  36776. /**
  36777. * Initializes the behavior
  36778. */
  36779. init(): void;
  36780. private _getCurrentDistance;
  36781. /**
  36782. * Attaches the scale behavior the passed in mesh
  36783. * @param ownerNode The mesh that will be scaled around once attached
  36784. */
  36785. attach(ownerNode: Mesh): void;
  36786. /**
  36787. * Detaches the behavior from the mesh
  36788. */
  36789. detach(): void;
  36790. }
  36791. }
  36792. declare module BABYLON {
  36793. /**
  36794. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  36795. */
  36796. export class SixDofDragBehavior implements Behavior<Mesh> {
  36797. private static _virtualScene;
  36798. private _ownerNode;
  36799. private _sceneRenderObserver;
  36800. private _scene;
  36801. private _targetPosition;
  36802. private _virtualOriginMesh;
  36803. private _virtualDragMesh;
  36804. private _pointerObserver;
  36805. private _moving;
  36806. private _startingOrientation;
  36807. /**
  36808. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  36809. */
  36810. private zDragFactor;
  36811. /**
  36812. * If the object should rotate to face the drag origin
  36813. */
  36814. rotateDraggedObject: boolean;
  36815. /**
  36816. * If the behavior is currently in a dragging state
  36817. */
  36818. dragging: boolean;
  36819. /**
  36820. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  36821. */
  36822. dragDeltaRatio: number;
  36823. /**
  36824. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36825. */
  36826. currentDraggingPointerID: number;
  36827. /**
  36828. * If camera controls should be detached during the drag
  36829. */
  36830. detachCameraControls: boolean;
  36831. /**
  36832. * Fires each time a drag starts
  36833. */
  36834. onDragStartObservable: Observable<{}>;
  36835. /**
  36836. * Fires each time a drag ends (eg. mouse release after drag)
  36837. */
  36838. onDragEndObservable: Observable<{}>;
  36839. /**
  36840. * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  36841. */
  36842. constructor();
  36843. /**
  36844. * The name of the behavior
  36845. */
  36846. readonly name: string;
  36847. /**
  36848. * Initializes the behavior
  36849. */
  36850. init(): void;
  36851. /**
  36852. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36853. */
  36854. private readonly _pointerCamera;
  36855. /**
  36856. * Attaches the scale behavior the passed in mesh
  36857. * @param ownerNode The mesh that will be scaled around once attached
  36858. */
  36859. attach(ownerNode: Mesh): void;
  36860. /**
  36861. * Detaches the behavior from the mesh
  36862. */
  36863. detach(): void;
  36864. }
  36865. }
  36866. declare module BABYLON {
  36867. /**
  36868. * Class used to apply inverse kinematics to bones
  36869. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36870. */
  36871. export class BoneIKController {
  36872. private static _tmpVecs;
  36873. private static _tmpQuat;
  36874. private static _tmpMats;
  36875. /**
  36876. * Gets or sets the target mesh
  36877. */
  36878. targetMesh: AbstractMesh;
  36879. /** Gets or sets the mesh used as pole */
  36880. poleTargetMesh: AbstractMesh;
  36881. /**
  36882. * Gets or sets the bone used as pole
  36883. */
  36884. poleTargetBone: Nullable<Bone>;
  36885. /**
  36886. * Gets or sets the target position
  36887. */
  36888. targetPosition: Vector3;
  36889. /**
  36890. * Gets or sets the pole target position
  36891. */
  36892. poleTargetPosition: Vector3;
  36893. /**
  36894. * Gets or sets the pole target local offset
  36895. */
  36896. poleTargetLocalOffset: Vector3;
  36897. /**
  36898. * Gets or sets the pole angle
  36899. */
  36900. poleAngle: number;
  36901. /**
  36902. * Gets or sets the mesh associated with the controller
  36903. */
  36904. mesh: AbstractMesh;
  36905. /**
  36906. * 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)
  36907. */
  36908. slerpAmount: number;
  36909. private _bone1Quat;
  36910. private _bone1Mat;
  36911. private _bone2Ang;
  36912. private _bone1;
  36913. private _bone2;
  36914. private _bone1Length;
  36915. private _bone2Length;
  36916. private _maxAngle;
  36917. private _maxReach;
  36918. private _rightHandedSystem;
  36919. private _bendAxis;
  36920. private _slerping;
  36921. private _adjustRoll;
  36922. /**
  36923. * Gets or sets maximum allowed angle
  36924. */
  36925. maxAngle: number;
  36926. /**
  36927. * Creates a new BoneIKController
  36928. * @param mesh defines the mesh to control
  36929. * @param bone defines the bone to control
  36930. * @param options defines options to set up the controller
  36931. */
  36932. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36933. targetMesh?: AbstractMesh;
  36934. poleTargetMesh?: AbstractMesh;
  36935. poleTargetBone?: Bone;
  36936. poleTargetLocalOffset?: Vector3;
  36937. poleAngle?: number;
  36938. bendAxis?: Vector3;
  36939. maxAngle?: number;
  36940. slerpAmount?: number;
  36941. });
  36942. private _setMaxAngle;
  36943. /**
  36944. * Force the controller to update the bones
  36945. */
  36946. update(): void;
  36947. }
  36948. }
  36949. declare module BABYLON {
  36950. /**
  36951. * Class used to make a bone look toward a point in space
  36952. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36953. */
  36954. export class BoneLookController {
  36955. private static _tmpVecs;
  36956. private static _tmpQuat;
  36957. private static _tmpMats;
  36958. /**
  36959. * The target Vector3 that the bone will look at
  36960. */
  36961. target: Vector3;
  36962. /**
  36963. * The mesh that the bone is attached to
  36964. */
  36965. mesh: AbstractMesh;
  36966. /**
  36967. * The bone that will be looking to the target
  36968. */
  36969. bone: Bone;
  36970. /**
  36971. * The up axis of the coordinate system that is used when the bone is rotated
  36972. */
  36973. upAxis: Vector3;
  36974. /**
  36975. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36976. */
  36977. upAxisSpace: Space;
  36978. /**
  36979. * Used to make an adjustment to the yaw of the bone
  36980. */
  36981. adjustYaw: number;
  36982. /**
  36983. * Used to make an adjustment to the pitch of the bone
  36984. */
  36985. adjustPitch: number;
  36986. /**
  36987. * Used to make an adjustment to the roll of the bone
  36988. */
  36989. adjustRoll: number;
  36990. /**
  36991. * 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)
  36992. */
  36993. slerpAmount: number;
  36994. private _minYaw;
  36995. private _maxYaw;
  36996. private _minPitch;
  36997. private _maxPitch;
  36998. private _minYawSin;
  36999. private _minYawCos;
  37000. private _maxYawSin;
  37001. private _maxYawCos;
  37002. private _midYawConstraint;
  37003. private _minPitchTan;
  37004. private _maxPitchTan;
  37005. private _boneQuat;
  37006. private _slerping;
  37007. private _transformYawPitch;
  37008. private _transformYawPitchInv;
  37009. private _firstFrameSkipped;
  37010. private _yawRange;
  37011. private _fowardAxis;
  37012. /**
  37013. * Gets or sets the minimum yaw angle that the bone can look to
  37014. */
  37015. minYaw: number;
  37016. /**
  37017. * Gets or sets the maximum yaw angle that the bone can look to
  37018. */
  37019. maxYaw: number;
  37020. /**
  37021. * Gets or sets the minimum pitch angle that the bone can look to
  37022. */
  37023. minPitch: number;
  37024. /**
  37025. * Gets or sets the maximum pitch angle that the bone can look to
  37026. */
  37027. maxPitch: number;
  37028. /**
  37029. * Create a BoneLookController
  37030. * @param mesh the mesh that the bone belongs to
  37031. * @param bone the bone that will be looking to the target
  37032. * @param target the target Vector3 to look at
  37033. * @param options optional settings:
  37034. * * maxYaw: the maximum angle the bone will yaw to
  37035. * * minYaw: the minimum angle the bone will yaw to
  37036. * * maxPitch: the maximum angle the bone will pitch to
  37037. * * minPitch: the minimum angle the bone will yaw to
  37038. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37039. * * upAxis: the up axis of the coordinate system
  37040. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37041. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37042. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37043. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37044. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37045. * * adjustRoll: used to make an adjustment to the roll of the bone
  37046. **/
  37047. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37048. maxYaw?: number;
  37049. minYaw?: number;
  37050. maxPitch?: number;
  37051. minPitch?: number;
  37052. slerpAmount?: number;
  37053. upAxis?: Vector3;
  37054. upAxisSpace?: Space;
  37055. yawAxis?: Vector3;
  37056. pitchAxis?: Vector3;
  37057. adjustYaw?: number;
  37058. adjustPitch?: number;
  37059. adjustRoll?: number;
  37060. });
  37061. /**
  37062. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37063. */
  37064. update(): void;
  37065. private _getAngleDiff;
  37066. private _getAngleBetween;
  37067. private _isAngleBetween;
  37068. }
  37069. }
  37070. declare module BABYLON {
  37071. /**
  37072. * Manage the gamepad inputs to control an arc rotate camera.
  37073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37074. */
  37075. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37076. /**
  37077. * Defines the camera the input is attached to.
  37078. */
  37079. camera: ArcRotateCamera;
  37080. /**
  37081. * Defines the gamepad the input is gathering event from.
  37082. */
  37083. gamepad: Nullable<Gamepad>;
  37084. /**
  37085. * Defines the gamepad rotation sensiblity.
  37086. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37087. */
  37088. gamepadRotationSensibility: number;
  37089. /**
  37090. * Defines the gamepad move sensiblity.
  37091. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37092. */
  37093. gamepadMoveSensibility: number;
  37094. private _onGamepadConnectedObserver;
  37095. private _onGamepadDisconnectedObserver;
  37096. /**
  37097. * Attach the input controls to a specific dom element to get the input from.
  37098. * @param element Defines the element the controls should be listened from
  37099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37100. */
  37101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37102. /**
  37103. * Detach the current controls from the specified dom element.
  37104. * @param element Defines the element to stop listening the inputs from
  37105. */
  37106. detachControl(element: Nullable<HTMLElement>): void;
  37107. /**
  37108. * Update the current camera state depending on the inputs that have been used this frame.
  37109. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37110. */
  37111. checkInputs(): void;
  37112. /**
  37113. * Gets the class name of the current intput.
  37114. * @returns the class name
  37115. */
  37116. getClassName(): string;
  37117. /**
  37118. * Get the friendly name associated with the input class.
  37119. * @returns the input friendly name
  37120. */
  37121. getSimpleName(): string;
  37122. }
  37123. }
  37124. declare module BABYLON {
  37125. interface ArcRotateCameraInputsManager {
  37126. /**
  37127. * Add orientation input support to the input manager.
  37128. * @returns the current input manager
  37129. */
  37130. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37131. }
  37132. /**
  37133. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37135. */
  37136. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37137. /**
  37138. * Defines the camera the input is attached to.
  37139. */
  37140. camera: ArcRotateCamera;
  37141. /**
  37142. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37143. */
  37144. alphaCorrection: number;
  37145. /**
  37146. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37147. */
  37148. gammaCorrection: number;
  37149. private _alpha;
  37150. private _gamma;
  37151. private _dirty;
  37152. private _deviceOrientationHandler;
  37153. /**
  37154. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37155. */
  37156. constructor();
  37157. /**
  37158. * Attach the input controls to a specific dom element to get the input from.
  37159. * @param element Defines the element the controls should be listened from
  37160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37161. */
  37162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37163. /** @hidden */
  37164. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37165. /**
  37166. * Update the current camera state depending on the inputs that have been used this frame.
  37167. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37168. */
  37169. checkInputs(): void;
  37170. /**
  37171. * Detach the current controls from the specified dom element.
  37172. * @param element Defines the element to stop listening the inputs from
  37173. */
  37174. detachControl(element: Nullable<HTMLElement>): void;
  37175. /**
  37176. * Gets the class name of the current intput.
  37177. * @returns the class name
  37178. */
  37179. getClassName(): string;
  37180. /**
  37181. * Get the friendly name associated with the input class.
  37182. * @returns the input friendly name
  37183. */
  37184. getSimpleName(): string;
  37185. }
  37186. }
  37187. declare module BABYLON {
  37188. /**
  37189. * Listen to mouse events to control the camera.
  37190. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37191. */
  37192. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37193. /**
  37194. * Defines the camera the input is attached to.
  37195. */
  37196. camera: FlyCamera;
  37197. /**
  37198. * Defines if touch is enabled. (Default is true.)
  37199. */
  37200. touchEnabled: boolean;
  37201. /**
  37202. * Defines the buttons associated with the input to handle camera rotation.
  37203. */
  37204. buttons: number[];
  37205. /**
  37206. * Assign buttons for Yaw control.
  37207. */
  37208. buttonsYaw: number[];
  37209. /**
  37210. * Assign buttons for Pitch control.
  37211. */
  37212. buttonsPitch: number[];
  37213. /**
  37214. * Assign buttons for Roll control.
  37215. */
  37216. buttonsRoll: number[];
  37217. /**
  37218. * Detect if any button is being pressed while mouse is moved.
  37219. * -1 = Mouse locked.
  37220. * 0 = Left button.
  37221. * 1 = Middle Button.
  37222. * 2 = Right Button.
  37223. */
  37224. activeButton: number;
  37225. /**
  37226. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37227. * Higher values reduce its sensitivity.
  37228. */
  37229. angularSensibility: number;
  37230. private _mousemoveCallback;
  37231. private _observer;
  37232. private _rollObserver;
  37233. private previousPosition;
  37234. private noPreventDefault;
  37235. private element;
  37236. /**
  37237. * Listen to mouse events to control the camera.
  37238. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37239. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37240. */
  37241. constructor(touchEnabled?: boolean);
  37242. /**
  37243. * Attach the mouse control to the HTML DOM element.
  37244. * @param element Defines the element that listens to the input events.
  37245. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37246. */
  37247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37248. /**
  37249. * Detach the current controls from the specified dom element.
  37250. * @param element Defines the element to stop listening the inputs from
  37251. */
  37252. detachControl(element: Nullable<HTMLElement>): void;
  37253. /**
  37254. * Gets the class name of the current input.
  37255. * @returns the class name.
  37256. */
  37257. getClassName(): string;
  37258. /**
  37259. * Get the friendly name associated with the input class.
  37260. * @returns the input's friendly name.
  37261. */
  37262. getSimpleName(): string;
  37263. private _pointerInput;
  37264. private _onMouseMove;
  37265. /**
  37266. * Rotate camera by mouse offset.
  37267. */
  37268. private rotateCamera;
  37269. }
  37270. }
  37271. declare module BABYLON {
  37272. /**
  37273. * Default Inputs manager for the FlyCamera.
  37274. * It groups all the default supported inputs for ease of use.
  37275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37276. */
  37277. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37278. /**
  37279. * Instantiates a new FlyCameraInputsManager.
  37280. * @param camera Defines the camera the inputs belong to.
  37281. */
  37282. constructor(camera: FlyCamera);
  37283. /**
  37284. * Add keyboard input support to the input manager.
  37285. * @returns the new FlyCameraKeyboardMoveInput().
  37286. */
  37287. addKeyboard(): FlyCameraInputsManager;
  37288. /**
  37289. * Add mouse input support to the input manager.
  37290. * @param touchEnabled Enable touch screen support.
  37291. * @returns the new FlyCameraMouseInput().
  37292. */
  37293. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37294. }
  37295. }
  37296. declare module BABYLON {
  37297. /**
  37298. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37299. * such as in a 3D Space Shooter or a Flight Simulator.
  37300. */
  37301. export class FlyCamera extends TargetCamera {
  37302. /**
  37303. * Define the collision ellipsoid of the camera.
  37304. * This is helpful for simulating a camera body, like a player's body.
  37305. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37306. */
  37307. ellipsoid: Vector3;
  37308. /**
  37309. * Define an offset for the position of the ellipsoid around the camera.
  37310. * This can be helpful if the camera is attached away from the player's body center,
  37311. * such as at its head.
  37312. */
  37313. ellipsoidOffset: Vector3;
  37314. /**
  37315. * Enable or disable collisions of the camera with the rest of the scene objects.
  37316. */
  37317. checkCollisions: boolean;
  37318. /**
  37319. * Enable or disable gravity on the camera.
  37320. */
  37321. applyGravity: boolean;
  37322. /**
  37323. * Define the current direction the camera is moving to.
  37324. */
  37325. cameraDirection: Vector3;
  37326. /**
  37327. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37328. * This overrides and empties cameraRotation.
  37329. */
  37330. rotationQuaternion: Quaternion;
  37331. /**
  37332. * Track Roll to maintain the wanted Rolling when looking around.
  37333. */
  37334. _trackRoll: number;
  37335. /**
  37336. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37337. */
  37338. rollCorrect: number;
  37339. /**
  37340. * Mimic a banked turn, Rolling the camera when Yawing.
  37341. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37342. */
  37343. bankedTurn: boolean;
  37344. /**
  37345. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37346. */
  37347. bankedTurnLimit: number;
  37348. /**
  37349. * Value of 0 disables the banked Roll.
  37350. * Value of 1 is equal to the Yaw angle in radians.
  37351. */
  37352. bankedTurnMultiplier: number;
  37353. /**
  37354. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37355. */
  37356. inputs: FlyCameraInputsManager;
  37357. /**
  37358. * Gets the input sensibility for mouse input.
  37359. * Higher values reduce sensitivity.
  37360. */
  37361. /**
  37362. * Sets the input sensibility for a mouse input.
  37363. * Higher values reduce sensitivity.
  37364. */
  37365. angularSensibility: number;
  37366. /**
  37367. * Get the keys for camera movement forward.
  37368. */
  37369. /**
  37370. * Set the keys for camera movement forward.
  37371. */
  37372. keysForward: number[];
  37373. /**
  37374. * Get the keys for camera movement backward.
  37375. */
  37376. keysBackward: number[];
  37377. /**
  37378. * Get the keys for camera movement up.
  37379. */
  37380. /**
  37381. * Set the keys for camera movement up.
  37382. */
  37383. keysUp: number[];
  37384. /**
  37385. * Get the keys for camera movement down.
  37386. */
  37387. /**
  37388. * Set the keys for camera movement down.
  37389. */
  37390. keysDown: number[];
  37391. /**
  37392. * Get the keys for camera movement left.
  37393. */
  37394. /**
  37395. * Set the keys for camera movement left.
  37396. */
  37397. keysLeft: number[];
  37398. /**
  37399. * Set the keys for camera movement right.
  37400. */
  37401. /**
  37402. * Set the keys for camera movement right.
  37403. */
  37404. keysRight: number[];
  37405. /**
  37406. * Event raised when the camera collides with a mesh in the scene.
  37407. */
  37408. onCollide: (collidedMesh: AbstractMesh) => void;
  37409. private _collider;
  37410. private _needMoveForGravity;
  37411. private _oldPosition;
  37412. private _diffPosition;
  37413. private _newPosition;
  37414. /** @hidden */
  37415. _localDirection: Vector3;
  37416. /** @hidden */
  37417. _transformedDirection: Vector3;
  37418. /**
  37419. * Instantiates a FlyCamera.
  37420. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37421. * such as in a 3D Space Shooter or a Flight Simulator.
  37422. * @param name Define the name of the camera in the scene.
  37423. * @param position Define the starting position of the camera in the scene.
  37424. * @param scene Define the scene the camera belongs to.
  37425. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37426. */
  37427. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37428. /**
  37429. * Attach a control to the HTML DOM element.
  37430. * @param element Defines the element that listens to the input events.
  37431. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37432. */
  37433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37434. /**
  37435. * Detach a control from the HTML DOM element.
  37436. * The camera will stop reacting to that input.
  37437. * @param element Defines the element that listens to the input events.
  37438. */
  37439. detachControl(element: HTMLElement): void;
  37440. private _collisionMask;
  37441. /**
  37442. * Get the mask that the camera ignores in collision events.
  37443. */
  37444. /**
  37445. * Set the mask that the camera ignores in collision events.
  37446. */
  37447. collisionMask: number;
  37448. /** @hidden */
  37449. _collideWithWorld(displacement: Vector3): void;
  37450. /** @hidden */
  37451. private _onCollisionPositionChange;
  37452. /** @hidden */
  37453. _checkInputs(): void;
  37454. /** @hidden */
  37455. _decideIfNeedsToMove(): boolean;
  37456. /** @hidden */
  37457. _updatePosition(): void;
  37458. /**
  37459. * Restore the Roll to its target value at the rate specified.
  37460. * @param rate - Higher means slower restoring.
  37461. * @hidden
  37462. */
  37463. restoreRoll(rate: number): void;
  37464. /**
  37465. * Destroy the camera and release the current resources held by it.
  37466. */
  37467. dispose(): void;
  37468. /**
  37469. * Get the current object class name.
  37470. * @returns the class name.
  37471. */
  37472. getClassName(): string;
  37473. }
  37474. }
  37475. declare module BABYLON {
  37476. /**
  37477. * Listen to keyboard events to control the camera.
  37478. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37479. */
  37480. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37481. /**
  37482. * Defines the camera the input is attached to.
  37483. */
  37484. camera: FlyCamera;
  37485. /**
  37486. * The list of keyboard keys used to control the forward move of the camera.
  37487. */
  37488. keysForward: number[];
  37489. /**
  37490. * The list of keyboard keys used to control the backward move of the camera.
  37491. */
  37492. keysBackward: number[];
  37493. /**
  37494. * The list of keyboard keys used to control the forward move of the camera.
  37495. */
  37496. keysUp: number[];
  37497. /**
  37498. * The list of keyboard keys used to control the backward move of the camera.
  37499. */
  37500. keysDown: number[];
  37501. /**
  37502. * The list of keyboard keys used to control the right strafe move of the camera.
  37503. */
  37504. keysRight: number[];
  37505. /**
  37506. * The list of keyboard keys used to control the left strafe move of the camera.
  37507. */
  37508. keysLeft: number[];
  37509. private _keys;
  37510. private _onCanvasBlurObserver;
  37511. private _onKeyboardObserver;
  37512. private _engine;
  37513. private _scene;
  37514. /**
  37515. * Attach the input controls to a specific dom element to get the input from.
  37516. * @param element Defines the element the controls should be listened from
  37517. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37518. */
  37519. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37520. /**
  37521. * Detach the current controls from the specified dom element.
  37522. * @param element Defines the element to stop listening the inputs from
  37523. */
  37524. detachControl(element: Nullable<HTMLElement>): void;
  37525. /**
  37526. * Gets the class name of the current intput.
  37527. * @returns the class name
  37528. */
  37529. getClassName(): string;
  37530. /** @hidden */
  37531. _onLostFocus(e: FocusEvent): void;
  37532. /**
  37533. * Get the friendly name associated with the input class.
  37534. * @returns the input friendly name
  37535. */
  37536. getSimpleName(): string;
  37537. /**
  37538. * Update the current camera state depending on the inputs that have been used this frame.
  37539. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37540. */
  37541. checkInputs(): void;
  37542. }
  37543. }
  37544. declare module BABYLON {
  37545. /**
  37546. * Manage the mouse wheel inputs to control a follow camera.
  37547. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37548. */
  37549. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37550. /**
  37551. * Defines the camera the input is attached to.
  37552. */
  37553. camera: FollowCamera;
  37554. /**
  37555. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37556. */
  37557. axisControlRadius: boolean;
  37558. /**
  37559. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37560. */
  37561. axisControlHeight: boolean;
  37562. /**
  37563. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37564. */
  37565. axisControlRotation: boolean;
  37566. /**
  37567. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37568. * relation to mouseWheel events.
  37569. */
  37570. wheelPrecision: number;
  37571. /**
  37572. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37573. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37574. */
  37575. wheelDeltaPercentage: number;
  37576. private _wheel;
  37577. private _observer;
  37578. /**
  37579. * Attach the input controls to a specific dom element to get the input from.
  37580. * @param element Defines the element the controls should be listened from
  37581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37582. */
  37583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37584. /**
  37585. * Detach the current controls from the specified dom element.
  37586. * @param element Defines the element to stop listening the inputs from
  37587. */
  37588. detachControl(element: Nullable<HTMLElement>): void;
  37589. /**
  37590. * Gets the class name of the current intput.
  37591. * @returns the class name
  37592. */
  37593. getClassName(): string;
  37594. /**
  37595. * Get the friendly name associated with the input class.
  37596. * @returns the input friendly name
  37597. */
  37598. getSimpleName(): string;
  37599. }
  37600. }
  37601. declare module BABYLON {
  37602. /**
  37603. * Manage the pointers inputs to control an follow camera.
  37604. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37605. */
  37606. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37607. /**
  37608. * Defines the camera the input is attached to.
  37609. */
  37610. camera: FollowCamera;
  37611. /**
  37612. * Gets the class name of the current input.
  37613. * @returns the class name
  37614. */
  37615. getClassName(): string;
  37616. /**
  37617. * Defines the pointer angular sensibility along the X axis or how fast is
  37618. * the camera rotating.
  37619. * A negative number will reverse the axis direction.
  37620. */
  37621. angularSensibilityX: number;
  37622. /**
  37623. * Defines the pointer angular sensibility along the Y axis or how fast is
  37624. * the camera rotating.
  37625. * A negative number will reverse the axis direction.
  37626. */
  37627. angularSensibilityY: number;
  37628. /**
  37629. * Defines the pointer pinch precision or how fast is the camera zooming.
  37630. * A negative number will reverse the axis direction.
  37631. */
  37632. pinchPrecision: number;
  37633. /**
  37634. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37635. * from 0.
  37636. * It defines the percentage of current camera.radius to use as delta when
  37637. * pinch zoom is used.
  37638. */
  37639. pinchDeltaPercentage: number;
  37640. /**
  37641. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37642. */
  37643. axisXControlRadius: boolean;
  37644. /**
  37645. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37646. */
  37647. axisXControlHeight: boolean;
  37648. /**
  37649. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37650. */
  37651. axisXControlRotation: boolean;
  37652. /**
  37653. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37654. */
  37655. axisYControlRadius: boolean;
  37656. /**
  37657. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37658. */
  37659. axisYControlHeight: boolean;
  37660. /**
  37661. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37662. */
  37663. axisYControlRotation: boolean;
  37664. /**
  37665. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37666. */
  37667. axisPinchControlRadius: boolean;
  37668. /**
  37669. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37670. */
  37671. axisPinchControlHeight: boolean;
  37672. /**
  37673. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37674. */
  37675. axisPinchControlRotation: boolean;
  37676. /**
  37677. * Log error messages if basic misconfiguration has occurred.
  37678. */
  37679. warningEnable: boolean;
  37680. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37681. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37682. private _warningCounter;
  37683. private _warning;
  37684. }
  37685. }
  37686. declare module BABYLON {
  37687. /**
  37688. * Default Inputs manager for the FollowCamera.
  37689. * It groups all the default supported inputs for ease of use.
  37690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37691. */
  37692. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37693. /**
  37694. * Instantiates a new FollowCameraInputsManager.
  37695. * @param camera Defines the camera the inputs belong to
  37696. */
  37697. constructor(camera: FollowCamera);
  37698. /**
  37699. * Add keyboard input support to the input manager.
  37700. * @returns the current input manager
  37701. */
  37702. addKeyboard(): FollowCameraInputsManager;
  37703. /**
  37704. * Add mouse wheel input support to the input manager.
  37705. * @returns the current input manager
  37706. */
  37707. addMouseWheel(): FollowCameraInputsManager;
  37708. /**
  37709. * Add pointers input support to the input manager.
  37710. * @returns the current input manager
  37711. */
  37712. addPointers(): FollowCameraInputsManager;
  37713. /**
  37714. * Add orientation input support to the input manager.
  37715. * @returns the current input manager
  37716. */
  37717. addVRDeviceOrientation(): FollowCameraInputsManager;
  37718. }
  37719. }
  37720. declare module BABYLON {
  37721. /**
  37722. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37723. * an arc rotate version arcFollowCamera are available.
  37724. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37725. */
  37726. export class FollowCamera extends TargetCamera {
  37727. /**
  37728. * Distance the follow camera should follow an object at
  37729. */
  37730. radius: number;
  37731. /**
  37732. * Minimum allowed distance of the camera to the axis of rotation
  37733. * (The camera can not get closer).
  37734. * This can help limiting how the Camera is able to move in the scene.
  37735. */
  37736. lowerRadiusLimit: Nullable<number>;
  37737. /**
  37738. * Maximum allowed distance of the camera to the axis of rotation
  37739. * (The camera can not get further).
  37740. * This can help limiting how the Camera is able to move in the scene.
  37741. */
  37742. upperRadiusLimit: Nullable<number>;
  37743. /**
  37744. * Define a rotation offset between the camera and the object it follows
  37745. */
  37746. rotationOffset: number;
  37747. /**
  37748. * Minimum allowed angle to camera position relative to target object.
  37749. * This can help limiting how the Camera is able to move in the scene.
  37750. */
  37751. lowerRotationOffsetLimit: Nullable<number>;
  37752. /**
  37753. * Maximum allowed angle to camera position relative to target object.
  37754. * This can help limiting how the Camera is able to move in the scene.
  37755. */
  37756. upperRotationOffsetLimit: Nullable<number>;
  37757. /**
  37758. * Define a height offset between the camera and the object it follows.
  37759. * It can help following an object from the top (like a car chaing a plane)
  37760. */
  37761. heightOffset: number;
  37762. /**
  37763. * Minimum allowed height of camera position relative to target object.
  37764. * This can help limiting how the Camera is able to move in the scene.
  37765. */
  37766. lowerHeightOffsetLimit: Nullable<number>;
  37767. /**
  37768. * Maximum allowed height of camera position relative to target object.
  37769. * This can help limiting how the Camera is able to move in the scene.
  37770. */
  37771. upperHeightOffsetLimit: Nullable<number>;
  37772. /**
  37773. * Define how fast the camera can accelerate to follow it s target.
  37774. */
  37775. cameraAcceleration: number;
  37776. /**
  37777. * Define the speed limit of the camera following an object.
  37778. */
  37779. maxCameraSpeed: number;
  37780. /**
  37781. * Define the target of the camera.
  37782. */
  37783. lockedTarget: Nullable<AbstractMesh>;
  37784. /**
  37785. * Defines the input associated with the camera.
  37786. */
  37787. inputs: FollowCameraInputsManager;
  37788. /**
  37789. * Instantiates the follow camera.
  37790. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37791. * @param name Define the name of the camera in the scene
  37792. * @param position Define the position of the camera
  37793. * @param scene Define the scene the camera belong to
  37794. * @param lockedTarget Define the target of the camera
  37795. */
  37796. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37797. private _follow;
  37798. /**
  37799. * Attached controls to the current camera.
  37800. * @param element Defines the element the controls should be listened from
  37801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37802. */
  37803. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37804. /**
  37805. * Detach the current controls from the camera.
  37806. * The camera will stop reacting to inputs.
  37807. * @param element Defines the element to stop listening the inputs from
  37808. */
  37809. detachControl(element: HTMLElement): void;
  37810. /** @hidden */
  37811. _checkInputs(): void;
  37812. private _checkLimits;
  37813. /**
  37814. * Gets the camera class name.
  37815. * @returns the class name
  37816. */
  37817. getClassName(): string;
  37818. }
  37819. /**
  37820. * Arc Rotate version of the follow camera.
  37821. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37822. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37823. */
  37824. export class ArcFollowCamera extends TargetCamera {
  37825. /** The longitudinal angle of the camera */
  37826. alpha: number;
  37827. /** The latitudinal angle of the camera */
  37828. beta: number;
  37829. /** The radius of the camera from its target */
  37830. radius: number;
  37831. /** Define the camera target (the messh it should follow) */
  37832. target: Nullable<AbstractMesh>;
  37833. private _cartesianCoordinates;
  37834. /**
  37835. * Instantiates a new ArcFollowCamera
  37836. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37837. * @param name Define the name of the camera
  37838. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37839. * @param beta Define the rotation angle of the camera around the elevation axis
  37840. * @param radius Define the radius of the camera from its target point
  37841. * @param target Define the target of the camera
  37842. * @param scene Define the scene the camera belongs to
  37843. */
  37844. constructor(name: string,
  37845. /** The longitudinal angle of the camera */
  37846. alpha: number,
  37847. /** The latitudinal angle of the camera */
  37848. beta: number,
  37849. /** The radius of the camera from its target */
  37850. radius: number,
  37851. /** Define the camera target (the messh it should follow) */
  37852. target: Nullable<AbstractMesh>, scene: Scene);
  37853. private _follow;
  37854. /** @hidden */
  37855. _checkInputs(): void;
  37856. /**
  37857. * Returns the class name of the object.
  37858. * It is mostly used internally for serialization purposes.
  37859. */
  37860. getClassName(): string;
  37861. }
  37862. }
  37863. declare module BABYLON {
  37864. /**
  37865. * Manage the keyboard inputs to control the movement of a follow camera.
  37866. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37867. */
  37868. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37869. /**
  37870. * Defines the camera the input is attached to.
  37871. */
  37872. camera: FollowCamera;
  37873. /**
  37874. * Defines the list of key codes associated with the up action (increase heightOffset)
  37875. */
  37876. keysHeightOffsetIncr: number[];
  37877. /**
  37878. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37879. */
  37880. keysHeightOffsetDecr: number[];
  37881. /**
  37882. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37883. */
  37884. keysHeightOffsetModifierAlt: boolean;
  37885. /**
  37886. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37887. */
  37888. keysHeightOffsetModifierCtrl: boolean;
  37889. /**
  37890. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37891. */
  37892. keysHeightOffsetModifierShift: boolean;
  37893. /**
  37894. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37895. */
  37896. keysRotationOffsetIncr: number[];
  37897. /**
  37898. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37899. */
  37900. keysRotationOffsetDecr: number[];
  37901. /**
  37902. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37903. */
  37904. keysRotationOffsetModifierAlt: boolean;
  37905. /**
  37906. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37907. */
  37908. keysRotationOffsetModifierCtrl: boolean;
  37909. /**
  37910. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37911. */
  37912. keysRotationOffsetModifierShift: boolean;
  37913. /**
  37914. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37915. */
  37916. keysRadiusIncr: number[];
  37917. /**
  37918. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37919. */
  37920. keysRadiusDecr: number[];
  37921. /**
  37922. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37923. */
  37924. keysRadiusModifierAlt: boolean;
  37925. /**
  37926. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37927. */
  37928. keysRadiusModifierCtrl: boolean;
  37929. /**
  37930. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37931. */
  37932. keysRadiusModifierShift: boolean;
  37933. /**
  37934. * Defines the rate of change of heightOffset.
  37935. */
  37936. heightSensibility: number;
  37937. /**
  37938. * Defines the rate of change of rotationOffset.
  37939. */
  37940. rotationSensibility: number;
  37941. /**
  37942. * Defines the rate of change of radius.
  37943. */
  37944. radiusSensibility: number;
  37945. private _keys;
  37946. private _ctrlPressed;
  37947. private _altPressed;
  37948. private _shiftPressed;
  37949. private _onCanvasBlurObserver;
  37950. private _onKeyboardObserver;
  37951. private _engine;
  37952. private _scene;
  37953. /**
  37954. * Attach the input controls to a specific dom element to get the input from.
  37955. * @param element Defines the element the controls should be listened from
  37956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37957. */
  37958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37959. /**
  37960. * Detach the current controls from the specified dom element.
  37961. * @param element Defines the element to stop listening the inputs from
  37962. */
  37963. detachControl(element: Nullable<HTMLElement>): void;
  37964. /**
  37965. * Update the current camera state depending on the inputs that have been used this frame.
  37966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37967. */
  37968. checkInputs(): void;
  37969. /**
  37970. * Gets the class name of the current input.
  37971. * @returns the class name
  37972. */
  37973. getClassName(): string;
  37974. /**
  37975. * Get the friendly name associated with the input class.
  37976. * @returns the input friendly name
  37977. */
  37978. getSimpleName(): string;
  37979. /**
  37980. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37981. * allow modification of the heightOffset value.
  37982. */
  37983. private _modifierHeightOffset;
  37984. /**
  37985. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37986. * allow modification of the rotationOffset value.
  37987. */
  37988. private _modifierRotationOffset;
  37989. /**
  37990. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37991. * allow modification of the radius value.
  37992. */
  37993. private _modifierRadius;
  37994. }
  37995. }
  37996. declare module BABYLON {
  37997. interface FreeCameraInputsManager {
  37998. /**
  37999. * @hidden
  38000. */
  38001. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38002. /**
  38003. * Add orientation input support to the input manager.
  38004. * @returns the current input manager
  38005. */
  38006. addDeviceOrientation(): FreeCameraInputsManager;
  38007. }
  38008. /**
  38009. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38010. * Screen rotation is taken into account.
  38011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38012. */
  38013. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38014. private _camera;
  38015. private _screenOrientationAngle;
  38016. private _constantTranform;
  38017. private _screenQuaternion;
  38018. private _alpha;
  38019. private _beta;
  38020. private _gamma;
  38021. /**
  38022. * Can be used to detect if a device orientation sensor is availible on a device
  38023. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38024. * @returns a promise that will resolve on orientation change
  38025. */
  38026. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38027. /**
  38028. * @hidden
  38029. */
  38030. _onDeviceOrientationChangedObservable: Observable<void>;
  38031. /**
  38032. * Instantiates a new input
  38033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38034. */
  38035. constructor();
  38036. /**
  38037. * Define the camera controlled by the input.
  38038. */
  38039. camera: FreeCamera;
  38040. /**
  38041. * Attach the input controls to a specific dom element to get the input from.
  38042. * @param element Defines the element the controls should be listened from
  38043. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38044. */
  38045. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38046. private _orientationChanged;
  38047. private _deviceOrientation;
  38048. /**
  38049. * Detach the current controls from the specified dom element.
  38050. * @param element Defines the element to stop listening the inputs from
  38051. */
  38052. detachControl(element: Nullable<HTMLElement>): void;
  38053. /**
  38054. * Update the current camera state depending on the inputs that have been used this frame.
  38055. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38056. */
  38057. checkInputs(): void;
  38058. /**
  38059. * Gets the class name of the current intput.
  38060. * @returns the class name
  38061. */
  38062. getClassName(): string;
  38063. /**
  38064. * Get the friendly name associated with the input class.
  38065. * @returns the input friendly name
  38066. */
  38067. getSimpleName(): string;
  38068. }
  38069. }
  38070. declare module BABYLON {
  38071. /**
  38072. * Manage the gamepad inputs to control a free camera.
  38073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38074. */
  38075. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38076. /**
  38077. * Define the camera the input is attached to.
  38078. */
  38079. camera: FreeCamera;
  38080. /**
  38081. * Define the Gamepad controlling the input
  38082. */
  38083. gamepad: Nullable<Gamepad>;
  38084. /**
  38085. * Defines the gamepad rotation sensiblity.
  38086. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38087. */
  38088. gamepadAngularSensibility: number;
  38089. /**
  38090. * Defines the gamepad move sensiblity.
  38091. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38092. */
  38093. gamepadMoveSensibility: number;
  38094. private _onGamepadConnectedObserver;
  38095. private _onGamepadDisconnectedObserver;
  38096. private _cameraTransform;
  38097. private _deltaTransform;
  38098. private _vector3;
  38099. private _vector2;
  38100. /**
  38101. * Attach the input controls to a specific dom element to get the input from.
  38102. * @param element Defines the element the controls should be listened from
  38103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38104. */
  38105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38106. /**
  38107. * Detach the current controls from the specified dom element.
  38108. * @param element Defines the element to stop listening the inputs from
  38109. */
  38110. detachControl(element: Nullable<HTMLElement>): void;
  38111. /**
  38112. * Update the current camera state depending on the inputs that have been used this frame.
  38113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38114. */
  38115. checkInputs(): void;
  38116. /**
  38117. * Gets the class name of the current intput.
  38118. * @returns the class name
  38119. */
  38120. getClassName(): string;
  38121. /**
  38122. * Get the friendly name associated with the input class.
  38123. * @returns the input friendly name
  38124. */
  38125. getSimpleName(): string;
  38126. }
  38127. }
  38128. declare module BABYLON {
  38129. /**
  38130. * Defines the potential axis of a Joystick
  38131. */
  38132. export enum JoystickAxis {
  38133. /** X axis */
  38134. X = 0,
  38135. /** Y axis */
  38136. Y = 1,
  38137. /** Z axis */
  38138. Z = 2
  38139. }
  38140. /**
  38141. * Class used to define virtual joystick (used in touch mode)
  38142. */
  38143. export class VirtualJoystick {
  38144. /**
  38145. * Gets or sets a boolean indicating that left and right values must be inverted
  38146. */
  38147. reverseLeftRight: boolean;
  38148. /**
  38149. * Gets or sets a boolean indicating that up and down values must be inverted
  38150. */
  38151. reverseUpDown: boolean;
  38152. /**
  38153. * Gets the offset value for the position (ie. the change of the position value)
  38154. */
  38155. deltaPosition: Vector3;
  38156. /**
  38157. * Gets a boolean indicating if the virtual joystick was pressed
  38158. */
  38159. pressed: boolean;
  38160. /**
  38161. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38162. */
  38163. static Canvas: Nullable<HTMLCanvasElement>;
  38164. private static _globalJoystickIndex;
  38165. private static vjCanvasContext;
  38166. private static vjCanvasWidth;
  38167. private static vjCanvasHeight;
  38168. private static halfWidth;
  38169. private _action;
  38170. private _axisTargetedByLeftAndRight;
  38171. private _axisTargetedByUpAndDown;
  38172. private _joystickSensibility;
  38173. private _inversedSensibility;
  38174. private _joystickPointerID;
  38175. private _joystickColor;
  38176. private _joystickPointerPos;
  38177. private _joystickPreviousPointerPos;
  38178. private _joystickPointerStartPos;
  38179. private _deltaJoystickVector;
  38180. private _leftJoystick;
  38181. private _touches;
  38182. private _onPointerDownHandlerRef;
  38183. private _onPointerMoveHandlerRef;
  38184. private _onPointerUpHandlerRef;
  38185. private _onResize;
  38186. /**
  38187. * Creates a new virtual joystick
  38188. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38189. */
  38190. constructor(leftJoystick?: boolean);
  38191. /**
  38192. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38193. * @param newJoystickSensibility defines the new sensibility
  38194. */
  38195. setJoystickSensibility(newJoystickSensibility: number): void;
  38196. private _onPointerDown;
  38197. private _onPointerMove;
  38198. private _onPointerUp;
  38199. /**
  38200. * Change the color of the virtual joystick
  38201. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38202. */
  38203. setJoystickColor(newColor: string): void;
  38204. /**
  38205. * Defines a callback to call when the joystick is touched
  38206. * @param action defines the callback
  38207. */
  38208. setActionOnTouch(action: () => any): void;
  38209. /**
  38210. * Defines which axis you'd like to control for left & right
  38211. * @param axis defines the axis to use
  38212. */
  38213. setAxisForLeftRight(axis: JoystickAxis): void;
  38214. /**
  38215. * Defines which axis you'd like to control for up & down
  38216. * @param axis defines the axis to use
  38217. */
  38218. setAxisForUpDown(axis: JoystickAxis): void;
  38219. private _drawVirtualJoystick;
  38220. /**
  38221. * Release internal HTML canvas
  38222. */
  38223. releaseCanvas(): void;
  38224. }
  38225. }
  38226. declare module BABYLON {
  38227. interface FreeCameraInputsManager {
  38228. /**
  38229. * Add virtual joystick input support to the input manager.
  38230. * @returns the current input manager
  38231. */
  38232. addVirtualJoystick(): FreeCameraInputsManager;
  38233. }
  38234. /**
  38235. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38236. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38237. */
  38238. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38239. /**
  38240. * Defines the camera the input is attached to.
  38241. */
  38242. camera: FreeCamera;
  38243. private _leftjoystick;
  38244. private _rightjoystick;
  38245. /**
  38246. * Gets the left stick of the virtual joystick.
  38247. * @returns The virtual Joystick
  38248. */
  38249. getLeftJoystick(): VirtualJoystick;
  38250. /**
  38251. * Gets the right stick of the virtual joystick.
  38252. * @returns The virtual Joystick
  38253. */
  38254. getRightJoystick(): VirtualJoystick;
  38255. /**
  38256. * Update the current camera state depending on the inputs that have been used this frame.
  38257. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38258. */
  38259. checkInputs(): void;
  38260. /**
  38261. * Attach the input controls to a specific dom element to get the input from.
  38262. * @param element Defines the element the controls should be listened from
  38263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38264. */
  38265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38266. /**
  38267. * Detach the current controls from the specified dom element.
  38268. * @param element Defines the element to stop listening the inputs from
  38269. */
  38270. detachControl(element: Nullable<HTMLElement>): void;
  38271. /**
  38272. * Gets the class name of the current intput.
  38273. * @returns the class name
  38274. */
  38275. getClassName(): string;
  38276. /**
  38277. * Get the friendly name associated with the input class.
  38278. * @returns the input friendly name
  38279. */
  38280. getSimpleName(): string;
  38281. }
  38282. }
  38283. declare module BABYLON {
  38284. /**
  38285. * This represents a FPS type of camera controlled by touch.
  38286. * This is like a universal camera minus the Gamepad controls.
  38287. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38288. */
  38289. export class TouchCamera extends FreeCamera {
  38290. /**
  38291. * Defines the touch sensibility for rotation.
  38292. * The higher the faster.
  38293. */
  38294. touchAngularSensibility: number;
  38295. /**
  38296. * Defines the touch sensibility for move.
  38297. * The higher the faster.
  38298. */
  38299. touchMoveSensibility: number;
  38300. /**
  38301. * Instantiates a new touch camera.
  38302. * This represents a FPS type of camera controlled by touch.
  38303. * This is like a universal camera minus the Gamepad controls.
  38304. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38305. * @param name Define the name of the camera in the scene
  38306. * @param position Define the start position of the camera in the scene
  38307. * @param scene Define the scene the camera belongs to
  38308. */
  38309. constructor(name: string, position: Vector3, scene: Scene);
  38310. /**
  38311. * Gets the current object class name.
  38312. * @return the class name
  38313. */
  38314. getClassName(): string;
  38315. /** @hidden */
  38316. _setupInputs(): void;
  38317. }
  38318. }
  38319. declare module BABYLON {
  38320. /**
  38321. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38322. * being tilted forward or back and left or right.
  38323. */
  38324. export class DeviceOrientationCamera extends FreeCamera {
  38325. private _initialQuaternion;
  38326. private _quaternionCache;
  38327. private _tmpDragQuaternion;
  38328. private _disablePointerInputWhenUsingDeviceOrientation;
  38329. /**
  38330. * Creates a new device orientation camera
  38331. * @param name The name of the camera
  38332. * @param position The start position camera
  38333. * @param scene The scene the camera belongs to
  38334. */
  38335. constructor(name: string, position: Vector3, scene: Scene);
  38336. /**
  38337. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38338. */
  38339. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38340. private _dragFactor;
  38341. /**
  38342. * Enabled turning on the y axis when the orientation sensor is active
  38343. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38344. */
  38345. enableHorizontalDragging(dragFactor?: number): void;
  38346. /**
  38347. * Gets the current instance class name ("DeviceOrientationCamera").
  38348. * This helps avoiding instanceof at run time.
  38349. * @returns the class name
  38350. */
  38351. getClassName(): string;
  38352. /**
  38353. * @hidden
  38354. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38355. */
  38356. _checkInputs(): void;
  38357. /**
  38358. * Reset the camera to its default orientation on the specified axis only.
  38359. * @param axis The axis to reset
  38360. */
  38361. resetToCurrentRotation(axis?: Axis): void;
  38362. }
  38363. }
  38364. declare module BABYLON {
  38365. /**
  38366. * Defines supported buttons for XBox360 compatible gamepads
  38367. */
  38368. export enum Xbox360Button {
  38369. /** A */
  38370. A = 0,
  38371. /** B */
  38372. B = 1,
  38373. /** X */
  38374. X = 2,
  38375. /** Y */
  38376. Y = 3,
  38377. /** Start */
  38378. Start = 4,
  38379. /** Back */
  38380. Back = 5,
  38381. /** Left button */
  38382. LB = 6,
  38383. /** Right button */
  38384. RB = 7,
  38385. /** Left stick */
  38386. LeftStick = 8,
  38387. /** Right stick */
  38388. RightStick = 9
  38389. }
  38390. /** Defines values for XBox360 DPad */
  38391. export enum Xbox360Dpad {
  38392. /** Up */
  38393. Up = 0,
  38394. /** Down */
  38395. Down = 1,
  38396. /** Left */
  38397. Left = 2,
  38398. /** Right */
  38399. Right = 3
  38400. }
  38401. /**
  38402. * Defines a XBox360 gamepad
  38403. */
  38404. export class Xbox360Pad extends Gamepad {
  38405. private _leftTrigger;
  38406. private _rightTrigger;
  38407. private _onlefttriggerchanged;
  38408. private _onrighttriggerchanged;
  38409. private _onbuttondown;
  38410. private _onbuttonup;
  38411. private _ondpaddown;
  38412. private _ondpadup;
  38413. /** Observable raised when a button is pressed */
  38414. onButtonDownObservable: Observable<Xbox360Button>;
  38415. /** Observable raised when a button is released */
  38416. onButtonUpObservable: Observable<Xbox360Button>;
  38417. /** Observable raised when a pad is pressed */
  38418. onPadDownObservable: Observable<Xbox360Dpad>;
  38419. /** Observable raised when a pad is released */
  38420. onPadUpObservable: Observable<Xbox360Dpad>;
  38421. private _buttonA;
  38422. private _buttonB;
  38423. private _buttonX;
  38424. private _buttonY;
  38425. private _buttonBack;
  38426. private _buttonStart;
  38427. private _buttonLB;
  38428. private _buttonRB;
  38429. private _buttonLeftStick;
  38430. private _buttonRightStick;
  38431. private _dPadUp;
  38432. private _dPadDown;
  38433. private _dPadLeft;
  38434. private _dPadRight;
  38435. private _isXboxOnePad;
  38436. /**
  38437. * Creates a new XBox360 gamepad object
  38438. * @param id defines the id of this gamepad
  38439. * @param index defines its index
  38440. * @param gamepad defines the internal HTML gamepad object
  38441. * @param xboxOne defines if it is a XBox One gamepad
  38442. */
  38443. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38444. /**
  38445. * Defines the callback to call when left trigger is pressed
  38446. * @param callback defines the callback to use
  38447. */
  38448. onlefttriggerchanged(callback: (value: number) => void): void;
  38449. /**
  38450. * Defines the callback to call when right trigger is pressed
  38451. * @param callback defines the callback to use
  38452. */
  38453. onrighttriggerchanged(callback: (value: number) => void): void;
  38454. /**
  38455. * Gets the left trigger value
  38456. */
  38457. /**
  38458. * Sets the left trigger value
  38459. */
  38460. leftTrigger: number;
  38461. /**
  38462. * Gets the right trigger value
  38463. */
  38464. /**
  38465. * Sets the right trigger value
  38466. */
  38467. rightTrigger: number;
  38468. /**
  38469. * Defines the callback to call when a button is pressed
  38470. * @param callback defines the callback to use
  38471. */
  38472. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38473. /**
  38474. * Defines the callback to call when a button is released
  38475. * @param callback defines the callback to use
  38476. */
  38477. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38478. /**
  38479. * Defines the callback to call when a pad is pressed
  38480. * @param callback defines the callback to use
  38481. */
  38482. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38483. /**
  38484. * Defines the callback to call when a pad is released
  38485. * @param callback defines the callback to use
  38486. */
  38487. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38488. private _setButtonValue;
  38489. private _setDPadValue;
  38490. /**
  38491. * Gets the value of the `A` button
  38492. */
  38493. /**
  38494. * Sets the value of the `A` button
  38495. */
  38496. buttonA: number;
  38497. /**
  38498. * Gets the value of the `B` button
  38499. */
  38500. /**
  38501. * Sets the value of the `B` button
  38502. */
  38503. buttonB: number;
  38504. /**
  38505. * Gets the value of the `X` button
  38506. */
  38507. /**
  38508. * Sets the value of the `X` button
  38509. */
  38510. buttonX: number;
  38511. /**
  38512. * Gets the value of the `Y` button
  38513. */
  38514. /**
  38515. * Sets the value of the `Y` button
  38516. */
  38517. buttonY: number;
  38518. /**
  38519. * Gets the value of the `Start` button
  38520. */
  38521. /**
  38522. * Sets the value of the `Start` button
  38523. */
  38524. buttonStart: number;
  38525. /**
  38526. * Gets the value of the `Back` button
  38527. */
  38528. /**
  38529. * Sets the value of the `Back` button
  38530. */
  38531. buttonBack: number;
  38532. /**
  38533. * Gets the value of the `Left` button
  38534. */
  38535. /**
  38536. * Sets the value of the `Left` button
  38537. */
  38538. buttonLB: number;
  38539. /**
  38540. * Gets the value of the `Right` button
  38541. */
  38542. /**
  38543. * Sets the value of the `Right` button
  38544. */
  38545. buttonRB: number;
  38546. /**
  38547. * Gets the value of the Left joystick
  38548. */
  38549. /**
  38550. * Sets the value of the Left joystick
  38551. */
  38552. buttonLeftStick: number;
  38553. /**
  38554. * Gets the value of the Right joystick
  38555. */
  38556. /**
  38557. * Sets the value of the Right joystick
  38558. */
  38559. buttonRightStick: number;
  38560. /**
  38561. * Gets the value of D-pad up
  38562. */
  38563. /**
  38564. * Sets the value of D-pad up
  38565. */
  38566. dPadUp: number;
  38567. /**
  38568. * Gets the value of D-pad down
  38569. */
  38570. /**
  38571. * Sets the value of D-pad down
  38572. */
  38573. dPadDown: number;
  38574. /**
  38575. * Gets the value of D-pad left
  38576. */
  38577. /**
  38578. * Sets the value of D-pad left
  38579. */
  38580. dPadLeft: number;
  38581. /**
  38582. * Gets the value of D-pad right
  38583. */
  38584. /**
  38585. * Sets the value of D-pad right
  38586. */
  38587. dPadRight: number;
  38588. /**
  38589. * Force the gamepad to synchronize with device values
  38590. */
  38591. update(): void;
  38592. /**
  38593. * Disposes the gamepad
  38594. */
  38595. dispose(): void;
  38596. }
  38597. }
  38598. declare module BABYLON {
  38599. /**
  38600. * Defines supported buttons for DualShock compatible gamepads
  38601. */
  38602. export enum DualShockButton {
  38603. /** Cross */
  38604. Cross = 0,
  38605. /** Circle */
  38606. Circle = 1,
  38607. /** Square */
  38608. Square = 2,
  38609. /** Triangle */
  38610. Triangle = 3,
  38611. /** Options */
  38612. Options = 4,
  38613. /** Share */
  38614. Share = 5,
  38615. /** L1 */
  38616. L1 = 6,
  38617. /** R1 */
  38618. R1 = 7,
  38619. /** Left stick */
  38620. LeftStick = 8,
  38621. /** Right stick */
  38622. RightStick = 9
  38623. }
  38624. /** Defines values for DualShock DPad */
  38625. export enum DualShockDpad {
  38626. /** Up */
  38627. Up = 0,
  38628. /** Down */
  38629. Down = 1,
  38630. /** Left */
  38631. Left = 2,
  38632. /** Right */
  38633. Right = 3
  38634. }
  38635. /**
  38636. * Defines a DualShock gamepad
  38637. */
  38638. export class DualShockPad extends Gamepad {
  38639. private _leftTrigger;
  38640. private _rightTrigger;
  38641. private _onlefttriggerchanged;
  38642. private _onrighttriggerchanged;
  38643. private _onbuttondown;
  38644. private _onbuttonup;
  38645. private _ondpaddown;
  38646. private _ondpadup;
  38647. /** Observable raised when a button is pressed */
  38648. onButtonDownObservable: Observable<DualShockButton>;
  38649. /** Observable raised when a button is released */
  38650. onButtonUpObservable: Observable<DualShockButton>;
  38651. /** Observable raised when a pad is pressed */
  38652. onPadDownObservable: Observable<DualShockDpad>;
  38653. /** Observable raised when a pad is released */
  38654. onPadUpObservable: Observable<DualShockDpad>;
  38655. private _buttonCross;
  38656. private _buttonCircle;
  38657. private _buttonSquare;
  38658. private _buttonTriangle;
  38659. private _buttonShare;
  38660. private _buttonOptions;
  38661. private _buttonL1;
  38662. private _buttonR1;
  38663. private _buttonLeftStick;
  38664. private _buttonRightStick;
  38665. private _dPadUp;
  38666. private _dPadDown;
  38667. private _dPadLeft;
  38668. private _dPadRight;
  38669. /**
  38670. * Creates a new DualShock gamepad object
  38671. * @param id defines the id of this gamepad
  38672. * @param index defines its index
  38673. * @param gamepad defines the internal HTML gamepad object
  38674. */
  38675. constructor(id: string, index: number, gamepad: any);
  38676. /**
  38677. * Defines the callback to call when left trigger is pressed
  38678. * @param callback defines the callback to use
  38679. */
  38680. onlefttriggerchanged(callback: (value: number) => void): void;
  38681. /**
  38682. * Defines the callback to call when right trigger is pressed
  38683. * @param callback defines the callback to use
  38684. */
  38685. onrighttriggerchanged(callback: (value: number) => void): void;
  38686. /**
  38687. * Gets the left trigger value
  38688. */
  38689. /**
  38690. * Sets the left trigger value
  38691. */
  38692. leftTrigger: number;
  38693. /**
  38694. * Gets the right trigger value
  38695. */
  38696. /**
  38697. * Sets the right trigger value
  38698. */
  38699. rightTrigger: number;
  38700. /**
  38701. * Defines the callback to call when a button is pressed
  38702. * @param callback defines the callback to use
  38703. */
  38704. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38705. /**
  38706. * Defines the callback to call when a button is released
  38707. * @param callback defines the callback to use
  38708. */
  38709. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38710. /**
  38711. * Defines the callback to call when a pad is pressed
  38712. * @param callback defines the callback to use
  38713. */
  38714. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38715. /**
  38716. * Defines the callback to call when a pad is released
  38717. * @param callback defines the callback to use
  38718. */
  38719. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38720. private _setButtonValue;
  38721. private _setDPadValue;
  38722. /**
  38723. * Gets the value of the `Cross` button
  38724. */
  38725. /**
  38726. * Sets the value of the `Cross` button
  38727. */
  38728. buttonCross: number;
  38729. /**
  38730. * Gets the value of the `Circle` button
  38731. */
  38732. /**
  38733. * Sets the value of the `Circle` button
  38734. */
  38735. buttonCircle: number;
  38736. /**
  38737. * Gets the value of the `Square` button
  38738. */
  38739. /**
  38740. * Sets the value of the `Square` button
  38741. */
  38742. buttonSquare: number;
  38743. /**
  38744. * Gets the value of the `Triangle` button
  38745. */
  38746. /**
  38747. * Sets the value of the `Triangle` button
  38748. */
  38749. buttonTriangle: number;
  38750. /**
  38751. * Gets the value of the `Options` button
  38752. */
  38753. /**
  38754. * Sets the value of the `Options` button
  38755. */
  38756. buttonOptions: number;
  38757. /**
  38758. * Gets the value of the `Share` button
  38759. */
  38760. /**
  38761. * Sets the value of the `Share` button
  38762. */
  38763. buttonShare: number;
  38764. /**
  38765. * Gets the value of the `L1` button
  38766. */
  38767. /**
  38768. * Sets the value of the `L1` button
  38769. */
  38770. buttonL1: number;
  38771. /**
  38772. * Gets the value of the `R1` button
  38773. */
  38774. /**
  38775. * Sets the value of the `R1` button
  38776. */
  38777. buttonR1: number;
  38778. /**
  38779. * Gets the value of the Left joystick
  38780. */
  38781. /**
  38782. * Sets the value of the Left joystick
  38783. */
  38784. buttonLeftStick: number;
  38785. /**
  38786. * Gets the value of the Right joystick
  38787. */
  38788. /**
  38789. * Sets the value of the Right joystick
  38790. */
  38791. buttonRightStick: number;
  38792. /**
  38793. * Gets the value of D-pad up
  38794. */
  38795. /**
  38796. * Sets the value of D-pad up
  38797. */
  38798. dPadUp: number;
  38799. /**
  38800. * Gets the value of D-pad down
  38801. */
  38802. /**
  38803. * Sets the value of D-pad down
  38804. */
  38805. dPadDown: number;
  38806. /**
  38807. * Gets the value of D-pad left
  38808. */
  38809. /**
  38810. * Sets the value of D-pad left
  38811. */
  38812. dPadLeft: number;
  38813. /**
  38814. * Gets the value of D-pad right
  38815. */
  38816. /**
  38817. * Sets the value of D-pad right
  38818. */
  38819. dPadRight: number;
  38820. /**
  38821. * Force the gamepad to synchronize with device values
  38822. */
  38823. update(): void;
  38824. /**
  38825. * Disposes the gamepad
  38826. */
  38827. dispose(): void;
  38828. }
  38829. }
  38830. declare module BABYLON {
  38831. /**
  38832. * Manager for handling gamepads
  38833. */
  38834. export class GamepadManager {
  38835. private _scene?;
  38836. private _babylonGamepads;
  38837. private _oneGamepadConnected;
  38838. /** @hidden */
  38839. _isMonitoring: boolean;
  38840. private _gamepadEventSupported;
  38841. private _gamepadSupport;
  38842. /**
  38843. * observable to be triggered when the gamepad controller has been connected
  38844. */
  38845. onGamepadConnectedObservable: Observable<Gamepad>;
  38846. /**
  38847. * observable to be triggered when the gamepad controller has been disconnected
  38848. */
  38849. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38850. private _onGamepadConnectedEvent;
  38851. private _onGamepadDisconnectedEvent;
  38852. /**
  38853. * Initializes the gamepad manager
  38854. * @param _scene BabylonJS scene
  38855. */
  38856. constructor(_scene?: Scene | undefined);
  38857. /**
  38858. * The gamepads in the game pad manager
  38859. */
  38860. readonly gamepads: Gamepad[];
  38861. /**
  38862. * Get the gamepad controllers based on type
  38863. * @param type The type of gamepad controller
  38864. * @returns Nullable gamepad
  38865. */
  38866. getGamepadByType(type?: number): Nullable<Gamepad>;
  38867. /**
  38868. * Disposes the gamepad manager
  38869. */
  38870. dispose(): void;
  38871. private _addNewGamepad;
  38872. private _startMonitoringGamepads;
  38873. private _stopMonitoringGamepads;
  38874. /** @hidden */
  38875. _checkGamepadsStatus(): void;
  38876. private _updateGamepadObjects;
  38877. }
  38878. }
  38879. declare module BABYLON {
  38880. interface Scene {
  38881. /** @hidden */
  38882. _gamepadManager: Nullable<GamepadManager>;
  38883. /**
  38884. * Gets the gamepad manager associated with the scene
  38885. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38886. */
  38887. gamepadManager: GamepadManager;
  38888. }
  38889. /**
  38890. * Interface representing a free camera inputs manager
  38891. */
  38892. interface FreeCameraInputsManager {
  38893. /**
  38894. * Adds gamepad input support to the FreeCameraInputsManager.
  38895. * @returns the FreeCameraInputsManager
  38896. */
  38897. addGamepad(): FreeCameraInputsManager;
  38898. }
  38899. /**
  38900. * Interface representing an arc rotate camera inputs manager
  38901. */
  38902. interface ArcRotateCameraInputsManager {
  38903. /**
  38904. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38905. * @returns the camera inputs manager
  38906. */
  38907. addGamepad(): ArcRotateCameraInputsManager;
  38908. }
  38909. /**
  38910. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38911. */
  38912. export class GamepadSystemSceneComponent implements ISceneComponent {
  38913. /**
  38914. * The component name helpfull to identify the component in the list of scene components.
  38915. */
  38916. readonly name: string;
  38917. /**
  38918. * The scene the component belongs to.
  38919. */
  38920. scene: Scene;
  38921. /**
  38922. * Creates a new instance of the component for the given scene
  38923. * @param scene Defines the scene to register the component in
  38924. */
  38925. constructor(scene: Scene);
  38926. /**
  38927. * Registers the component in a given scene
  38928. */
  38929. register(): void;
  38930. /**
  38931. * Rebuilds the elements related to this component in case of
  38932. * context lost for instance.
  38933. */
  38934. rebuild(): void;
  38935. /**
  38936. * Disposes the component and the associated ressources
  38937. */
  38938. dispose(): void;
  38939. private _beforeCameraUpdate;
  38940. }
  38941. }
  38942. declare module BABYLON {
  38943. /**
  38944. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  38945. * which still works and will still be found in many Playgrounds.
  38946. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38947. */
  38948. export class UniversalCamera extends TouchCamera {
  38949. /**
  38950. * Defines the gamepad rotation sensiblity.
  38951. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38952. */
  38953. gamepadAngularSensibility: number;
  38954. /**
  38955. * Defines the gamepad move sensiblity.
  38956. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38957. */
  38958. gamepadMoveSensibility: number;
  38959. /**
  38960. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  38961. * which still works and will still be found in many Playgrounds.
  38962. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38963. * @param name Define the name of the camera in the scene
  38964. * @param position Define the start position of the camera in the scene
  38965. * @param scene Define the scene the camera belongs to
  38966. */
  38967. constructor(name: string, position: Vector3, scene: Scene);
  38968. /**
  38969. * Gets the current object class name.
  38970. * @return the class name
  38971. */
  38972. getClassName(): string;
  38973. }
  38974. }
  38975. declare module BABYLON {
  38976. /**
  38977. * This represents a FPS type of camera. This is only here for back compat purpose.
  38978. * Please use the UniversalCamera instead as both are identical.
  38979. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38980. */
  38981. export class GamepadCamera extends UniversalCamera {
  38982. /**
  38983. * Instantiates a new Gamepad Camera
  38984. * This represents a FPS type of camera. This is only here for back compat purpose.
  38985. * Please use the UniversalCamera instead as both are identical.
  38986. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38987. * @param name Define the name of the camera in the scene
  38988. * @param position Define the start position of the camera in the scene
  38989. * @param scene Define the scene the camera belongs to
  38990. */
  38991. constructor(name: string, position: Vector3, scene: Scene);
  38992. /**
  38993. * Gets the current object class name.
  38994. * @return the class name
  38995. */
  38996. getClassName(): string;
  38997. }
  38998. }
  38999. declare module BABYLON {
  39000. /** @hidden */
  39001. export var passPixelShader: {
  39002. name: string;
  39003. shader: string;
  39004. };
  39005. }
  39006. declare module BABYLON {
  39007. /** @hidden */
  39008. export var passCubePixelShader: {
  39009. name: string;
  39010. shader: string;
  39011. };
  39012. }
  39013. declare module BABYLON {
  39014. /**
  39015. * PassPostProcess which produces an output the same as it's input
  39016. */
  39017. export class PassPostProcess extends PostProcess {
  39018. /**
  39019. * Creates the PassPostProcess
  39020. * @param name The name of the effect.
  39021. * @param options The required width/height ratio to downsize to before computing the render pass.
  39022. * @param camera The camera to apply the render pass to.
  39023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39024. * @param engine The engine which the post process will be applied. (default: current engine)
  39025. * @param reusable If the post process can be reused on the same frame. (default: false)
  39026. * @param textureType The type of texture to be used when performing the post processing.
  39027. * @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)
  39028. */
  39029. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39030. }
  39031. /**
  39032. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39033. */
  39034. export class PassCubePostProcess extends PostProcess {
  39035. private _face;
  39036. /**
  39037. * Gets or sets the cube face to display.
  39038. * * 0 is +X
  39039. * * 1 is -X
  39040. * * 2 is +Y
  39041. * * 3 is -Y
  39042. * * 4 is +Z
  39043. * * 5 is -Z
  39044. */
  39045. face: number;
  39046. /**
  39047. * Creates the PassCubePostProcess
  39048. * @param name The name of the effect.
  39049. * @param options The required width/height ratio to downsize to before computing the render pass.
  39050. * @param camera The camera to apply the render pass to.
  39051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39052. * @param engine The engine which the post process will be applied. (default: current engine)
  39053. * @param reusable If the post process can be reused on the same frame. (default: false)
  39054. * @param textureType The type of texture to be used when performing the post processing.
  39055. * @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)
  39056. */
  39057. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39058. }
  39059. }
  39060. declare module BABYLON {
  39061. /** @hidden */
  39062. export var anaglyphPixelShader: {
  39063. name: string;
  39064. shader: string;
  39065. };
  39066. }
  39067. declare module BABYLON {
  39068. /**
  39069. * Postprocess used to generate anaglyphic rendering
  39070. */
  39071. export class AnaglyphPostProcess extends PostProcess {
  39072. private _passedProcess;
  39073. /**
  39074. * Creates a new AnaglyphPostProcess
  39075. * @param name defines postprocess name
  39076. * @param options defines creation options or target ratio scale
  39077. * @param rigCameras defines cameras using this postprocess
  39078. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39079. * @param engine defines hosting engine
  39080. * @param reusable defines if the postprocess will be reused multiple times per frame
  39081. */
  39082. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39083. }
  39084. }
  39085. declare module BABYLON {
  39086. /**
  39087. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39088. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39089. */
  39090. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39091. /**
  39092. * Creates a new AnaglyphArcRotateCamera
  39093. * @param name defines camera name
  39094. * @param alpha defines alpha angle (in radians)
  39095. * @param beta defines beta angle (in radians)
  39096. * @param radius defines radius
  39097. * @param target defines camera target
  39098. * @param interaxialDistance defines distance between each color axis
  39099. * @param scene defines the hosting scene
  39100. */
  39101. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39102. /**
  39103. * Gets camera class name
  39104. * @returns AnaglyphArcRotateCamera
  39105. */
  39106. getClassName(): string;
  39107. }
  39108. }
  39109. declare module BABYLON {
  39110. /**
  39111. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39112. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39113. */
  39114. export class AnaglyphFreeCamera extends FreeCamera {
  39115. /**
  39116. * Creates a new AnaglyphFreeCamera
  39117. * @param name defines camera name
  39118. * @param position defines initial position
  39119. * @param interaxialDistance defines distance between each color axis
  39120. * @param scene defines the hosting scene
  39121. */
  39122. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39123. /**
  39124. * Gets camera class name
  39125. * @returns AnaglyphFreeCamera
  39126. */
  39127. getClassName(): string;
  39128. }
  39129. }
  39130. declare module BABYLON {
  39131. /**
  39132. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39133. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39134. */
  39135. export class AnaglyphGamepadCamera extends GamepadCamera {
  39136. /**
  39137. * Creates a new AnaglyphGamepadCamera
  39138. * @param name defines camera name
  39139. * @param position defines initial position
  39140. * @param interaxialDistance defines distance between each color axis
  39141. * @param scene defines the hosting scene
  39142. */
  39143. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39144. /**
  39145. * Gets camera class name
  39146. * @returns AnaglyphGamepadCamera
  39147. */
  39148. getClassName(): string;
  39149. }
  39150. }
  39151. declare module BABYLON {
  39152. /**
  39153. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39154. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39155. */
  39156. export class AnaglyphUniversalCamera extends UniversalCamera {
  39157. /**
  39158. * Creates a new AnaglyphUniversalCamera
  39159. * @param name defines camera name
  39160. * @param position defines initial position
  39161. * @param interaxialDistance defines distance between each color axis
  39162. * @param scene defines the hosting scene
  39163. */
  39164. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39165. /**
  39166. * Gets camera class name
  39167. * @returns AnaglyphUniversalCamera
  39168. */
  39169. getClassName(): string;
  39170. }
  39171. }
  39172. declare module BABYLON {
  39173. /** @hidden */
  39174. export var stereoscopicInterlacePixelShader: {
  39175. name: string;
  39176. shader: string;
  39177. };
  39178. }
  39179. declare module BABYLON {
  39180. /**
  39181. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39182. */
  39183. export class StereoscopicInterlacePostProcess extends PostProcess {
  39184. private _stepSize;
  39185. private _passedProcess;
  39186. /**
  39187. * Initializes a StereoscopicInterlacePostProcess
  39188. * @param name The name of the effect.
  39189. * @param rigCameras The rig cameras to be appled to the post process
  39190. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39192. * @param engine The engine which the post process will be applied. (default: current engine)
  39193. * @param reusable If the post process can be reused on the same frame. (default: false)
  39194. */
  39195. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39196. }
  39197. }
  39198. declare module BABYLON {
  39199. /**
  39200. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39201. * @see http://doc.babylonjs.com/features/cameras
  39202. */
  39203. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39204. /**
  39205. * Creates a new StereoscopicArcRotateCamera
  39206. * @param name defines camera name
  39207. * @param alpha defines alpha angle (in radians)
  39208. * @param beta defines beta angle (in radians)
  39209. * @param radius defines radius
  39210. * @param target defines camera target
  39211. * @param interaxialDistance defines distance between each color axis
  39212. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39213. * @param scene defines the hosting scene
  39214. */
  39215. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39216. /**
  39217. * Gets camera class name
  39218. * @returns StereoscopicArcRotateCamera
  39219. */
  39220. getClassName(): string;
  39221. }
  39222. }
  39223. declare module BABYLON {
  39224. /**
  39225. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39226. * @see http://doc.babylonjs.com/features/cameras
  39227. */
  39228. export class StereoscopicFreeCamera extends FreeCamera {
  39229. /**
  39230. * Creates a new StereoscopicFreeCamera
  39231. * @param name defines camera name
  39232. * @param position defines initial position
  39233. * @param interaxialDistance defines distance between each color axis
  39234. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39235. * @param scene defines the hosting scene
  39236. */
  39237. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39238. /**
  39239. * Gets camera class name
  39240. * @returns StereoscopicFreeCamera
  39241. */
  39242. getClassName(): string;
  39243. }
  39244. }
  39245. declare module BABYLON {
  39246. /**
  39247. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39248. * @see http://doc.babylonjs.com/features/cameras
  39249. */
  39250. export class StereoscopicGamepadCamera extends GamepadCamera {
  39251. /**
  39252. * Creates a new StereoscopicGamepadCamera
  39253. * @param name defines camera name
  39254. * @param position defines initial position
  39255. * @param interaxialDistance defines distance between each color axis
  39256. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39257. * @param scene defines the hosting scene
  39258. */
  39259. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39260. /**
  39261. * Gets camera class name
  39262. * @returns StereoscopicGamepadCamera
  39263. */
  39264. getClassName(): string;
  39265. }
  39266. }
  39267. declare module BABYLON {
  39268. /**
  39269. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39270. * @see http://doc.babylonjs.com/features/cameras
  39271. */
  39272. export class StereoscopicUniversalCamera extends UniversalCamera {
  39273. /**
  39274. * Creates a new StereoscopicUniversalCamera
  39275. * @param name defines camera name
  39276. * @param position defines initial position
  39277. * @param interaxialDistance defines distance between each color axis
  39278. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39279. * @param scene defines the hosting scene
  39280. */
  39281. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39282. /**
  39283. * Gets camera class name
  39284. * @returns StereoscopicUniversalCamera
  39285. */
  39286. getClassName(): string;
  39287. }
  39288. }
  39289. declare module BABYLON {
  39290. /**
  39291. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39292. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39293. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39294. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39295. */
  39296. export class VirtualJoysticksCamera extends FreeCamera {
  39297. /**
  39298. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39299. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39300. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39301. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39302. * @param name Define the name of the camera in the scene
  39303. * @param position Define the start position of the camera in the scene
  39304. * @param scene Define the scene the camera belongs to
  39305. */
  39306. constructor(name: string, position: Vector3, scene: Scene);
  39307. /**
  39308. * Gets the current object class name.
  39309. * @return the class name
  39310. */
  39311. getClassName(): string;
  39312. }
  39313. }
  39314. declare module BABYLON {
  39315. /**
  39316. * This represents all the required metrics to create a VR camera.
  39317. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39318. */
  39319. export class VRCameraMetrics {
  39320. /**
  39321. * Define the horizontal resolution off the screen.
  39322. */
  39323. hResolution: number;
  39324. /**
  39325. * Define the vertical resolution off the screen.
  39326. */
  39327. vResolution: number;
  39328. /**
  39329. * Define the horizontal screen size.
  39330. */
  39331. hScreenSize: number;
  39332. /**
  39333. * Define the vertical screen size.
  39334. */
  39335. vScreenSize: number;
  39336. /**
  39337. * Define the vertical screen center position.
  39338. */
  39339. vScreenCenter: number;
  39340. /**
  39341. * Define the distance of the eyes to the screen.
  39342. */
  39343. eyeToScreenDistance: number;
  39344. /**
  39345. * Define the distance between both lenses
  39346. */
  39347. lensSeparationDistance: number;
  39348. /**
  39349. * Define the distance between both viewer's eyes.
  39350. */
  39351. interpupillaryDistance: number;
  39352. /**
  39353. * Define the distortion factor of the VR postprocess.
  39354. * Please, touch with care.
  39355. */
  39356. distortionK: number[];
  39357. /**
  39358. * Define the chromatic aberration correction factors for the VR post process.
  39359. */
  39360. chromaAbCorrection: number[];
  39361. /**
  39362. * Define the scale factor of the post process.
  39363. * The smaller the better but the slower.
  39364. */
  39365. postProcessScaleFactor: number;
  39366. /**
  39367. * Define an offset for the lens center.
  39368. */
  39369. lensCenterOffset: number;
  39370. /**
  39371. * Define if the current vr camera should compensate the distortion of the lense or not.
  39372. */
  39373. compensateDistortion: boolean;
  39374. /**
  39375. * Defines if multiview should be enabled when rendering (Default: false)
  39376. */
  39377. multiviewEnabled: boolean;
  39378. /**
  39379. * Gets the rendering aspect ratio based on the provided resolutions.
  39380. */
  39381. readonly aspectRatio: number;
  39382. /**
  39383. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39384. */
  39385. readonly aspectRatioFov: number;
  39386. /**
  39387. * @hidden
  39388. */
  39389. readonly leftHMatrix: Matrix;
  39390. /**
  39391. * @hidden
  39392. */
  39393. readonly rightHMatrix: Matrix;
  39394. /**
  39395. * @hidden
  39396. */
  39397. readonly leftPreViewMatrix: Matrix;
  39398. /**
  39399. * @hidden
  39400. */
  39401. readonly rightPreViewMatrix: Matrix;
  39402. /**
  39403. * Get the default VRMetrics based on the most generic setup.
  39404. * @returns the default vr metrics
  39405. */
  39406. static GetDefault(): VRCameraMetrics;
  39407. }
  39408. }
  39409. declare module BABYLON {
  39410. /** @hidden */
  39411. export var vrDistortionCorrectionPixelShader: {
  39412. name: string;
  39413. shader: string;
  39414. };
  39415. }
  39416. declare module BABYLON {
  39417. /**
  39418. * VRDistortionCorrectionPostProcess used for mobile VR
  39419. */
  39420. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39421. private _isRightEye;
  39422. private _distortionFactors;
  39423. private _postProcessScaleFactor;
  39424. private _lensCenterOffset;
  39425. private _scaleIn;
  39426. private _scaleFactor;
  39427. private _lensCenter;
  39428. /**
  39429. * Initializes the VRDistortionCorrectionPostProcess
  39430. * @param name The name of the effect.
  39431. * @param camera The camera to apply the render pass to.
  39432. * @param isRightEye If this is for the right eye distortion
  39433. * @param vrMetrics All the required metrics for the VR camera
  39434. */
  39435. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39436. }
  39437. }
  39438. declare module BABYLON {
  39439. /**
  39440. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39441. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39442. */
  39443. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39444. /**
  39445. * Creates a new VRDeviceOrientationArcRotateCamera
  39446. * @param name defines camera name
  39447. * @param alpha defines the camera rotation along the logitudinal axis
  39448. * @param beta defines the camera rotation along the latitudinal axis
  39449. * @param radius defines the camera distance from its target
  39450. * @param target defines the camera target
  39451. * @param scene defines the scene the camera belongs to
  39452. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39453. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39454. */
  39455. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39456. /**
  39457. * Gets camera class name
  39458. * @returns VRDeviceOrientationArcRotateCamera
  39459. */
  39460. getClassName(): string;
  39461. }
  39462. }
  39463. declare module BABYLON {
  39464. /**
  39465. * Camera used to simulate VR rendering (based on FreeCamera)
  39466. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39467. */
  39468. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39469. /**
  39470. * Creates a new VRDeviceOrientationFreeCamera
  39471. * @param name defines camera name
  39472. * @param position defines the start position of the camera
  39473. * @param scene defines the scene the camera belongs to
  39474. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39475. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39476. */
  39477. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39478. /**
  39479. * Gets camera class name
  39480. * @returns VRDeviceOrientationFreeCamera
  39481. */
  39482. getClassName(): string;
  39483. }
  39484. }
  39485. declare module BABYLON {
  39486. /**
  39487. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39488. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39489. */
  39490. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39491. /**
  39492. * Creates a new VRDeviceOrientationGamepadCamera
  39493. * @param name defines camera name
  39494. * @param position defines the start position of the camera
  39495. * @param scene defines the scene the camera belongs to
  39496. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39497. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39498. */
  39499. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39500. /**
  39501. * Gets camera class name
  39502. * @returns VRDeviceOrientationGamepadCamera
  39503. */
  39504. getClassName(): string;
  39505. }
  39506. }
  39507. declare module BABYLON {
  39508. /**
  39509. * Base class of materials working in push mode in babylon JS
  39510. * @hidden
  39511. */
  39512. export class PushMaterial extends Material {
  39513. protected _activeEffect: Effect;
  39514. protected _normalMatrix: Matrix;
  39515. /**
  39516. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39517. * This means that the material can keep using a previous shader while a new one is being compiled.
  39518. * This is mostly used when shader parallel compilation is supported (true by default)
  39519. */
  39520. allowShaderHotSwapping: boolean;
  39521. constructor(name: string, scene: Scene);
  39522. getEffect(): Effect;
  39523. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39524. /**
  39525. * Binds the given world matrix to the active effect
  39526. *
  39527. * @param world the matrix to bind
  39528. */
  39529. bindOnlyWorldMatrix(world: Matrix): void;
  39530. /**
  39531. * Binds the given normal matrix to the active effect
  39532. *
  39533. * @param normalMatrix the matrix to bind
  39534. */
  39535. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39536. bind(world: Matrix, mesh?: Mesh): void;
  39537. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39538. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39539. }
  39540. }
  39541. declare module BABYLON {
  39542. /**
  39543. * This groups all the flags used to control the materials channel.
  39544. */
  39545. export class MaterialFlags {
  39546. private static _DiffuseTextureEnabled;
  39547. /**
  39548. * Are diffuse textures enabled in the application.
  39549. */
  39550. static DiffuseTextureEnabled: boolean;
  39551. private static _AmbientTextureEnabled;
  39552. /**
  39553. * Are ambient textures enabled in the application.
  39554. */
  39555. static AmbientTextureEnabled: boolean;
  39556. private static _OpacityTextureEnabled;
  39557. /**
  39558. * Are opacity textures enabled in the application.
  39559. */
  39560. static OpacityTextureEnabled: boolean;
  39561. private static _ReflectionTextureEnabled;
  39562. /**
  39563. * Are reflection textures enabled in the application.
  39564. */
  39565. static ReflectionTextureEnabled: boolean;
  39566. private static _EmissiveTextureEnabled;
  39567. /**
  39568. * Are emissive textures enabled in the application.
  39569. */
  39570. static EmissiveTextureEnabled: boolean;
  39571. private static _SpecularTextureEnabled;
  39572. /**
  39573. * Are specular textures enabled in the application.
  39574. */
  39575. static SpecularTextureEnabled: boolean;
  39576. private static _BumpTextureEnabled;
  39577. /**
  39578. * Are bump textures enabled in the application.
  39579. */
  39580. static BumpTextureEnabled: boolean;
  39581. private static _LightmapTextureEnabled;
  39582. /**
  39583. * Are lightmap textures enabled in the application.
  39584. */
  39585. static LightmapTextureEnabled: boolean;
  39586. private static _RefractionTextureEnabled;
  39587. /**
  39588. * Are refraction textures enabled in the application.
  39589. */
  39590. static RefractionTextureEnabled: boolean;
  39591. private static _ColorGradingTextureEnabled;
  39592. /**
  39593. * Are color grading textures enabled in the application.
  39594. */
  39595. static ColorGradingTextureEnabled: boolean;
  39596. private static _FresnelEnabled;
  39597. /**
  39598. * Are fresnels enabled in the application.
  39599. */
  39600. static FresnelEnabled: boolean;
  39601. private static _ClearCoatTextureEnabled;
  39602. /**
  39603. * Are clear coat textures enabled in the application.
  39604. */
  39605. static ClearCoatTextureEnabled: boolean;
  39606. private static _ClearCoatBumpTextureEnabled;
  39607. /**
  39608. * Are clear coat bump textures enabled in the application.
  39609. */
  39610. static ClearCoatBumpTextureEnabled: boolean;
  39611. private static _ClearCoatTintTextureEnabled;
  39612. /**
  39613. * Are clear coat tint textures enabled in the application.
  39614. */
  39615. static ClearCoatTintTextureEnabled: boolean;
  39616. private static _SheenTextureEnabled;
  39617. /**
  39618. * Are sheen textures enabled in the application.
  39619. */
  39620. static SheenTextureEnabled: boolean;
  39621. private static _AnisotropicTextureEnabled;
  39622. /**
  39623. * Are anisotropic textures enabled in the application.
  39624. */
  39625. static AnisotropicTextureEnabled: boolean;
  39626. private static _ThicknessTextureEnabled;
  39627. /**
  39628. * Are thickness textures enabled in the application.
  39629. */
  39630. static ThicknessTextureEnabled: boolean;
  39631. }
  39632. }
  39633. declare module BABYLON {
  39634. /** @hidden */
  39635. export var defaultFragmentDeclaration: {
  39636. name: string;
  39637. shader: string;
  39638. };
  39639. }
  39640. declare module BABYLON {
  39641. /** @hidden */
  39642. export var defaultUboDeclaration: {
  39643. name: string;
  39644. shader: string;
  39645. };
  39646. }
  39647. declare module BABYLON {
  39648. /** @hidden */
  39649. export var lightFragmentDeclaration: {
  39650. name: string;
  39651. shader: string;
  39652. };
  39653. }
  39654. declare module BABYLON {
  39655. /** @hidden */
  39656. export var lightUboDeclaration: {
  39657. name: string;
  39658. shader: string;
  39659. };
  39660. }
  39661. declare module BABYLON {
  39662. /** @hidden */
  39663. export var lightsFragmentFunctions: {
  39664. name: string;
  39665. shader: string;
  39666. };
  39667. }
  39668. declare module BABYLON {
  39669. /** @hidden */
  39670. export var shadowsFragmentFunctions: {
  39671. name: string;
  39672. shader: string;
  39673. };
  39674. }
  39675. declare module BABYLON {
  39676. /** @hidden */
  39677. export var fresnelFunction: {
  39678. name: string;
  39679. shader: string;
  39680. };
  39681. }
  39682. declare module BABYLON {
  39683. /** @hidden */
  39684. export var reflectionFunction: {
  39685. name: string;
  39686. shader: string;
  39687. };
  39688. }
  39689. declare module BABYLON {
  39690. /** @hidden */
  39691. export var bumpFragmentFunctions: {
  39692. name: string;
  39693. shader: string;
  39694. };
  39695. }
  39696. declare module BABYLON {
  39697. /** @hidden */
  39698. export var logDepthDeclaration: {
  39699. name: string;
  39700. shader: string;
  39701. };
  39702. }
  39703. declare module BABYLON {
  39704. /** @hidden */
  39705. export var bumpFragment: {
  39706. name: string;
  39707. shader: string;
  39708. };
  39709. }
  39710. declare module BABYLON {
  39711. /** @hidden */
  39712. export var depthPrePass: {
  39713. name: string;
  39714. shader: string;
  39715. };
  39716. }
  39717. declare module BABYLON {
  39718. /** @hidden */
  39719. export var lightFragment: {
  39720. name: string;
  39721. shader: string;
  39722. };
  39723. }
  39724. declare module BABYLON {
  39725. /** @hidden */
  39726. export var logDepthFragment: {
  39727. name: string;
  39728. shader: string;
  39729. };
  39730. }
  39731. declare module BABYLON {
  39732. /** @hidden */
  39733. export var defaultPixelShader: {
  39734. name: string;
  39735. shader: string;
  39736. };
  39737. }
  39738. declare module BABYLON {
  39739. /** @hidden */
  39740. export var defaultVertexDeclaration: {
  39741. name: string;
  39742. shader: string;
  39743. };
  39744. }
  39745. declare module BABYLON {
  39746. /** @hidden */
  39747. export var bumpVertexDeclaration: {
  39748. name: string;
  39749. shader: string;
  39750. };
  39751. }
  39752. declare module BABYLON {
  39753. /** @hidden */
  39754. export var bumpVertex: {
  39755. name: string;
  39756. shader: string;
  39757. };
  39758. }
  39759. declare module BABYLON {
  39760. /** @hidden */
  39761. export var fogVertex: {
  39762. name: string;
  39763. shader: string;
  39764. };
  39765. }
  39766. declare module BABYLON {
  39767. /** @hidden */
  39768. export var shadowsVertex: {
  39769. name: string;
  39770. shader: string;
  39771. };
  39772. }
  39773. declare module BABYLON {
  39774. /** @hidden */
  39775. export var pointCloudVertex: {
  39776. name: string;
  39777. shader: string;
  39778. };
  39779. }
  39780. declare module BABYLON {
  39781. /** @hidden */
  39782. export var logDepthVertex: {
  39783. name: string;
  39784. shader: string;
  39785. };
  39786. }
  39787. declare module BABYLON {
  39788. /** @hidden */
  39789. export var defaultVertexShader: {
  39790. name: string;
  39791. shader: string;
  39792. };
  39793. }
  39794. declare module BABYLON {
  39795. /** @hidden */
  39796. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39797. MAINUV1: boolean;
  39798. MAINUV2: boolean;
  39799. DIFFUSE: boolean;
  39800. DIFFUSEDIRECTUV: number;
  39801. AMBIENT: boolean;
  39802. AMBIENTDIRECTUV: number;
  39803. OPACITY: boolean;
  39804. OPACITYDIRECTUV: number;
  39805. OPACITYRGB: boolean;
  39806. REFLECTION: boolean;
  39807. EMISSIVE: boolean;
  39808. EMISSIVEDIRECTUV: number;
  39809. SPECULAR: boolean;
  39810. SPECULARDIRECTUV: number;
  39811. BUMP: boolean;
  39812. BUMPDIRECTUV: number;
  39813. PARALLAX: boolean;
  39814. PARALLAXOCCLUSION: boolean;
  39815. SPECULAROVERALPHA: boolean;
  39816. CLIPPLANE: boolean;
  39817. CLIPPLANE2: boolean;
  39818. CLIPPLANE3: boolean;
  39819. CLIPPLANE4: boolean;
  39820. ALPHATEST: boolean;
  39821. DEPTHPREPASS: boolean;
  39822. ALPHAFROMDIFFUSE: boolean;
  39823. POINTSIZE: boolean;
  39824. FOG: boolean;
  39825. SPECULARTERM: boolean;
  39826. DIFFUSEFRESNEL: boolean;
  39827. OPACITYFRESNEL: boolean;
  39828. REFLECTIONFRESNEL: boolean;
  39829. REFRACTIONFRESNEL: boolean;
  39830. EMISSIVEFRESNEL: boolean;
  39831. FRESNEL: boolean;
  39832. NORMAL: boolean;
  39833. UV1: boolean;
  39834. UV2: boolean;
  39835. VERTEXCOLOR: boolean;
  39836. VERTEXALPHA: boolean;
  39837. NUM_BONE_INFLUENCERS: number;
  39838. BonesPerMesh: number;
  39839. BONETEXTURE: boolean;
  39840. INSTANCES: boolean;
  39841. GLOSSINESS: boolean;
  39842. ROUGHNESS: boolean;
  39843. EMISSIVEASILLUMINATION: boolean;
  39844. LINKEMISSIVEWITHDIFFUSE: boolean;
  39845. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39846. LIGHTMAP: boolean;
  39847. LIGHTMAPDIRECTUV: number;
  39848. OBJECTSPACE_NORMALMAP: boolean;
  39849. USELIGHTMAPASSHADOWMAP: boolean;
  39850. REFLECTIONMAP_3D: boolean;
  39851. REFLECTIONMAP_SPHERICAL: boolean;
  39852. REFLECTIONMAP_PLANAR: boolean;
  39853. REFLECTIONMAP_CUBIC: boolean;
  39854. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39855. REFLECTIONMAP_PROJECTION: boolean;
  39856. REFLECTIONMAP_SKYBOX: boolean;
  39857. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39858. REFLECTIONMAP_EXPLICIT: boolean;
  39859. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39860. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39861. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39862. INVERTCUBICMAP: boolean;
  39863. LOGARITHMICDEPTH: boolean;
  39864. REFRACTION: boolean;
  39865. REFRACTIONMAP_3D: boolean;
  39866. REFLECTIONOVERALPHA: boolean;
  39867. TWOSIDEDLIGHTING: boolean;
  39868. SHADOWFLOAT: boolean;
  39869. MORPHTARGETS: boolean;
  39870. MORPHTARGETS_NORMAL: boolean;
  39871. MORPHTARGETS_TANGENT: boolean;
  39872. MORPHTARGETS_UV: boolean;
  39873. NUM_MORPH_INFLUENCERS: number;
  39874. NONUNIFORMSCALING: boolean;
  39875. PREMULTIPLYALPHA: boolean;
  39876. IMAGEPROCESSING: boolean;
  39877. VIGNETTE: boolean;
  39878. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39879. VIGNETTEBLENDMODEOPAQUE: boolean;
  39880. TONEMAPPING: boolean;
  39881. TONEMAPPING_ACES: boolean;
  39882. CONTRAST: boolean;
  39883. COLORCURVES: boolean;
  39884. COLORGRADING: boolean;
  39885. COLORGRADING3D: boolean;
  39886. SAMPLER3DGREENDEPTH: boolean;
  39887. SAMPLER3DBGRMAP: boolean;
  39888. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39889. MULTIVIEW: boolean;
  39890. /**
  39891. * If the reflection texture on this material is in linear color space
  39892. * @hidden
  39893. */
  39894. IS_REFLECTION_LINEAR: boolean;
  39895. /**
  39896. * If the refraction texture on this material is in linear color space
  39897. * @hidden
  39898. */
  39899. IS_REFRACTION_LINEAR: boolean;
  39900. EXPOSURE: boolean;
  39901. constructor();
  39902. setReflectionMode(modeToEnable: string): void;
  39903. }
  39904. /**
  39905. * This is the default material used in Babylon. It is the best trade off between quality
  39906. * and performances.
  39907. * @see http://doc.babylonjs.com/babylon101/materials
  39908. */
  39909. export class StandardMaterial extends PushMaterial {
  39910. private _diffuseTexture;
  39911. /**
  39912. * The basic texture of the material as viewed under a light.
  39913. */
  39914. diffuseTexture: Nullable<BaseTexture>;
  39915. private _ambientTexture;
  39916. /**
  39917. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39918. */
  39919. ambientTexture: Nullable<BaseTexture>;
  39920. private _opacityTexture;
  39921. /**
  39922. * Define the transparency of the material from a texture.
  39923. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39924. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39925. */
  39926. opacityTexture: Nullable<BaseTexture>;
  39927. private _reflectionTexture;
  39928. /**
  39929. * Define the texture used to display the reflection.
  39930. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39931. */
  39932. reflectionTexture: Nullable<BaseTexture>;
  39933. private _emissiveTexture;
  39934. /**
  39935. * Define texture of the material as if self lit.
  39936. * This will be mixed in the final result even in the absence of light.
  39937. */
  39938. emissiveTexture: Nullable<BaseTexture>;
  39939. private _specularTexture;
  39940. /**
  39941. * Define how the color and intensity of the highlight given by the light in the material.
  39942. */
  39943. specularTexture: Nullable<BaseTexture>;
  39944. private _bumpTexture;
  39945. /**
  39946. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39947. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  39948. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39949. */
  39950. bumpTexture: Nullable<BaseTexture>;
  39951. private _lightmapTexture;
  39952. /**
  39953. * Complex lighting can be computationally expensive to compute at runtime.
  39954. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39955. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39956. */
  39957. lightmapTexture: Nullable<BaseTexture>;
  39958. private _refractionTexture;
  39959. /**
  39960. * Define the texture used to display the refraction.
  39961. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39962. */
  39963. refractionTexture: Nullable<BaseTexture>;
  39964. /**
  39965. * The color of the material lit by the environmental background lighting.
  39966. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39967. */
  39968. ambientColor: Color3;
  39969. /**
  39970. * The basic color of the material as viewed under a light.
  39971. */
  39972. diffuseColor: Color3;
  39973. /**
  39974. * Define how the color and intensity of the highlight given by the light in the material.
  39975. */
  39976. specularColor: Color3;
  39977. /**
  39978. * Define the color of the material as if self lit.
  39979. * This will be mixed in the final result even in the absence of light.
  39980. */
  39981. emissiveColor: Color3;
  39982. /**
  39983. * Defines how sharp are the highlights in the material.
  39984. * The bigger the value the sharper giving a more glossy feeling to the result.
  39985. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39986. */
  39987. specularPower: number;
  39988. private _useAlphaFromDiffuseTexture;
  39989. /**
  39990. * Does the transparency come from the diffuse texture alpha channel.
  39991. */
  39992. useAlphaFromDiffuseTexture: boolean;
  39993. private _useEmissiveAsIllumination;
  39994. /**
  39995. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39996. */
  39997. useEmissiveAsIllumination: boolean;
  39998. private _linkEmissiveWithDiffuse;
  39999. /**
  40000. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40001. * the emissive level when the final color is close to one.
  40002. */
  40003. linkEmissiveWithDiffuse: boolean;
  40004. private _useSpecularOverAlpha;
  40005. /**
  40006. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40007. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40008. */
  40009. useSpecularOverAlpha: boolean;
  40010. private _useReflectionOverAlpha;
  40011. /**
  40012. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40013. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40014. */
  40015. useReflectionOverAlpha: boolean;
  40016. private _disableLighting;
  40017. /**
  40018. * Does lights from the scene impacts this material.
  40019. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40020. */
  40021. disableLighting: boolean;
  40022. private _useObjectSpaceNormalMap;
  40023. /**
  40024. * Allows using an object space normal map (instead of tangent space).
  40025. */
  40026. useObjectSpaceNormalMap: boolean;
  40027. private _useParallax;
  40028. /**
  40029. * Is parallax enabled or not.
  40030. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40031. */
  40032. useParallax: boolean;
  40033. private _useParallaxOcclusion;
  40034. /**
  40035. * Is parallax occlusion enabled or not.
  40036. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40037. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40038. */
  40039. useParallaxOcclusion: boolean;
  40040. /**
  40041. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  40042. */
  40043. parallaxScaleBias: number;
  40044. private _roughness;
  40045. /**
  40046. * Helps to define how blurry the reflections should appears in the material.
  40047. */
  40048. roughness: number;
  40049. /**
  40050. * In case of refraction, define the value of the index of refraction.
  40051. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40052. */
  40053. indexOfRefraction: number;
  40054. /**
  40055. * Invert the refraction texture alongside the y axis.
  40056. * It can be useful with procedural textures or probe for instance.
  40057. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40058. */
  40059. invertRefractionY: boolean;
  40060. /**
  40061. * Defines the alpha limits in alpha test mode.
  40062. */
  40063. alphaCutOff: number;
  40064. private _useLightmapAsShadowmap;
  40065. /**
  40066. * In case of light mapping, define whether the map contains light or shadow informations.
  40067. */
  40068. useLightmapAsShadowmap: boolean;
  40069. private _diffuseFresnelParameters;
  40070. /**
  40071. * Define the diffuse fresnel parameters of the material.
  40072. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40073. */
  40074. diffuseFresnelParameters: FresnelParameters;
  40075. private _opacityFresnelParameters;
  40076. /**
  40077. * Define the opacity fresnel parameters of the material.
  40078. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40079. */
  40080. opacityFresnelParameters: FresnelParameters;
  40081. private _reflectionFresnelParameters;
  40082. /**
  40083. * Define the reflection fresnel parameters of the material.
  40084. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40085. */
  40086. reflectionFresnelParameters: FresnelParameters;
  40087. private _refractionFresnelParameters;
  40088. /**
  40089. * Define the refraction fresnel parameters of the material.
  40090. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40091. */
  40092. refractionFresnelParameters: FresnelParameters;
  40093. private _emissiveFresnelParameters;
  40094. /**
  40095. * Define the emissive fresnel parameters of the material.
  40096. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40097. */
  40098. emissiveFresnelParameters: FresnelParameters;
  40099. private _useReflectionFresnelFromSpecular;
  40100. /**
  40101. * If true automatically deducts the fresnels values from the material specularity.
  40102. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40103. */
  40104. useReflectionFresnelFromSpecular: boolean;
  40105. private _useGlossinessFromSpecularMapAlpha;
  40106. /**
  40107. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40108. */
  40109. useGlossinessFromSpecularMapAlpha: boolean;
  40110. private _maxSimultaneousLights;
  40111. /**
  40112. * Defines the maximum number of lights that can be used in the material
  40113. */
  40114. maxSimultaneousLights: number;
  40115. private _invertNormalMapX;
  40116. /**
  40117. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40118. */
  40119. invertNormalMapX: boolean;
  40120. private _invertNormalMapY;
  40121. /**
  40122. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40123. */
  40124. invertNormalMapY: boolean;
  40125. private _twoSidedLighting;
  40126. /**
  40127. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40128. */
  40129. twoSidedLighting: boolean;
  40130. /**
  40131. * Default configuration related to image processing available in the standard Material.
  40132. */
  40133. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40134. /**
  40135. * Gets the image processing configuration used either in this material.
  40136. */
  40137. /**
  40138. * Sets the Default image processing configuration used either in the this material.
  40139. *
  40140. * If sets to null, the scene one is in use.
  40141. */
  40142. imageProcessingConfiguration: ImageProcessingConfiguration;
  40143. /**
  40144. * Keep track of the image processing observer to allow dispose and replace.
  40145. */
  40146. private _imageProcessingObserver;
  40147. /**
  40148. * Attaches a new image processing configuration to the Standard Material.
  40149. * @param configuration
  40150. */
  40151. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40152. /**
  40153. * Gets wether the color curves effect is enabled.
  40154. */
  40155. /**
  40156. * Sets wether the color curves effect is enabled.
  40157. */
  40158. cameraColorCurvesEnabled: boolean;
  40159. /**
  40160. * Gets wether the color grading effect is enabled.
  40161. */
  40162. /**
  40163. * Gets wether the color grading effect is enabled.
  40164. */
  40165. cameraColorGradingEnabled: boolean;
  40166. /**
  40167. * Gets wether tonemapping is enabled or not.
  40168. */
  40169. /**
  40170. * Sets wether tonemapping is enabled or not
  40171. */
  40172. cameraToneMappingEnabled: boolean;
  40173. /**
  40174. * The camera exposure used on this material.
  40175. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40176. * This corresponds to a photographic exposure.
  40177. */
  40178. /**
  40179. * The camera exposure used on this material.
  40180. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40181. * This corresponds to a photographic exposure.
  40182. */
  40183. cameraExposure: number;
  40184. /**
  40185. * Gets The camera contrast used on this material.
  40186. */
  40187. /**
  40188. * Sets The camera contrast used on this material.
  40189. */
  40190. cameraContrast: number;
  40191. /**
  40192. * Gets the Color Grading 2D Lookup Texture.
  40193. */
  40194. /**
  40195. * Sets the Color Grading 2D Lookup Texture.
  40196. */
  40197. cameraColorGradingTexture: Nullable<BaseTexture>;
  40198. /**
  40199. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40200. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40201. * 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;
  40202. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40203. */
  40204. /**
  40205. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40206. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40207. * 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;
  40208. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40209. */
  40210. cameraColorCurves: Nullable<ColorCurves>;
  40211. /**
  40212. * Custom callback helping to override the default shader used in the material.
  40213. */
  40214. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40215. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40216. protected _worldViewProjectionMatrix: Matrix;
  40217. protected _globalAmbientColor: Color3;
  40218. protected _useLogarithmicDepth: boolean;
  40219. /**
  40220. * Instantiates a new standard material.
  40221. * This is the default material used in Babylon. It is the best trade off between quality
  40222. * and performances.
  40223. * @see http://doc.babylonjs.com/babylon101/materials
  40224. * @param name Define the name of the material in the scene
  40225. * @param scene Define the scene the material belong to
  40226. */
  40227. constructor(name: string, scene: Scene);
  40228. /**
  40229. * Gets a boolean indicating that current material needs to register RTT
  40230. */
  40231. readonly hasRenderTargetTextures: boolean;
  40232. /**
  40233. * Gets the current class name of the material e.g. "StandardMaterial"
  40234. * Mainly use in serialization.
  40235. * @returns the class name
  40236. */
  40237. getClassName(): string;
  40238. /**
  40239. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40240. * You can try switching to logarithmic depth.
  40241. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40242. */
  40243. useLogarithmicDepth: boolean;
  40244. /**
  40245. * Specifies if the material will require alpha blending
  40246. * @returns a boolean specifying if alpha blending is needed
  40247. */
  40248. needAlphaBlending(): boolean;
  40249. /**
  40250. * Specifies if this material should be rendered in alpha test mode
  40251. * @returns a boolean specifying if an alpha test is needed.
  40252. */
  40253. needAlphaTesting(): boolean;
  40254. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40255. /**
  40256. * Get the texture used for alpha test purpose.
  40257. * @returns the diffuse texture in case of the standard material.
  40258. */
  40259. getAlphaTestTexture(): Nullable<BaseTexture>;
  40260. /**
  40261. * Get if the submesh is ready to be used and all its information available.
  40262. * Child classes can use it to update shaders
  40263. * @param mesh defines the mesh to check
  40264. * @param subMesh defines which submesh to check
  40265. * @param useInstances specifies that instances should be used
  40266. * @returns a boolean indicating that the submesh is ready or not
  40267. */
  40268. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40269. /**
  40270. * Builds the material UBO layouts.
  40271. * Used internally during the effect preparation.
  40272. */
  40273. buildUniformLayout(): void;
  40274. /**
  40275. * Unbinds the material from the mesh
  40276. */
  40277. unbind(): void;
  40278. /**
  40279. * Binds the submesh to this material by preparing the effect and shader to draw
  40280. * @param world defines the world transformation matrix
  40281. * @param mesh defines the mesh containing the submesh
  40282. * @param subMesh defines the submesh to bind the material to
  40283. */
  40284. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40285. /**
  40286. * Get the list of animatables in the material.
  40287. * @returns the list of animatables object used in the material
  40288. */
  40289. getAnimatables(): IAnimatable[];
  40290. /**
  40291. * Gets the active textures from the material
  40292. * @returns an array of textures
  40293. */
  40294. getActiveTextures(): BaseTexture[];
  40295. /**
  40296. * Specifies if the material uses a texture
  40297. * @param texture defines the texture to check against the material
  40298. * @returns a boolean specifying if the material uses the texture
  40299. */
  40300. hasTexture(texture: BaseTexture): boolean;
  40301. /**
  40302. * Disposes the material
  40303. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40304. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40305. */
  40306. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40307. /**
  40308. * Makes a duplicate of the material, and gives it a new name
  40309. * @param name defines the new name for the duplicated material
  40310. * @returns the cloned material
  40311. */
  40312. clone(name: string): StandardMaterial;
  40313. /**
  40314. * Serializes this material in a JSON representation
  40315. * @returns the serialized material object
  40316. */
  40317. serialize(): any;
  40318. /**
  40319. * Creates a standard material from parsed material data
  40320. * @param source defines the JSON representation of the material
  40321. * @param scene defines the hosting scene
  40322. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40323. * @returns a new standard material
  40324. */
  40325. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40326. /**
  40327. * Are diffuse textures enabled in the application.
  40328. */
  40329. static DiffuseTextureEnabled: boolean;
  40330. /**
  40331. * Are ambient textures enabled in the application.
  40332. */
  40333. static AmbientTextureEnabled: boolean;
  40334. /**
  40335. * Are opacity textures enabled in the application.
  40336. */
  40337. static OpacityTextureEnabled: boolean;
  40338. /**
  40339. * Are reflection textures enabled in the application.
  40340. */
  40341. static ReflectionTextureEnabled: boolean;
  40342. /**
  40343. * Are emissive textures enabled in the application.
  40344. */
  40345. static EmissiveTextureEnabled: boolean;
  40346. /**
  40347. * Are specular textures enabled in the application.
  40348. */
  40349. static SpecularTextureEnabled: boolean;
  40350. /**
  40351. * Are bump textures enabled in the application.
  40352. */
  40353. static BumpTextureEnabled: boolean;
  40354. /**
  40355. * Are lightmap textures enabled in the application.
  40356. */
  40357. static LightmapTextureEnabled: boolean;
  40358. /**
  40359. * Are refraction textures enabled in the application.
  40360. */
  40361. static RefractionTextureEnabled: boolean;
  40362. /**
  40363. * Are color grading textures enabled in the application.
  40364. */
  40365. static ColorGradingTextureEnabled: boolean;
  40366. /**
  40367. * Are fresnels enabled in the application.
  40368. */
  40369. static FresnelEnabled: boolean;
  40370. }
  40371. }
  40372. declare module BABYLON {
  40373. /**
  40374. * A class extending Texture allowing drawing on a texture
  40375. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40376. */
  40377. export class DynamicTexture extends Texture {
  40378. private _generateMipMaps;
  40379. private _canvas;
  40380. private _context;
  40381. private _engine;
  40382. /**
  40383. * Creates a DynamicTexture
  40384. * @param name defines the name of the texture
  40385. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  40386. * @param scene defines the scene where you want the texture
  40387. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40388. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40389. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40390. */
  40391. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40392. /**
  40393. * Get the current class name of the texture useful for serialization or dynamic coding.
  40394. * @returns "DynamicTexture"
  40395. */
  40396. getClassName(): string;
  40397. /**
  40398. * Gets the current state of canRescale
  40399. */
  40400. readonly canRescale: boolean;
  40401. private _recreate;
  40402. /**
  40403. * Scales the texture
  40404. * @param ratio the scale factor to apply to both width and height
  40405. */
  40406. scale(ratio: number): void;
  40407. /**
  40408. * Resizes the texture
  40409. * @param width the new width
  40410. * @param height the new height
  40411. */
  40412. scaleTo(width: number, height: number): void;
  40413. /**
  40414. * Gets the context of the canvas used by the texture
  40415. * @returns the canvas context of the dynamic texture
  40416. */
  40417. getContext(): CanvasRenderingContext2D;
  40418. /**
  40419. * Clears the texture
  40420. */
  40421. clear(): void;
  40422. /**
  40423. * Updates the texture
  40424. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40425. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40426. */
  40427. update(invertY?: boolean, premulAlpha?: boolean): void;
  40428. /**
  40429. * Draws text onto the texture
  40430. * @param text defines the text to be drawn
  40431. * @param x defines the placement of the text from the left
  40432. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40433. * @param font defines the font to be used with font-style, font-size, font-name
  40434. * @param color defines the color used for the text
  40435. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40436. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40437. * @param update defines whether texture is immediately update (default is true)
  40438. */
  40439. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40440. /**
  40441. * Clones the texture
  40442. * @returns the clone of the texture.
  40443. */
  40444. clone(): DynamicTexture;
  40445. /**
  40446. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40447. * @returns a serialized dynamic texture object
  40448. */
  40449. serialize(): any;
  40450. /** @hidden */
  40451. _rebuild(): void;
  40452. }
  40453. }
  40454. declare module BABYLON {
  40455. /** @hidden */
  40456. export var imageProcessingPixelShader: {
  40457. name: string;
  40458. shader: string;
  40459. };
  40460. }
  40461. declare module BABYLON {
  40462. /**
  40463. * ImageProcessingPostProcess
  40464. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40465. */
  40466. export class ImageProcessingPostProcess extends PostProcess {
  40467. /**
  40468. * Default configuration related to image processing available in the PBR Material.
  40469. */
  40470. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40471. /**
  40472. * Gets the image processing configuration used either in this material.
  40473. */
  40474. /**
  40475. * Sets the Default image processing configuration used either in the this material.
  40476. *
  40477. * If sets to null, the scene one is in use.
  40478. */
  40479. imageProcessingConfiguration: ImageProcessingConfiguration;
  40480. /**
  40481. * Keep track of the image processing observer to allow dispose and replace.
  40482. */
  40483. private _imageProcessingObserver;
  40484. /**
  40485. * Attaches a new image processing configuration to the PBR Material.
  40486. * @param configuration
  40487. */
  40488. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40489. /**
  40490. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40491. */
  40492. /**
  40493. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40494. */
  40495. colorCurves: Nullable<ColorCurves>;
  40496. /**
  40497. * Gets wether the color curves effect is enabled.
  40498. */
  40499. /**
  40500. * Sets wether the color curves effect is enabled.
  40501. */
  40502. colorCurvesEnabled: boolean;
  40503. /**
  40504. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40505. */
  40506. /**
  40507. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40508. */
  40509. colorGradingTexture: Nullable<BaseTexture>;
  40510. /**
  40511. * Gets wether the color grading effect is enabled.
  40512. */
  40513. /**
  40514. * Gets wether the color grading effect is enabled.
  40515. */
  40516. colorGradingEnabled: boolean;
  40517. /**
  40518. * Gets exposure used in the effect.
  40519. */
  40520. /**
  40521. * Sets exposure used in the effect.
  40522. */
  40523. exposure: number;
  40524. /**
  40525. * Gets wether tonemapping is enabled or not.
  40526. */
  40527. /**
  40528. * Sets wether tonemapping is enabled or not
  40529. */
  40530. toneMappingEnabled: boolean;
  40531. /**
  40532. * Gets the type of tone mapping effect.
  40533. */
  40534. /**
  40535. * Sets the type of tone mapping effect.
  40536. */
  40537. toneMappingType: number;
  40538. /**
  40539. * Gets contrast used in the effect.
  40540. */
  40541. /**
  40542. * Sets contrast used in the effect.
  40543. */
  40544. contrast: number;
  40545. /**
  40546. * Gets Vignette stretch size.
  40547. */
  40548. /**
  40549. * Sets Vignette stretch size.
  40550. */
  40551. vignetteStretch: number;
  40552. /**
  40553. * Gets Vignette centre X Offset.
  40554. */
  40555. /**
  40556. * Sets Vignette centre X Offset.
  40557. */
  40558. vignetteCentreX: number;
  40559. /**
  40560. * Gets Vignette centre Y Offset.
  40561. */
  40562. /**
  40563. * Sets Vignette centre Y Offset.
  40564. */
  40565. vignetteCentreY: number;
  40566. /**
  40567. * Gets Vignette weight or intensity of the vignette effect.
  40568. */
  40569. /**
  40570. * Sets Vignette weight or intensity of the vignette effect.
  40571. */
  40572. vignetteWeight: number;
  40573. /**
  40574. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40575. * if vignetteEnabled is set to true.
  40576. */
  40577. /**
  40578. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40579. * if vignetteEnabled is set to true.
  40580. */
  40581. vignetteColor: Color4;
  40582. /**
  40583. * Gets Camera field of view used by the Vignette effect.
  40584. */
  40585. /**
  40586. * Sets Camera field of view used by the Vignette effect.
  40587. */
  40588. vignetteCameraFov: number;
  40589. /**
  40590. * Gets the vignette blend mode allowing different kind of effect.
  40591. */
  40592. /**
  40593. * Sets the vignette blend mode allowing different kind of effect.
  40594. */
  40595. vignetteBlendMode: number;
  40596. /**
  40597. * Gets wether the vignette effect is enabled.
  40598. */
  40599. /**
  40600. * Sets wether the vignette effect is enabled.
  40601. */
  40602. vignetteEnabled: boolean;
  40603. private _fromLinearSpace;
  40604. /**
  40605. * Gets wether the input of the processing is in Gamma or Linear Space.
  40606. */
  40607. /**
  40608. * Sets wether the input of the processing is in Gamma or Linear Space.
  40609. */
  40610. fromLinearSpace: boolean;
  40611. /**
  40612. * Defines cache preventing GC.
  40613. */
  40614. private _defines;
  40615. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40616. /**
  40617. * "ImageProcessingPostProcess"
  40618. * @returns "ImageProcessingPostProcess"
  40619. */
  40620. getClassName(): string;
  40621. protected _updateParameters(): void;
  40622. dispose(camera?: Camera): void;
  40623. }
  40624. }
  40625. declare module BABYLON {
  40626. /**
  40627. * Class containing static functions to help procedurally build meshes
  40628. */
  40629. export class GroundBuilder {
  40630. /**
  40631. * Creates a ground mesh
  40632. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40633. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40635. * @param name defines the name of the mesh
  40636. * @param options defines the options used to create the mesh
  40637. * @param scene defines the hosting scene
  40638. * @returns the ground mesh
  40639. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40640. */
  40641. static CreateGround(name: string, options: {
  40642. width?: number;
  40643. height?: number;
  40644. subdivisions?: number;
  40645. subdivisionsX?: number;
  40646. subdivisionsY?: number;
  40647. updatable?: boolean;
  40648. }, scene: any): Mesh;
  40649. /**
  40650. * Creates a tiled ground mesh
  40651. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40652. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40653. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  40654. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  40655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40656. * @param name defines the name of the mesh
  40657. * @param options defines the options used to create the mesh
  40658. * @param scene defines the hosting scene
  40659. * @returns the tiled ground mesh
  40660. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40661. */
  40662. static CreateTiledGround(name: string, options: {
  40663. xmin: number;
  40664. zmin: number;
  40665. xmax: number;
  40666. zmax: number;
  40667. subdivisions?: {
  40668. w: number;
  40669. h: number;
  40670. };
  40671. precision?: {
  40672. w: number;
  40673. h: number;
  40674. };
  40675. updatable?: boolean;
  40676. }, scene?: Nullable<Scene>): Mesh;
  40677. /**
  40678. * Creates a ground mesh from a height map
  40679. * * The parameter `url` sets the URL of the height map image resource.
  40680. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40681. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40682. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40683. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40684. * * 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.
  40685. * * 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).
  40686. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40688. * @param name defines the name of the mesh
  40689. * @param url defines the url to the height map
  40690. * @param options defines the options used to create the mesh
  40691. * @param scene defines the hosting scene
  40692. * @returns the ground mesh
  40693. * @see https://doc.babylonjs.com/babylon101/height_map
  40694. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40695. */
  40696. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40697. width?: number;
  40698. height?: number;
  40699. subdivisions?: number;
  40700. minHeight?: number;
  40701. maxHeight?: number;
  40702. colorFilter?: Color3;
  40703. alphaFilter?: number;
  40704. updatable?: boolean;
  40705. onReady?: (mesh: GroundMesh) => void;
  40706. }, scene?: Nullable<Scene>): GroundMesh;
  40707. }
  40708. }
  40709. declare module BABYLON {
  40710. /**
  40711. * Class containing static functions to help procedurally build meshes
  40712. */
  40713. export class TorusBuilder {
  40714. /**
  40715. * Creates a torus mesh
  40716. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40717. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40718. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40720. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40722. * @param name defines the name of the mesh
  40723. * @param options defines the options used to create the mesh
  40724. * @param scene defines the hosting scene
  40725. * @returns the torus mesh
  40726. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40727. */
  40728. static CreateTorus(name: string, options: {
  40729. diameter?: number;
  40730. thickness?: number;
  40731. tessellation?: number;
  40732. updatable?: boolean;
  40733. sideOrientation?: number;
  40734. frontUVs?: Vector4;
  40735. backUVs?: Vector4;
  40736. }, scene: any): Mesh;
  40737. }
  40738. }
  40739. declare module BABYLON {
  40740. /**
  40741. * Class containing static functions to help procedurally build meshes
  40742. */
  40743. export class CylinderBuilder {
  40744. /**
  40745. * Creates a cylinder or a cone mesh
  40746. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40747. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40748. * * 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.
  40749. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40750. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40751. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40752. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40753. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  40754. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40755. * * 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).
  40756. * * 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
  40757. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40758. * * 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
  40759. * * 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.
  40760. * * If `enclose` is false, a ring surface is one element.
  40761. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40762. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  40763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40764. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40766. * @param name defines the name of the mesh
  40767. * @param options defines the options used to create the mesh
  40768. * @param scene defines the hosting scene
  40769. * @returns the cylinder mesh
  40770. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40771. */
  40772. static CreateCylinder(name: string, options: {
  40773. height?: number;
  40774. diameterTop?: number;
  40775. diameterBottom?: number;
  40776. diameter?: number;
  40777. tessellation?: number;
  40778. subdivisions?: number;
  40779. arc?: number;
  40780. faceColors?: Color4[];
  40781. faceUV?: Vector4[];
  40782. updatable?: boolean;
  40783. hasRings?: boolean;
  40784. enclose?: boolean;
  40785. cap?: number;
  40786. sideOrientation?: number;
  40787. frontUVs?: Vector4;
  40788. backUVs?: Vector4;
  40789. }, scene: any): Mesh;
  40790. }
  40791. }
  40792. declare module BABYLON {
  40793. /**
  40794. * Options to modify the vr teleportation behavior.
  40795. */
  40796. export interface VRTeleportationOptions {
  40797. /**
  40798. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40799. */
  40800. floorMeshName?: string;
  40801. /**
  40802. * A list of meshes to be used as the teleportation floor. (default: empty)
  40803. */
  40804. floorMeshes?: Mesh[];
  40805. }
  40806. /**
  40807. * Options to modify the vr experience helper's behavior.
  40808. */
  40809. export interface VRExperienceHelperOptions extends WebVROptions {
  40810. /**
  40811. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40812. */
  40813. createDeviceOrientationCamera?: boolean;
  40814. /**
  40815. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40816. */
  40817. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40818. /**
  40819. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40820. */
  40821. laserToggle?: boolean;
  40822. /**
  40823. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40824. */
  40825. floorMeshes?: Mesh[];
  40826. /**
  40827. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40828. */
  40829. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40830. }
  40831. /**
  40832. * Event containing information after VR has been entered
  40833. */
  40834. export class OnAfterEnteringVRObservableEvent {
  40835. /**
  40836. * If entering vr was successful
  40837. */
  40838. success: boolean;
  40839. }
  40840. /**
  40841. * Helps to quickly add VR support to an existing scene.
  40842. * See http://doc.babylonjs.com/how_to/webvr_helper
  40843. */
  40844. export class VRExperienceHelper {
  40845. /** Options to modify the vr experience helper's behavior. */
  40846. webVROptions: VRExperienceHelperOptions;
  40847. private _scene;
  40848. private _position;
  40849. private _btnVR;
  40850. private _btnVRDisplayed;
  40851. private _webVRsupported;
  40852. private _webVRready;
  40853. private _webVRrequesting;
  40854. private _webVRpresenting;
  40855. private _hasEnteredVR;
  40856. private _fullscreenVRpresenting;
  40857. private _canvas;
  40858. private _webVRCamera;
  40859. private _vrDeviceOrientationCamera;
  40860. private _deviceOrientationCamera;
  40861. private _existingCamera;
  40862. private _onKeyDown;
  40863. private _onVrDisplayPresentChange;
  40864. private _onVRDisplayChanged;
  40865. private _onVRRequestPresentStart;
  40866. private _onVRRequestPresentComplete;
  40867. /**
  40868. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  40869. */
  40870. enableGazeEvenWhenNoPointerLock: boolean;
  40871. /**
  40872. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40873. */
  40874. exitVROnDoubleTap: boolean;
  40875. /**
  40876. * Observable raised right before entering VR.
  40877. */
  40878. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40879. /**
  40880. * Observable raised when entering VR has completed.
  40881. */
  40882. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40883. /**
  40884. * Observable raised when exiting VR.
  40885. */
  40886. onExitingVRObservable: Observable<VRExperienceHelper>;
  40887. /**
  40888. * Observable raised when controller mesh is loaded.
  40889. */
  40890. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40891. /** Return this.onEnteringVRObservable
  40892. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40893. */
  40894. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40895. /** Return this.onExitingVRObservable
  40896. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40897. */
  40898. readonly onExitingVR: Observable<VRExperienceHelper>;
  40899. /** Return this.onControllerMeshLoadedObservable
  40900. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40901. */
  40902. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40903. private _rayLength;
  40904. private _useCustomVRButton;
  40905. private _teleportationRequested;
  40906. private _teleportActive;
  40907. private _floorMeshName;
  40908. private _floorMeshesCollection;
  40909. private _rotationAllowed;
  40910. private _teleportBackwardsVector;
  40911. private _teleportationTarget;
  40912. private _isDefaultTeleportationTarget;
  40913. private _postProcessMove;
  40914. private _teleportationFillColor;
  40915. private _teleportationBorderColor;
  40916. private _rotationAngle;
  40917. private _haloCenter;
  40918. private _cameraGazer;
  40919. private _padSensibilityUp;
  40920. private _padSensibilityDown;
  40921. private _leftController;
  40922. private _rightController;
  40923. /**
  40924. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40925. */
  40926. onNewMeshSelected: Observable<AbstractMesh>;
  40927. /**
  40928. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40929. * This observable will provide the mesh and the controller used to select the mesh
  40930. */
  40931. onMeshSelectedWithController: Observable<{
  40932. mesh: AbstractMesh;
  40933. controller: WebVRController;
  40934. }>;
  40935. /**
  40936. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40937. */
  40938. onNewMeshPicked: Observable<PickingInfo>;
  40939. private _circleEase;
  40940. /**
  40941. * Observable raised before camera teleportation
  40942. */
  40943. onBeforeCameraTeleport: Observable<Vector3>;
  40944. /**
  40945. * Observable raised after camera teleportation
  40946. */
  40947. onAfterCameraTeleport: Observable<Vector3>;
  40948. /**
  40949. * Observable raised when current selected mesh gets unselected
  40950. */
  40951. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40952. private _raySelectionPredicate;
  40953. /**
  40954. * To be optionaly changed by user to define custom ray selection
  40955. */
  40956. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40957. /**
  40958. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40959. */
  40960. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40961. /**
  40962. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40963. */
  40964. teleportationEnabled: boolean;
  40965. private _defaultHeight;
  40966. private _teleportationInitialized;
  40967. private _interactionsEnabled;
  40968. private _interactionsRequested;
  40969. private _displayGaze;
  40970. private _displayLaserPointer;
  40971. /**
  40972. * The mesh used to display where the user is going to teleport.
  40973. */
  40974. /**
  40975. * Sets the mesh to be used to display where the user is going to teleport.
  40976. */
  40977. teleportationTarget: Mesh;
  40978. /**
  40979. * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
  40980. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40981. * See http://doc.babylonjs.com/resources/baking_transformations
  40982. */
  40983. gazeTrackerMesh: Mesh;
  40984. /**
  40985. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40986. */
  40987. updateGazeTrackerScale: boolean;
  40988. /**
  40989. * If the gaze trackers color should be updated when selecting meshes
  40990. */
  40991. updateGazeTrackerColor: boolean;
  40992. /**
  40993. * The gaze tracking mesh corresponding to the left controller
  40994. */
  40995. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40996. /**
  40997. * The gaze tracking mesh corresponding to the right controller
  40998. */
  40999. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41000. /**
  41001. * If the ray of the gaze should be displayed.
  41002. */
  41003. /**
  41004. * Sets if the ray of the gaze should be displayed.
  41005. */
  41006. displayGaze: boolean;
  41007. /**
  41008. * If the ray of the LaserPointer should be displayed.
  41009. */
  41010. /**
  41011. * Sets if the ray of the LaserPointer should be displayed.
  41012. */
  41013. displayLaserPointer: boolean;
  41014. /**
  41015. * The deviceOrientationCamera used as the camera when not in VR.
  41016. */
  41017. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41018. /**
  41019. * Based on the current WebVR support, returns the current VR camera used.
  41020. */
  41021. readonly currentVRCamera: Nullable<Camera>;
  41022. /**
  41023. * The webVRCamera which is used when in VR.
  41024. */
  41025. readonly webVRCamera: WebVRFreeCamera;
  41026. /**
  41027. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41028. */
  41029. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41030. /**
  41031. * The html button that is used to trigger entering into VR.
  41032. */
  41033. readonly vrButton: Nullable<HTMLButtonElement>;
  41034. private readonly _teleportationRequestInitiated;
  41035. /**
  41036. * Defines wether or not Pointer lock should be requested when switching to
  41037. * full screen.
  41038. */
  41039. requestPointerLockOnFullScreen: boolean;
  41040. /**
  41041. * Instantiates a VRExperienceHelper.
  41042. * Helps to quickly add VR support to an existing scene.
  41043. * @param scene The scene the VRExperienceHelper belongs to.
  41044. * @param webVROptions Options to modify the vr experience helper's behavior.
  41045. */
  41046. constructor(scene: Scene,
  41047. /** Options to modify the vr experience helper's behavior. */
  41048. webVROptions?: VRExperienceHelperOptions);
  41049. private _onDefaultMeshLoaded;
  41050. private _onResize;
  41051. private _onFullscreenChange;
  41052. /**
  41053. * Gets a value indicating if we are currently in VR mode.
  41054. */
  41055. readonly isInVRMode: boolean;
  41056. private onVrDisplayPresentChange;
  41057. private onVRDisplayChanged;
  41058. private moveButtonToBottomRight;
  41059. private displayVRButton;
  41060. private updateButtonVisibility;
  41061. private _cachedAngularSensibility;
  41062. /**
  41063. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41064. * Otherwise, will use the fullscreen API.
  41065. */
  41066. enterVR(): void;
  41067. /**
  41068. * Attempt to exit VR, or fullscreen.
  41069. */
  41070. exitVR(): void;
  41071. /**
  41072. * The position of the vr experience helper.
  41073. */
  41074. /**
  41075. * Sets the position of the vr experience helper.
  41076. */
  41077. position: Vector3;
  41078. /**
  41079. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41080. */
  41081. enableInteractions(): void;
  41082. private readonly _noControllerIsActive;
  41083. private beforeRender;
  41084. private _isTeleportationFloor;
  41085. /**
  41086. * Adds a floor mesh to be used for teleportation.
  41087. * @param floorMesh the mesh to be used for teleportation.
  41088. */
  41089. addFloorMesh(floorMesh: Mesh): void;
  41090. /**
  41091. * Removes a floor mesh from being used for teleportation.
  41092. * @param floorMesh the mesh to be removed.
  41093. */
  41094. removeFloorMesh(floorMesh: Mesh): void;
  41095. /**
  41096. * Enables interactions and teleportation using the VR controllers and gaze.
  41097. * @param vrTeleportationOptions options to modify teleportation behavior.
  41098. */
  41099. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41100. private _onNewGamepadConnected;
  41101. private _tryEnableInteractionOnController;
  41102. private _onNewGamepadDisconnected;
  41103. private _enableInteractionOnController;
  41104. private _checkTeleportWithRay;
  41105. private _checkRotate;
  41106. private _checkTeleportBackwards;
  41107. private _enableTeleportationOnController;
  41108. private _createTeleportationCircles;
  41109. private _displayTeleportationTarget;
  41110. private _hideTeleportationTarget;
  41111. private _rotateCamera;
  41112. private _moveTeleportationSelectorTo;
  41113. private _workingVector;
  41114. private _workingQuaternion;
  41115. private _workingMatrix;
  41116. /**
  41117. * Teleports the users feet to the desired location
  41118. * @param location The location where the user's feet should be placed
  41119. */
  41120. teleportCamera(location: Vector3): void;
  41121. private _convertNormalToDirectionOfRay;
  41122. private _castRayAndSelectObject;
  41123. private _notifySelectedMeshUnselected;
  41124. /**
  41125. * Sets the color of the laser ray from the vr controllers.
  41126. * @param color new color for the ray.
  41127. */
  41128. changeLaserColor(color: Color3): void;
  41129. /**
  41130. * Sets the color of the ray from the vr headsets gaze.
  41131. * @param color new color for the ray.
  41132. */
  41133. changeGazeColor(color: Color3): void;
  41134. /**
  41135. * Exits VR and disposes of the vr experience helper
  41136. */
  41137. dispose(): void;
  41138. /**
  41139. * Gets the name of the VRExperienceHelper class
  41140. * @returns "VRExperienceHelper"
  41141. */
  41142. getClassName(): string;
  41143. }
  41144. }
  41145. declare module BABYLON {
  41146. /**
  41147. * Manages an XRSession to work with Babylon's engine
  41148. * @see https://doc.babylonjs.com/how_to/webxr
  41149. */
  41150. export class WebXRSessionManager implements IDisposable {
  41151. private scene;
  41152. /**
  41153. * Fires every time a new xrFrame arrives which can be used to update the camera
  41154. */
  41155. onXRFrameObservable: Observable<any>;
  41156. /**
  41157. * Fires when the xr session is ended either by the device or manually done
  41158. */
  41159. onXRSessionEnded: Observable<any>;
  41160. /**
  41161. * Underlying xr session
  41162. */
  41163. session: XRSession;
  41164. /**
  41165. * Type of reference space used when creating the session
  41166. */
  41167. referenceSpace: XRReferenceSpace;
  41168. /** @hidden */
  41169. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41170. /**
  41171. * Current XR frame
  41172. */
  41173. currentFrame: Nullable<XRFrame>;
  41174. private _xrNavigator;
  41175. private baseLayer;
  41176. /**
  41177. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41178. * @param scene The scene which the session should be created for
  41179. */
  41180. constructor(scene: Scene);
  41181. /**
  41182. * Initializes the manager
  41183. * After initialization enterXR can be called to start an XR session
  41184. * @returns Promise which resolves after it is initialized
  41185. */
  41186. initializeAsync(): Promise<void>;
  41187. /**
  41188. * Initializes an xr session
  41189. * @param xrSessionMode mode to initialize
  41190. * @returns a promise which will resolve once the session has been initialized
  41191. */
  41192. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41193. /**
  41194. * Sets the reference space on the xr session
  41195. * @param referenceSpace space to set
  41196. * @returns a promise that will resolve once the reference space has been set
  41197. */
  41198. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41199. /**
  41200. * Updates the render state of the session
  41201. * @param state state to set
  41202. * @returns a promise that resolves once the render state has been updated
  41203. */
  41204. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41205. /**
  41206. * Starts rendering to the xr layer
  41207. * @returns a promise that will resolve once rendering has started
  41208. */
  41209. startRenderingToXRAsync(): Promise<void>;
  41210. /**
  41211. * Stops the xrSession and restores the renderloop
  41212. * @returns Promise which resolves after it exits XR
  41213. */
  41214. exitXRAsync(): Promise<unknown>;
  41215. /**
  41216. * Checks if a session would be supported for the creation options specified
  41217. * @param sessionMode session mode to check if supported eg. immersive-vr
  41218. * @returns true if supported
  41219. */
  41220. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41221. /**
  41222. * @hidden
  41223. * Converts the render layer of xrSession to a render target
  41224. * @param session session to create render target for
  41225. * @param scene scene the new render target should be created for
  41226. */
  41227. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41228. /**
  41229. * Disposes of the session manager
  41230. */
  41231. dispose(): void;
  41232. }
  41233. }
  41234. declare module BABYLON {
  41235. /**
  41236. * WebXR Camera which holds the views for the xrSession
  41237. * @see https://doc.babylonjs.com/how_to/webxr
  41238. */
  41239. export class WebXRCamera extends FreeCamera {
  41240. private static _TmpMatrix;
  41241. /**
  41242. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41243. * @param name the name of the camera
  41244. * @param scene the scene to add the camera to
  41245. */
  41246. constructor(name: string, scene: Scene);
  41247. private _updateNumberOfRigCameras;
  41248. /** @hidden */
  41249. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41250. /**
  41251. * Updates the cameras position from the current pose information of the XR session
  41252. * @param xrSessionManager the session containing pose information
  41253. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41254. */
  41255. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41256. }
  41257. }
  41258. declare module BABYLON {
  41259. /**
  41260. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41261. */
  41262. export class WebXRManagedOutputCanvas implements IDisposable {
  41263. private helper;
  41264. private _canvas;
  41265. /**
  41266. * xrpresent context of the canvas which can be used to display/mirror xr content
  41267. */
  41268. canvasContext: WebGLRenderingContext;
  41269. /**
  41270. * xr layer for the canvas
  41271. */
  41272. xrLayer: Nullable<XRWebGLLayer>;
  41273. /**
  41274. * Initializes the xr layer for the session
  41275. * @param xrSession xr session
  41276. * @returns a promise that will resolve once the XR Layer has been created
  41277. */
  41278. initializeXRLayerAsync(xrSession: any): any;
  41279. /**
  41280. * Initializes the canvas to be added/removed upon entering/exiting xr
  41281. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41282. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41283. */
  41284. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41285. /**
  41286. * Disposes of the object
  41287. */
  41288. dispose(): void;
  41289. private _setManagedOutputCanvas;
  41290. private _addCanvas;
  41291. private _removeCanvas;
  41292. }
  41293. }
  41294. declare module BABYLON {
  41295. /**
  41296. * States of the webXR experience
  41297. */
  41298. export enum WebXRState {
  41299. /**
  41300. * Transitioning to being in XR mode
  41301. */
  41302. ENTERING_XR = 0,
  41303. /**
  41304. * Transitioning to non XR mode
  41305. */
  41306. EXITING_XR = 1,
  41307. /**
  41308. * In XR mode and presenting
  41309. */
  41310. IN_XR = 2,
  41311. /**
  41312. * Not entered XR mode
  41313. */
  41314. NOT_IN_XR = 3
  41315. }
  41316. /**
  41317. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41318. * @see https://doc.babylonjs.com/how_to/webxr
  41319. */
  41320. export class WebXRExperienceHelper implements IDisposable {
  41321. private scene;
  41322. /**
  41323. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  41324. */
  41325. container: AbstractMesh;
  41326. /**
  41327. * Camera used to render xr content
  41328. */
  41329. camera: WebXRCamera;
  41330. /**
  41331. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41332. */
  41333. state: WebXRState;
  41334. private _setState;
  41335. private static _TmpVector;
  41336. /**
  41337. * Fires when the state of the experience helper has changed
  41338. */
  41339. onStateChangedObservable: Observable<WebXRState>;
  41340. /** Session manager used to keep track of xr session */
  41341. sessionManager: WebXRSessionManager;
  41342. private _nonVRCamera;
  41343. private _originalSceneAutoClear;
  41344. private _supported;
  41345. /**
  41346. * Creates the experience helper
  41347. * @param scene the scene to attach the experience helper to
  41348. * @returns a promise for the experience helper
  41349. */
  41350. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41351. /**
  41352. * Creates a WebXRExperienceHelper
  41353. * @param scene The scene the helper should be created in
  41354. */
  41355. private constructor();
  41356. /**
  41357. * Exits XR mode and returns the scene to its original state
  41358. * @returns promise that resolves after xr mode has exited
  41359. */
  41360. exitXRAsync(): Promise<unknown>;
  41361. /**
  41362. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41363. * @param sessionCreationOptions options for the XR session
  41364. * @param referenceSpaceType frame of reference of the XR session
  41365. * @param outputCanvas the output canvas that will be used to enter XR mode
  41366. * @returns promise that resolves after xr mode has entered
  41367. */
  41368. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41369. /**
  41370. * Updates the global position of the camera by moving the camera's container
  41371. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41372. * @param position The desired global position of the camera
  41373. */
  41374. setPositionOfCameraUsingContainer(position: Vector3): void;
  41375. /**
  41376. * Rotates the xr camera by rotating the camera's container around the camera's position
  41377. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41378. * @param rotation the desired quaternion rotation to apply to the camera
  41379. */
  41380. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41381. /**
  41382. * Disposes of the experience helper
  41383. */
  41384. dispose(): void;
  41385. }
  41386. }
  41387. declare module BABYLON {
  41388. /**
  41389. * Button which can be used to enter a different mode of XR
  41390. */
  41391. export class WebXREnterExitUIButton {
  41392. /** button element */
  41393. element: HTMLElement;
  41394. /** XR initialization options for the button */
  41395. sessionMode: XRSessionMode;
  41396. /** Reference space type */
  41397. referenceSpaceType: XRReferenceSpaceType;
  41398. /**
  41399. * Creates a WebXREnterExitUIButton
  41400. * @param element button element
  41401. * @param sessionMode XR initialization session mode
  41402. * @param referenceSpaceType the type of reference space to be used
  41403. */
  41404. constructor(
  41405. /** button element */
  41406. element: HTMLElement,
  41407. /** XR initialization options for the button */
  41408. sessionMode: XRSessionMode,
  41409. /** Reference space type */
  41410. referenceSpaceType: XRReferenceSpaceType);
  41411. /**
  41412. * Overwritable function which can be used to update the button's visuals when the state changes
  41413. * @param activeButton the current active button in the UI
  41414. */
  41415. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41416. }
  41417. /**
  41418. * Options to create the webXR UI
  41419. */
  41420. export class WebXREnterExitUIOptions {
  41421. /**
  41422. * Context to enter xr with
  41423. */
  41424. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41425. /**
  41426. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41427. */
  41428. customButtons?: Array<WebXREnterExitUIButton>;
  41429. }
  41430. /**
  41431. * UI to allow the user to enter/exit XR mode
  41432. */
  41433. export class WebXREnterExitUI implements IDisposable {
  41434. private scene;
  41435. private _overlay;
  41436. private _buttons;
  41437. private _activeButton;
  41438. /**
  41439. * Fired every time the active button is changed.
  41440. *
  41441. * When xr is entered via a button that launches xr that button will be the callback parameter
  41442. *
  41443. * When exiting xr the callback parameter will be null)
  41444. */
  41445. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41446. /**
  41447. * Creates UI to allow the user to enter/exit XR mode
  41448. * @param scene the scene to add the ui to
  41449. * @param helper the xr experience helper to enter/exit xr with
  41450. * @param options options to configure the UI
  41451. * @returns the created ui
  41452. */
  41453. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41454. private constructor();
  41455. private _updateButtons;
  41456. /**
  41457. * Disposes of the object
  41458. */
  41459. dispose(): void;
  41460. }
  41461. }
  41462. declare module BABYLON {
  41463. /**
  41464. * Represents an XR input
  41465. */
  41466. export class WebXRController {
  41467. private scene;
  41468. /** The underlying input source for the controller */
  41469. inputSource: XRInputSource;
  41470. private parentContainer;
  41471. /**
  41472. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  41473. */
  41474. grip?: AbstractMesh;
  41475. /**
  41476. * Pointer which can be used to select objects or attach a visible laser to
  41477. */
  41478. pointer: AbstractMesh;
  41479. /**
  41480. * Event that fires when the controller is removed/disposed
  41481. */
  41482. onDisposeObservable: Observable<{}>;
  41483. private _tmpMatrix;
  41484. private _tmpQuaternion;
  41485. private _tmpVector;
  41486. /**
  41487. * Creates the controller
  41488. * @see https://doc.babylonjs.com/how_to/webxr
  41489. * @param scene the scene which the controller should be associated to
  41490. * @param inputSource the underlying input source for the controller
  41491. * @param parentContainer parent that the controller meshes should be children of
  41492. */
  41493. constructor(scene: Scene,
  41494. /** The underlying input source for the controller */
  41495. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41496. /**
  41497. * Updates the controller pose based on the given XRFrame
  41498. * @param xrFrame xr frame to update the pose with
  41499. * @param referenceSpace reference space to use
  41500. */
  41501. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41502. /**
  41503. * Gets a world space ray coming from the controller
  41504. * @param result the resulting ray
  41505. */
  41506. getWorldPointerRayToRef(result: Ray): void;
  41507. /**
  41508. * Disposes of the object
  41509. */
  41510. dispose(): void;
  41511. }
  41512. }
  41513. declare module BABYLON {
  41514. /**
  41515. * XR input used to track XR inputs such as controllers/rays
  41516. */
  41517. export class WebXRInput implements IDisposable {
  41518. /**
  41519. * Base experience the input listens to
  41520. */
  41521. baseExperience: WebXRExperienceHelper;
  41522. /**
  41523. * XR controllers being tracked
  41524. */
  41525. controllers: Array<WebXRController>;
  41526. private _frameObserver;
  41527. private _stateObserver;
  41528. /**
  41529. * Event when a controller has been connected/added
  41530. */
  41531. onControllerAddedObservable: Observable<WebXRController>;
  41532. /**
  41533. * Event when a controller has been removed/disconnected
  41534. */
  41535. onControllerRemovedObservable: Observable<WebXRController>;
  41536. /**
  41537. * Initializes the WebXRInput
  41538. * @param baseExperience experience helper which the input should be created for
  41539. */
  41540. constructor(
  41541. /**
  41542. * Base experience the input listens to
  41543. */
  41544. baseExperience: WebXRExperienceHelper);
  41545. private _onInputSourcesChange;
  41546. private _addAndRemoveControllers;
  41547. /**
  41548. * Disposes of the object
  41549. */
  41550. dispose(): void;
  41551. }
  41552. }
  41553. declare module BABYLON {
  41554. /**
  41555. * Enables teleportation
  41556. */
  41557. export class WebXRControllerTeleportation {
  41558. private _teleportationFillColor;
  41559. private _teleportationBorderColor;
  41560. private _tmpRay;
  41561. private _tmpVector;
  41562. /**
  41563. * Creates a WebXRControllerTeleportation
  41564. * @param input input manager to add teleportation to
  41565. * @param floorMeshes floormeshes which can be teleported to
  41566. */
  41567. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41568. }
  41569. }
  41570. declare module BABYLON {
  41571. /**
  41572. * Handles pointer input automatically for the pointer of XR controllers
  41573. */
  41574. export class WebXRControllerPointerSelection {
  41575. private static _idCounter;
  41576. private _tmpRay;
  41577. /**
  41578. * Creates a WebXRControllerPointerSelection
  41579. * @param input input manager to setup pointer selection
  41580. */
  41581. constructor(input: WebXRInput);
  41582. private _convertNormalToDirectionOfRay;
  41583. private _updatePointerDistance;
  41584. }
  41585. }
  41586. declare module BABYLON {
  41587. /**
  41588. * Class used to represent data loading progression
  41589. */
  41590. export class SceneLoaderProgressEvent {
  41591. /** defines if data length to load can be evaluated */
  41592. readonly lengthComputable: boolean;
  41593. /** defines the loaded data length */
  41594. readonly loaded: number;
  41595. /** defines the data length to load */
  41596. readonly total: number;
  41597. /**
  41598. * Create a new progress event
  41599. * @param lengthComputable defines if data length to load can be evaluated
  41600. * @param loaded defines the loaded data length
  41601. * @param total defines the data length to load
  41602. */
  41603. constructor(
  41604. /** defines if data length to load can be evaluated */
  41605. lengthComputable: boolean,
  41606. /** defines the loaded data length */
  41607. loaded: number,
  41608. /** defines the data length to load */
  41609. total: number);
  41610. /**
  41611. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41612. * @param event defines the source event
  41613. * @returns a new SceneLoaderProgressEvent
  41614. */
  41615. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41616. }
  41617. /**
  41618. * Interface used by SceneLoader plugins to define supported file extensions
  41619. */
  41620. export interface ISceneLoaderPluginExtensions {
  41621. /**
  41622. * Defines the list of supported extensions
  41623. */
  41624. [extension: string]: {
  41625. isBinary: boolean;
  41626. };
  41627. }
  41628. /**
  41629. * Interface used by SceneLoader plugin factory
  41630. */
  41631. export interface ISceneLoaderPluginFactory {
  41632. /**
  41633. * Defines the name of the factory
  41634. */
  41635. name: string;
  41636. /**
  41637. * Function called to create a new plugin
  41638. * @return the new plugin
  41639. */
  41640. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41641. /**
  41642. * Boolean indicating if the plugin can direct load specific data
  41643. */
  41644. canDirectLoad?: (data: string) => boolean;
  41645. }
  41646. /**
  41647. * Interface used to define a SceneLoader plugin
  41648. */
  41649. export interface ISceneLoaderPlugin {
  41650. /**
  41651. * The friendly name of this plugin.
  41652. */
  41653. name: string;
  41654. /**
  41655. * The file extensions supported by this plugin.
  41656. */
  41657. extensions: string | ISceneLoaderPluginExtensions;
  41658. /**
  41659. * Import meshes into a scene.
  41660. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41661. * @param scene The scene to import into
  41662. * @param data The data to import
  41663. * @param rootUrl The root url for scene and resources
  41664. * @param meshes The meshes array to import into
  41665. * @param particleSystems The particle systems array to import into
  41666. * @param skeletons The skeletons array to import into
  41667. * @param onError The callback when import fails
  41668. * @returns True if successful or false otherwise
  41669. */
  41670. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41671. /**
  41672. * Load into a scene.
  41673. * @param scene The scene to load into
  41674. * @param data The data to import
  41675. * @param rootUrl The root url for scene and resources
  41676. * @param onError The callback when import fails
  41677. * @returns true if successful or false otherwise
  41678. */
  41679. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41680. /**
  41681. * The callback that returns true if the data can be directly loaded.
  41682. */
  41683. canDirectLoad?: (data: string) => boolean;
  41684. /**
  41685. * The callback that allows custom handling of the root url based on the response url.
  41686. */
  41687. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41688. /**
  41689. * Load into an asset container.
  41690. * @param scene The scene to load into
  41691. * @param data The data to import
  41692. * @param rootUrl The root url for scene and resources
  41693. * @param onError The callback when import fails
  41694. * @returns The loaded asset container
  41695. */
  41696. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41697. }
  41698. /**
  41699. * Interface used to define an async SceneLoader plugin
  41700. */
  41701. export interface ISceneLoaderPluginAsync {
  41702. /**
  41703. * The friendly name of this plugin.
  41704. */
  41705. name: string;
  41706. /**
  41707. * The file extensions supported by this plugin.
  41708. */
  41709. extensions: string | ISceneLoaderPluginExtensions;
  41710. /**
  41711. * Import meshes into a scene.
  41712. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41713. * @param scene The scene to import into
  41714. * @param data The data to import
  41715. * @param rootUrl The root url for scene and resources
  41716. * @param onProgress The callback when the load progresses
  41717. * @param fileName Defines the name of the file to load
  41718. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41719. */
  41720. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41721. meshes: AbstractMesh[];
  41722. particleSystems: IParticleSystem[];
  41723. skeletons: Skeleton[];
  41724. animationGroups: AnimationGroup[];
  41725. }>;
  41726. /**
  41727. * Load into a scene.
  41728. * @param scene The scene to load into
  41729. * @param data The data to import
  41730. * @param rootUrl The root url for scene and resources
  41731. * @param onProgress The callback when the load progresses
  41732. * @param fileName Defines the name of the file to load
  41733. * @returns Nothing
  41734. */
  41735. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41736. /**
  41737. * The callback that returns true if the data can be directly loaded.
  41738. */
  41739. canDirectLoad?: (data: string) => boolean;
  41740. /**
  41741. * The callback that allows custom handling of the root url based on the response url.
  41742. */
  41743. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41744. /**
  41745. * Load into an asset container.
  41746. * @param scene The scene to load into
  41747. * @param data The data to import
  41748. * @param rootUrl The root url for scene and resources
  41749. * @param onProgress The callback when the load progresses
  41750. * @param fileName Defines the name of the file to load
  41751. * @returns The loaded asset container
  41752. */
  41753. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41754. }
  41755. /**
  41756. * Class used to load scene from various file formats using registered plugins
  41757. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41758. */
  41759. export class SceneLoader {
  41760. /**
  41761. * No logging while loading
  41762. */
  41763. static readonly NO_LOGGING: number;
  41764. /**
  41765. * Minimal logging while loading
  41766. */
  41767. static readonly MINIMAL_LOGGING: number;
  41768. /**
  41769. * Summary logging while loading
  41770. */
  41771. static readonly SUMMARY_LOGGING: number;
  41772. /**
  41773. * Detailled logging while loading
  41774. */
  41775. static readonly DETAILED_LOGGING: number;
  41776. /**
  41777. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41778. */
  41779. static ForceFullSceneLoadingForIncremental: boolean;
  41780. /**
  41781. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41782. */
  41783. static ShowLoadingScreen: boolean;
  41784. /**
  41785. * Defines the current logging level (while loading the scene)
  41786. * @ignorenaming
  41787. */
  41788. static loggingLevel: number;
  41789. /**
  41790. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41791. */
  41792. static CleanBoneMatrixWeights: boolean;
  41793. /**
  41794. * Event raised when a plugin is used to load a scene
  41795. */
  41796. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41797. private static _registeredPlugins;
  41798. private static _getDefaultPlugin;
  41799. private static _getPluginForExtension;
  41800. private static _getPluginForDirectLoad;
  41801. private static _getPluginForFilename;
  41802. private static _getDirectLoad;
  41803. private static _loadData;
  41804. private static _getFileInfo;
  41805. /**
  41806. * Gets a plugin that can load the given extension
  41807. * @param extension defines the extension to load
  41808. * @returns a plugin or null if none works
  41809. */
  41810. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41811. /**
  41812. * Gets a boolean indicating that the given extension can be loaded
  41813. * @param extension defines the extension to load
  41814. * @returns true if the extension is supported
  41815. */
  41816. static IsPluginForExtensionAvailable(extension: string): boolean;
  41817. /**
  41818. * Adds a new plugin to the list of registered plugins
  41819. * @param plugin defines the plugin to add
  41820. */
  41821. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41822. /**
  41823. * Import meshes into a scene
  41824. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41825. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41826. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41827. * @param scene the instance of BABYLON.Scene to append to
  41828. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41829. * @param onProgress a callback with a progress event for each file being loaded
  41830. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41831. * @param pluginExtension the extension used to determine the plugin
  41832. * @returns The loaded plugin
  41833. */
  41834. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41835. /**
  41836. * Import meshes into a scene
  41837. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41838. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41839. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41840. * @param scene the instance of BABYLON.Scene to append to
  41841. * @param onProgress a callback with a progress event for each file being loaded
  41842. * @param pluginExtension the extension used to determine the plugin
  41843. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41844. */
  41845. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41846. meshes: AbstractMesh[];
  41847. particleSystems: IParticleSystem[];
  41848. skeletons: Skeleton[];
  41849. animationGroups: AnimationGroup[];
  41850. }>;
  41851. /**
  41852. * Load a scene
  41853. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41854. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41855. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41856. * @param onSuccess a callback with the scene when import succeeds
  41857. * @param onProgress a callback with a progress event for each file being loaded
  41858. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41859. * @param pluginExtension the extension used to determine the plugin
  41860. * @returns The loaded plugin
  41861. */
  41862. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<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>;
  41863. /**
  41864. * Load a scene
  41865. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41866. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41867. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41868. * @param onProgress a callback with a progress event for each file being loaded
  41869. * @param pluginExtension the extension used to determine the plugin
  41870. * @returns The loaded scene
  41871. */
  41872. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41873. /**
  41874. * Append a scene
  41875. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41876. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41877. * @param scene is the instance of BABYLON.Scene to append to
  41878. * @param onSuccess a callback with the scene when import succeeds
  41879. * @param onProgress a callback with a progress event for each file being loaded
  41880. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41881. * @param pluginExtension the extension used to determine the plugin
  41882. * @returns The loaded plugin
  41883. */
  41884. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<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>;
  41885. /**
  41886. * Append a scene
  41887. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41888. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41889. * @param scene is the instance of BABYLON.Scene to append to
  41890. * @param onProgress a callback with a progress event for each file being loaded
  41891. * @param pluginExtension the extension used to determine the plugin
  41892. * @returns The given scene
  41893. */
  41894. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41895. /**
  41896. * Load a scene into an asset container
  41897. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41898. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41899. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41900. * @param onSuccess a callback with the scene when import succeeds
  41901. * @param onProgress a callback with a progress event for each file being loaded
  41902. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41903. * @param pluginExtension the extension used to determine the plugin
  41904. * @returns The loaded plugin
  41905. */
  41906. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<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>;
  41907. /**
  41908. * Load a scene into an asset container
  41909. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41910. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  41911. * @param scene is the instance of Scene to append to
  41912. * @param onProgress a callback with a progress event for each file being loaded
  41913. * @param pluginExtension the extension used to determine the plugin
  41914. * @returns The loaded asset container
  41915. */
  41916. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41917. }
  41918. }
  41919. declare module BABYLON {
  41920. /**
  41921. * Generic Controller
  41922. */
  41923. export class GenericController extends WebVRController {
  41924. /**
  41925. * Base Url for the controller model.
  41926. */
  41927. static readonly MODEL_BASE_URL: string;
  41928. /**
  41929. * File name for the controller model.
  41930. */
  41931. static readonly MODEL_FILENAME: string;
  41932. /**
  41933. * Creates a new GenericController from a gamepad
  41934. * @param vrGamepad the gamepad that the controller should be created from
  41935. */
  41936. constructor(vrGamepad: any);
  41937. /**
  41938. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41939. * @param scene scene in which to add meshes
  41940. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41941. */
  41942. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41943. /**
  41944. * Called once for each button that changed state since the last frame
  41945. * @param buttonIdx Which button index changed
  41946. * @param state New state of the button
  41947. * @param changes Which properties on the state changed since last frame
  41948. */
  41949. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41950. }
  41951. }
  41952. declare module BABYLON {
  41953. /**
  41954. * Defines the WindowsMotionController object that the state of the windows motion controller
  41955. */
  41956. export class WindowsMotionController extends WebVRController {
  41957. /**
  41958. * The base url used to load the left and right controller models
  41959. */
  41960. static MODEL_BASE_URL: string;
  41961. /**
  41962. * The name of the left controller model file
  41963. */
  41964. static MODEL_LEFT_FILENAME: string;
  41965. /**
  41966. * The name of the right controller model file
  41967. */
  41968. static MODEL_RIGHT_FILENAME: string;
  41969. /**
  41970. * The controller name prefix for this controller type
  41971. */
  41972. static readonly GAMEPAD_ID_PREFIX: string;
  41973. /**
  41974. * The controller id pattern for this controller type
  41975. */
  41976. private static readonly GAMEPAD_ID_PATTERN;
  41977. private _loadedMeshInfo;
  41978. private readonly _mapping;
  41979. /**
  41980. * Fired when the trackpad on this controller is clicked
  41981. */
  41982. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41983. /**
  41984. * Fired when the trackpad on this controller is modified
  41985. */
  41986. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41987. /**
  41988. * The current x and y values of this controller's trackpad
  41989. */
  41990. trackpad: StickValues;
  41991. /**
  41992. * Creates a new WindowsMotionController from a gamepad
  41993. * @param vrGamepad the gamepad that the controller should be created from
  41994. */
  41995. constructor(vrGamepad: any);
  41996. /**
  41997. * Fired when the trigger on this controller is modified
  41998. */
  41999. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42000. /**
  42001. * Fired when the menu button on this controller is modified
  42002. */
  42003. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42004. /**
  42005. * Fired when the grip button on this controller is modified
  42006. */
  42007. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42008. /**
  42009. * Fired when the thumbstick button on this controller is modified
  42010. */
  42011. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42012. /**
  42013. * Fired when the touchpad button on this controller is modified
  42014. */
  42015. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42016. /**
  42017. * Fired when the touchpad values on this controller are modified
  42018. */
  42019. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42020. private _updateTrackpad;
  42021. /**
  42022. * Called once per frame by the engine.
  42023. */
  42024. update(): void;
  42025. /**
  42026. * Called once for each button that changed state since the last frame
  42027. * @param buttonIdx Which button index changed
  42028. * @param state New state of the button
  42029. * @param changes Which properties on the state changed since last frame
  42030. */
  42031. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42032. /**
  42033. * Moves the buttons on the controller mesh based on their current state
  42034. * @param buttonName the name of the button to move
  42035. * @param buttonValue the value of the button which determines the buttons new position
  42036. */
  42037. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42038. /**
  42039. * Moves the axis on the controller mesh based on its current state
  42040. * @param axis the index of the axis
  42041. * @param axisValue the value of the axis which determines the meshes new position
  42042. * @hidden
  42043. */
  42044. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42045. /**
  42046. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42047. * @param scene scene in which to add meshes
  42048. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42049. */
  42050. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42051. /**
  42052. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42053. * can be transformed by button presses and axes values, based on this._mapping.
  42054. *
  42055. * @param scene scene in which the meshes exist
  42056. * @param meshes list of meshes that make up the controller model to process
  42057. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42058. */
  42059. private processModel;
  42060. private createMeshInfo;
  42061. /**
  42062. * Gets the ray of the controller in the direction the controller is pointing
  42063. * @param length the length the resulting ray should be
  42064. * @returns a ray in the direction the controller is pointing
  42065. */
  42066. getForwardRay(length?: number): Ray;
  42067. /**
  42068. * Disposes of the controller
  42069. */
  42070. dispose(): void;
  42071. }
  42072. }
  42073. declare module BABYLON {
  42074. /**
  42075. * Oculus Touch Controller
  42076. */
  42077. export class OculusTouchController extends WebVRController {
  42078. /**
  42079. * Base Url for the controller model.
  42080. */
  42081. static MODEL_BASE_URL: string;
  42082. /**
  42083. * File name for the left controller model.
  42084. */
  42085. static MODEL_LEFT_FILENAME: string;
  42086. /**
  42087. * File name for the right controller model.
  42088. */
  42089. static MODEL_RIGHT_FILENAME: string;
  42090. /**
  42091. * Base Url for the Quest controller model.
  42092. */
  42093. static QUEST_MODEL_BASE_URL: string;
  42094. /**
  42095. * @hidden
  42096. * If the controllers are running on a device that needs the updated Quest controller models
  42097. */
  42098. static _IsQuest: boolean;
  42099. /**
  42100. * Fired when the secondary trigger on this controller is modified
  42101. */
  42102. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42103. /**
  42104. * Fired when the thumb rest on this controller is modified
  42105. */
  42106. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42107. /**
  42108. * Creates a new OculusTouchController from a gamepad
  42109. * @param vrGamepad the gamepad that the controller should be created from
  42110. */
  42111. constructor(vrGamepad: any);
  42112. /**
  42113. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42114. * @param scene scene in which to add meshes
  42115. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42116. */
  42117. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42118. /**
  42119. * Fired when the A button on this controller is modified
  42120. */
  42121. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42122. /**
  42123. * Fired when the B button on this controller is modified
  42124. */
  42125. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42126. /**
  42127. * Fired when the X button on this controller is modified
  42128. */
  42129. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42130. /**
  42131. * Fired when the Y button on this controller is modified
  42132. */
  42133. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42134. /**
  42135. * Called once for each button that changed state since the last frame
  42136. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42137. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42138. * 2) secondary trigger (same)
  42139. * 3) A (right) X (left), touch, pressed = value
  42140. * 4) B / Y
  42141. * 5) thumb rest
  42142. * @param buttonIdx Which button index changed
  42143. * @param state New state of the button
  42144. * @param changes Which properties on the state changed since last frame
  42145. */
  42146. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42147. }
  42148. }
  42149. declare module BABYLON {
  42150. /**
  42151. * Vive Controller
  42152. */
  42153. export class ViveController extends WebVRController {
  42154. /**
  42155. * Base Url for the controller model.
  42156. */
  42157. static MODEL_BASE_URL: string;
  42158. /**
  42159. * File name for the controller model.
  42160. */
  42161. static MODEL_FILENAME: string;
  42162. /**
  42163. * Creates a new ViveController from a gamepad
  42164. * @param vrGamepad the gamepad that the controller should be created from
  42165. */
  42166. constructor(vrGamepad: any);
  42167. /**
  42168. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42169. * @param scene scene in which to add meshes
  42170. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42171. */
  42172. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42173. /**
  42174. * Fired when the left button on this controller is modified
  42175. */
  42176. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42177. /**
  42178. * Fired when the right button on this controller is modified
  42179. */
  42180. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42181. /**
  42182. * Fired when the menu button on this controller is modified
  42183. */
  42184. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42185. /**
  42186. * Called once for each button that changed state since the last frame
  42187. * Vive mapping:
  42188. * 0: touchpad
  42189. * 1: trigger
  42190. * 2: left AND right buttons
  42191. * 3: menu button
  42192. * @param buttonIdx Which button index changed
  42193. * @param state New state of the button
  42194. * @param changes Which properties on the state changed since last frame
  42195. */
  42196. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42197. }
  42198. }
  42199. declare module BABYLON {
  42200. /**
  42201. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42202. */
  42203. export class WebXRControllerModelLoader {
  42204. /**
  42205. * Creates the WebXRControllerModelLoader
  42206. * @param input xr input that creates the controllers
  42207. */
  42208. constructor(input: WebXRInput);
  42209. }
  42210. }
  42211. declare module BABYLON {
  42212. /**
  42213. * Contains an array of blocks representing the octree
  42214. */
  42215. export interface IOctreeContainer<T> {
  42216. /**
  42217. * Blocks within the octree
  42218. */
  42219. blocks: Array<OctreeBlock<T>>;
  42220. }
  42221. /**
  42222. * Class used to store a cell in an octree
  42223. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42224. */
  42225. export class OctreeBlock<T> {
  42226. /**
  42227. * Gets the content of the current block
  42228. */
  42229. entries: T[];
  42230. /**
  42231. * Gets the list of block children
  42232. */
  42233. blocks: Array<OctreeBlock<T>>;
  42234. private _depth;
  42235. private _maxDepth;
  42236. private _capacity;
  42237. private _minPoint;
  42238. private _maxPoint;
  42239. private _boundingVectors;
  42240. private _creationFunc;
  42241. /**
  42242. * Creates a new block
  42243. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42244. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42245. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42246. * @param depth defines the current depth of this block in the octree
  42247. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42248. * @param creationFunc defines a callback to call when an element is added to the block
  42249. */
  42250. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42251. /**
  42252. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42253. */
  42254. readonly capacity: number;
  42255. /**
  42256. * Gets the minimum vector (in world space) of the block's bounding box
  42257. */
  42258. readonly minPoint: Vector3;
  42259. /**
  42260. * Gets the maximum vector (in world space) of the block's bounding box
  42261. */
  42262. readonly maxPoint: Vector3;
  42263. /**
  42264. * Add a new element to this block
  42265. * @param entry defines the element to add
  42266. */
  42267. addEntry(entry: T): void;
  42268. /**
  42269. * Remove an element from this block
  42270. * @param entry defines the element to remove
  42271. */
  42272. removeEntry(entry: T): void;
  42273. /**
  42274. * Add an array of elements to this block
  42275. * @param entries defines the array of elements to add
  42276. */
  42277. addEntries(entries: T[]): void;
  42278. /**
  42279. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42280. * @param frustumPlanes defines the frustum planes to test
  42281. * @param selection defines the array to store current content if selection is positive
  42282. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42283. */
  42284. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42285. /**
  42286. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42287. * @param sphereCenter defines the bounding sphere center
  42288. * @param sphereRadius defines the bounding sphere radius
  42289. * @param selection defines the array to store current content if selection is positive
  42290. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42291. */
  42292. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42293. /**
  42294. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42295. * @param ray defines the ray to test with
  42296. * @param selection defines the array to store current content if selection is positive
  42297. */
  42298. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42299. /**
  42300. * Subdivide the content into child blocks (this block will then be empty)
  42301. */
  42302. createInnerBlocks(): void;
  42303. /**
  42304. * @hidden
  42305. */
  42306. 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;
  42307. }
  42308. }
  42309. declare module BABYLON {
  42310. /**
  42311. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42312. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42313. */
  42314. export class Octree<T> {
  42315. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  42316. maxDepth: number;
  42317. /**
  42318. * Blocks within the octree containing objects
  42319. */
  42320. blocks: Array<OctreeBlock<T>>;
  42321. /**
  42322. * Content stored in the octree
  42323. */
  42324. dynamicContent: T[];
  42325. private _maxBlockCapacity;
  42326. private _selectionContent;
  42327. private _creationFunc;
  42328. /**
  42329. * Creates a octree
  42330. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42331. * @param creationFunc function to be used to instatiate the octree
  42332. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42333. * @param maxDepth defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)
  42334. */
  42335. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42336. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  42337. maxDepth?: number);
  42338. /**
  42339. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42340. * @param worldMin worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  42341. * @param worldMax worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  42342. * @param entries meshes to be added to the octree blocks
  42343. */
  42344. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42345. /**
  42346. * Adds a mesh to the octree
  42347. * @param entry Mesh to add to the octree
  42348. */
  42349. addMesh(entry: T): void;
  42350. /**
  42351. * Remove an element from the octree
  42352. * @param entry defines the element to remove
  42353. */
  42354. removeMesh(entry: T): void;
  42355. /**
  42356. * Selects an array of meshes within the frustum
  42357. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42358. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42359. * @returns array of meshes within the frustum
  42360. */
  42361. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42362. /**
  42363. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42364. * @param sphereCenter defines the bounding sphere center
  42365. * @param sphereRadius defines the bounding sphere radius
  42366. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42367. * @returns an array of objects that intersect the sphere
  42368. */
  42369. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42370. /**
  42371. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42372. * @param ray defines the ray to test with
  42373. * @returns array of intersected objects
  42374. */
  42375. intersectsRay(ray: Ray): SmartArray<T>;
  42376. /**
  42377. * Adds a mesh into the octree block if it intersects the block
  42378. */
  42379. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42380. /**
  42381. * Adds a submesh into the octree block if it intersects the block
  42382. */
  42383. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42384. }
  42385. }
  42386. declare module BABYLON {
  42387. interface Scene {
  42388. /**
  42389. * @hidden
  42390. * Backing Filed
  42391. */
  42392. _selectionOctree: Octree<AbstractMesh>;
  42393. /**
  42394. * Gets the octree used to boost mesh selection (picking)
  42395. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42396. */
  42397. selectionOctree: Octree<AbstractMesh>;
  42398. /**
  42399. * Creates or updates the octree used to boost selection (picking)
  42400. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42401. * @param maxCapacity defines the maximum capacity per leaf
  42402. * @param maxDepth defines the maximum depth of the octree
  42403. * @returns an octree of AbstractMesh
  42404. */
  42405. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42406. }
  42407. interface AbstractMesh {
  42408. /**
  42409. * @hidden
  42410. * Backing Field
  42411. */
  42412. _submeshesOctree: Octree<SubMesh>;
  42413. /**
  42414. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42415. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42416. * @param maxCapacity defines the maximum size of each block (64 by default)
  42417. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42418. * @returns the new octree
  42419. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42421. */
  42422. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42423. }
  42424. /**
  42425. * Defines the octree scene component responsible to manage any octrees
  42426. * in a given scene.
  42427. */
  42428. export class OctreeSceneComponent {
  42429. /**
  42430. * The component name help to identify the component in the list of scene components.
  42431. */
  42432. readonly name: string;
  42433. /**
  42434. * The scene the component belongs to.
  42435. */
  42436. scene: Scene;
  42437. /**
  42438. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42439. */
  42440. readonly checksIsEnabled: boolean;
  42441. /**
  42442. * Creates a new instance of the component for the given scene
  42443. * @param scene Defines the scene to register the component in
  42444. */
  42445. constructor(scene: Scene);
  42446. /**
  42447. * Registers the component in a given scene
  42448. */
  42449. register(): void;
  42450. /**
  42451. * Return the list of active meshes
  42452. * @returns the list of active meshes
  42453. */
  42454. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42455. /**
  42456. * Return the list of active sub meshes
  42457. * @param mesh The mesh to get the candidates sub meshes from
  42458. * @returns the list of active sub meshes
  42459. */
  42460. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42461. private _tempRay;
  42462. /**
  42463. * Return the list of sub meshes intersecting with a given local ray
  42464. * @param mesh defines the mesh to find the submesh for
  42465. * @param localRay defines the ray in local space
  42466. * @returns the list of intersecting sub meshes
  42467. */
  42468. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42469. /**
  42470. * Return the list of sub meshes colliding with a collider
  42471. * @param mesh defines the mesh to find the submesh for
  42472. * @param collider defines the collider to evaluate the collision against
  42473. * @returns the list of colliding sub meshes
  42474. */
  42475. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42476. /**
  42477. * Rebuilds the elements related to this component in case of
  42478. * context lost for instance.
  42479. */
  42480. rebuild(): void;
  42481. /**
  42482. * Disposes the component and the associated ressources.
  42483. */
  42484. dispose(): void;
  42485. }
  42486. }
  42487. declare module BABYLON {
  42488. /**
  42489. * Renders a layer on top of an existing scene
  42490. */
  42491. export class UtilityLayerRenderer implements IDisposable {
  42492. /** the original scene that will be rendered on top of */
  42493. originalScene: Scene;
  42494. private _pointerCaptures;
  42495. private _lastPointerEvents;
  42496. private static _DefaultUtilityLayer;
  42497. private static _DefaultKeepDepthUtilityLayer;
  42498. private _sharedGizmoLight;
  42499. private _renderCamera;
  42500. /**
  42501. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42502. * @returns the camera that is used when rendering the utility layer
  42503. */
  42504. getRenderCamera(): Nullable<Camera>;
  42505. /**
  42506. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42507. * @param cam the camera that should be used when rendering the utility layer
  42508. */
  42509. setRenderCamera(cam: Nullable<Camera>): void;
  42510. /**
  42511. * @hidden
  42512. * Light which used by gizmos to get light shading
  42513. */
  42514. _getSharedGizmoLight(): HemisphericLight;
  42515. /**
  42516. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42517. */
  42518. pickUtilitySceneFirst: boolean;
  42519. /**
  42520. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  42521. */
  42522. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42523. /**
  42524. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  42525. */
  42526. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42527. /**
  42528. * The scene that is rendered on top of the original scene
  42529. */
  42530. utilityLayerScene: Scene;
  42531. /**
  42532. * If the utility layer should automatically be rendered on top of existing scene
  42533. */
  42534. shouldRender: boolean;
  42535. /**
  42536. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42537. */
  42538. onlyCheckPointerDownEvents: boolean;
  42539. /**
  42540. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42541. */
  42542. processAllEvents: boolean;
  42543. /**
  42544. * Observable raised when the pointer move from the utility layer scene to the main scene
  42545. */
  42546. onPointerOutObservable: Observable<number>;
  42547. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42548. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42549. private _afterRenderObserver;
  42550. private _sceneDisposeObserver;
  42551. private _originalPointerObserver;
  42552. /**
  42553. * Instantiates a UtilityLayerRenderer
  42554. * @param originalScene the original scene that will be rendered on top of
  42555. * @param handleEvents boolean indicating if the utility layer should handle events
  42556. */
  42557. constructor(
  42558. /** the original scene that will be rendered on top of */
  42559. originalScene: Scene, handleEvents?: boolean);
  42560. private _notifyObservers;
  42561. /**
  42562. * Renders the utility layers scene on top of the original scene
  42563. */
  42564. render(): void;
  42565. /**
  42566. * Disposes of the renderer
  42567. */
  42568. dispose(): void;
  42569. private _updateCamera;
  42570. }
  42571. }
  42572. declare module BABYLON {
  42573. /**
  42574. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42575. */
  42576. export class Gizmo implements IDisposable {
  42577. /** The utility layer the gizmo will be added to */
  42578. gizmoLayer: UtilityLayerRenderer;
  42579. /**
  42580. * The root mesh of the gizmo
  42581. */
  42582. _rootMesh: Mesh;
  42583. private _attachedMesh;
  42584. /**
  42585. * Ratio for the scale of the gizmo (Default: 1)
  42586. */
  42587. scaleRatio: number;
  42588. /**
  42589. * If a custom mesh has been set (Default: false)
  42590. */
  42591. protected _customMeshSet: boolean;
  42592. /**
  42593. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42594. * * When set, interactions will be enabled
  42595. */
  42596. attachedMesh: Nullable<AbstractMesh>;
  42597. /**
  42598. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42599. * @param mesh The mesh to replace the default mesh of the gizmo
  42600. */
  42601. setCustomMesh(mesh: Mesh): void;
  42602. /**
  42603. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42604. */
  42605. updateGizmoRotationToMatchAttachedMesh: boolean;
  42606. /**
  42607. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42608. */
  42609. updateGizmoPositionToMatchAttachedMesh: boolean;
  42610. /**
  42611. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42612. */
  42613. updateScale: boolean;
  42614. protected _interactionsEnabled: boolean;
  42615. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42616. private _beforeRenderObserver;
  42617. private _tempVector;
  42618. /**
  42619. * Creates a gizmo
  42620. * @param gizmoLayer The utility layer the gizmo will be added to
  42621. */
  42622. constructor(
  42623. /** The utility layer the gizmo will be added to */
  42624. gizmoLayer?: UtilityLayerRenderer);
  42625. /**
  42626. * Updates the gizmo to match the attached mesh's position/rotation
  42627. */
  42628. protected _update(): void;
  42629. /**
  42630. * Disposes of the gizmo
  42631. */
  42632. dispose(): void;
  42633. }
  42634. }
  42635. declare module BABYLON {
  42636. /**
  42637. * Single plane drag gizmo
  42638. */
  42639. export class PlaneDragGizmo extends Gizmo {
  42640. /**
  42641. * Drag behavior responsible for the gizmos dragging interactions
  42642. */
  42643. dragBehavior: PointerDragBehavior;
  42644. private _pointerObserver;
  42645. /**
  42646. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42647. */
  42648. snapDistance: number;
  42649. /**
  42650. * Event that fires each time the gizmo snaps to a new location.
  42651. * * snapDistance is the the change in distance
  42652. */
  42653. onSnapObservable: Observable<{
  42654. snapDistance: number;
  42655. }>;
  42656. private _plane;
  42657. private _coloredMaterial;
  42658. private _hoverMaterial;
  42659. private _isEnabled;
  42660. private _parent;
  42661. /** @hidden */
  42662. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42663. /** @hidden */
  42664. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42665. /**
  42666. * Creates a PlaneDragGizmo
  42667. * @param gizmoLayer The utility layer the gizmo will be added to
  42668. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42669. * @param color The color of the gizmo
  42670. */
  42671. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42672. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42673. /**
  42674. * If the gizmo is enabled
  42675. */
  42676. isEnabled: boolean;
  42677. /**
  42678. * Disposes of the gizmo
  42679. */
  42680. dispose(): void;
  42681. }
  42682. }
  42683. declare module BABYLON {
  42684. /**
  42685. * Gizmo that enables dragging a mesh along 3 axis
  42686. */
  42687. export class PositionGizmo extends Gizmo {
  42688. /**
  42689. * Internal gizmo used for interactions on the x axis
  42690. */
  42691. xGizmo: AxisDragGizmo;
  42692. /**
  42693. * Internal gizmo used for interactions on the y axis
  42694. */
  42695. yGizmo: AxisDragGizmo;
  42696. /**
  42697. * Internal gizmo used for interactions on the z axis
  42698. */
  42699. zGizmo: AxisDragGizmo;
  42700. /**
  42701. * Internal gizmo used for interactions on the yz plane
  42702. */
  42703. xPlaneGizmo: PlaneDragGizmo;
  42704. /**
  42705. * Internal gizmo used for interactions on the xz plane
  42706. */
  42707. yPlaneGizmo: PlaneDragGizmo;
  42708. /**
  42709. * Internal gizmo used for interactions on the xy plane
  42710. */
  42711. zPlaneGizmo: PlaneDragGizmo;
  42712. /**
  42713. * private variables
  42714. */
  42715. private _meshAttached;
  42716. private _updateGizmoRotationToMatchAttachedMesh;
  42717. private _snapDistance;
  42718. private _scaleRatio;
  42719. /** Fires an event when any of it's sub gizmos are dragged */
  42720. onDragStartObservable: Observable<unknown>;
  42721. /** Fires an event when any of it's sub gizmos are released from dragging */
  42722. onDragEndObservable: Observable<unknown>;
  42723. /**
  42724. * If set to true, planar drag is enabled
  42725. */
  42726. private _planarGizmoEnabled;
  42727. attachedMesh: Nullable<AbstractMesh>;
  42728. /**
  42729. * Creates a PositionGizmo
  42730. * @param gizmoLayer The utility layer the gizmo will be added to
  42731. */
  42732. constructor(gizmoLayer?: UtilityLayerRenderer);
  42733. /**
  42734. * If the planar drag gizmo is enabled
  42735. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42736. */
  42737. planarGizmoEnabled: boolean;
  42738. updateGizmoRotationToMatchAttachedMesh: boolean;
  42739. /**
  42740. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42741. */
  42742. snapDistance: number;
  42743. /**
  42744. * Ratio for the scale of the gizmo (Default: 1)
  42745. */
  42746. scaleRatio: number;
  42747. /**
  42748. * Disposes of the gizmo
  42749. */
  42750. dispose(): void;
  42751. /**
  42752. * CustomMeshes are not supported by this gizmo
  42753. * @param mesh The mesh to replace the default mesh of the gizmo
  42754. */
  42755. setCustomMesh(mesh: Mesh): void;
  42756. }
  42757. }
  42758. declare module BABYLON {
  42759. /**
  42760. * Single axis drag gizmo
  42761. */
  42762. export class AxisDragGizmo extends Gizmo {
  42763. /**
  42764. * Drag behavior responsible for the gizmos dragging interactions
  42765. */
  42766. dragBehavior: PointerDragBehavior;
  42767. private _pointerObserver;
  42768. /**
  42769. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42770. */
  42771. snapDistance: number;
  42772. /**
  42773. * Event that fires each time the gizmo snaps to a new location.
  42774. * * snapDistance is the the change in distance
  42775. */
  42776. onSnapObservable: Observable<{
  42777. snapDistance: number;
  42778. }>;
  42779. private _isEnabled;
  42780. private _parent;
  42781. private _arrow;
  42782. private _coloredMaterial;
  42783. private _hoverMaterial;
  42784. /** @hidden */
  42785. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42786. /** @hidden */
  42787. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42788. /**
  42789. * Creates an AxisDragGizmo
  42790. * @param gizmoLayer The utility layer the gizmo will be added to
  42791. * @param dragAxis The axis which the gizmo will be able to drag on
  42792. * @param color The color of the gizmo
  42793. */
  42794. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42795. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42796. /**
  42797. * If the gizmo is enabled
  42798. */
  42799. isEnabled: boolean;
  42800. /**
  42801. * Disposes of the gizmo
  42802. */
  42803. dispose(): void;
  42804. }
  42805. }
  42806. declare module BABYLON.Debug {
  42807. /**
  42808. * The Axes viewer will show 3 axes in a specific point in space
  42809. */
  42810. export class AxesViewer {
  42811. private _xAxis;
  42812. private _yAxis;
  42813. private _zAxis;
  42814. private _scaleLinesFactor;
  42815. private _instanced;
  42816. /**
  42817. * Gets the hosting scene
  42818. */
  42819. scene: Scene;
  42820. /**
  42821. * Gets or sets a number used to scale line length
  42822. */
  42823. scaleLines: number;
  42824. /** Gets the node hierarchy used to render x-axis */
  42825. readonly xAxis: TransformNode;
  42826. /** Gets the node hierarchy used to render y-axis */
  42827. readonly yAxis: TransformNode;
  42828. /** Gets the node hierarchy used to render z-axis */
  42829. readonly zAxis: TransformNode;
  42830. /**
  42831. * Creates a new AxesViewer
  42832. * @param scene defines the hosting scene
  42833. * @param scaleLines defines a number used to scale line length (1 by default)
  42834. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42835. * @param xAxis defines the node hierarchy used to render the x-axis
  42836. * @param yAxis defines the node hierarchy used to render the y-axis
  42837. * @param zAxis defines the node hierarchy used to render the z-axis
  42838. */
  42839. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42840. /**
  42841. * Force the viewer to update
  42842. * @param position defines the position of the viewer
  42843. * @param xaxis defines the x axis of the viewer
  42844. * @param yaxis defines the y axis of the viewer
  42845. * @param zaxis defines the z axis of the viewer
  42846. */
  42847. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42848. /**
  42849. * Creates an instance of this axes viewer.
  42850. * @returns a new axes viewer with instanced meshes
  42851. */
  42852. createInstance(): AxesViewer;
  42853. /** Releases resources */
  42854. dispose(): void;
  42855. private static _SetRenderingGroupId;
  42856. }
  42857. }
  42858. declare module BABYLON.Debug {
  42859. /**
  42860. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42861. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42862. */
  42863. export class BoneAxesViewer extends AxesViewer {
  42864. /**
  42865. * Gets or sets the target mesh where to display the axes viewer
  42866. */
  42867. mesh: Nullable<Mesh>;
  42868. /**
  42869. * Gets or sets the target bone where to display the axes viewer
  42870. */
  42871. bone: Nullable<Bone>;
  42872. /** Gets current position */
  42873. pos: Vector3;
  42874. /** Gets direction of X axis */
  42875. xaxis: Vector3;
  42876. /** Gets direction of Y axis */
  42877. yaxis: Vector3;
  42878. /** Gets direction of Z axis */
  42879. zaxis: Vector3;
  42880. /**
  42881. * Creates a new BoneAxesViewer
  42882. * @param scene defines the hosting scene
  42883. * @param bone defines the target bone
  42884. * @param mesh defines the target mesh
  42885. * @param scaleLines defines a scaling factor for line length (1 by default)
  42886. */
  42887. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42888. /**
  42889. * Force the viewer to update
  42890. */
  42891. update(): void;
  42892. /** Releases resources */
  42893. dispose(): void;
  42894. }
  42895. }
  42896. declare module BABYLON {
  42897. /**
  42898. * Interface used to define scene explorer extensibility option
  42899. */
  42900. export interface IExplorerExtensibilityOption {
  42901. /**
  42902. * Define the option label
  42903. */
  42904. label: string;
  42905. /**
  42906. * Defines the action to execute on click
  42907. */
  42908. action: (entity: any) => void;
  42909. }
  42910. /**
  42911. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42912. */
  42913. export interface IExplorerExtensibilityGroup {
  42914. /**
  42915. * Defines a predicate to test if a given type mut be extended
  42916. */
  42917. predicate: (entity: any) => boolean;
  42918. /**
  42919. * Gets the list of options added to a type
  42920. */
  42921. entries: IExplorerExtensibilityOption[];
  42922. }
  42923. /**
  42924. * Interface used to define the options to use to create the Inspector
  42925. */
  42926. export interface IInspectorOptions {
  42927. /**
  42928. * Display in overlay mode (default: false)
  42929. */
  42930. overlay?: boolean;
  42931. /**
  42932. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42933. */
  42934. globalRoot?: HTMLElement;
  42935. /**
  42936. * Display the Scene explorer
  42937. */
  42938. showExplorer?: boolean;
  42939. /**
  42940. * Display the property inspector
  42941. */
  42942. showInspector?: boolean;
  42943. /**
  42944. * Display in embed mode (both panes on the right)
  42945. */
  42946. embedMode?: boolean;
  42947. /**
  42948. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42949. */
  42950. handleResize?: boolean;
  42951. /**
  42952. * Allow the panes to popup (default: true)
  42953. */
  42954. enablePopup?: boolean;
  42955. /**
  42956. * Allow the panes to be closed by users (default: true)
  42957. */
  42958. enableClose?: boolean;
  42959. /**
  42960. * Optional list of extensibility entries
  42961. */
  42962. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42963. /**
  42964. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42965. */
  42966. inspectorURL?: string;
  42967. }
  42968. interface Scene {
  42969. /**
  42970. * @hidden
  42971. * Backing field
  42972. */
  42973. _debugLayer: DebugLayer;
  42974. /**
  42975. * Gets the debug layer (aka Inspector) associated with the scene
  42976. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42977. */
  42978. debugLayer: DebugLayer;
  42979. }
  42980. /**
  42981. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42982. * what is happening in your scene
  42983. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42984. */
  42985. export class DebugLayer {
  42986. /**
  42987. * Define the url to get the inspector script from.
  42988. * By default it uses the babylonjs CDN.
  42989. * @ignoreNaming
  42990. */
  42991. static InspectorURL: string;
  42992. private _scene;
  42993. private BJSINSPECTOR;
  42994. private _onPropertyChangedObservable?;
  42995. /**
  42996. * Observable triggered when a property is changed through the inspector.
  42997. */
  42998. readonly onPropertyChangedObservable: any;
  42999. /**
  43000. * Instantiates a new debug layer.
  43001. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43002. * what is happening in your scene
  43003. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43004. * @param scene Defines the scene to inspect
  43005. */
  43006. constructor(scene: Scene);
  43007. /** Creates the inspector window. */
  43008. private _createInspector;
  43009. /**
  43010. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43011. * @param entity defines the entity to select
  43012. * @param lineContainerTitle defines the specific block to highlight
  43013. */
  43014. select(entity: any, lineContainerTitle?: string): void;
  43015. /** Get the inspector from bundle or global */
  43016. private _getGlobalInspector;
  43017. /**
  43018. * Get if the inspector is visible or not.
  43019. * @returns true if visible otherwise, false
  43020. */
  43021. isVisible(): boolean;
  43022. /**
  43023. * Hide the inspector and close its window.
  43024. */
  43025. hide(): void;
  43026. /**
  43027. * Launch the debugLayer.
  43028. * @param config Define the configuration of the inspector
  43029. * @return a promise fulfilled when the debug layer is visible
  43030. */
  43031. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43032. }
  43033. }
  43034. declare module BABYLON {
  43035. /**
  43036. * Class containing static functions to help procedurally build meshes
  43037. */
  43038. export class BoxBuilder {
  43039. /**
  43040. * Creates a box mesh
  43041. * * The parameter `size` sets the size (float) of each box side (default 1)
  43042. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43043. * * 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)
  43044. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43046. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43048. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43049. * @param name defines the name of the mesh
  43050. * @param options defines the options used to create the mesh
  43051. * @param scene defines the hosting scene
  43052. * @returns the box mesh
  43053. */
  43054. static CreateBox(name: string, options: {
  43055. size?: number;
  43056. width?: number;
  43057. height?: number;
  43058. depth?: number;
  43059. faceUV?: Vector4[];
  43060. faceColors?: Color4[];
  43061. sideOrientation?: number;
  43062. frontUVs?: Vector4;
  43063. backUVs?: Vector4;
  43064. wrap?: boolean;
  43065. topBaseAt?: number;
  43066. bottomBaseAt?: number;
  43067. updatable?: boolean;
  43068. }, scene?: Nullable<Scene>): Mesh;
  43069. }
  43070. }
  43071. declare module BABYLON {
  43072. /**
  43073. * Class containing static functions to help procedurally build meshes
  43074. */
  43075. export class SphereBuilder {
  43076. /**
  43077. * Creates a sphere mesh
  43078. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43079. * * 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 of `diameter`)
  43080. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43081. * * 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
  43082. * * 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)
  43083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43084. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43086. * @param name defines the name of the mesh
  43087. * @param options defines the options used to create the mesh
  43088. * @param scene defines the hosting scene
  43089. * @returns the sphere mesh
  43090. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43091. */
  43092. static CreateSphere(name: string, options: {
  43093. segments?: number;
  43094. diameter?: number;
  43095. diameterX?: number;
  43096. diameterY?: number;
  43097. diameterZ?: number;
  43098. arc?: number;
  43099. slice?: number;
  43100. sideOrientation?: number;
  43101. frontUVs?: Vector4;
  43102. backUVs?: Vector4;
  43103. updatable?: boolean;
  43104. }, scene?: Nullable<Scene>): Mesh;
  43105. }
  43106. }
  43107. declare module BABYLON.Debug {
  43108. /**
  43109. * Used to show the physics impostor around the specific mesh
  43110. */
  43111. export class PhysicsViewer {
  43112. /** @hidden */
  43113. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43114. /** @hidden */
  43115. protected _meshes: Array<Nullable<AbstractMesh>>;
  43116. /** @hidden */
  43117. protected _scene: Nullable<Scene>;
  43118. /** @hidden */
  43119. protected _numMeshes: number;
  43120. /** @hidden */
  43121. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43122. private _renderFunction;
  43123. private _utilityLayer;
  43124. private _debugBoxMesh;
  43125. private _debugSphereMesh;
  43126. private _debugCylinderMesh;
  43127. private _debugMaterial;
  43128. private _debugMeshMeshes;
  43129. /**
  43130. * Creates a new PhysicsViewer
  43131. * @param scene defines the hosting scene
  43132. */
  43133. constructor(scene: Scene);
  43134. /** @hidden */
  43135. protected _updateDebugMeshes(): void;
  43136. /**
  43137. * Renders a specified physic impostor
  43138. * @param impostor defines the impostor to render
  43139. * @param targetMesh defines the mesh represented by the impostor
  43140. * @returns the new debug mesh used to render the impostor
  43141. */
  43142. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43143. /**
  43144. * Hides a specified physic impostor
  43145. * @param impostor defines the impostor to hide
  43146. */
  43147. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43148. private _getDebugMaterial;
  43149. private _getDebugBoxMesh;
  43150. private _getDebugSphereMesh;
  43151. private _getDebugCylinderMesh;
  43152. private _getDebugMeshMesh;
  43153. private _getDebugMesh;
  43154. /** Releases all resources */
  43155. dispose(): void;
  43156. }
  43157. }
  43158. declare module BABYLON {
  43159. /**
  43160. * Class containing static functions to help procedurally build meshes
  43161. */
  43162. export class LinesBuilder {
  43163. /**
  43164. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43165. * * 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
  43166. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43167. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43168. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43169. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43170. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43171. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  43172. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43175. * @param name defines the name of the new line system
  43176. * @param options defines the options used to create the line system
  43177. * @param scene defines the hosting scene
  43178. * @returns a new line system mesh
  43179. */
  43180. static CreateLineSystem(name: string, options: {
  43181. lines: Vector3[][];
  43182. updatable?: boolean;
  43183. instance?: Nullable<LinesMesh>;
  43184. colors?: Nullable<Color4[][]>;
  43185. useVertexAlpha?: boolean;
  43186. }, scene: Nullable<Scene>): LinesMesh;
  43187. /**
  43188. * Creates a line mesh
  43189. * 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
  43190. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43191. * * The parameter `points` is an array successive Vector3
  43192. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  43193. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43194. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43195. * * When updating an instance, remember that only point positions can change, not the number of points
  43196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43198. * @param name defines the name of the new line system
  43199. * @param options defines the options used to create the line system
  43200. * @param scene defines the hosting scene
  43201. * @returns a new line mesh
  43202. */
  43203. static CreateLines(name: string, options: {
  43204. points: Vector3[];
  43205. updatable?: boolean;
  43206. instance?: Nullable<LinesMesh>;
  43207. colors?: Color4[];
  43208. useVertexAlpha?: boolean;
  43209. }, scene?: Nullable<Scene>): LinesMesh;
  43210. /**
  43211. * Creates a dashed line mesh
  43212. * * 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
  43213. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43214. * * The parameter `points` is an array successive Vector3
  43215. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43216. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43217. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43218. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  43219. * * When updating an instance, remember that only point positions can change, not the number of points
  43220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43221. * @param name defines the name of the mesh
  43222. * @param options defines the options used to create the mesh
  43223. * @param scene defines the hosting scene
  43224. * @returns the dashed line mesh
  43225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43226. */
  43227. static CreateDashedLines(name: string, options: {
  43228. points: Vector3[];
  43229. dashSize?: number;
  43230. gapSize?: number;
  43231. dashNb?: number;
  43232. updatable?: boolean;
  43233. instance?: LinesMesh;
  43234. }, scene?: Nullable<Scene>): LinesMesh;
  43235. }
  43236. }
  43237. declare module BABYLON {
  43238. /**
  43239. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43240. * in order to better appreciate the issue one might have.
  43241. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43242. */
  43243. export class RayHelper {
  43244. /**
  43245. * Defines the ray we are currently tryin to visualize.
  43246. */
  43247. ray: Nullable<Ray>;
  43248. private _renderPoints;
  43249. private _renderLine;
  43250. private _renderFunction;
  43251. private _scene;
  43252. private _updateToMeshFunction;
  43253. private _attachedToMesh;
  43254. private _meshSpaceDirection;
  43255. private _meshSpaceOrigin;
  43256. /**
  43257. * Helper function to create a colored helper in a scene in one line.
  43258. * @param ray Defines the ray we are currently tryin to visualize
  43259. * @param scene Defines the scene the ray is used in
  43260. * @param color Defines the color we want to see the ray in
  43261. * @returns The newly created ray helper.
  43262. */
  43263. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43264. /**
  43265. * Instantiate a new ray helper.
  43266. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43267. * in order to better appreciate the issue one might have.
  43268. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43269. * @param ray Defines the ray we are currently tryin to visualize
  43270. */
  43271. constructor(ray: Ray);
  43272. /**
  43273. * Shows the ray we are willing to debug.
  43274. * @param scene Defines the scene the ray needs to be rendered in
  43275. * @param color Defines the color the ray needs to be rendered in
  43276. */
  43277. show(scene: Scene, color?: Color3): void;
  43278. /**
  43279. * Hides the ray we are debugging.
  43280. */
  43281. hide(): void;
  43282. private _render;
  43283. /**
  43284. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43285. * @param mesh Defines the mesh we want the helper attached to
  43286. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43287. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43288. * @param length Defines the length of the ray
  43289. */
  43290. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43291. /**
  43292. * Detach the ray helper from the mesh it has previously been attached to.
  43293. */
  43294. detachFromMesh(): void;
  43295. private _updateToMesh;
  43296. /**
  43297. * Dispose the helper and release its associated resources.
  43298. */
  43299. dispose(): void;
  43300. }
  43301. }
  43302. declare module BABYLON.Debug {
  43303. /**
  43304. * Class used to render a debug view of a given skeleton
  43305. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43306. */
  43307. export class SkeletonViewer {
  43308. /** defines the skeleton to render */
  43309. skeleton: Skeleton;
  43310. /** defines the mesh attached to the skeleton */
  43311. mesh: AbstractMesh;
  43312. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43313. autoUpdateBonesMatrices: boolean;
  43314. /** defines the rendering group id to use with the viewer */
  43315. renderingGroupId: number;
  43316. /** Gets or sets the color used to render the skeleton */
  43317. color: Color3;
  43318. private _scene;
  43319. private _debugLines;
  43320. private _debugMesh;
  43321. private _isEnabled;
  43322. private _renderFunction;
  43323. private _utilityLayer;
  43324. /**
  43325. * Returns the mesh used to render the bones
  43326. */
  43327. readonly debugMesh: Nullable<LinesMesh>;
  43328. /**
  43329. * Creates a new SkeletonViewer
  43330. * @param skeleton defines the skeleton to render
  43331. * @param mesh defines the mesh attached to the skeleton
  43332. * @param scene defines the hosting scene
  43333. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43334. * @param renderingGroupId defines the rendering group id to use with the viewer
  43335. */
  43336. constructor(
  43337. /** defines the skeleton to render */
  43338. skeleton: Skeleton,
  43339. /** defines the mesh attached to the skeleton */
  43340. mesh: AbstractMesh, scene: Scene,
  43341. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43342. autoUpdateBonesMatrices?: boolean,
  43343. /** defines the rendering group id to use with the viewer */
  43344. renderingGroupId?: number);
  43345. /** Gets or sets a boolean indicating if the viewer is enabled */
  43346. isEnabled: boolean;
  43347. private _getBonePosition;
  43348. private _getLinesForBonesWithLength;
  43349. private _getLinesForBonesNoLength;
  43350. /** Update the viewer to sync with current skeleton state */
  43351. update(): void;
  43352. /** Release associated resources */
  43353. dispose(): void;
  43354. }
  43355. }
  43356. declare module BABYLON {
  43357. /**
  43358. * Options to create the null engine
  43359. */
  43360. export class NullEngineOptions {
  43361. /**
  43362. * Render width (Default: 512)
  43363. */
  43364. renderWidth: number;
  43365. /**
  43366. * Render height (Default: 256)
  43367. */
  43368. renderHeight: number;
  43369. /**
  43370. * Texture size (Default: 512)
  43371. */
  43372. textureSize: number;
  43373. /**
  43374. * If delta time between frames should be constant
  43375. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43376. */
  43377. deterministicLockstep: boolean;
  43378. /**
  43379. * Maximum about of steps between frames (Default: 4)
  43380. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43381. */
  43382. lockstepMaxSteps: number;
  43383. }
  43384. /**
  43385. * The null engine class provides support for headless version of babylon.js.
  43386. * This can be used in server side scenario or for testing purposes
  43387. */
  43388. export class NullEngine extends Engine {
  43389. private _options;
  43390. /**
  43391. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43392. */
  43393. isDeterministicLockStep(): boolean;
  43394. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43395. getLockstepMaxSteps(): number;
  43396. /**
  43397. * Sets hardware scaling, used to save performance if needed
  43398. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43399. */
  43400. getHardwareScalingLevel(): number;
  43401. constructor(options?: NullEngineOptions);
  43402. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43403. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43404. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43405. getRenderWidth(useScreen?: boolean): number;
  43406. getRenderHeight(useScreen?: boolean): number;
  43407. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43408. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43409. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43410. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43411. bindSamplers(effect: Effect): void;
  43412. enableEffect(effect: Effect): void;
  43413. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43414. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43415. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43416. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43417. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43418. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43419. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43420. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43421. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43422. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43423. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43424. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43425. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43426. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43427. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43428. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43429. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43430. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43431. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43432. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43433. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43434. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43435. bindBuffers(vertexBuffers: {
  43436. [key: string]: VertexBuffer;
  43437. }, indexBuffer: DataBuffer, effect: Effect): void;
  43438. wipeCaches(bruteForce?: boolean): void;
  43439. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43440. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43441. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43442. /** @hidden */
  43443. _createTexture(): WebGLTexture;
  43444. /** @hidden */
  43445. _releaseTexture(texture: InternalTexture): void;
  43446. 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;
  43447. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43448. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43449. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43450. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43451. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43452. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43453. areAllEffectsReady(): boolean;
  43454. /**
  43455. * @hidden
  43456. * Get the current error code of the webGL context
  43457. * @returns the error code
  43458. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43459. */
  43460. getError(): number;
  43461. /** @hidden */
  43462. _getUnpackAlignement(): number;
  43463. /** @hidden */
  43464. _unpackFlipY(value: boolean): void;
  43465. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43466. /**
  43467. * Updates a dynamic vertex buffer.
  43468. * @param vertexBuffer the vertex buffer to update
  43469. * @param data the data used to update the vertex buffer
  43470. * @param byteOffset the byte offset of the data (optional)
  43471. * @param byteLength the byte length of the data (optional)
  43472. */
  43473. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43474. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43475. /** @hidden */
  43476. _bindTexture(channel: number, texture: InternalTexture): void;
  43477. /** @hidden */
  43478. _releaseBuffer(buffer: DataBuffer): boolean;
  43479. releaseEffects(): void;
  43480. displayLoadingUI(): void;
  43481. hideLoadingUI(): void;
  43482. /** @hidden */
  43483. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43484. /** @hidden */
  43485. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43486. /** @hidden */
  43487. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43488. /** @hidden */
  43489. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43490. }
  43491. }
  43492. declare module BABYLON {
  43493. /** @hidden */
  43494. export class _OcclusionDataStorage {
  43495. /** @hidden */
  43496. occlusionInternalRetryCounter: number;
  43497. /** @hidden */
  43498. isOcclusionQueryInProgress: boolean;
  43499. /** @hidden */
  43500. isOccluded: boolean;
  43501. /** @hidden */
  43502. occlusionRetryCount: number;
  43503. /** @hidden */
  43504. occlusionType: number;
  43505. /** @hidden */
  43506. occlusionQueryAlgorithmType: number;
  43507. }
  43508. interface Engine {
  43509. /**
  43510. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43511. * @return the new query
  43512. */
  43513. createQuery(): WebGLQuery;
  43514. /**
  43515. * Delete and release a webGL query
  43516. * @param query defines the query to delete
  43517. * @return the current engine
  43518. */
  43519. deleteQuery(query: WebGLQuery): Engine;
  43520. /**
  43521. * Check if a given query has resolved and got its value
  43522. * @param query defines the query to check
  43523. * @returns true if the query got its value
  43524. */
  43525. isQueryResultAvailable(query: WebGLQuery): boolean;
  43526. /**
  43527. * Gets the value of a given query
  43528. * @param query defines the query to check
  43529. * @returns the value of the query
  43530. */
  43531. getQueryResult(query: WebGLQuery): number;
  43532. /**
  43533. * Initiates an occlusion query
  43534. * @param algorithmType defines the algorithm to use
  43535. * @param query defines the query to use
  43536. * @returns the current engine
  43537. * @see http://doc.babylonjs.com/features/occlusionquery
  43538. */
  43539. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43540. /**
  43541. * Ends an occlusion query
  43542. * @see http://doc.babylonjs.com/features/occlusionquery
  43543. * @param algorithmType defines the algorithm to use
  43544. * @returns the current engine
  43545. */
  43546. endOcclusionQuery(algorithmType: number): Engine;
  43547. /**
  43548. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43549. * Please note that only one query can be issued at a time
  43550. * @returns a time token used to track the time span
  43551. */
  43552. startTimeQuery(): Nullable<_TimeToken>;
  43553. /**
  43554. * Ends a time query
  43555. * @param token defines the token used to measure the time span
  43556. * @returns the time spent (in ns)
  43557. */
  43558. endTimeQuery(token: _TimeToken): int;
  43559. /** @hidden */
  43560. _currentNonTimestampToken: Nullable<_TimeToken>;
  43561. /** @hidden */
  43562. _createTimeQuery(): WebGLQuery;
  43563. /** @hidden */
  43564. _deleteTimeQuery(query: WebGLQuery): void;
  43565. /** @hidden */
  43566. _getGlAlgorithmType(algorithmType: number): number;
  43567. /** @hidden */
  43568. _getTimeQueryResult(query: WebGLQuery): any;
  43569. /** @hidden */
  43570. _getTimeQueryAvailability(query: WebGLQuery): any;
  43571. }
  43572. interface AbstractMesh {
  43573. /**
  43574. * Backing filed
  43575. * @hidden
  43576. */
  43577. __occlusionDataStorage: _OcclusionDataStorage;
  43578. /**
  43579. * Access property
  43580. * @hidden
  43581. */
  43582. _occlusionDataStorage: _OcclusionDataStorage;
  43583. /**
  43584. * 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.
  43585. * The default value is -1 which means don't break the query and wait till the result
  43586. * @see http://doc.babylonjs.com/features/occlusionquery
  43587. */
  43588. occlusionRetryCount: number;
  43589. /**
  43590. * 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:
  43591. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43592. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43593. * * 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.
  43594. * @see http://doc.babylonjs.com/features/occlusionquery
  43595. */
  43596. occlusionType: number;
  43597. /**
  43598. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43599. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43600. * * 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.
  43601. * @see http://doc.babylonjs.com/features/occlusionquery
  43602. */
  43603. occlusionQueryAlgorithmType: number;
  43604. /**
  43605. * 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
  43606. * @see http://doc.babylonjs.com/features/occlusionquery
  43607. */
  43608. isOccluded: boolean;
  43609. /**
  43610. * Flag to check the progress status of the query
  43611. * @see http://doc.babylonjs.com/features/occlusionquery
  43612. */
  43613. isOcclusionQueryInProgress: boolean;
  43614. }
  43615. }
  43616. declare module BABYLON {
  43617. /** @hidden */
  43618. export var _forceTransformFeedbackToBundle: boolean;
  43619. interface Engine {
  43620. /**
  43621. * Creates a webGL transform feedback object
  43622. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43623. * @returns the webGL transform feedback object
  43624. */
  43625. createTransformFeedback(): WebGLTransformFeedback;
  43626. /**
  43627. * Delete a webGL transform feedback object
  43628. * @param value defines the webGL transform feedback object to delete
  43629. */
  43630. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43631. /**
  43632. * Bind a webGL transform feedback object to the webgl context
  43633. * @param value defines the webGL transform feedback object to bind
  43634. */
  43635. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43636. /**
  43637. * Begins a transform feedback operation
  43638. * @param usePoints defines if points or triangles must be used
  43639. */
  43640. beginTransformFeedback(usePoints: boolean): void;
  43641. /**
  43642. * Ends a transform feedback operation
  43643. */
  43644. endTransformFeedback(): void;
  43645. /**
  43646. * Specify the varyings to use with transform feedback
  43647. * @param program defines the associated webGL program
  43648. * @param value defines the list of strings representing the varying names
  43649. */
  43650. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43651. /**
  43652. * Bind a webGL buffer for a transform feedback operation
  43653. * @param value defines the webGL buffer to bind
  43654. */
  43655. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43656. }
  43657. }
  43658. declare module BABYLON {
  43659. /**
  43660. * Creation options of the multi render target texture.
  43661. */
  43662. export interface IMultiRenderTargetOptions {
  43663. /**
  43664. * Define if the texture needs to create mip maps after render.
  43665. */
  43666. generateMipMaps?: boolean;
  43667. /**
  43668. * Define the types of all the draw buffers we want to create
  43669. */
  43670. types?: number[];
  43671. /**
  43672. * Define the sampling modes of all the draw buffers we want to create
  43673. */
  43674. samplingModes?: number[];
  43675. /**
  43676. * Define if a depth buffer is required
  43677. */
  43678. generateDepthBuffer?: boolean;
  43679. /**
  43680. * Define if a stencil buffer is required
  43681. */
  43682. generateStencilBuffer?: boolean;
  43683. /**
  43684. * Define if a depth texture is required instead of a depth buffer
  43685. */
  43686. generateDepthTexture?: boolean;
  43687. /**
  43688. * Define the number of desired draw buffers
  43689. */
  43690. textureCount?: number;
  43691. /**
  43692. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43693. */
  43694. doNotChangeAspectRatio?: boolean;
  43695. /**
  43696. * Define the default type of the buffers we are creating
  43697. */
  43698. defaultType?: number;
  43699. }
  43700. /**
  43701. * A multi render target, like a render target provides the ability to render to a texture.
  43702. * Unlike the render target, it can render to several draw buffers in one draw.
  43703. * This is specially interesting in deferred rendering or for any effects requiring more than
  43704. * just one color from a single pass.
  43705. */
  43706. export class MultiRenderTarget extends RenderTargetTexture {
  43707. private _internalTextures;
  43708. private _textures;
  43709. private _multiRenderTargetOptions;
  43710. /**
  43711. * Get if draw buffers are currently supported by the used hardware and browser.
  43712. */
  43713. readonly isSupported: boolean;
  43714. /**
  43715. * Get the list of textures generated by the multi render target.
  43716. */
  43717. readonly textures: Texture[];
  43718. /**
  43719. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43720. */
  43721. readonly depthTexture: Texture;
  43722. /**
  43723. * Set the wrapping mode on U of all the textures we are rendering to.
  43724. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43725. */
  43726. wrapU: number;
  43727. /**
  43728. * Set the wrapping mode on V of all the textures we are rendering to.
  43729. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43730. */
  43731. wrapV: number;
  43732. /**
  43733. * Instantiate a new multi render target texture.
  43734. * A multi render target, like a render target provides the ability to render to a texture.
  43735. * Unlike the render target, it can render to several draw buffers in one draw.
  43736. * This is specially interesting in deferred rendering or for any effects requiring more than
  43737. * just one color from a single pass.
  43738. * @param name Define the name of the texture
  43739. * @param size Define the size of the buffers to render to
  43740. * @param count Define the number of target we are rendering into
  43741. * @param scene Define the scene the texture belongs to
  43742. * @param options Define the options used to create the multi render target
  43743. */
  43744. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43745. /** @hidden */
  43746. _rebuild(): void;
  43747. private _createInternalTextures;
  43748. private _createTextures;
  43749. /**
  43750. * Define the number of samples used if MSAA is enabled.
  43751. */
  43752. samples: number;
  43753. /**
  43754. * Resize all the textures in the multi render target.
  43755. * Be carrefull as it will recreate all the data in the new texture.
  43756. * @param size Define the new size
  43757. */
  43758. resize(size: any): void;
  43759. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43760. /**
  43761. * Dispose the render targets and their associated resources
  43762. */
  43763. dispose(): void;
  43764. /**
  43765. * Release all the underlying texture used as draw buffers.
  43766. */
  43767. releaseInternalTextures(): void;
  43768. }
  43769. }
  43770. declare module BABYLON {
  43771. interface Engine {
  43772. /**
  43773. * Unbind a list of render target textures from the webGL context
  43774. * This is used only when drawBuffer extension or webGL2 are active
  43775. * @param textures defines the render target textures to unbind
  43776. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43777. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43778. */
  43779. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43780. /**
  43781. * Create a multi render target texture
  43782. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43783. * @param size defines the size of the texture
  43784. * @param options defines the creation options
  43785. * @returns the cube texture as an InternalTexture
  43786. */
  43787. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43788. /**
  43789. * Update the sample count for a given multiple render target texture
  43790. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43791. * @param textures defines the textures to update
  43792. * @param samples defines the sample count to set
  43793. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43794. */
  43795. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43796. }
  43797. }
  43798. declare module BABYLON {
  43799. /**
  43800. * Gather the list of clipboard event types as constants.
  43801. */
  43802. export class ClipboardEventTypes {
  43803. /**
  43804. * The clipboard event is fired when a copy command is active (pressed).
  43805. */
  43806. static readonly COPY: number;
  43807. /**
  43808. * The clipboard event is fired when a cut command is active (pressed).
  43809. */
  43810. static readonly CUT: number;
  43811. /**
  43812. * The clipboard event is fired when a paste command is active (pressed).
  43813. */
  43814. static readonly PASTE: number;
  43815. }
  43816. /**
  43817. * This class is used to store clipboard related info for the onClipboardObservable event.
  43818. */
  43819. export class ClipboardInfo {
  43820. /**
  43821. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43822. */
  43823. type: number;
  43824. /**
  43825. * Defines the related dom event
  43826. */
  43827. event: ClipboardEvent;
  43828. /**
  43829. *Creates an instance of ClipboardInfo.
  43830. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43831. * @param event Defines the related dom event
  43832. */
  43833. constructor(
  43834. /**
  43835. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43836. */
  43837. type: number,
  43838. /**
  43839. * Defines the related dom event
  43840. */
  43841. event: ClipboardEvent);
  43842. /**
  43843. * Get the clipboard event's type from the keycode.
  43844. * @param keyCode Defines the keyCode for the current keyboard event.
  43845. * @return {number}
  43846. */
  43847. static GetTypeFromCharacter(keyCode: number): number;
  43848. }
  43849. }
  43850. declare module BABYLON {
  43851. /**
  43852. * Google Daydream controller
  43853. */
  43854. export class DaydreamController extends WebVRController {
  43855. /**
  43856. * Base Url for the controller model.
  43857. */
  43858. static MODEL_BASE_URL: string;
  43859. /**
  43860. * File name for the controller model.
  43861. */
  43862. static MODEL_FILENAME: string;
  43863. /**
  43864. * Gamepad Id prefix used to identify Daydream Controller.
  43865. */
  43866. static readonly GAMEPAD_ID_PREFIX: string;
  43867. /**
  43868. * Creates a new DaydreamController from a gamepad
  43869. * @param vrGamepad the gamepad that the controller should be created from
  43870. */
  43871. constructor(vrGamepad: any);
  43872. /**
  43873. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43874. * @param scene scene in which to add meshes
  43875. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43876. */
  43877. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43878. /**
  43879. * Called once for each button that changed state since the last frame
  43880. * @param buttonIdx Which button index changed
  43881. * @param state New state of the button
  43882. * @param changes Which properties on the state changed since last frame
  43883. */
  43884. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43885. }
  43886. }
  43887. declare module BABYLON {
  43888. /**
  43889. * Gear VR Controller
  43890. */
  43891. export class GearVRController extends WebVRController {
  43892. /**
  43893. * Base Url for the controller model.
  43894. */
  43895. static MODEL_BASE_URL: string;
  43896. /**
  43897. * File name for the controller model.
  43898. */
  43899. static MODEL_FILENAME: string;
  43900. /**
  43901. * Gamepad Id prefix used to identify this controller.
  43902. */
  43903. static readonly GAMEPAD_ID_PREFIX: string;
  43904. private readonly _buttonIndexToObservableNameMap;
  43905. /**
  43906. * Creates a new GearVRController from a gamepad
  43907. * @param vrGamepad the gamepad that the controller should be created from
  43908. */
  43909. constructor(vrGamepad: any);
  43910. /**
  43911. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43912. * @param scene scene in which to add meshes
  43913. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43914. */
  43915. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43916. /**
  43917. * Called once for each button that changed state since the last frame
  43918. * @param buttonIdx Which button index changed
  43919. * @param state New state of the button
  43920. * @param changes Which properties on the state changed since last frame
  43921. */
  43922. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43923. }
  43924. }
  43925. declare module BABYLON {
  43926. /**
  43927. * Class containing static functions to help procedurally build meshes
  43928. */
  43929. export class PolyhedronBuilder {
  43930. /**
  43931. * Creates a polyhedron mesh
  43932. * * 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 to choose the wanted type
  43933. * * The parameter `size` (positive float, default 1) sets the polygon size
  43934. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43935. * * 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`
  43936. * * 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
  43937. * * 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)`)
  43938. * * 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 : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43939. * * 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
  43940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43941. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43943. * @param name defines the name of the mesh
  43944. * @param options defines the options used to create the mesh
  43945. * @param scene defines the hosting scene
  43946. * @returns the polyhedron mesh
  43947. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43948. */
  43949. static CreatePolyhedron(name: string, options: {
  43950. type?: number;
  43951. size?: number;
  43952. sizeX?: number;
  43953. sizeY?: number;
  43954. sizeZ?: number;
  43955. custom?: any;
  43956. faceUV?: Vector4[];
  43957. faceColors?: Color4[];
  43958. flat?: boolean;
  43959. updatable?: boolean;
  43960. sideOrientation?: number;
  43961. frontUVs?: Vector4;
  43962. backUVs?: Vector4;
  43963. }, scene?: Nullable<Scene>): Mesh;
  43964. }
  43965. }
  43966. declare module BABYLON {
  43967. /**
  43968. * Gizmo that enables scaling a mesh along 3 axis
  43969. */
  43970. export class ScaleGizmo extends Gizmo {
  43971. /**
  43972. * Internal gizmo used for interactions on the x axis
  43973. */
  43974. xGizmo: AxisScaleGizmo;
  43975. /**
  43976. * Internal gizmo used for interactions on the y axis
  43977. */
  43978. yGizmo: AxisScaleGizmo;
  43979. /**
  43980. * Internal gizmo used for interactions on the z axis
  43981. */
  43982. zGizmo: AxisScaleGizmo;
  43983. /**
  43984. * Internal gizmo used to scale all axis equally
  43985. */
  43986. uniformScaleGizmo: AxisScaleGizmo;
  43987. private _meshAttached;
  43988. private _updateGizmoRotationToMatchAttachedMesh;
  43989. private _snapDistance;
  43990. private _scaleRatio;
  43991. private _uniformScalingMesh;
  43992. private _octahedron;
  43993. /** Fires an event when any of it's sub gizmos are dragged */
  43994. onDragStartObservable: Observable<unknown>;
  43995. /** Fires an event when any of it's sub gizmos are released from dragging */
  43996. onDragEndObservable: Observable<unknown>;
  43997. attachedMesh: Nullable<AbstractMesh>;
  43998. /**
  43999. * Creates a ScaleGizmo
  44000. * @param gizmoLayer The utility layer the gizmo will be added to
  44001. */
  44002. constructor(gizmoLayer?: UtilityLayerRenderer);
  44003. updateGizmoRotationToMatchAttachedMesh: boolean;
  44004. /**
  44005. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44006. */
  44007. snapDistance: number;
  44008. /**
  44009. * Ratio for the scale of the gizmo (Default: 1)
  44010. */
  44011. scaleRatio: number;
  44012. /**
  44013. * Disposes of the gizmo
  44014. */
  44015. dispose(): void;
  44016. }
  44017. }
  44018. declare module BABYLON {
  44019. /**
  44020. * Single axis scale gizmo
  44021. */
  44022. export class AxisScaleGizmo extends Gizmo {
  44023. /**
  44024. * Drag behavior responsible for the gizmos dragging interactions
  44025. */
  44026. dragBehavior: PointerDragBehavior;
  44027. private _pointerObserver;
  44028. /**
  44029. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44030. */
  44031. snapDistance: number;
  44032. /**
  44033. * Event that fires each time the gizmo snaps to a new location.
  44034. * * snapDistance is the the change in distance
  44035. */
  44036. onSnapObservable: Observable<{
  44037. snapDistance: number;
  44038. }>;
  44039. /**
  44040. * If the scaling operation should be done on all axis (default: false)
  44041. */
  44042. uniformScaling: boolean;
  44043. private _isEnabled;
  44044. private _parent;
  44045. private _arrow;
  44046. private _coloredMaterial;
  44047. private _hoverMaterial;
  44048. /**
  44049. * Creates an AxisScaleGizmo
  44050. * @param gizmoLayer The utility layer the gizmo will be added to
  44051. * @param dragAxis The axis which the gizmo will be able to scale on
  44052. * @param color The color of the gizmo
  44053. */
  44054. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44055. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44056. /**
  44057. * If the gizmo is enabled
  44058. */
  44059. isEnabled: boolean;
  44060. /**
  44061. * Disposes of the gizmo
  44062. */
  44063. dispose(): void;
  44064. /**
  44065. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44066. * @param mesh The mesh to replace the default mesh of the gizmo
  44067. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44068. */
  44069. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44070. }
  44071. }
  44072. declare module BABYLON {
  44073. /**
  44074. * Bounding box gizmo
  44075. */
  44076. export class BoundingBoxGizmo extends Gizmo {
  44077. private _lineBoundingBox;
  44078. private _rotateSpheresParent;
  44079. private _scaleBoxesParent;
  44080. private _boundingDimensions;
  44081. private _renderObserver;
  44082. private _pointerObserver;
  44083. private _scaleDragSpeed;
  44084. private _tmpQuaternion;
  44085. private _tmpVector;
  44086. private _tmpRotationMatrix;
  44087. /**
  44088. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  44089. */
  44090. ignoreChildren: boolean;
  44091. /**
  44092. * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)
  44093. */
  44094. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44095. /**
  44096. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44097. */
  44098. rotationSphereSize: number;
  44099. /**
  44100. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44101. */
  44102. scaleBoxSize: number;
  44103. /**
  44104. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  44105. */
  44106. fixedDragMeshScreenSize: boolean;
  44107. /**
  44108. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44109. */
  44110. fixedDragMeshScreenSizeDistanceFactor: number;
  44111. /**
  44112. * Fired when a rotation sphere or scale box is dragged
  44113. */
  44114. onDragStartObservable: Observable<{}>;
  44115. /**
  44116. * Fired when a scale box is dragged
  44117. */
  44118. onScaleBoxDragObservable: Observable<{}>;
  44119. /**
  44120. * Fired when a scale box drag is ended
  44121. */
  44122. onScaleBoxDragEndObservable: Observable<{}>;
  44123. /**
  44124. * Fired when a rotation sphere is dragged
  44125. */
  44126. onRotationSphereDragObservable: Observable<{}>;
  44127. /**
  44128. * Fired when a rotation sphere drag is ended
  44129. */
  44130. onRotationSphereDragEndObservable: Observable<{}>;
  44131. /**
  44132. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  44133. */
  44134. scalePivot: Nullable<Vector3>;
  44135. /**
  44136. * Mesh used as a pivot to rotate the attached mesh
  44137. */
  44138. private _anchorMesh;
  44139. private _existingMeshScale;
  44140. private _dragMesh;
  44141. private pointerDragBehavior;
  44142. private coloredMaterial;
  44143. private hoverColoredMaterial;
  44144. /**
  44145. * Sets the color of the bounding box gizmo
  44146. * @param color the color to set
  44147. */
  44148. setColor(color: Color3): void;
  44149. /**
  44150. * Creates an BoundingBoxGizmo
  44151. * @param gizmoLayer The utility layer the gizmo will be added to
  44152. * @param color The color of the gizmo
  44153. */
  44154. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44155. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44156. private _selectNode;
  44157. /**
  44158. * Updates the bounding box information for the Gizmo
  44159. */
  44160. updateBoundingBox(): void;
  44161. private _updateRotationSpheres;
  44162. private _updateScaleBoxes;
  44163. /**
  44164. * Enables rotation on the specified axis and disables rotation on the others
  44165. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44166. */
  44167. setEnabledRotationAxis(axis: string): void;
  44168. /**
  44169. * Enables/disables scaling
  44170. * @param enable if scaling should be enabled
  44171. */
  44172. setEnabledScaling(enable: boolean): void;
  44173. private _updateDummy;
  44174. /**
  44175. * Enables a pointer drag behavior on the bounding box of the gizmo
  44176. */
  44177. enableDragBehavior(): void;
  44178. /**
  44179. * Disposes of the gizmo
  44180. */
  44181. dispose(): void;
  44182. /**
  44183. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  44184. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44185. * @returns the bounding box mesh with the passed in mesh as a child
  44186. */
  44187. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44188. /**
  44189. * CustomMeshes are not supported by this gizmo
  44190. * @param mesh The mesh to replace the default mesh of the gizmo
  44191. */
  44192. setCustomMesh(mesh: Mesh): void;
  44193. }
  44194. }
  44195. declare module BABYLON {
  44196. /**
  44197. * Single plane rotation gizmo
  44198. */
  44199. export class PlaneRotationGizmo extends Gizmo {
  44200. /**
  44201. * Drag behavior responsible for the gizmos dragging interactions
  44202. */
  44203. dragBehavior: PointerDragBehavior;
  44204. private _pointerObserver;
  44205. /**
  44206. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44207. */
  44208. snapDistance: number;
  44209. /**
  44210. * Event that fires each time the gizmo snaps to a new location.
  44211. * * snapDistance is the the change in distance
  44212. */
  44213. onSnapObservable: Observable<{
  44214. snapDistance: number;
  44215. }>;
  44216. private _isEnabled;
  44217. private _parent;
  44218. /**
  44219. * Creates a PlaneRotationGizmo
  44220. * @param gizmoLayer The utility layer the gizmo will be added to
  44221. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44222. * @param color The color of the gizmo
  44223. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44224. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44225. */
  44226. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44227. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44228. /**
  44229. * If the gizmo is enabled
  44230. */
  44231. isEnabled: boolean;
  44232. /**
  44233. * Disposes of the gizmo
  44234. */
  44235. dispose(): void;
  44236. }
  44237. }
  44238. declare module BABYLON {
  44239. /**
  44240. * Gizmo that enables rotating a mesh along 3 axis
  44241. */
  44242. export class RotationGizmo extends Gizmo {
  44243. /**
  44244. * Internal gizmo used for interactions on the x axis
  44245. */
  44246. xGizmo: PlaneRotationGizmo;
  44247. /**
  44248. * Internal gizmo used for interactions on the y axis
  44249. */
  44250. yGizmo: PlaneRotationGizmo;
  44251. /**
  44252. * Internal gizmo used for interactions on the z axis
  44253. */
  44254. zGizmo: PlaneRotationGizmo;
  44255. /** Fires an event when any of it's sub gizmos are dragged */
  44256. onDragStartObservable: Observable<unknown>;
  44257. /** Fires an event when any of it's sub gizmos are released from dragging */
  44258. onDragEndObservable: Observable<unknown>;
  44259. private _meshAttached;
  44260. attachedMesh: Nullable<AbstractMesh>;
  44261. /**
  44262. * Creates a RotationGizmo
  44263. * @param gizmoLayer The utility layer the gizmo will be added to
  44264. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44265. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44266. */
  44267. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44268. updateGizmoRotationToMatchAttachedMesh: boolean;
  44269. /**
  44270. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44271. */
  44272. snapDistance: number;
  44273. /**
  44274. * Ratio for the scale of the gizmo (Default: 1)
  44275. */
  44276. scaleRatio: number;
  44277. /**
  44278. * Disposes of the gizmo
  44279. */
  44280. dispose(): void;
  44281. /**
  44282. * CustomMeshes are not supported by this gizmo
  44283. * @param mesh The mesh to replace the default mesh of the gizmo
  44284. */
  44285. setCustomMesh(mesh: Mesh): void;
  44286. }
  44287. }
  44288. declare module BABYLON {
  44289. /**
  44290. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44291. */
  44292. export class GizmoManager implements IDisposable {
  44293. private scene;
  44294. /**
  44295. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44296. */
  44297. gizmos: {
  44298. positionGizmo: Nullable<PositionGizmo>;
  44299. rotationGizmo: Nullable<RotationGizmo>;
  44300. scaleGizmo: Nullable<ScaleGizmo>;
  44301. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44302. };
  44303. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44304. clearGizmoOnEmptyPointerEvent: boolean;
  44305. /** Fires an event when the manager is attached to a mesh */
  44306. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44307. private _gizmosEnabled;
  44308. private _pointerObserver;
  44309. private _attachedMesh;
  44310. private _boundingBoxColor;
  44311. private _defaultUtilityLayer;
  44312. private _defaultKeepDepthUtilityLayer;
  44313. /**
  44314. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44315. */
  44316. boundingBoxDragBehavior: SixDofDragBehavior;
  44317. /**
  44318. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44319. */
  44320. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44321. /**
  44322. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44323. */
  44324. usePointerToAttachGizmos: boolean;
  44325. /**
  44326. * Utility layer that the bounding box gizmo belongs to
  44327. */
  44328. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44329. /**
  44330. * Utility layer that all gizmos besides bounding box belong to
  44331. */
  44332. readonly utilityLayer: UtilityLayerRenderer;
  44333. /**
  44334. * Instatiates a gizmo manager
  44335. * @param scene the scene to overlay the gizmos on top of
  44336. */
  44337. constructor(scene: Scene);
  44338. /**
  44339. * Attaches a set of gizmos to the specified mesh
  44340. * @param mesh The mesh the gizmo's should be attached to
  44341. */
  44342. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44343. /**
  44344. * If the position gizmo is enabled
  44345. */
  44346. positionGizmoEnabled: boolean;
  44347. /**
  44348. * If the rotation gizmo is enabled
  44349. */
  44350. rotationGizmoEnabled: boolean;
  44351. /**
  44352. * If the scale gizmo is enabled
  44353. */
  44354. scaleGizmoEnabled: boolean;
  44355. /**
  44356. * If the boundingBox gizmo is enabled
  44357. */
  44358. boundingBoxGizmoEnabled: boolean;
  44359. /**
  44360. * Disposes of the gizmo manager
  44361. */
  44362. dispose(): void;
  44363. }
  44364. }
  44365. declare module BABYLON {
  44366. /**
  44367. * A directional light is defined by a direction (what a surprise!).
  44368. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44369. * 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.
  44370. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44371. */
  44372. export class DirectionalLight extends ShadowLight {
  44373. private _shadowFrustumSize;
  44374. /**
  44375. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44376. */
  44377. /**
  44378. * Specifies a fix frustum size for the shadow generation.
  44379. */
  44380. shadowFrustumSize: number;
  44381. private _shadowOrthoScale;
  44382. /**
  44383. * Gets the shadow projection scale against the optimal computed one.
  44384. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44385. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44386. */
  44387. /**
  44388. * Sets the shadow projection scale against the optimal computed one.
  44389. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44390. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44391. */
  44392. shadowOrthoScale: number;
  44393. /**
  44394. * Automatically compute the projection matrix to best fit (including all the casters)
  44395. * on each frame.
  44396. */
  44397. autoUpdateExtends: boolean;
  44398. private _orthoLeft;
  44399. private _orthoRight;
  44400. private _orthoTop;
  44401. private _orthoBottom;
  44402. /**
  44403. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44404. * The directional light is emitted from everywhere in the given direction.
  44405. * It can cast shadows.
  44406. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44407. * @param name The friendly name of the light
  44408. * @param direction The direction of the light
  44409. * @param scene The scene the light belongs to
  44410. */
  44411. constructor(name: string, direction: Vector3, scene: Scene);
  44412. /**
  44413. * Returns the string "DirectionalLight".
  44414. * @return The class name
  44415. */
  44416. getClassName(): string;
  44417. /**
  44418. * Returns the integer 1.
  44419. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44420. */
  44421. getTypeID(): number;
  44422. /**
  44423. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44424. * Returns the DirectionalLight Shadow projection matrix.
  44425. */
  44426. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44427. /**
  44428. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44429. * Returns the DirectionalLight Shadow projection matrix.
  44430. */
  44431. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44432. /**
  44433. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44434. * Returns the DirectionalLight Shadow projection matrix.
  44435. */
  44436. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44437. protected _buildUniformLayout(): void;
  44438. /**
  44439. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44440. * @param effect The effect to update
  44441. * @param lightIndex The index of the light in the effect to update
  44442. * @returns The directional light
  44443. */
  44444. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44445. /**
  44446. * Gets the minZ used for shadow according to both the scene and the light.
  44447. *
  44448. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44449. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44450. * @param activeCamera The camera we are returning the min for
  44451. * @returns the depth min z
  44452. */
  44453. getDepthMinZ(activeCamera: Camera): number;
  44454. /**
  44455. * Gets the maxZ used for shadow according to both the scene and the light.
  44456. *
  44457. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44458. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44459. * @param activeCamera The camera we are returning the max for
  44460. * @returns the depth max z
  44461. */
  44462. getDepthMaxZ(activeCamera: Camera): number;
  44463. /**
  44464. * Prepares the list of defines specific to the light type.
  44465. * @param defines the list of defines
  44466. * @param lightIndex defines the index of the light for the effect
  44467. */
  44468. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44469. }
  44470. }
  44471. declare module BABYLON {
  44472. /**
  44473. * Class containing static functions to help procedurally build meshes
  44474. */
  44475. export class HemisphereBuilder {
  44476. /**
  44477. * Creates a hemisphere mesh
  44478. * @param name defines the name of the mesh
  44479. * @param options defines the options used to create the mesh
  44480. * @param scene defines the hosting scene
  44481. * @returns the hemisphere mesh
  44482. */
  44483. static CreateHemisphere(name: string, options: {
  44484. segments?: number;
  44485. diameter?: number;
  44486. sideOrientation?: number;
  44487. }, scene: any): Mesh;
  44488. }
  44489. }
  44490. declare module BABYLON {
  44491. /**
  44492. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44493. * These values define a cone of light starting from the position, emitting toward the direction.
  44494. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44495. * and the exponent defines the speed of the decay of the light with distance (reach).
  44496. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44497. */
  44498. export class SpotLight extends ShadowLight {
  44499. private _angle;
  44500. private _innerAngle;
  44501. private _cosHalfAngle;
  44502. private _lightAngleScale;
  44503. private _lightAngleOffset;
  44504. /**
  44505. * Gets the cone angle of the spot light in Radians.
  44506. */
  44507. /**
  44508. * Sets the cone angle of the spot light in Radians.
  44509. */
  44510. angle: number;
  44511. /**
  44512. * Only used in gltf falloff mode, this defines the angle where
  44513. * the directional falloff will start before cutting at angle which could be seen
  44514. * as outer angle.
  44515. */
  44516. /**
  44517. * Only used in gltf falloff mode, this defines the angle where
  44518. * the directional falloff will start before cutting at angle which could be seen
  44519. * as outer angle.
  44520. */
  44521. innerAngle: number;
  44522. private _shadowAngleScale;
  44523. /**
  44524. * Allows scaling the angle of the light for shadow generation only.
  44525. */
  44526. /**
  44527. * Allows scaling the angle of the light for shadow generation only.
  44528. */
  44529. shadowAngleScale: number;
  44530. /**
  44531. * The light decay speed with the distance from the emission spot.
  44532. */
  44533. exponent: number;
  44534. private _projectionTextureMatrix;
  44535. /**
  44536. * Allows reading the projecton texture
  44537. */
  44538. readonly projectionTextureMatrix: Matrix;
  44539. protected _projectionTextureLightNear: number;
  44540. /**
  44541. * Gets the near clip of the Spotlight for texture projection.
  44542. */
  44543. /**
  44544. * Sets the near clip of the Spotlight for texture projection.
  44545. */
  44546. projectionTextureLightNear: number;
  44547. protected _projectionTextureLightFar: number;
  44548. /**
  44549. * Gets the far clip of the Spotlight for texture projection.
  44550. */
  44551. /**
  44552. * Sets the far clip of the Spotlight for texture projection.
  44553. */
  44554. projectionTextureLightFar: number;
  44555. protected _projectionTextureUpDirection: Vector3;
  44556. /**
  44557. * Gets the Up vector of the Spotlight for texture projection.
  44558. */
  44559. /**
  44560. * Sets the Up vector of the Spotlight for texture projection.
  44561. */
  44562. projectionTextureUpDirection: Vector3;
  44563. private _projectionTexture;
  44564. /**
  44565. * Gets the projection texture of the light.
  44566. */
  44567. /**
  44568. * Sets the projection texture of the light.
  44569. */
  44570. projectionTexture: Nullable<BaseTexture>;
  44571. private _projectionTextureViewLightDirty;
  44572. private _projectionTextureProjectionLightDirty;
  44573. private _projectionTextureDirty;
  44574. private _projectionTextureViewTargetVector;
  44575. private _projectionTextureViewLightMatrix;
  44576. private _projectionTextureProjectionLightMatrix;
  44577. private _projectionTextureScalingMatrix;
  44578. /**
  44579. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44580. * It can cast shadows.
  44581. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44582. * @param name The light friendly name
  44583. * @param position The position of the spot light in the scene
  44584. * @param direction The direction of the light in the scene
  44585. * @param angle The cone angle of the light in Radians
  44586. * @param exponent The light decay speed with the distance from the emission spot
  44587. * @param scene The scene the lights belongs to
  44588. */
  44589. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44590. /**
  44591. * Returns the string "SpotLight".
  44592. * @returns the class name
  44593. */
  44594. getClassName(): string;
  44595. /**
  44596. * Returns the integer 2.
  44597. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44598. */
  44599. getTypeID(): number;
  44600. /**
  44601. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44602. */
  44603. protected _setDirection(value: Vector3): void;
  44604. /**
  44605. * Overrides the position setter to recompute the projection texture view light Matrix.
  44606. */
  44607. protected _setPosition(value: Vector3): void;
  44608. /**
  44609. * 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.
  44610. * Returns the SpotLight.
  44611. */
  44612. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44613. protected _computeProjectionTextureViewLightMatrix(): void;
  44614. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44615. /**
  44616. * Main function for light texture projection matrix computing.
  44617. */
  44618. protected _computeProjectionTextureMatrix(): void;
  44619. protected _buildUniformLayout(): void;
  44620. private _computeAngleValues;
  44621. /**
  44622. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44623. * @param effect The effect to update
  44624. * @param lightIndex The index of the light in the effect to update
  44625. * @returns The spot light
  44626. */
  44627. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44628. /**
  44629. * Disposes the light and the associated resources.
  44630. */
  44631. dispose(): void;
  44632. /**
  44633. * Prepares the list of defines specific to the light type.
  44634. * @param defines the list of defines
  44635. * @param lightIndex defines the index of the light for the effect
  44636. */
  44637. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44638. }
  44639. }
  44640. declare module BABYLON {
  44641. /**
  44642. * Gizmo that enables viewing a light
  44643. */
  44644. export class LightGizmo extends Gizmo {
  44645. private _lightMesh;
  44646. private _material;
  44647. private cachedPosition;
  44648. private cachedForward;
  44649. /**
  44650. * Creates a LightGizmo
  44651. * @param gizmoLayer The utility layer the gizmo will be added to
  44652. */
  44653. constructor(gizmoLayer?: UtilityLayerRenderer);
  44654. private _light;
  44655. /**
  44656. * The light that the gizmo is attached to
  44657. */
  44658. light: Nullable<Light>;
  44659. /**
  44660. * Gets the material used to render the light gizmo
  44661. */
  44662. readonly material: StandardMaterial;
  44663. /**
  44664. * @hidden
  44665. * Updates the gizmo to match the attached mesh's position/rotation
  44666. */
  44667. protected _update(): void;
  44668. private static _Scale;
  44669. /**
  44670. * Creates the lines for a light mesh
  44671. */
  44672. private static _createLightLines;
  44673. /**
  44674. * Disposes of the light gizmo
  44675. */
  44676. dispose(): void;
  44677. private static _CreateHemisphericLightMesh;
  44678. private static _CreatePointLightMesh;
  44679. private static _CreateSpotLightMesh;
  44680. private static _CreateDirectionalLightMesh;
  44681. }
  44682. }
  44683. declare module BABYLON {
  44684. /** @hidden */
  44685. export var backgroundFragmentDeclaration: {
  44686. name: string;
  44687. shader: string;
  44688. };
  44689. }
  44690. declare module BABYLON {
  44691. /** @hidden */
  44692. export var backgroundUboDeclaration: {
  44693. name: string;
  44694. shader: string;
  44695. };
  44696. }
  44697. declare module BABYLON {
  44698. /** @hidden */
  44699. export var backgroundPixelShader: {
  44700. name: string;
  44701. shader: string;
  44702. };
  44703. }
  44704. declare module BABYLON {
  44705. /** @hidden */
  44706. export var backgroundVertexDeclaration: {
  44707. name: string;
  44708. shader: string;
  44709. };
  44710. }
  44711. declare module BABYLON {
  44712. /** @hidden */
  44713. export var backgroundVertexShader: {
  44714. name: string;
  44715. shader: string;
  44716. };
  44717. }
  44718. declare module BABYLON {
  44719. /**
  44720. * Background material used to create an efficient environement around your scene.
  44721. */
  44722. export class BackgroundMaterial extends PushMaterial {
  44723. /**
  44724. * Standard reflectance value at parallel view angle.
  44725. */
  44726. static StandardReflectance0: number;
  44727. /**
  44728. * Standard reflectance value at grazing angle.
  44729. */
  44730. static StandardReflectance90: number;
  44731. protected _primaryColor: Color3;
  44732. /**
  44733. * Key light Color (multiply against the environement texture)
  44734. */
  44735. primaryColor: Color3;
  44736. protected __perceptualColor: Nullable<Color3>;
  44737. /**
  44738. * Experimental Internal Use Only.
  44739. *
  44740. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44741. * This acts as a helper to set the primary color to a more "human friendly" value.
  44742. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44743. * output color as close as possible from the chosen value.
  44744. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44745. * part of lighting setup.)
  44746. */
  44747. _perceptualColor: Nullable<Color3>;
  44748. protected _primaryColorShadowLevel: float;
  44749. /**
  44750. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44751. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44752. */
  44753. primaryColorShadowLevel: float;
  44754. protected _primaryColorHighlightLevel: float;
  44755. /**
  44756. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44757. * The primary color is used at the level chosen to define what the white area would look.
  44758. */
  44759. primaryColorHighlightLevel: float;
  44760. protected _reflectionTexture: Nullable<BaseTexture>;
  44761. /**
  44762. * Reflection Texture used in the material.
  44763. * Should be author in a specific way for the best result (refer to the documentation).
  44764. */
  44765. reflectionTexture: Nullable<BaseTexture>;
  44766. protected _reflectionBlur: float;
  44767. /**
  44768. * Reflection Texture level of blur.
  44769. *
  44770. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44771. * texture twice.
  44772. */
  44773. reflectionBlur: float;
  44774. protected _diffuseTexture: Nullable<BaseTexture>;
  44775. /**
  44776. * Diffuse Texture used in the material.
  44777. * Should be author in a specific way for the best result (refer to the documentation).
  44778. */
  44779. diffuseTexture: Nullable<BaseTexture>;
  44780. protected _shadowLights: Nullable<IShadowLight[]>;
  44781. /**
  44782. * Specify the list of lights casting shadow on the material.
  44783. * All scene shadow lights will be included if null.
  44784. */
  44785. shadowLights: Nullable<IShadowLight[]>;
  44786. protected _shadowLevel: float;
  44787. /**
  44788. * Helps adjusting the shadow to a softer level if required.
  44789. * 0 means black shadows and 1 means no shadows.
  44790. */
  44791. shadowLevel: float;
  44792. protected _sceneCenter: Vector3;
  44793. /**
  44794. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44795. * It is usually zero but might be interesting to modify according to your setup.
  44796. */
  44797. sceneCenter: Vector3;
  44798. protected _opacityFresnel: boolean;
  44799. /**
  44800. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44801. * This helps ensuring a nice transition when the camera goes under the ground.
  44802. */
  44803. opacityFresnel: boolean;
  44804. protected _reflectionFresnel: boolean;
  44805. /**
  44806. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44807. * This helps adding a mirror texture on the ground.
  44808. */
  44809. reflectionFresnel: boolean;
  44810. protected _reflectionFalloffDistance: number;
  44811. /**
  44812. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44813. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44814. */
  44815. reflectionFalloffDistance: number;
  44816. protected _reflectionAmount: number;
  44817. /**
  44818. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44819. */
  44820. reflectionAmount: number;
  44821. protected _reflectionReflectance0: number;
  44822. /**
  44823. * This specifies the weight of the reflection at grazing angle.
  44824. */
  44825. reflectionReflectance0: number;
  44826. protected _reflectionReflectance90: number;
  44827. /**
  44828. * This specifies the weight of the reflection at a perpendicular point of view.
  44829. */
  44830. reflectionReflectance90: number;
  44831. /**
  44832. * Sets the reflection reflectance fresnel values according to the default standard
  44833. * empirically know to work well :-)
  44834. */
  44835. reflectionStandardFresnelWeight: number;
  44836. protected _useRGBColor: boolean;
  44837. /**
  44838. * Helps to directly use the maps channels instead of their level.
  44839. */
  44840. useRGBColor: boolean;
  44841. protected _enableNoise: boolean;
  44842. /**
  44843. * This helps reducing the banding effect that could occur on the background.
  44844. */
  44845. enableNoise: boolean;
  44846. /**
  44847. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44848. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44849. * Recommended to be keep at 1.0 except for special cases.
  44850. */
  44851. fovMultiplier: number;
  44852. private _fovMultiplier;
  44853. /**
  44854. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44855. */
  44856. useEquirectangularFOV: boolean;
  44857. private _maxSimultaneousLights;
  44858. /**
  44859. * Number of Simultaneous lights allowed on the material.
  44860. */
  44861. maxSimultaneousLights: int;
  44862. /**
  44863. * Default configuration related to image processing available in the Background Material.
  44864. */
  44865. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44866. /**
  44867. * Keep track of the image processing observer to allow dispose and replace.
  44868. */
  44869. private _imageProcessingObserver;
  44870. /**
  44871. * Attaches a new image processing configuration to the PBR Material.
  44872. * @param configuration (if null the scene configuration will be use)
  44873. */
  44874. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44875. /**
  44876. * Gets the image processing configuration used either in this material.
  44877. */
  44878. /**
  44879. * Sets the Default image processing configuration used either in the this material.
  44880. *
  44881. * If sets to null, the scene one is in use.
  44882. */
  44883. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44884. /**
  44885. * Gets wether the color curves effect is enabled.
  44886. */
  44887. /**
  44888. * Sets wether the color curves effect is enabled.
  44889. */
  44890. cameraColorCurvesEnabled: boolean;
  44891. /**
  44892. * Gets wether the color grading effect is enabled.
  44893. */
  44894. /**
  44895. * Gets wether the color grading effect is enabled.
  44896. */
  44897. cameraColorGradingEnabled: boolean;
  44898. /**
  44899. * Gets wether tonemapping is enabled or not.
  44900. */
  44901. /**
  44902. * Sets wether tonemapping is enabled or not
  44903. */
  44904. cameraToneMappingEnabled: boolean;
  44905. /**
  44906. * The camera exposure used on this material.
  44907. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44908. * This corresponds to a photographic exposure.
  44909. */
  44910. /**
  44911. * The camera exposure used on this material.
  44912. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44913. * This corresponds to a photographic exposure.
  44914. */
  44915. cameraExposure: float;
  44916. /**
  44917. * Gets The camera contrast used on this material.
  44918. */
  44919. /**
  44920. * Sets The camera contrast used on this material.
  44921. */
  44922. cameraContrast: float;
  44923. /**
  44924. * Gets the Color Grading 2D Lookup Texture.
  44925. */
  44926. /**
  44927. * Sets the Color Grading 2D Lookup Texture.
  44928. */
  44929. cameraColorGradingTexture: Nullable<BaseTexture>;
  44930. /**
  44931. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44932. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44933. * 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;
  44934. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44935. */
  44936. /**
  44937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44939. * 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;
  44940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44941. */
  44942. cameraColorCurves: Nullable<ColorCurves>;
  44943. /**
  44944. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44945. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44946. */
  44947. switchToBGR: boolean;
  44948. private _renderTargets;
  44949. private _reflectionControls;
  44950. private _white;
  44951. private _primaryShadowColor;
  44952. private _primaryHighlightColor;
  44953. /**
  44954. * Instantiates a Background Material in the given scene
  44955. * @param name The friendly name of the material
  44956. * @param scene The scene to add the material to
  44957. */
  44958. constructor(name: string, scene: Scene);
  44959. /**
  44960. * Gets a boolean indicating that current material needs to register RTT
  44961. */
  44962. readonly hasRenderTargetTextures: boolean;
  44963. /**
  44964. * The entire material has been created in order to prevent overdraw.
  44965. * @returns false
  44966. */
  44967. needAlphaTesting(): boolean;
  44968. /**
  44969. * The entire material has been created in order to prevent overdraw.
  44970. * @returns true if blending is enable
  44971. */
  44972. needAlphaBlending(): boolean;
  44973. /**
  44974. * Checks wether the material is ready to be rendered for a given mesh.
  44975. * @param mesh The mesh to render
  44976. * @param subMesh The submesh to check against
  44977. * @param useInstances Specify wether or not the material is used with instances
  44978. * @returns true if all the dependencies are ready (Textures, Effects...)
  44979. */
  44980. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44981. /**
  44982. * Compute the primary color according to the chosen perceptual color.
  44983. */
  44984. private _computePrimaryColorFromPerceptualColor;
  44985. /**
  44986. * Compute the highlights and shadow colors according to their chosen levels.
  44987. */
  44988. private _computePrimaryColors;
  44989. /**
  44990. * Build the uniform buffer used in the material.
  44991. */
  44992. buildUniformLayout(): void;
  44993. /**
  44994. * Unbind the material.
  44995. */
  44996. unbind(): void;
  44997. /**
  44998. * Bind only the world matrix to the material.
  44999. * @param world The world matrix to bind.
  45000. */
  45001. bindOnlyWorldMatrix(world: Matrix): void;
  45002. /**
  45003. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45004. * @param world The world matrix to bind.
  45005. * @param subMesh The submesh to bind for.
  45006. */
  45007. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45008. /**
  45009. * Dispose the material.
  45010. * @param forceDisposeEffect Force disposal of the associated effect.
  45011. * @param forceDisposeTextures Force disposal of the associated textures.
  45012. */
  45013. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45014. /**
  45015. * Clones the material.
  45016. * @param name The cloned name.
  45017. * @returns The cloned material.
  45018. */
  45019. clone(name: string): BackgroundMaterial;
  45020. /**
  45021. * Serializes the current material to its JSON representation.
  45022. * @returns The JSON representation.
  45023. */
  45024. serialize(): any;
  45025. /**
  45026. * Gets the class name of the material
  45027. * @returns "BackgroundMaterial"
  45028. */
  45029. getClassName(): string;
  45030. /**
  45031. * Parse a JSON input to create back a background material.
  45032. * @param source The JSON data to parse
  45033. * @param scene The scene to create the parsed material in
  45034. * @param rootUrl The root url of the assets the material depends upon
  45035. * @returns the instantiated BackgroundMaterial.
  45036. */
  45037. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45038. }
  45039. }
  45040. declare module BABYLON {
  45041. /**
  45042. * Represents the different options available during the creation of
  45043. * a Environment helper.
  45044. *
  45045. * This can control the default ground, skybox and image processing setup of your scene.
  45046. */
  45047. export interface IEnvironmentHelperOptions {
  45048. /**
  45049. * Specifies wether or not to create a ground.
  45050. * True by default.
  45051. */
  45052. createGround: boolean;
  45053. /**
  45054. * Specifies the ground size.
  45055. * 15 by default.
  45056. */
  45057. groundSize: number;
  45058. /**
  45059. * The texture used on the ground for the main color.
  45060. * Comes from the BabylonJS CDN by default.
  45061. *
  45062. * Remarks: Can be either a texture or a url.
  45063. */
  45064. groundTexture: string | BaseTexture;
  45065. /**
  45066. * The color mixed in the ground texture by default.
  45067. * BabylonJS clearColor by default.
  45068. */
  45069. groundColor: Color3;
  45070. /**
  45071. * Specifies the ground opacity.
  45072. * 1 by default.
  45073. */
  45074. groundOpacity: number;
  45075. /**
  45076. * Enables the ground to receive shadows.
  45077. * True by default.
  45078. */
  45079. enableGroundShadow: boolean;
  45080. /**
  45081. * Helps preventing the shadow to be fully black on the ground.
  45082. * 0.5 by default.
  45083. */
  45084. groundShadowLevel: number;
  45085. /**
  45086. * Creates a mirror texture attach to the ground.
  45087. * false by default.
  45088. */
  45089. enableGroundMirror: boolean;
  45090. /**
  45091. * Specifies the ground mirror size ratio.
  45092. * 0.3 by default as the default kernel is 64.
  45093. */
  45094. groundMirrorSizeRatio: number;
  45095. /**
  45096. * Specifies the ground mirror blur kernel size.
  45097. * 64 by default.
  45098. */
  45099. groundMirrorBlurKernel: number;
  45100. /**
  45101. * Specifies the ground mirror visibility amount.
  45102. * 1 by default
  45103. */
  45104. groundMirrorAmount: number;
  45105. /**
  45106. * Specifies the ground mirror reflectance weight.
  45107. * This uses the standard weight of the background material to setup the fresnel effect
  45108. * of the mirror.
  45109. * 1 by default.
  45110. */
  45111. groundMirrorFresnelWeight: number;
  45112. /**
  45113. * Specifies the ground mirror Falloff distance.
  45114. * This can helps reducing the size of the reflection.
  45115. * 0 by Default.
  45116. */
  45117. groundMirrorFallOffDistance: number;
  45118. /**
  45119. * Specifies the ground mirror texture type.
  45120. * Unsigned Int by Default.
  45121. */
  45122. groundMirrorTextureType: number;
  45123. /**
  45124. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45125. * the shown objects.
  45126. */
  45127. groundYBias: number;
  45128. /**
  45129. * Specifies wether or not to create a skybox.
  45130. * True by default.
  45131. */
  45132. createSkybox: boolean;
  45133. /**
  45134. * Specifies the skybox size.
  45135. * 20 by default.
  45136. */
  45137. skyboxSize: number;
  45138. /**
  45139. * The texture used on the skybox for the main color.
  45140. * Comes from the BabylonJS CDN by default.
  45141. *
  45142. * Remarks: Can be either a texture or a url.
  45143. */
  45144. skyboxTexture: string | BaseTexture;
  45145. /**
  45146. * The color mixed in the skybox texture by default.
  45147. * BabylonJS clearColor by default.
  45148. */
  45149. skyboxColor: Color3;
  45150. /**
  45151. * The background rotation around the Y axis of the scene.
  45152. * This helps aligning the key lights of your scene with the background.
  45153. * 0 by default.
  45154. */
  45155. backgroundYRotation: number;
  45156. /**
  45157. * Compute automatically the size of the elements to best fit with the scene.
  45158. */
  45159. sizeAuto: boolean;
  45160. /**
  45161. * Default position of the rootMesh if autoSize is not true.
  45162. */
  45163. rootPosition: Vector3;
  45164. /**
  45165. * Sets up the image processing in the scene.
  45166. * true by default.
  45167. */
  45168. setupImageProcessing: boolean;
  45169. /**
  45170. * The texture used as your environment texture in the scene.
  45171. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45172. *
  45173. * Remarks: Can be either a texture or a url.
  45174. */
  45175. environmentTexture: string | BaseTexture;
  45176. /**
  45177. * The value of the exposure to apply to the scene.
  45178. * 0.6 by default if setupImageProcessing is true.
  45179. */
  45180. cameraExposure: number;
  45181. /**
  45182. * The value of the contrast to apply to the scene.
  45183. * 1.6 by default if setupImageProcessing is true.
  45184. */
  45185. cameraContrast: number;
  45186. /**
  45187. * Specifies wether or not tonemapping should be enabled in the scene.
  45188. * true by default if setupImageProcessing is true.
  45189. */
  45190. toneMappingEnabled: boolean;
  45191. }
  45192. /**
  45193. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45194. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45195. * It also helps with the default setup of your imageProcessing configuration.
  45196. */
  45197. export class EnvironmentHelper {
  45198. /**
  45199. * Default ground texture URL.
  45200. */
  45201. private static _groundTextureCDNUrl;
  45202. /**
  45203. * Default skybox texture URL.
  45204. */
  45205. private static _skyboxTextureCDNUrl;
  45206. /**
  45207. * Default environment texture URL.
  45208. */
  45209. private static _environmentTextureCDNUrl;
  45210. /**
  45211. * Creates the default options for the helper.
  45212. */
  45213. private static _getDefaultOptions;
  45214. private _rootMesh;
  45215. /**
  45216. * Gets the root mesh created by the helper.
  45217. */
  45218. readonly rootMesh: Mesh;
  45219. private _skybox;
  45220. /**
  45221. * Gets the skybox created by the helper.
  45222. */
  45223. readonly skybox: Nullable<Mesh>;
  45224. private _skyboxTexture;
  45225. /**
  45226. * Gets the skybox texture created by the helper.
  45227. */
  45228. readonly skyboxTexture: Nullable<BaseTexture>;
  45229. private _skyboxMaterial;
  45230. /**
  45231. * Gets the skybox material created by the helper.
  45232. */
  45233. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45234. private _ground;
  45235. /**
  45236. * Gets the ground mesh created by the helper.
  45237. */
  45238. readonly ground: Nullable<Mesh>;
  45239. private _groundTexture;
  45240. /**
  45241. * Gets the ground texture created by the helper.
  45242. */
  45243. readonly groundTexture: Nullable<BaseTexture>;
  45244. private _groundMirror;
  45245. /**
  45246. * Gets the ground mirror created by the helper.
  45247. */
  45248. readonly groundMirror: Nullable<MirrorTexture>;
  45249. /**
  45250. * Gets the ground mirror render list to helps pushing the meshes
  45251. * you wish in the ground reflection.
  45252. */
  45253. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45254. private _groundMaterial;
  45255. /**
  45256. * Gets the ground material created by the helper.
  45257. */
  45258. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45259. /**
  45260. * Stores the creation options.
  45261. */
  45262. private readonly _scene;
  45263. private _options;
  45264. /**
  45265. * This observable will be notified with any error during the creation of the environment,
  45266. * mainly texture creation errors.
  45267. */
  45268. onErrorObservable: Observable<{
  45269. message?: string;
  45270. exception?: any;
  45271. }>;
  45272. /**
  45273. * constructor
  45274. * @param options Defines the options we want to customize the helper
  45275. * @param scene The scene to add the material to
  45276. */
  45277. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45278. /**
  45279. * Updates the background according to the new options
  45280. * @param options
  45281. */
  45282. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45283. /**
  45284. * Sets the primary color of all the available elements.
  45285. * @param color the main color to affect to the ground and the background
  45286. */
  45287. setMainColor(color: Color3): void;
  45288. /**
  45289. * Setup the image processing according to the specified options.
  45290. */
  45291. private _setupImageProcessing;
  45292. /**
  45293. * Setup the environment texture according to the specified options.
  45294. */
  45295. private _setupEnvironmentTexture;
  45296. /**
  45297. * Setup the background according to the specified options.
  45298. */
  45299. private _setupBackground;
  45300. /**
  45301. * Get the scene sizes according to the setup.
  45302. */
  45303. private _getSceneSize;
  45304. /**
  45305. * Setup the ground according to the specified options.
  45306. */
  45307. private _setupGround;
  45308. /**
  45309. * Setup the ground material according to the specified options.
  45310. */
  45311. private _setupGroundMaterial;
  45312. /**
  45313. * Setup the ground diffuse texture according to the specified options.
  45314. */
  45315. private _setupGroundDiffuseTexture;
  45316. /**
  45317. * Setup the ground mirror texture according to the specified options.
  45318. */
  45319. private _setupGroundMirrorTexture;
  45320. /**
  45321. * Setup the ground to receive the mirror texture.
  45322. */
  45323. private _setupMirrorInGroundMaterial;
  45324. /**
  45325. * Setup the skybox according to the specified options.
  45326. */
  45327. private _setupSkybox;
  45328. /**
  45329. * Setup the skybox material according to the specified options.
  45330. */
  45331. private _setupSkyboxMaterial;
  45332. /**
  45333. * Setup the skybox reflection texture according to the specified options.
  45334. */
  45335. private _setupSkyboxReflectionTexture;
  45336. private _errorHandler;
  45337. /**
  45338. * Dispose all the elements created by the Helper.
  45339. */
  45340. dispose(): void;
  45341. }
  45342. }
  45343. declare module BABYLON {
  45344. /**
  45345. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45346. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45347. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45348. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45349. */
  45350. export class PhotoDome extends TransformNode {
  45351. /**
  45352. * Define the image as a Monoscopic panoramic 360 image.
  45353. */
  45354. static readonly MODE_MONOSCOPIC: number;
  45355. /**
  45356. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45357. */
  45358. static readonly MODE_TOPBOTTOM: number;
  45359. /**
  45360. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45361. */
  45362. static readonly MODE_SIDEBYSIDE: number;
  45363. private _useDirectMapping;
  45364. /**
  45365. * The texture being displayed on the sphere
  45366. */
  45367. protected _photoTexture: Texture;
  45368. /**
  45369. * Gets or sets the texture being displayed on the sphere
  45370. */
  45371. photoTexture: Texture;
  45372. /**
  45373. * Observable raised when an error occured while loading the 360 image
  45374. */
  45375. onLoadErrorObservable: Observable<string>;
  45376. /**
  45377. * The skybox material
  45378. */
  45379. protected _material: BackgroundMaterial;
  45380. /**
  45381. * The surface used for the skybox
  45382. */
  45383. protected _mesh: Mesh;
  45384. /**
  45385. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45386. * Also see the options.resolution property.
  45387. */
  45388. fovMultiplier: number;
  45389. private _imageMode;
  45390. /**
  45391. * Gets or set the current video mode for the video. It can be:
  45392. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45393. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45394. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45395. */
  45396. imageMode: number;
  45397. /**
  45398. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45399. * @param name Element's name, child elements will append suffixes for their own names.
  45400. * @param urlsOfPhoto defines the url of the photo to display
  45401. * @param options defines an object containing optional or exposed sub element properties
  45402. * @param onError defines a callback called when an error occured while loading the texture
  45403. */
  45404. constructor(name: string, urlOfPhoto: string, options: {
  45405. resolution?: number;
  45406. size?: number;
  45407. useDirectMapping?: boolean;
  45408. faceForward?: boolean;
  45409. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45410. private _onBeforeCameraRenderObserver;
  45411. private _changeImageMode;
  45412. /**
  45413. * Releases resources associated with this node.
  45414. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45415. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45416. */
  45417. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45418. }
  45419. }
  45420. declare module BABYLON {
  45421. /** @hidden */
  45422. export var rgbdDecodePixelShader: {
  45423. name: string;
  45424. shader: string;
  45425. };
  45426. }
  45427. declare module BABYLON {
  45428. /**
  45429. * Class used to host texture specific utilities
  45430. */
  45431. export class BRDFTextureTools {
  45432. /**
  45433. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45434. * @param texture the texture to expand.
  45435. */
  45436. private static _ExpandDefaultBRDFTexture;
  45437. /**
  45438. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45439. * @param scene defines the hosting scene
  45440. * @returns the environment BRDF texture
  45441. */
  45442. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45443. private static _environmentBRDFBase64Texture;
  45444. }
  45445. }
  45446. declare module BABYLON {
  45447. /**
  45448. * @hidden
  45449. */
  45450. export interface IMaterialClearCoatDefines {
  45451. CLEARCOAT: boolean;
  45452. CLEARCOAT_DEFAULTIOR: boolean;
  45453. CLEARCOAT_TEXTURE: boolean;
  45454. CLEARCOAT_TEXTUREDIRECTUV: number;
  45455. CLEARCOAT_BUMP: boolean;
  45456. CLEARCOAT_BUMPDIRECTUV: number;
  45457. CLEARCOAT_TINT: boolean;
  45458. CLEARCOAT_TINT_TEXTURE: boolean;
  45459. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45460. /** @hidden */
  45461. _areTexturesDirty: boolean;
  45462. }
  45463. /**
  45464. * Define the code related to the clear coat parameters of the pbr material.
  45465. */
  45466. export class PBRClearCoatConfiguration {
  45467. /**
  45468. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45469. * The default fits with a polyurethane material.
  45470. */
  45471. private static readonly _DefaultIndexOfRefraction;
  45472. private _isEnabled;
  45473. /**
  45474. * Defines if the clear coat is enabled in the material.
  45475. */
  45476. isEnabled: boolean;
  45477. /**
  45478. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45479. */
  45480. intensity: number;
  45481. /**
  45482. * Defines the clear coat layer roughness.
  45483. */
  45484. roughness: number;
  45485. private _indexOfRefraction;
  45486. /**
  45487. * Defines the index of refraction of the clear coat.
  45488. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45489. * The default fits with a polyurethane material.
  45490. * Changing the default value is more performance intensive.
  45491. */
  45492. indexOfRefraction: number;
  45493. private _texture;
  45494. /**
  45495. * Stores the clear coat values in a texture.
  45496. */
  45497. texture: Nullable<BaseTexture>;
  45498. private _bumpTexture;
  45499. /**
  45500. * Define the clear coat specific bump texture.
  45501. */
  45502. bumpTexture: Nullable<BaseTexture>;
  45503. private _isTintEnabled;
  45504. /**
  45505. * Defines if the clear coat tint is enabled in the material.
  45506. */
  45507. isTintEnabled: boolean;
  45508. /**
  45509. * Defines the clear coat tint of the material.
  45510. * This is only use if tint is enabled
  45511. */
  45512. tintColor: Color3;
  45513. /**
  45514. * Defines the distance at which the tint color should be found in the
  45515. * clear coat media.
  45516. * This is only use if tint is enabled
  45517. */
  45518. tintColorAtDistance: number;
  45519. /**
  45520. * Defines the clear coat layer thickness.
  45521. * This is only use if tint is enabled
  45522. */
  45523. tintThickness: number;
  45524. private _tintTexture;
  45525. /**
  45526. * Stores the clear tint values in a texture.
  45527. * rgb is tint
  45528. * a is a thickness factor
  45529. */
  45530. tintTexture: Nullable<BaseTexture>;
  45531. /** @hidden */
  45532. private _internalMarkAllSubMeshesAsTexturesDirty;
  45533. /** @hidden */
  45534. _markAllSubMeshesAsTexturesDirty(): void;
  45535. /**
  45536. * Instantiate a new istance of clear coat configuration.
  45537. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45538. */
  45539. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45540. /**
  45541. * Gets wehter the submesh is ready to be used or not.
  45542. * @param defines the list of "defines" to update.
  45543. * @param scene defines the scene the material belongs to.
  45544. * @param engine defines the engine the material belongs to.
  45545. * @param disableBumpMap defines wether the material disables bump or not.
  45546. * @returns - boolean indicating that the submesh is ready or not.
  45547. */
  45548. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45549. /**
  45550. * Checks to see if a texture is used in the material.
  45551. * @param defines the list of "defines" to update.
  45552. * @param scene defines the scene to the material belongs to.
  45553. */
  45554. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45555. /**
  45556. * Binds the material data.
  45557. * @param uniformBuffer defines the Uniform buffer to fill in.
  45558. * @param scene defines the scene the material belongs to.
  45559. * @param engine defines the engine the material belongs to.
  45560. * @param disableBumpMap defines wether the material disables bump or not.
  45561. * @param isFrozen defines wether the material is frozen or not.
  45562. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45563. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45564. */
  45565. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45566. /**
  45567. * Checks to see if a texture is used in the material.
  45568. * @param texture - Base texture to use.
  45569. * @returns - Boolean specifying if a texture is used in the material.
  45570. */
  45571. hasTexture(texture: BaseTexture): boolean;
  45572. /**
  45573. * Returns an array of the actively used textures.
  45574. * @param activeTextures Array of BaseTextures
  45575. */
  45576. getActiveTextures(activeTextures: BaseTexture[]): void;
  45577. /**
  45578. * Returns the animatable textures.
  45579. * @param animatables Array of animatable textures.
  45580. */
  45581. getAnimatables(animatables: IAnimatable[]): void;
  45582. /**
  45583. * Disposes the resources of the material.
  45584. * @param forceDisposeTextures - Forces the disposal of all textures.
  45585. */
  45586. dispose(forceDisposeTextures?: boolean): void;
  45587. /**
  45588. * Get the current class name of the texture useful for serialization or dynamic coding.
  45589. * @returns "PBRClearCoatConfiguration"
  45590. */
  45591. getClassName(): string;
  45592. /**
  45593. * Add fallbacks to the effect fallbacks list.
  45594. * @param defines defines the Base texture to use.
  45595. * @param fallbacks defines the current fallback list.
  45596. * @param currentRank defines the current fallback rank.
  45597. * @returns the new fallback rank.
  45598. */
  45599. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45600. /**
  45601. * Add the required uniforms to the current list.
  45602. * @param uniforms defines the current uniform list.
  45603. */
  45604. static AddUniforms(uniforms: string[]): void;
  45605. /**
  45606. * Add the required samplers to the current list.
  45607. * @param samplers defines the current sampler list.
  45608. */
  45609. static AddSamplers(samplers: string[]): void;
  45610. /**
  45611. * Add the required uniforms to the current buffer.
  45612. * @param uniformBuffer defines the current uniform buffer.
  45613. */
  45614. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45615. /**
  45616. * Makes a duplicate of the current configuration into another one.
  45617. * @param clearCoatConfiguration define the config where to copy the info
  45618. */
  45619. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45620. /**
  45621. * Serializes this clear coat configuration.
  45622. * @returns - An object with the serialized config.
  45623. */
  45624. serialize(): any;
  45625. /**
  45626. * Parses a anisotropy Configuration from a serialized object.
  45627. * @param source - Serialized object.
  45628. * @param scene Defines the scene we are parsing for
  45629. * @param rootUrl Defines the rootUrl to load from
  45630. */
  45631. parse(source: any, scene: Scene, rootUrl: string): void;
  45632. }
  45633. }
  45634. declare module BABYLON {
  45635. /**
  45636. * @hidden
  45637. */
  45638. export interface IMaterialAnisotropicDefines {
  45639. ANISOTROPIC: boolean;
  45640. ANISOTROPIC_TEXTURE: boolean;
  45641. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45642. MAINUV1: boolean;
  45643. _areTexturesDirty: boolean;
  45644. _needUVs: boolean;
  45645. }
  45646. /**
  45647. * Define the code related to the anisotropic parameters of the pbr material.
  45648. */
  45649. export class PBRAnisotropicConfiguration {
  45650. private _isEnabled;
  45651. /**
  45652. * Defines if the anisotropy is enabled in the material.
  45653. */
  45654. isEnabled: boolean;
  45655. /**
  45656. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45657. */
  45658. intensity: number;
  45659. /**
  45660. * Defines if the effect is along the tangents, bitangents or in between.
  45661. * By default, the effect is "strectching" the highlights along the tangents.
  45662. */
  45663. direction: Vector2;
  45664. private _texture;
  45665. /**
  45666. * Stores the anisotropy values in a texture.
  45667. * rg is direction (like normal from -1 to 1)
  45668. * b is a intensity
  45669. */
  45670. texture: Nullable<BaseTexture>;
  45671. /** @hidden */
  45672. private _internalMarkAllSubMeshesAsTexturesDirty;
  45673. /** @hidden */
  45674. _markAllSubMeshesAsTexturesDirty(): void;
  45675. /**
  45676. * Instantiate a new istance of anisotropy configuration.
  45677. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45678. */
  45679. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45680. /**
  45681. * Specifies that the submesh is ready to be used.
  45682. * @param defines the list of "defines" to update.
  45683. * @param scene defines the scene the material belongs to.
  45684. * @returns - boolean indicating that the submesh is ready or not.
  45685. */
  45686. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45687. /**
  45688. * Checks to see if a texture is used in the material.
  45689. * @param defines the list of "defines" to update.
  45690. * @param mesh the mesh we are preparing the defines for.
  45691. * @param scene defines the scene the material belongs to.
  45692. */
  45693. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45694. /**
  45695. * Binds the material data.
  45696. * @param uniformBuffer defines the Uniform buffer to fill in.
  45697. * @param scene defines the scene the material belongs to.
  45698. * @param isFrozen defines wether the material is frozen or not.
  45699. */
  45700. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45701. /**
  45702. * Checks to see if a texture is used in the material.
  45703. * @param texture - Base texture to use.
  45704. * @returns - Boolean specifying if a texture is used in the material.
  45705. */
  45706. hasTexture(texture: BaseTexture): boolean;
  45707. /**
  45708. * Returns an array of the actively used textures.
  45709. * @param activeTextures Array of BaseTextures
  45710. */
  45711. getActiveTextures(activeTextures: BaseTexture[]): void;
  45712. /**
  45713. * Returns the animatable textures.
  45714. * @param animatables Array of animatable textures.
  45715. */
  45716. getAnimatables(animatables: IAnimatable[]): void;
  45717. /**
  45718. * Disposes the resources of the material.
  45719. * @param forceDisposeTextures - Forces the disposal of all textures.
  45720. */
  45721. dispose(forceDisposeTextures?: boolean): void;
  45722. /**
  45723. * Get the current class name of the texture useful for serialization or dynamic coding.
  45724. * @returns "PBRAnisotropicConfiguration"
  45725. */
  45726. getClassName(): string;
  45727. /**
  45728. * Add fallbacks to the effect fallbacks list.
  45729. * @param defines defines the Base texture to use.
  45730. * @param fallbacks defines the current fallback list.
  45731. * @param currentRank defines the current fallback rank.
  45732. * @returns the new fallback rank.
  45733. */
  45734. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45735. /**
  45736. * Add the required uniforms to the current list.
  45737. * @param uniforms defines the current uniform list.
  45738. */
  45739. static AddUniforms(uniforms: string[]): void;
  45740. /**
  45741. * Add the required uniforms to the current buffer.
  45742. * @param uniformBuffer defines the current uniform buffer.
  45743. */
  45744. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45745. /**
  45746. * Add the required samplers to the current list.
  45747. * @param samplers defines the current sampler list.
  45748. */
  45749. static AddSamplers(samplers: string[]): void;
  45750. /**
  45751. * Makes a duplicate of the current configuration into another one.
  45752. * @param anisotropicConfiguration define the config where to copy the info
  45753. */
  45754. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45755. /**
  45756. * Serializes this anisotropy configuration.
  45757. * @returns - An object with the serialized config.
  45758. */
  45759. serialize(): any;
  45760. /**
  45761. * Parses a anisotropy Configuration from a serialized object.
  45762. * @param source - Serialized object.
  45763. * @param scene Defines the scene we are parsing for
  45764. * @param rootUrl Defines the rootUrl to load from
  45765. */
  45766. parse(source: any, scene: Scene, rootUrl: string): void;
  45767. }
  45768. }
  45769. declare module BABYLON {
  45770. /**
  45771. * @hidden
  45772. */
  45773. export interface IMaterialBRDFDefines {
  45774. BRDF_V_HEIGHT_CORRELATED: boolean;
  45775. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45776. SPHERICAL_HARMONICS: boolean;
  45777. /** @hidden */
  45778. _areMiscDirty: boolean;
  45779. }
  45780. /**
  45781. * Define the code related to the BRDF parameters of the pbr material.
  45782. */
  45783. export class PBRBRDFConfiguration {
  45784. /**
  45785. * Default value used for the energy conservation.
  45786. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45787. */
  45788. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45789. /**
  45790. * Default value used for the Smith Visibility Height Correlated mode.
  45791. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45792. */
  45793. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45794. /**
  45795. * Default value used for the IBL diffuse part.
  45796. * This can help switching back to the polynomials mode globally which is a tiny bit
  45797. * less GPU intensive at the drawback of a lower quality.
  45798. */
  45799. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45800. private _useEnergyConservation;
  45801. /**
  45802. * Defines if the material uses energy conservation.
  45803. */
  45804. useEnergyConservation: boolean;
  45805. private _useSmithVisibilityHeightCorrelated;
  45806. /**
  45807. * LEGACY Mode set to false
  45808. * Defines if the material uses height smith correlated visibility term.
  45809. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45810. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45811. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45812. * Not relying on height correlated will also disable energy conservation.
  45813. */
  45814. useSmithVisibilityHeightCorrelated: boolean;
  45815. private _useSphericalHarmonics;
  45816. /**
  45817. * LEGACY Mode set to false
  45818. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45819. * diffuse part of the IBL.
  45820. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45821. * to the ground truth.
  45822. */
  45823. useSphericalHarmonics: boolean;
  45824. /** @hidden */
  45825. private _internalMarkAllSubMeshesAsMiscDirty;
  45826. /** @hidden */
  45827. _markAllSubMeshesAsMiscDirty(): void;
  45828. /**
  45829. * Instantiate a new istance of clear coat configuration.
  45830. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45831. */
  45832. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45833. /**
  45834. * Checks to see if a texture is used in the material.
  45835. * @param defines the list of "defines" to update.
  45836. */
  45837. prepareDefines(defines: IMaterialBRDFDefines): void;
  45838. /**
  45839. * Get the current class name of the texture useful for serialization or dynamic coding.
  45840. * @returns "PBRClearCoatConfiguration"
  45841. */
  45842. getClassName(): string;
  45843. /**
  45844. * Makes a duplicate of the current configuration into another one.
  45845. * @param brdfConfiguration define the config where to copy the info
  45846. */
  45847. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45848. /**
  45849. * Serializes this BRDF configuration.
  45850. * @returns - An object with the serialized config.
  45851. */
  45852. serialize(): any;
  45853. /**
  45854. * Parses a anisotropy Configuration from a serialized object.
  45855. * @param source - Serialized object.
  45856. * @param scene Defines the scene we are parsing for
  45857. * @param rootUrl Defines the rootUrl to load from
  45858. */
  45859. parse(source: any, scene: Scene, rootUrl: string): void;
  45860. }
  45861. }
  45862. declare module BABYLON {
  45863. /**
  45864. * @hidden
  45865. */
  45866. export interface IMaterialSheenDefines {
  45867. SHEEN: boolean;
  45868. SHEEN_TEXTURE: boolean;
  45869. SHEEN_TEXTUREDIRECTUV: number;
  45870. SHEEN_LINKWITHALBEDO: boolean;
  45871. /** @hidden */
  45872. _areTexturesDirty: boolean;
  45873. }
  45874. /**
  45875. * Define the code related to the Sheen parameters of the pbr material.
  45876. */
  45877. export class PBRSheenConfiguration {
  45878. private _isEnabled;
  45879. /**
  45880. * Defines if the material uses sheen.
  45881. */
  45882. isEnabled: boolean;
  45883. private _linkSheenWithAlbedo;
  45884. /**
  45885. * Defines if the sheen is linked to the sheen color.
  45886. */
  45887. linkSheenWithAlbedo: boolean;
  45888. /**
  45889. * Defines the sheen intensity.
  45890. */
  45891. intensity: number;
  45892. /**
  45893. * Defines the sheen color.
  45894. */
  45895. color: Color3;
  45896. private _texture;
  45897. /**
  45898. * Stores the sheen tint values in a texture.
  45899. * rgb is tint
  45900. * a is a intensity
  45901. */
  45902. texture: Nullable<BaseTexture>;
  45903. /** @hidden */
  45904. private _internalMarkAllSubMeshesAsTexturesDirty;
  45905. /** @hidden */
  45906. _markAllSubMeshesAsTexturesDirty(): void;
  45907. /**
  45908. * Instantiate a new istance of clear coat configuration.
  45909. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45910. */
  45911. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45912. /**
  45913. * Specifies that the submesh is ready to be used.
  45914. * @param defines the list of "defines" to update.
  45915. * @param scene defines the scene the material belongs to.
  45916. * @returns - boolean indicating that the submesh is ready or not.
  45917. */
  45918. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45919. /**
  45920. * Checks to see if a texture is used in the material.
  45921. * @param defines the list of "defines" to update.
  45922. * @param scene defines the scene the material belongs to.
  45923. */
  45924. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45925. /**
  45926. * Binds the material data.
  45927. * @param uniformBuffer defines the Uniform buffer to fill in.
  45928. * @param scene defines the scene the material belongs to.
  45929. * @param isFrozen defines wether the material is frozen or not.
  45930. */
  45931. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45932. /**
  45933. * Checks to see if a texture is used in the material.
  45934. * @param texture - Base texture to use.
  45935. * @returns - Boolean specifying if a texture is used in the material.
  45936. */
  45937. hasTexture(texture: BaseTexture): boolean;
  45938. /**
  45939. * Returns an array of the actively used textures.
  45940. * @param activeTextures Array of BaseTextures
  45941. */
  45942. getActiveTextures(activeTextures: BaseTexture[]): void;
  45943. /**
  45944. * Returns the animatable textures.
  45945. * @param animatables Array of animatable textures.
  45946. */
  45947. getAnimatables(animatables: IAnimatable[]): void;
  45948. /**
  45949. * Disposes the resources of the material.
  45950. * @param forceDisposeTextures - Forces the disposal of all textures.
  45951. */
  45952. dispose(forceDisposeTextures?: boolean): void;
  45953. /**
  45954. * Get the current class name of the texture useful for serialization or dynamic coding.
  45955. * @returns "PBRSheenConfiguration"
  45956. */
  45957. getClassName(): string;
  45958. /**
  45959. * Add fallbacks to the effect fallbacks list.
  45960. * @param defines defines the Base texture to use.
  45961. * @param fallbacks defines the current fallback list.
  45962. * @param currentRank defines the current fallback rank.
  45963. * @returns the new fallback rank.
  45964. */
  45965. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45966. /**
  45967. * Add the required uniforms to the current list.
  45968. * @param uniforms defines the current uniform list.
  45969. */
  45970. static AddUniforms(uniforms: string[]): void;
  45971. /**
  45972. * Add the required uniforms to the current buffer.
  45973. * @param uniformBuffer defines the current uniform buffer.
  45974. */
  45975. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45976. /**
  45977. * Add the required samplers to the current list.
  45978. * @param samplers defines the current sampler list.
  45979. */
  45980. static AddSamplers(samplers: string[]): void;
  45981. /**
  45982. * Makes a duplicate of the current configuration into another one.
  45983. * @param sheenConfiguration define the config where to copy the info
  45984. */
  45985. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45986. /**
  45987. * Serializes this BRDF configuration.
  45988. * @returns - An object with the serialized config.
  45989. */
  45990. serialize(): any;
  45991. /**
  45992. * Parses a anisotropy Configuration from a serialized object.
  45993. * @param source - Serialized object.
  45994. * @param scene Defines the scene we are parsing for
  45995. * @param rootUrl Defines the rootUrl to load from
  45996. */
  45997. parse(source: any, scene: Scene, rootUrl: string): void;
  45998. }
  45999. }
  46000. declare module BABYLON {
  46001. /**
  46002. * @hidden
  46003. */
  46004. export interface IMaterialSubSurfaceDefines {
  46005. SUBSURFACE: boolean;
  46006. SS_REFRACTION: boolean;
  46007. SS_TRANSLUCENCY: boolean;
  46008. SS_SCATERRING: boolean;
  46009. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46010. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46011. SS_REFRACTIONMAP_3D: boolean;
  46012. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46013. SS_LODINREFRACTIONALPHA: boolean;
  46014. SS_GAMMAREFRACTION: boolean;
  46015. SS_RGBDREFRACTION: boolean;
  46016. SS_LINEARSPECULARREFRACTION: boolean;
  46017. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46018. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46019. /** @hidden */
  46020. _areTexturesDirty: boolean;
  46021. }
  46022. /**
  46023. * Define the code related to the sub surface parameters of the pbr material.
  46024. */
  46025. export class PBRSubSurfaceConfiguration {
  46026. private _isRefractionEnabled;
  46027. /**
  46028. * Defines if the refraction is enabled in the material.
  46029. */
  46030. isRefractionEnabled: boolean;
  46031. private _isTranslucencyEnabled;
  46032. /**
  46033. * Defines if the translucency is enabled in the material.
  46034. */
  46035. isTranslucencyEnabled: boolean;
  46036. private _isScatteringEnabled;
  46037. /**
  46038. * Defines the refraction intensity of the material.
  46039. * The refraction when enabled replaces the Diffuse part of the material.
  46040. * The intensity helps transitionning between diffuse and refraction.
  46041. */
  46042. refractionIntensity: number;
  46043. /**
  46044. * Defines the translucency intensity of the material.
  46045. * When translucency has been enabled, this defines how much of the "translucency"
  46046. * is addded to the diffuse part of the material.
  46047. */
  46048. translucencyIntensity: number;
  46049. /**
  46050. * Defines the scattering intensity of the material.
  46051. * When scattering has been enabled, this defines how much of the "scattered light"
  46052. * is addded to the diffuse part of the material.
  46053. */
  46054. scatteringIntensity: number;
  46055. private _thicknessTexture;
  46056. /**
  46057. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46058. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46059. * 0 would mean minimumThickness
  46060. * 1 would mean maximumThickness
  46061. * The other channels might be use as a mask to vary the different effects intensity.
  46062. */
  46063. thicknessTexture: Nullable<BaseTexture>;
  46064. private _refractionTexture;
  46065. /**
  46066. * Defines the texture to use for refraction.
  46067. */
  46068. refractionTexture: Nullable<BaseTexture>;
  46069. private _indexOfRefraction;
  46070. /**
  46071. * Defines the index of refraction used in the material.
  46072. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46073. */
  46074. indexOfRefraction: number;
  46075. private _invertRefractionY;
  46076. /**
  46077. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46078. */
  46079. invertRefractionY: boolean;
  46080. private _linkRefractionWithTransparency;
  46081. /**
  46082. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46083. * Materials half opaque for instance using refraction could benefit from this control.
  46084. */
  46085. linkRefractionWithTransparency: boolean;
  46086. /**
  46087. * Defines the minimum thickness stored in the thickness map.
  46088. * If no thickness map is defined, this value will be used to simulate thickness.
  46089. */
  46090. minimumThickness: number;
  46091. /**
  46092. * Defines the maximum thickness stored in the thickness map.
  46093. */
  46094. maximumThickness: number;
  46095. /**
  46096. * Defines the volume tint of the material.
  46097. * This is used for both translucency and scattering.
  46098. */
  46099. tintColor: Color3;
  46100. /**
  46101. * Defines the distance at which the tint color should be found in the media.
  46102. * This is used for refraction only.
  46103. */
  46104. tintColorAtDistance: number;
  46105. /**
  46106. * Defines how far each channel transmit through the media.
  46107. * It is defined as a color to simplify it selection.
  46108. */
  46109. diffusionDistance: Color3;
  46110. private _useMaskFromThicknessTexture;
  46111. /**
  46112. * Stores the intensity of the different subsurface effects in the thickness texture.
  46113. * * the green channel is the translucency intensity.
  46114. * * the blue channel is the scattering intensity.
  46115. * * the alpha channel is the refraction intensity.
  46116. */
  46117. useMaskFromThicknessTexture: boolean;
  46118. /** @hidden */
  46119. private _internalMarkAllSubMeshesAsTexturesDirty;
  46120. /** @hidden */
  46121. _markAllSubMeshesAsTexturesDirty(): void;
  46122. /**
  46123. * Instantiate a new istance of sub surface configuration.
  46124. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46125. */
  46126. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46127. /**
  46128. * Gets wehter the submesh is ready to be used or not.
  46129. * @param defines the list of "defines" to update.
  46130. * @param scene defines the scene the material belongs to.
  46131. * @returns - boolean indicating that the submesh is ready or not.
  46132. */
  46133. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46134. /**
  46135. * Checks to see if a texture is used in the material.
  46136. * @param defines the list of "defines" to update.
  46137. * @param scene defines the scene to the material belongs to.
  46138. */
  46139. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46140. /**
  46141. * Binds the material data.
  46142. * @param uniformBuffer defines the Uniform buffer to fill in.
  46143. * @param scene defines the scene the material belongs to.
  46144. * @param engine defines the engine the material belongs to.
  46145. * @param isFrozen defines wether the material is frozen or not.
  46146. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46147. */
  46148. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46149. /**
  46150. * Unbinds the material from the mesh.
  46151. * @param activeEffect defines the effect that should be unbound from.
  46152. * @returns true if unbound, otherwise false
  46153. */
  46154. unbind(activeEffect: Effect): boolean;
  46155. /**
  46156. * Returns the texture used for refraction or null if none is used.
  46157. * @param scene defines the scene the material belongs to.
  46158. * @returns - Refraction texture if present. If no refraction texture and refraction
  46159. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46160. */
  46161. private _getRefractionTexture;
  46162. /**
  46163. * Returns true if alpha blending should be disabled.
  46164. */
  46165. readonly disableAlphaBlending: boolean;
  46166. /**
  46167. * Fills the list of render target textures.
  46168. * @param renderTargets the list of render targets to update
  46169. */
  46170. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46171. /**
  46172. * Checks to see if a texture is used in the material.
  46173. * @param texture - Base texture to use.
  46174. * @returns - Boolean specifying if a texture is used in the material.
  46175. */
  46176. hasTexture(texture: BaseTexture): boolean;
  46177. /**
  46178. * Gets a boolean indicating that current material needs to register RTT
  46179. * @returns true if this uses a render target otherwise false.
  46180. */
  46181. hasRenderTargetTextures(): boolean;
  46182. /**
  46183. * Returns an array of the actively used textures.
  46184. * @param activeTextures Array of BaseTextures
  46185. */
  46186. getActiveTextures(activeTextures: BaseTexture[]): void;
  46187. /**
  46188. * Returns the animatable textures.
  46189. * @param animatables Array of animatable textures.
  46190. */
  46191. getAnimatables(animatables: IAnimatable[]): void;
  46192. /**
  46193. * Disposes the resources of the material.
  46194. * @param forceDisposeTextures - Forces the disposal of all textures.
  46195. */
  46196. dispose(forceDisposeTextures?: boolean): void;
  46197. /**
  46198. * Get the current class name of the texture useful for serialization or dynamic coding.
  46199. * @returns "PBRSubSurfaceConfiguration"
  46200. */
  46201. getClassName(): string;
  46202. /**
  46203. * Add fallbacks to the effect fallbacks list.
  46204. * @param defines defines the Base texture to use.
  46205. * @param fallbacks defines the current fallback list.
  46206. * @param currentRank defines the current fallback rank.
  46207. * @returns the new fallback rank.
  46208. */
  46209. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46210. /**
  46211. * Add the required uniforms to the current list.
  46212. * @param uniforms defines the current uniform list.
  46213. */
  46214. static AddUniforms(uniforms: string[]): void;
  46215. /**
  46216. * Add the required samplers to the current list.
  46217. * @param samplers defines the current sampler list.
  46218. */
  46219. static AddSamplers(samplers: string[]): void;
  46220. /**
  46221. * Add the required uniforms to the current buffer.
  46222. * @param uniformBuffer defines the current uniform buffer.
  46223. */
  46224. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46225. /**
  46226. * Makes a duplicate of the current configuration into another one.
  46227. * @param configuration define the config where to copy the info
  46228. */
  46229. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46230. /**
  46231. * Serializes this Sub Surface configuration.
  46232. * @returns - An object with the serialized config.
  46233. */
  46234. serialize(): any;
  46235. /**
  46236. * Parses a anisotropy Configuration from a serialized object.
  46237. * @param source - Serialized object.
  46238. * @param scene Defines the scene we are parsing for
  46239. * @param rootUrl Defines the rootUrl to load from
  46240. */
  46241. parse(source: any, scene: Scene, rootUrl: string): void;
  46242. }
  46243. }
  46244. declare module BABYLON {
  46245. /** @hidden */
  46246. export var pbrFragmentDeclaration: {
  46247. name: string;
  46248. shader: string;
  46249. };
  46250. }
  46251. declare module BABYLON {
  46252. /** @hidden */
  46253. export var pbrUboDeclaration: {
  46254. name: string;
  46255. shader: string;
  46256. };
  46257. }
  46258. declare module BABYLON {
  46259. /** @hidden */
  46260. export var pbrFragmentExtraDeclaration: {
  46261. name: string;
  46262. shader: string;
  46263. };
  46264. }
  46265. declare module BABYLON {
  46266. /** @hidden */
  46267. export var pbrFragmentSamplersDeclaration: {
  46268. name: string;
  46269. shader: string;
  46270. };
  46271. }
  46272. declare module BABYLON {
  46273. /** @hidden */
  46274. export var pbrHelperFunctions: {
  46275. name: string;
  46276. shader: string;
  46277. };
  46278. }
  46279. declare module BABYLON {
  46280. /** @hidden */
  46281. export var harmonicsFunctions: {
  46282. name: string;
  46283. shader: string;
  46284. };
  46285. }
  46286. declare module BABYLON {
  46287. /** @hidden */
  46288. export var pbrDirectLightingSetupFunctions: {
  46289. name: string;
  46290. shader: string;
  46291. };
  46292. }
  46293. declare module BABYLON {
  46294. /** @hidden */
  46295. export var pbrDirectLightingFalloffFunctions: {
  46296. name: string;
  46297. shader: string;
  46298. };
  46299. }
  46300. declare module BABYLON {
  46301. /** @hidden */
  46302. export var pbrBRDFFunctions: {
  46303. name: string;
  46304. shader: string;
  46305. };
  46306. }
  46307. declare module BABYLON {
  46308. /** @hidden */
  46309. export var pbrDirectLightingFunctions: {
  46310. name: string;
  46311. shader: string;
  46312. };
  46313. }
  46314. declare module BABYLON {
  46315. /** @hidden */
  46316. export var pbrIBLFunctions: {
  46317. name: string;
  46318. shader: string;
  46319. };
  46320. }
  46321. declare module BABYLON {
  46322. /** @hidden */
  46323. export var pbrDebug: {
  46324. name: string;
  46325. shader: string;
  46326. };
  46327. }
  46328. declare module BABYLON {
  46329. /** @hidden */
  46330. export var pbrPixelShader: {
  46331. name: string;
  46332. shader: string;
  46333. };
  46334. }
  46335. declare module BABYLON {
  46336. /** @hidden */
  46337. export var pbrVertexDeclaration: {
  46338. name: string;
  46339. shader: string;
  46340. };
  46341. }
  46342. declare module BABYLON {
  46343. /** @hidden */
  46344. export var pbrVertexShader: {
  46345. name: string;
  46346. shader: string;
  46347. };
  46348. }
  46349. declare module BABYLON {
  46350. /**
  46351. * Manages the defines for the PBR Material.
  46352. * @hidden
  46353. */
  46354. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46355. PBR: boolean;
  46356. MAINUV1: boolean;
  46357. MAINUV2: boolean;
  46358. UV1: boolean;
  46359. UV2: boolean;
  46360. ALBEDO: boolean;
  46361. ALBEDODIRECTUV: number;
  46362. VERTEXCOLOR: boolean;
  46363. AMBIENT: boolean;
  46364. AMBIENTDIRECTUV: number;
  46365. AMBIENTINGRAYSCALE: boolean;
  46366. OPACITY: boolean;
  46367. VERTEXALPHA: boolean;
  46368. OPACITYDIRECTUV: number;
  46369. OPACITYRGB: boolean;
  46370. ALPHATEST: boolean;
  46371. DEPTHPREPASS: boolean;
  46372. ALPHABLEND: boolean;
  46373. ALPHAFROMALBEDO: boolean;
  46374. ALPHATESTVALUE: string;
  46375. SPECULAROVERALPHA: boolean;
  46376. RADIANCEOVERALPHA: boolean;
  46377. ALPHAFRESNEL: boolean;
  46378. LINEARALPHAFRESNEL: boolean;
  46379. PREMULTIPLYALPHA: boolean;
  46380. EMISSIVE: boolean;
  46381. EMISSIVEDIRECTUV: number;
  46382. REFLECTIVITY: boolean;
  46383. REFLECTIVITYDIRECTUV: number;
  46384. SPECULARTERM: boolean;
  46385. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46386. MICROSURFACEAUTOMATIC: boolean;
  46387. LODBASEDMICROSFURACE: boolean;
  46388. MICROSURFACEMAP: boolean;
  46389. MICROSURFACEMAPDIRECTUV: number;
  46390. METALLICWORKFLOW: boolean;
  46391. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46392. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46393. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46394. AOSTOREINMETALMAPRED: boolean;
  46395. ENVIRONMENTBRDF: boolean;
  46396. ENVIRONMENTBRDF_RGBD: boolean;
  46397. NORMAL: boolean;
  46398. TANGENT: boolean;
  46399. BUMP: boolean;
  46400. BUMPDIRECTUV: number;
  46401. OBJECTSPACE_NORMALMAP: boolean;
  46402. PARALLAX: boolean;
  46403. PARALLAXOCCLUSION: boolean;
  46404. NORMALXYSCALE: boolean;
  46405. LIGHTMAP: boolean;
  46406. LIGHTMAPDIRECTUV: number;
  46407. USELIGHTMAPASSHADOWMAP: boolean;
  46408. GAMMALIGHTMAP: boolean;
  46409. REFLECTION: boolean;
  46410. REFLECTIONMAP_3D: boolean;
  46411. REFLECTIONMAP_SPHERICAL: boolean;
  46412. REFLECTIONMAP_PLANAR: boolean;
  46413. REFLECTIONMAP_CUBIC: boolean;
  46414. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46415. REFLECTIONMAP_PROJECTION: boolean;
  46416. REFLECTIONMAP_SKYBOX: boolean;
  46417. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46418. REFLECTIONMAP_EXPLICIT: boolean;
  46419. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46420. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46421. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46422. INVERTCUBICMAP: boolean;
  46423. USESPHERICALFROMREFLECTIONMAP: boolean;
  46424. USEIRRADIANCEMAP: boolean;
  46425. SPHERICAL_HARMONICS: boolean;
  46426. USESPHERICALINVERTEX: boolean;
  46427. REFLECTIONMAP_OPPOSITEZ: boolean;
  46428. LODINREFLECTIONALPHA: boolean;
  46429. GAMMAREFLECTION: boolean;
  46430. RGBDREFLECTION: boolean;
  46431. LINEARSPECULARREFLECTION: boolean;
  46432. RADIANCEOCCLUSION: boolean;
  46433. HORIZONOCCLUSION: boolean;
  46434. INSTANCES: boolean;
  46435. NUM_BONE_INFLUENCERS: number;
  46436. BonesPerMesh: number;
  46437. BONETEXTURE: boolean;
  46438. NONUNIFORMSCALING: boolean;
  46439. MORPHTARGETS: boolean;
  46440. MORPHTARGETS_NORMAL: boolean;
  46441. MORPHTARGETS_TANGENT: boolean;
  46442. MORPHTARGETS_UV: boolean;
  46443. NUM_MORPH_INFLUENCERS: number;
  46444. IMAGEPROCESSING: boolean;
  46445. VIGNETTE: boolean;
  46446. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46447. VIGNETTEBLENDMODEOPAQUE: boolean;
  46448. TONEMAPPING: boolean;
  46449. TONEMAPPING_ACES: boolean;
  46450. CONTRAST: boolean;
  46451. COLORCURVES: boolean;
  46452. COLORGRADING: boolean;
  46453. COLORGRADING3D: boolean;
  46454. SAMPLER3DGREENDEPTH: boolean;
  46455. SAMPLER3DBGRMAP: boolean;
  46456. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46457. EXPOSURE: boolean;
  46458. MULTIVIEW: boolean;
  46459. USEPHYSICALLIGHTFALLOFF: boolean;
  46460. USEGLTFLIGHTFALLOFF: boolean;
  46461. TWOSIDEDLIGHTING: boolean;
  46462. SHADOWFLOAT: boolean;
  46463. CLIPPLANE: boolean;
  46464. CLIPPLANE2: boolean;
  46465. CLIPPLANE3: boolean;
  46466. CLIPPLANE4: boolean;
  46467. POINTSIZE: boolean;
  46468. FOG: boolean;
  46469. LOGARITHMICDEPTH: boolean;
  46470. FORCENORMALFORWARD: boolean;
  46471. SPECULARAA: boolean;
  46472. CLEARCOAT: boolean;
  46473. CLEARCOAT_DEFAULTIOR: boolean;
  46474. CLEARCOAT_TEXTURE: boolean;
  46475. CLEARCOAT_TEXTUREDIRECTUV: number;
  46476. CLEARCOAT_BUMP: boolean;
  46477. CLEARCOAT_BUMPDIRECTUV: number;
  46478. CLEARCOAT_TINT: boolean;
  46479. CLEARCOAT_TINT_TEXTURE: boolean;
  46480. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46481. ANISOTROPIC: boolean;
  46482. ANISOTROPIC_TEXTURE: boolean;
  46483. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46484. BRDF_V_HEIGHT_CORRELATED: boolean;
  46485. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46486. SHEEN: boolean;
  46487. SHEEN_TEXTURE: boolean;
  46488. SHEEN_TEXTUREDIRECTUV: number;
  46489. SHEEN_LINKWITHALBEDO: boolean;
  46490. SUBSURFACE: boolean;
  46491. SS_REFRACTION: boolean;
  46492. SS_TRANSLUCENCY: boolean;
  46493. SS_SCATERRING: boolean;
  46494. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46495. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46496. SS_REFRACTIONMAP_3D: boolean;
  46497. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46498. SS_LODINREFRACTIONALPHA: boolean;
  46499. SS_GAMMAREFRACTION: boolean;
  46500. SS_RGBDREFRACTION: boolean;
  46501. SS_LINEARSPECULARREFRACTION: boolean;
  46502. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46503. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46504. UNLIT: boolean;
  46505. DEBUGMODE: number;
  46506. /**
  46507. * Initializes the PBR Material defines.
  46508. */
  46509. constructor();
  46510. /**
  46511. * Resets the PBR Material defines.
  46512. */
  46513. reset(): void;
  46514. }
  46515. /**
  46516. * The Physically based material base class of BJS.
  46517. *
  46518. * This offers the main features of a standard PBR material.
  46519. * For more information, please refer to the documentation :
  46520. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46521. */
  46522. export abstract class PBRBaseMaterial extends PushMaterial {
  46523. /**
  46524. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46525. */
  46526. static readonly PBRMATERIAL_OPAQUE: number;
  46527. /**
  46528. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46529. */
  46530. static readonly PBRMATERIAL_ALPHATEST: number;
  46531. /**
  46532. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46533. */
  46534. static readonly PBRMATERIAL_ALPHABLEND: number;
  46535. /**
  46536. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46537. * They are also discarded below the alpha cutoff threshold to improve performances.
  46538. */
  46539. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46540. /**
  46541. * Defines the default value of how much AO map is occluding the analytical lights
  46542. * (point spot...).
  46543. */
  46544. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46545. /**
  46546. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46547. */
  46548. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46549. /**
  46550. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46551. * to enhance interoperability with other engines.
  46552. */
  46553. static readonly LIGHTFALLOFF_GLTF: number;
  46554. /**
  46555. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46556. * to enhance interoperability with other materials.
  46557. */
  46558. static readonly LIGHTFALLOFF_STANDARD: number;
  46559. /**
  46560. * Intensity of the direct lights e.g. the four lights available in your scene.
  46561. * This impacts both the direct diffuse and specular highlights.
  46562. */
  46563. protected _directIntensity: number;
  46564. /**
  46565. * Intensity of the emissive part of the material.
  46566. * This helps controlling the emissive effect without modifying the emissive color.
  46567. */
  46568. protected _emissiveIntensity: number;
  46569. /**
  46570. * Intensity of the environment e.g. how much the environment will light the object
  46571. * either through harmonics for rough material or through the refelction for shiny ones.
  46572. */
  46573. protected _environmentIntensity: number;
  46574. /**
  46575. * This is a special control allowing the reduction of the specular highlights coming from the
  46576. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46577. */
  46578. protected _specularIntensity: number;
  46579. /**
  46580. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46581. */
  46582. private _lightingInfos;
  46583. /**
  46584. * Debug Control allowing disabling the bump map on this material.
  46585. */
  46586. protected _disableBumpMap: boolean;
  46587. /**
  46588. * AKA Diffuse Texture in standard nomenclature.
  46589. */
  46590. protected _albedoTexture: Nullable<BaseTexture>;
  46591. /**
  46592. * AKA Occlusion Texture in other nomenclature.
  46593. */
  46594. protected _ambientTexture: Nullable<BaseTexture>;
  46595. /**
  46596. * AKA Occlusion Texture Intensity in other nomenclature.
  46597. */
  46598. protected _ambientTextureStrength: number;
  46599. /**
  46600. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46601. * 1 means it completely occludes it
  46602. * 0 mean it has no impact
  46603. */
  46604. protected _ambientTextureImpactOnAnalyticalLights: number;
  46605. /**
  46606. * Stores the alpha values in a texture.
  46607. */
  46608. protected _opacityTexture: Nullable<BaseTexture>;
  46609. /**
  46610. * Stores the reflection values in a texture.
  46611. */
  46612. protected _reflectionTexture: Nullable<BaseTexture>;
  46613. /**
  46614. * Stores the emissive values in a texture.
  46615. */
  46616. protected _emissiveTexture: Nullable<BaseTexture>;
  46617. /**
  46618. * AKA Specular texture in other nomenclature.
  46619. */
  46620. protected _reflectivityTexture: Nullable<BaseTexture>;
  46621. /**
  46622. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46623. */
  46624. protected _metallicTexture: Nullable<BaseTexture>;
  46625. /**
  46626. * Specifies the metallic scalar of the metallic/roughness workflow.
  46627. * Can also be used to scale the metalness values of the metallic texture.
  46628. */
  46629. protected _metallic: Nullable<number>;
  46630. /**
  46631. * Specifies the roughness scalar of the metallic/roughness workflow.
  46632. * Can also be used to scale the roughness values of the metallic texture.
  46633. */
  46634. protected _roughness: Nullable<number>;
  46635. /**
  46636. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46637. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46638. */
  46639. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46640. /**
  46641. * Stores surface normal data used to displace a mesh in a texture.
  46642. */
  46643. protected _bumpTexture: Nullable<BaseTexture>;
  46644. /**
  46645. * Stores the pre-calculated light information of a mesh in a texture.
  46646. */
  46647. protected _lightmapTexture: Nullable<BaseTexture>;
  46648. /**
  46649. * The color of a material in ambient lighting.
  46650. */
  46651. protected _ambientColor: Color3;
  46652. /**
  46653. * AKA Diffuse Color in other nomenclature.
  46654. */
  46655. protected _albedoColor: Color3;
  46656. /**
  46657. * AKA Specular Color in other nomenclature.
  46658. */
  46659. protected _reflectivityColor: Color3;
  46660. /**
  46661. * The color applied when light is reflected from a material.
  46662. */
  46663. protected _reflectionColor: Color3;
  46664. /**
  46665. * The color applied when light is emitted from a material.
  46666. */
  46667. protected _emissiveColor: Color3;
  46668. /**
  46669. * AKA Glossiness in other nomenclature.
  46670. */
  46671. protected _microSurface: number;
  46672. /**
  46673. * Specifies that the material will use the light map as a show map.
  46674. */
  46675. protected _useLightmapAsShadowmap: boolean;
  46676. /**
  46677. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46678. * makes the reflect vector face the model (under horizon).
  46679. */
  46680. protected _useHorizonOcclusion: boolean;
  46681. /**
  46682. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46683. * too much the area relying on ambient texture to define their ambient occlusion.
  46684. */
  46685. protected _useRadianceOcclusion: boolean;
  46686. /**
  46687. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46688. */
  46689. protected _useAlphaFromAlbedoTexture: boolean;
  46690. /**
  46691. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46692. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46693. */
  46694. protected _useSpecularOverAlpha: boolean;
  46695. /**
  46696. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46697. */
  46698. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46699. /**
  46700. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46701. */
  46702. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46703. /**
  46704. * Specifies if the metallic texture contains the roughness information in its green channel.
  46705. */
  46706. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46707. /**
  46708. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46709. */
  46710. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46711. /**
  46712. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46713. */
  46714. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46715. /**
  46716. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46717. */
  46718. protected _useAmbientInGrayScale: boolean;
  46719. /**
  46720. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46721. * The material will try to infer what glossiness each pixel should be.
  46722. */
  46723. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46724. /**
  46725. * Defines the falloff type used in this material.
  46726. * It by default is Physical.
  46727. */
  46728. protected _lightFalloff: number;
  46729. /**
  46730. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46731. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46732. */
  46733. protected _useRadianceOverAlpha: boolean;
  46734. /**
  46735. * Allows using an object space normal map (instead of tangent space).
  46736. */
  46737. protected _useObjectSpaceNormalMap: boolean;
  46738. /**
  46739. * Allows using the bump map in parallax mode.
  46740. */
  46741. protected _useParallax: boolean;
  46742. /**
  46743. * Allows using the bump map in parallax occlusion mode.
  46744. */
  46745. protected _useParallaxOcclusion: boolean;
  46746. /**
  46747. * Controls the scale bias of the parallax mode.
  46748. */
  46749. protected _parallaxScaleBias: number;
  46750. /**
  46751. * If sets to true, disables all the lights affecting the material.
  46752. */
  46753. protected _disableLighting: boolean;
  46754. /**
  46755. * Number of Simultaneous lights allowed on the material.
  46756. */
  46757. protected _maxSimultaneousLights: number;
  46758. /**
  46759. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46760. */
  46761. protected _invertNormalMapX: boolean;
  46762. /**
  46763. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46764. */
  46765. protected _invertNormalMapY: boolean;
  46766. /**
  46767. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46768. */
  46769. protected _twoSidedLighting: boolean;
  46770. /**
  46771. * Defines the alpha limits in alpha test mode.
  46772. */
  46773. protected _alphaCutOff: number;
  46774. /**
  46775. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46776. */
  46777. protected _forceAlphaTest: boolean;
  46778. /**
  46779. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46780. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46781. */
  46782. protected _useAlphaFresnel: boolean;
  46783. /**
  46784. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46785. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46786. */
  46787. protected _useLinearAlphaFresnel: boolean;
  46788. /**
  46789. * The transparency mode of the material.
  46790. */
  46791. protected _transparencyMode: Nullable<number>;
  46792. /**
  46793. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46794. * from cos thetav and roughness:
  46795. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46796. */
  46797. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46798. /**
  46799. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46800. */
  46801. protected _forceIrradianceInFragment: boolean;
  46802. /**
  46803. * Force normal to face away from face.
  46804. */
  46805. protected _forceNormalForward: boolean;
  46806. /**
  46807. * Enables specular anti aliasing in the PBR shader.
  46808. * It will both interacts on the Geometry for analytical and IBL lighting.
  46809. * It also prefilter the roughness map based on the bump values.
  46810. */
  46811. protected _enableSpecularAntiAliasing: boolean;
  46812. /**
  46813. * Default configuration related to image processing available in the PBR Material.
  46814. */
  46815. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46816. /**
  46817. * Keep track of the image processing observer to allow dispose and replace.
  46818. */
  46819. private _imageProcessingObserver;
  46820. /**
  46821. * Attaches a new image processing configuration to the PBR Material.
  46822. * @param configuration
  46823. */
  46824. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46825. /**
  46826. * Stores the available render targets.
  46827. */
  46828. private _renderTargets;
  46829. /**
  46830. * Sets the global ambient color for the material used in lighting calculations.
  46831. */
  46832. private _globalAmbientColor;
  46833. /**
  46834. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46835. */
  46836. private _useLogarithmicDepth;
  46837. /**
  46838. * If set to true, no lighting calculations will be applied.
  46839. */
  46840. private _unlit;
  46841. private _debugMode;
  46842. /**
  46843. * @hidden
  46844. * This is reserved for the inspector.
  46845. * Defines the material debug mode.
  46846. * It helps seeing only some components of the material while troubleshooting.
  46847. */
  46848. debugMode: number;
  46849. /**
  46850. * @hidden
  46851. * This is reserved for the inspector.
  46852. * Specify from where on screen the debug mode should start.
  46853. * The value goes from -1 (full screen) to 1 (not visible)
  46854. * It helps with side by side comparison against the final render
  46855. * This defaults to -1
  46856. */
  46857. private debugLimit;
  46858. /**
  46859. * @hidden
  46860. * This is reserved for the inspector.
  46861. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46862. * You can use the factor to better multiply the final value.
  46863. */
  46864. private debugFactor;
  46865. /**
  46866. * Defines the clear coat layer parameters for the material.
  46867. */
  46868. readonly clearCoat: PBRClearCoatConfiguration;
  46869. /**
  46870. * Defines the anisotropic parameters for the material.
  46871. */
  46872. readonly anisotropy: PBRAnisotropicConfiguration;
  46873. /**
  46874. * Defines the BRDF parameters for the material.
  46875. */
  46876. readonly brdf: PBRBRDFConfiguration;
  46877. /**
  46878. * Defines the Sheen parameters for the material.
  46879. */
  46880. readonly sheen: PBRSheenConfiguration;
  46881. /**
  46882. * Defines the SubSurface parameters for the material.
  46883. */
  46884. readonly subSurface: PBRSubSurfaceConfiguration;
  46885. /**
  46886. * Custom callback helping to override the default shader used in the material.
  46887. */
  46888. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46889. /**
  46890. * Instantiates a new PBRMaterial instance.
  46891. *
  46892. * @param name The material name
  46893. * @param scene The scene the material will be use in.
  46894. */
  46895. constructor(name: string, scene: Scene);
  46896. /**
  46897. * Gets a boolean indicating that current material needs to register RTT
  46898. */
  46899. readonly hasRenderTargetTextures: boolean;
  46900. /**
  46901. * Gets the name of the material class.
  46902. */
  46903. getClassName(): string;
  46904. /**
  46905. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46906. */
  46907. /**
  46908. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46909. */
  46910. useLogarithmicDepth: boolean;
  46911. /**
  46912. * Gets the current transparency mode.
  46913. */
  46914. /**
  46915. * Sets the transparency mode of the material.
  46916. *
  46917. * | Value | Type | Description |
  46918. * | ----- | ----------------------------------- | ----------- |
  46919. * | 0 | OPAQUE | |
  46920. * | 1 | ALPHATEST | |
  46921. * | 2 | ALPHABLEND | |
  46922. * | 3 | ALPHATESTANDBLEND | |
  46923. *
  46924. */
  46925. transparencyMode: Nullable<number>;
  46926. /**
  46927. * Returns true if alpha blending should be disabled.
  46928. */
  46929. private readonly _disableAlphaBlending;
  46930. /**
  46931. * Specifies whether or not this material should be rendered in alpha blend mode.
  46932. */
  46933. needAlphaBlending(): boolean;
  46934. /**
  46935. * Specifies if the mesh will require alpha blending.
  46936. * @param mesh - BJS mesh.
  46937. */
  46938. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46939. /**
  46940. * Specifies whether or not this material should be rendered in alpha test mode.
  46941. */
  46942. needAlphaTesting(): boolean;
  46943. /**
  46944. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46945. */
  46946. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46947. /**
  46948. * Gets the texture used for the alpha test.
  46949. */
  46950. getAlphaTestTexture(): Nullable<BaseTexture>;
  46951. /**
  46952. * Specifies that the submesh is ready to be used.
  46953. * @param mesh - BJS mesh.
  46954. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46955. * @param useInstances - Specifies that instances should be used.
  46956. * @returns - boolean indicating that the submesh is ready or not.
  46957. */
  46958. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46959. /**
  46960. * Specifies if the material uses metallic roughness workflow.
  46961. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46962. */
  46963. isMetallicWorkflow(): boolean;
  46964. private _prepareEffect;
  46965. private _prepareDefines;
  46966. /**
  46967. * Force shader compilation
  46968. */
  46969. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46970. clipPlane: boolean;
  46971. }>): void;
  46972. /**
  46973. * Initializes the uniform buffer layout for the shader.
  46974. */
  46975. buildUniformLayout(): void;
  46976. /**
  46977. * Unbinds the material from the mesh
  46978. */
  46979. unbind(): void;
  46980. /**
  46981. * Binds the submesh data.
  46982. * @param world - The world matrix.
  46983. * @param mesh - The BJS mesh.
  46984. * @param subMesh - A submesh of the BJS mesh.
  46985. */
  46986. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46987. /**
  46988. * Returns the animatable textures.
  46989. * @returns - Array of animatable textures.
  46990. */
  46991. getAnimatables(): IAnimatable[];
  46992. /**
  46993. * Returns the texture used for reflections.
  46994. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46995. */
  46996. private _getReflectionTexture;
  46997. /**
  46998. * Returns an array of the actively used textures.
  46999. * @returns - Array of BaseTextures
  47000. */
  47001. getActiveTextures(): BaseTexture[];
  47002. /**
  47003. * Checks to see if a texture is used in the material.
  47004. * @param texture - Base texture to use.
  47005. * @returns - Boolean specifying if a texture is used in the material.
  47006. */
  47007. hasTexture(texture: BaseTexture): boolean;
  47008. /**
  47009. * Disposes the resources of the material.
  47010. * @param forceDisposeEffect - Forces the disposal of effects.
  47011. * @param forceDisposeTextures - Forces the disposal of all textures.
  47012. */
  47013. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47014. }
  47015. }
  47016. declare module BABYLON {
  47017. /**
  47018. * The Physically based material of BJS.
  47019. *
  47020. * This offers the main features of a standard PBR material.
  47021. * For more information, please refer to the documentation :
  47022. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47023. */
  47024. export class PBRMaterial extends PBRBaseMaterial {
  47025. /**
  47026. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47027. */
  47028. static readonly PBRMATERIAL_OPAQUE: number;
  47029. /**
  47030. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47031. */
  47032. static readonly PBRMATERIAL_ALPHATEST: number;
  47033. /**
  47034. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47035. */
  47036. static readonly PBRMATERIAL_ALPHABLEND: number;
  47037. /**
  47038. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47039. * They are also discarded below the alpha cutoff threshold to improve performances.
  47040. */
  47041. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47042. /**
  47043. * Defines the default value of how much AO map is occluding the analytical lights
  47044. * (point spot...).
  47045. */
  47046. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47047. /**
  47048. * Intensity of the direct lights e.g. the four lights available in your scene.
  47049. * This impacts both the direct diffuse and specular highlights.
  47050. */
  47051. directIntensity: number;
  47052. /**
  47053. * Intensity of the emissive part of the material.
  47054. * This helps controlling the emissive effect without modifying the emissive color.
  47055. */
  47056. emissiveIntensity: number;
  47057. /**
  47058. * Intensity of the environment e.g. how much the environment will light the object
  47059. * either through harmonics for rough material or through the refelction for shiny ones.
  47060. */
  47061. environmentIntensity: number;
  47062. /**
  47063. * This is a special control allowing the reduction of the specular highlights coming from the
  47064. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47065. */
  47066. specularIntensity: number;
  47067. /**
  47068. * Debug Control allowing disabling the bump map on this material.
  47069. */
  47070. disableBumpMap: boolean;
  47071. /**
  47072. * AKA Diffuse Texture in standard nomenclature.
  47073. */
  47074. albedoTexture: BaseTexture;
  47075. /**
  47076. * AKA Occlusion Texture in other nomenclature.
  47077. */
  47078. ambientTexture: BaseTexture;
  47079. /**
  47080. * AKA Occlusion Texture Intensity in other nomenclature.
  47081. */
  47082. ambientTextureStrength: number;
  47083. /**
  47084. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47085. * 1 means it completely occludes it
  47086. * 0 mean it has no impact
  47087. */
  47088. ambientTextureImpactOnAnalyticalLights: number;
  47089. /**
  47090. * Stores the alpha values in a texture.
  47091. */
  47092. opacityTexture: BaseTexture;
  47093. /**
  47094. * Stores the reflection values in a texture.
  47095. */
  47096. reflectionTexture: Nullable<BaseTexture>;
  47097. /**
  47098. * Stores the emissive values in a texture.
  47099. */
  47100. emissiveTexture: BaseTexture;
  47101. /**
  47102. * AKA Specular texture in other nomenclature.
  47103. */
  47104. reflectivityTexture: BaseTexture;
  47105. /**
  47106. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47107. */
  47108. metallicTexture: BaseTexture;
  47109. /**
  47110. * Specifies the metallic scalar of the metallic/roughness workflow.
  47111. * Can also be used to scale the metalness values of the metallic texture.
  47112. */
  47113. metallic: Nullable<number>;
  47114. /**
  47115. * Specifies the roughness scalar of the metallic/roughness workflow.
  47116. * Can also be used to scale the roughness values of the metallic texture.
  47117. */
  47118. roughness: Nullable<number>;
  47119. /**
  47120. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47121. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47122. */
  47123. microSurfaceTexture: BaseTexture;
  47124. /**
  47125. * Stores surface normal data used to displace a mesh in a texture.
  47126. */
  47127. bumpTexture: BaseTexture;
  47128. /**
  47129. * Stores the pre-calculated light information of a mesh in a texture.
  47130. */
  47131. lightmapTexture: BaseTexture;
  47132. /**
  47133. * Stores the refracted light information in a texture.
  47134. */
  47135. refractionTexture: Nullable<BaseTexture>;
  47136. /**
  47137. * The color of a material in ambient lighting.
  47138. */
  47139. ambientColor: Color3;
  47140. /**
  47141. * AKA Diffuse Color in other nomenclature.
  47142. */
  47143. albedoColor: Color3;
  47144. /**
  47145. * AKA Specular Color in other nomenclature.
  47146. */
  47147. reflectivityColor: Color3;
  47148. /**
  47149. * The color reflected from the material.
  47150. */
  47151. reflectionColor: Color3;
  47152. /**
  47153. * The color emitted from the material.
  47154. */
  47155. emissiveColor: Color3;
  47156. /**
  47157. * AKA Glossiness in other nomenclature.
  47158. */
  47159. microSurface: number;
  47160. /**
  47161. * source material index of refraction (IOR)' / 'destination material IOR.
  47162. */
  47163. indexOfRefraction: number;
  47164. /**
  47165. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47166. */
  47167. invertRefractionY: boolean;
  47168. /**
  47169. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47170. * Materials half opaque for instance using refraction could benefit from this control.
  47171. */
  47172. linkRefractionWithTransparency: boolean;
  47173. /**
  47174. * If true, the light map contains occlusion information instead of lighting info.
  47175. */
  47176. useLightmapAsShadowmap: boolean;
  47177. /**
  47178. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47179. */
  47180. useAlphaFromAlbedoTexture: boolean;
  47181. /**
  47182. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47183. */
  47184. forceAlphaTest: boolean;
  47185. /**
  47186. * Defines the alpha limits in alpha test mode.
  47187. */
  47188. alphaCutOff: number;
  47189. /**
  47190. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47191. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47192. */
  47193. useSpecularOverAlpha: boolean;
  47194. /**
  47195. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47196. */
  47197. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47198. /**
  47199. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47200. */
  47201. useRoughnessFromMetallicTextureAlpha: boolean;
  47202. /**
  47203. * Specifies if the metallic texture contains the roughness information in its green channel.
  47204. */
  47205. useRoughnessFromMetallicTextureGreen: boolean;
  47206. /**
  47207. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47208. */
  47209. useMetallnessFromMetallicTextureBlue: boolean;
  47210. /**
  47211. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47212. */
  47213. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47214. /**
  47215. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47216. */
  47217. useAmbientInGrayScale: boolean;
  47218. /**
  47219. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47220. * The material will try to infer what glossiness each pixel should be.
  47221. */
  47222. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47223. /**
  47224. * BJS is using an harcoded light falloff based on a manually sets up range.
  47225. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47226. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47227. */
  47228. /**
  47229. * BJS is using an harcoded light falloff based on a manually sets up range.
  47230. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47231. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47232. */
  47233. usePhysicalLightFalloff: boolean;
  47234. /**
  47235. * In order to support the falloff compatibility with gltf, a special mode has been added
  47236. * to reproduce the gltf light falloff.
  47237. */
  47238. /**
  47239. * In order to support the falloff compatibility with gltf, a special mode has been added
  47240. * to reproduce the gltf light falloff.
  47241. */
  47242. useGLTFLightFalloff: boolean;
  47243. /**
  47244. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47245. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47246. */
  47247. useRadianceOverAlpha: boolean;
  47248. /**
  47249. * Allows using an object space normal map (instead of tangent space).
  47250. */
  47251. useObjectSpaceNormalMap: boolean;
  47252. /**
  47253. * Allows using the bump map in parallax mode.
  47254. */
  47255. useParallax: boolean;
  47256. /**
  47257. * Allows using the bump map in parallax occlusion mode.
  47258. */
  47259. useParallaxOcclusion: boolean;
  47260. /**
  47261. * Controls the scale bias of the parallax mode.
  47262. */
  47263. parallaxScaleBias: number;
  47264. /**
  47265. * If sets to true, disables all the lights affecting the material.
  47266. */
  47267. disableLighting: boolean;
  47268. /**
  47269. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47270. */
  47271. forceIrradianceInFragment: boolean;
  47272. /**
  47273. * Number of Simultaneous lights allowed on the material.
  47274. */
  47275. maxSimultaneousLights: number;
  47276. /**
  47277. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47278. */
  47279. invertNormalMapX: boolean;
  47280. /**
  47281. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47282. */
  47283. invertNormalMapY: boolean;
  47284. /**
  47285. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47286. */
  47287. twoSidedLighting: boolean;
  47288. /**
  47289. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47290. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47291. */
  47292. useAlphaFresnel: boolean;
  47293. /**
  47294. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47295. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47296. */
  47297. useLinearAlphaFresnel: boolean;
  47298. /**
  47299. * Let user defines the brdf lookup texture used for IBL.
  47300. * A default 8bit version is embedded but you could point at :
  47301. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47302. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47303. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47304. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47305. */
  47306. environmentBRDFTexture: Nullable<BaseTexture>;
  47307. /**
  47308. * Force normal to face away from face.
  47309. */
  47310. forceNormalForward: boolean;
  47311. /**
  47312. * Enables specular anti aliasing in the PBR shader.
  47313. * It will both interacts on the Geometry for analytical and IBL lighting.
  47314. * It also prefilter the roughness map based on the bump values.
  47315. */
  47316. enableSpecularAntiAliasing: boolean;
  47317. /**
  47318. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47319. * makes the reflect vector face the model (under horizon).
  47320. */
  47321. useHorizonOcclusion: boolean;
  47322. /**
  47323. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47324. * too much the area relying on ambient texture to define their ambient occlusion.
  47325. */
  47326. useRadianceOcclusion: boolean;
  47327. /**
  47328. * If set to true, no lighting calculations will be applied.
  47329. */
  47330. unlit: boolean;
  47331. /**
  47332. * Gets the image processing configuration used either in this material.
  47333. */
  47334. /**
  47335. * Sets the Default image processing configuration used either in the this material.
  47336. *
  47337. * If sets to null, the scene one is in use.
  47338. */
  47339. imageProcessingConfiguration: ImageProcessingConfiguration;
  47340. /**
  47341. * Gets wether the color curves effect is enabled.
  47342. */
  47343. /**
  47344. * Sets wether the color curves effect is enabled.
  47345. */
  47346. cameraColorCurvesEnabled: boolean;
  47347. /**
  47348. * Gets wether the color grading effect is enabled.
  47349. */
  47350. /**
  47351. * Gets wether the color grading effect is enabled.
  47352. */
  47353. cameraColorGradingEnabled: boolean;
  47354. /**
  47355. * Gets wether tonemapping is enabled or not.
  47356. */
  47357. /**
  47358. * Sets wether tonemapping is enabled or not
  47359. */
  47360. cameraToneMappingEnabled: boolean;
  47361. /**
  47362. * The camera exposure used on this material.
  47363. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47364. * This corresponds to a photographic exposure.
  47365. */
  47366. /**
  47367. * The camera exposure used on this material.
  47368. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47369. * This corresponds to a photographic exposure.
  47370. */
  47371. cameraExposure: number;
  47372. /**
  47373. * Gets The camera contrast used on this material.
  47374. */
  47375. /**
  47376. * Sets The camera contrast used on this material.
  47377. */
  47378. cameraContrast: number;
  47379. /**
  47380. * Gets the Color Grading 2D Lookup Texture.
  47381. */
  47382. /**
  47383. * Sets the Color Grading 2D Lookup Texture.
  47384. */
  47385. cameraColorGradingTexture: Nullable<BaseTexture>;
  47386. /**
  47387. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47388. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47389. * 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;
  47390. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47391. */
  47392. /**
  47393. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47394. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47395. * 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;
  47396. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47397. */
  47398. cameraColorCurves: Nullable<ColorCurves>;
  47399. /**
  47400. * Instantiates a new PBRMaterial instance.
  47401. *
  47402. * @param name The material name
  47403. * @param scene The scene the material will be use in.
  47404. */
  47405. constructor(name: string, scene: Scene);
  47406. /**
  47407. * Returns the name of this material class.
  47408. */
  47409. getClassName(): string;
  47410. /**
  47411. * Makes a duplicate of the current material.
  47412. * @param name - name to use for the new material.
  47413. */
  47414. clone(name: string): PBRMaterial;
  47415. /**
  47416. * Serializes this PBR Material.
  47417. * @returns - An object with the serialized material.
  47418. */
  47419. serialize(): any;
  47420. /**
  47421. * Parses a PBR Material from a serialized object.
  47422. * @param source - Serialized object.
  47423. * @param scene - BJS scene instance.
  47424. * @param rootUrl - url for the scene object
  47425. * @returns - PBRMaterial
  47426. */
  47427. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47428. }
  47429. }
  47430. declare module BABYLON {
  47431. /**
  47432. * Direct draw surface info
  47433. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47434. */
  47435. export interface DDSInfo {
  47436. /**
  47437. * Width of the texture
  47438. */
  47439. width: number;
  47440. /**
  47441. * Width of the texture
  47442. */
  47443. height: number;
  47444. /**
  47445. * Number of Mipmaps for the texture
  47446. * @see https://en.wikipedia.org/wiki/Mipmap
  47447. */
  47448. mipmapCount: number;
  47449. /**
  47450. * If the textures format is a known fourCC format
  47451. * @see https://www.fourcc.org/
  47452. */
  47453. isFourCC: boolean;
  47454. /**
  47455. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47456. */
  47457. isRGB: boolean;
  47458. /**
  47459. * If the texture is a lumincance format
  47460. */
  47461. isLuminance: boolean;
  47462. /**
  47463. * If this is a cube texture
  47464. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47465. */
  47466. isCube: boolean;
  47467. /**
  47468. * If the texture is a compressed format eg. FOURCC_DXT1
  47469. */
  47470. isCompressed: boolean;
  47471. /**
  47472. * The dxgiFormat of the texture
  47473. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47474. */
  47475. dxgiFormat: number;
  47476. /**
  47477. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47478. */
  47479. textureType: number;
  47480. /**
  47481. * Sphericle polynomial created for the dds texture
  47482. */
  47483. sphericalPolynomial?: SphericalPolynomial;
  47484. }
  47485. /**
  47486. * Class used to provide DDS decompression tools
  47487. */
  47488. export class DDSTools {
  47489. /**
  47490. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47491. */
  47492. static StoreLODInAlphaChannel: boolean;
  47493. /**
  47494. * Gets DDS information from an array buffer
  47495. * @param arrayBuffer defines the array buffer to read data from
  47496. * @returns the DDS information
  47497. */
  47498. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47499. private static _FloatView;
  47500. private static _Int32View;
  47501. private static _ToHalfFloat;
  47502. private static _FromHalfFloat;
  47503. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47504. private static _GetHalfFloatRGBAArrayBuffer;
  47505. private static _GetFloatRGBAArrayBuffer;
  47506. private static _GetFloatAsUIntRGBAArrayBuffer;
  47507. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47508. private static _GetRGBAArrayBuffer;
  47509. private static _ExtractLongWordOrder;
  47510. private static _GetRGBArrayBuffer;
  47511. private static _GetLuminanceArrayBuffer;
  47512. /**
  47513. * Uploads DDS Levels to a Babylon Texture
  47514. * @hidden
  47515. */
  47516. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47517. }
  47518. interface Engine {
  47519. /**
  47520. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47521. * @param rootUrl defines the url where the file to load is located
  47522. * @param scene defines the current scene
  47523. * @param lodScale defines scale to apply to the mip map selection
  47524. * @param lodOffset defines offset to apply to the mip map selection
  47525. * @param onLoad defines an optional callback raised when the texture is loaded
  47526. * @param onError defines an optional callback raised if there is an issue to load the texture
  47527. * @param format defines the format of the data
  47528. * @param forcedExtension defines the extension to use to pick the right loader
  47529. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47530. * @returns the cube texture as an InternalTexture
  47531. */
  47532. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  47533. }
  47534. }
  47535. declare module BABYLON {
  47536. /**
  47537. * Implementation of the DDS Texture Loader.
  47538. * @hidden
  47539. */
  47540. export class _DDSTextureLoader implements IInternalTextureLoader {
  47541. /**
  47542. * Defines wether the loader supports cascade loading the different faces.
  47543. */
  47544. readonly supportCascades: boolean;
  47545. /**
  47546. * This returns if the loader support the current file information.
  47547. * @param extension defines the file extension of the file being loaded
  47548. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47549. * @param fallback defines the fallback internal texture if any
  47550. * @param isBase64 defines whether the texture is encoded as a base64
  47551. * @param isBuffer defines whether the texture data are stored as a buffer
  47552. * @returns true if the loader can load the specified file
  47553. */
  47554. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47555. /**
  47556. * Transform the url before loading if required.
  47557. * @param rootUrl the url of the texture
  47558. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47559. * @returns the transformed texture
  47560. */
  47561. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47562. /**
  47563. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47564. * @param rootUrl the url of the texture
  47565. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47566. * @returns the fallback texture
  47567. */
  47568. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47569. /**
  47570. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47571. * @param data contains the texture data
  47572. * @param texture defines the BabylonJS internal texture
  47573. * @param createPolynomials will be true if polynomials have been requested
  47574. * @param onLoad defines the callback to trigger once the texture is ready
  47575. * @param onError defines the callback to trigger in case of error
  47576. */
  47577. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47578. /**
  47579. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47580. * @param data contains the texture data
  47581. * @param texture defines the BabylonJS internal texture
  47582. * @param callback defines the method to call once ready to upload
  47583. */
  47584. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47585. }
  47586. }
  47587. declare module BABYLON {
  47588. /** @hidden */
  47589. export var rgbdEncodePixelShader: {
  47590. name: string;
  47591. shader: string;
  47592. };
  47593. }
  47594. declare module BABYLON {
  47595. /**
  47596. * Raw texture data and descriptor sufficient for WebGL texture upload
  47597. */
  47598. export interface EnvironmentTextureInfo {
  47599. /**
  47600. * Version of the environment map
  47601. */
  47602. version: number;
  47603. /**
  47604. * Width of image
  47605. */
  47606. width: number;
  47607. /**
  47608. * Irradiance information stored in the file.
  47609. */
  47610. irradiance: any;
  47611. /**
  47612. * Specular information stored in the file.
  47613. */
  47614. specular: any;
  47615. }
  47616. /**
  47617. * Sets of helpers addressing the serialization and deserialization of environment texture
  47618. * stored in a BabylonJS env file.
  47619. * Those files are usually stored as .env files.
  47620. */
  47621. export class EnvironmentTextureTools {
  47622. /**
  47623. * Magic number identifying the env file.
  47624. */
  47625. private static _MagicBytes;
  47626. /**
  47627. * Gets the environment info from an env file.
  47628. * @param data The array buffer containing the .env bytes.
  47629. * @returns the environment file info (the json header) if successfully parsed.
  47630. */
  47631. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47632. /**
  47633. * Creates an environment texture from a loaded cube texture.
  47634. * @param texture defines the cube texture to convert in env file
  47635. * @return a promise containing the environment data if succesfull.
  47636. */
  47637. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47638. /**
  47639. * Creates a JSON representation of the spherical data.
  47640. * @param texture defines the texture containing the polynomials
  47641. * @return the JSON representation of the spherical info
  47642. */
  47643. private static _CreateEnvTextureIrradiance;
  47644. /**
  47645. * Uploads the texture info contained in the env file to the GPU.
  47646. * @param texture defines the internal texture to upload to
  47647. * @param arrayBuffer defines the buffer cotaining the data to load
  47648. * @param info defines the texture info retrieved through the GetEnvInfo method
  47649. * @returns a promise
  47650. */
  47651. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47652. /**
  47653. * Uploads the levels of image data to the GPU.
  47654. * @param texture defines the internal texture to upload to
  47655. * @param imageData defines the array buffer views of image data [mipmap][face]
  47656. * @returns a promise
  47657. */
  47658. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47659. /**
  47660. * Uploads spherical polynomials information to the texture.
  47661. * @param texture defines the texture we are trying to upload the information to
  47662. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47663. */
  47664. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47665. /** @hidden */
  47666. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47667. }
  47668. }
  47669. declare module BABYLON {
  47670. /**
  47671. * Implementation of the ENV Texture Loader.
  47672. * @hidden
  47673. */
  47674. export class _ENVTextureLoader implements IInternalTextureLoader {
  47675. /**
  47676. * Defines wether the loader supports cascade loading the different faces.
  47677. */
  47678. readonly supportCascades: boolean;
  47679. /**
  47680. * This returns if the loader support the current file information.
  47681. * @param extension defines the file extension of the file being loaded
  47682. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47683. * @param fallback defines the fallback internal texture if any
  47684. * @param isBase64 defines whether the texture is encoded as a base64
  47685. * @param isBuffer defines whether the texture data are stored as a buffer
  47686. * @returns true if the loader can load the specified file
  47687. */
  47688. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47689. /**
  47690. * Transform the url before loading if required.
  47691. * @param rootUrl the url of the texture
  47692. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47693. * @returns the transformed texture
  47694. */
  47695. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47696. /**
  47697. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47698. * @param rootUrl the url of the texture
  47699. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47700. * @returns the fallback texture
  47701. */
  47702. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47703. /**
  47704. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47705. * @param data contains the texture data
  47706. * @param texture defines the BabylonJS internal texture
  47707. * @param createPolynomials will be true if polynomials have been requested
  47708. * @param onLoad defines the callback to trigger once the texture is ready
  47709. * @param onError defines the callback to trigger in case of error
  47710. */
  47711. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47712. /**
  47713. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47714. * @param data contains the texture data
  47715. * @param texture defines the BabylonJS internal texture
  47716. * @param callback defines the method to call once ready to upload
  47717. */
  47718. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47719. }
  47720. }
  47721. declare module BABYLON {
  47722. /**
  47723. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47724. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47725. */
  47726. export class KhronosTextureContainer {
  47727. /** contents of the KTX container file */
  47728. arrayBuffer: any;
  47729. private static HEADER_LEN;
  47730. private static COMPRESSED_2D;
  47731. private static COMPRESSED_3D;
  47732. private static TEX_2D;
  47733. private static TEX_3D;
  47734. /**
  47735. * Gets the openGL type
  47736. */
  47737. glType: number;
  47738. /**
  47739. * Gets the openGL type size
  47740. */
  47741. glTypeSize: number;
  47742. /**
  47743. * Gets the openGL format
  47744. */
  47745. glFormat: number;
  47746. /**
  47747. * Gets the openGL internal format
  47748. */
  47749. glInternalFormat: number;
  47750. /**
  47751. * Gets the base internal format
  47752. */
  47753. glBaseInternalFormat: number;
  47754. /**
  47755. * Gets image width in pixel
  47756. */
  47757. pixelWidth: number;
  47758. /**
  47759. * Gets image height in pixel
  47760. */
  47761. pixelHeight: number;
  47762. /**
  47763. * Gets image depth in pixels
  47764. */
  47765. pixelDepth: number;
  47766. /**
  47767. * Gets the number of array elements
  47768. */
  47769. numberOfArrayElements: number;
  47770. /**
  47771. * Gets the number of faces
  47772. */
  47773. numberOfFaces: number;
  47774. /**
  47775. * Gets the number of mipmap levels
  47776. */
  47777. numberOfMipmapLevels: number;
  47778. /**
  47779. * Gets the bytes of key value data
  47780. */
  47781. bytesOfKeyValueData: number;
  47782. /**
  47783. * Gets the load type
  47784. */
  47785. loadType: number;
  47786. /**
  47787. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47788. */
  47789. isInvalid: boolean;
  47790. /**
  47791. * Creates a new KhronosTextureContainer
  47792. * @param arrayBuffer contents of the KTX container file
  47793. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47794. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47795. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47796. */
  47797. constructor(
  47798. /** contents of the KTX container file */
  47799. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47800. /**
  47801. * Uploads KTX content to a Babylon Texture.
  47802. * It is assumed that the texture has already been created & is currently bound
  47803. * @hidden
  47804. */
  47805. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47806. private _upload2DCompressedLevels;
  47807. }
  47808. }
  47809. declare module BABYLON {
  47810. /**
  47811. * Implementation of the KTX Texture Loader.
  47812. * @hidden
  47813. */
  47814. export class _KTXTextureLoader implements IInternalTextureLoader {
  47815. /**
  47816. * Defines wether the loader supports cascade loading the different faces.
  47817. */
  47818. readonly supportCascades: boolean;
  47819. /**
  47820. * This returns if the loader support the current file information.
  47821. * @param extension defines the file extension of the file being loaded
  47822. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47823. * @param fallback defines the fallback internal texture if any
  47824. * @param isBase64 defines whether the texture is encoded as a base64
  47825. * @param isBuffer defines whether the texture data are stored as a buffer
  47826. * @returns true if the loader can load the specified file
  47827. */
  47828. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47829. /**
  47830. * Transform the url before loading if required.
  47831. * @param rootUrl the url of the texture
  47832. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47833. * @returns the transformed texture
  47834. */
  47835. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47836. /**
  47837. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47838. * @param rootUrl the url of the texture
  47839. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47840. * @returns the fallback texture
  47841. */
  47842. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47843. /**
  47844. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47845. * @param data contains the texture data
  47846. * @param texture defines the BabylonJS internal texture
  47847. * @param createPolynomials will be true if polynomials have been requested
  47848. * @param onLoad defines the callback to trigger once the texture is ready
  47849. * @param onError defines the callback to trigger in case of error
  47850. */
  47851. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47852. /**
  47853. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47854. * @param data contains the texture data
  47855. * @param texture defines the BabylonJS internal texture
  47856. * @param callback defines the method to call once ready to upload
  47857. */
  47858. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47859. }
  47860. }
  47861. declare module BABYLON {
  47862. /**
  47863. * Options for the default xr helper
  47864. */
  47865. export class WebXRDefaultExperienceOptions {
  47866. /**
  47867. * Floor meshes that should be used for teleporting
  47868. */
  47869. floorMeshes: Array<AbstractMesh>;
  47870. }
  47871. /**
  47872. * Default experience which provides a similar setup to the previous webVRExperience
  47873. */
  47874. export class WebXRDefaultExperience {
  47875. /**
  47876. * Base experience
  47877. */
  47878. baseExperience: WebXRExperienceHelper;
  47879. /**
  47880. * Input experience extension
  47881. */
  47882. input: WebXRInput;
  47883. /**
  47884. * Loads the controller models
  47885. */
  47886. controllerModelLoader: WebXRControllerModelLoader;
  47887. /**
  47888. * Enables laser pointer and selection
  47889. */
  47890. pointerSelection: WebXRControllerPointerSelection;
  47891. /**
  47892. * Enables teleportation
  47893. */
  47894. teleportation: WebXRControllerTeleportation;
  47895. /**
  47896. * Enables ui for enetering/exiting xr
  47897. */
  47898. enterExitUI: WebXREnterExitUI;
  47899. /**
  47900. * Default output canvas xr should render to
  47901. */
  47902. outputCanvas: WebXRManagedOutputCanvas;
  47903. /**
  47904. * Creates the default xr experience
  47905. * @param scene scene
  47906. * @param options options for basic configuration
  47907. * @returns resulting WebXRDefaultExperience
  47908. */
  47909. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47910. private constructor();
  47911. /**
  47912. * DIsposes of the experience helper
  47913. */
  47914. dispose(): void;
  47915. }
  47916. }
  47917. declare module BABYLON {
  47918. /** @hidden */
  47919. export var _forceSceneHelpersToBundle: boolean;
  47920. interface Scene {
  47921. /**
  47922. * Creates a default light for the scene.
  47923. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47924. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47925. */
  47926. createDefaultLight(replace?: boolean): void;
  47927. /**
  47928. * Creates a default camera for the scene.
  47929. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47930. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47931. * @param replace has default false, when true replaces the active camera in the scene
  47932. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47933. */
  47934. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47935. /**
  47936. * Creates a default camera and a default light.
  47937. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47938. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47939. * @param replace has the default false, when true replaces the active camera/light in the scene
  47940. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47941. */
  47942. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47943. /**
  47944. * Creates a new sky box
  47945. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47946. * @param environmentTexture defines the texture to use as environment texture
  47947. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47948. * @param scale defines the overall scale of the skybox
  47949. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47950. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47951. * @returns a new mesh holding the sky box
  47952. */
  47953. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47954. /**
  47955. * Creates a new environment
  47956. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47957. * @param options defines the options you can use to configure the environment
  47958. * @returns the new EnvironmentHelper
  47959. */
  47960. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47961. /**
  47962. * Creates a new VREXperienceHelper
  47963. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47964. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47965. * @returns a new VREXperienceHelper
  47966. */
  47967. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47968. /**
  47969. * Creates a new WebXRDefaultExperience
  47970. * @see http://doc.babylonjs.com/how_to/webxr
  47971. * @param options experience options
  47972. * @returns a promise for a new WebXRDefaultExperience
  47973. */
  47974. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47975. }
  47976. }
  47977. declare module BABYLON {
  47978. /**
  47979. * Contains position and normal vectors for a vertex
  47980. */
  47981. export class PositionNormalVertex {
  47982. /** the position of the vertex (defaut: 0,0,0) */
  47983. position: Vector3;
  47984. /** the normal of the vertex (defaut: 0,1,0) */
  47985. normal: Vector3;
  47986. /**
  47987. * Creates a PositionNormalVertex
  47988. * @param position the position of the vertex (defaut: 0,0,0)
  47989. * @param normal the normal of the vertex (defaut: 0,1,0)
  47990. */
  47991. constructor(
  47992. /** the position of the vertex (defaut: 0,0,0) */
  47993. position?: Vector3,
  47994. /** the normal of the vertex (defaut: 0,1,0) */
  47995. normal?: Vector3);
  47996. /**
  47997. * Clones the PositionNormalVertex
  47998. * @returns the cloned PositionNormalVertex
  47999. */
  48000. clone(): PositionNormalVertex;
  48001. }
  48002. /**
  48003. * Contains position, normal and uv vectors for a vertex
  48004. */
  48005. export class PositionNormalTextureVertex {
  48006. /** the position of the vertex (defaut: 0,0,0) */
  48007. position: Vector3;
  48008. /** the normal of the vertex (defaut: 0,1,0) */
  48009. normal: Vector3;
  48010. /** the uv of the vertex (default: 0,0) */
  48011. uv: Vector2;
  48012. /**
  48013. * Creates a PositionNormalTextureVertex
  48014. * @param position the position of the vertex (defaut: 0,0,0)
  48015. * @param normal the normal of the vertex (defaut: 0,1,0)
  48016. * @param uv the uv of the vertex (default: 0,0)
  48017. */
  48018. constructor(
  48019. /** the position of the vertex (defaut: 0,0,0) */
  48020. position?: Vector3,
  48021. /** the normal of the vertex (defaut: 0,1,0) */
  48022. normal?: Vector3,
  48023. /** the uv of the vertex (default: 0,0) */
  48024. uv?: Vector2);
  48025. /**
  48026. * Clones the PositionNormalTextureVertex
  48027. * @returns the cloned PositionNormalTextureVertex
  48028. */
  48029. clone(): PositionNormalTextureVertex;
  48030. }
  48031. }
  48032. declare module BABYLON {
  48033. /**
  48034. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48035. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48036. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48037. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48038. */
  48039. export class VideoDome extends TransformNode {
  48040. /**
  48041. * Define the video source as a Monoscopic panoramic 360 video.
  48042. */
  48043. static readonly MODE_MONOSCOPIC: number;
  48044. /**
  48045. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48046. */
  48047. static readonly MODE_TOPBOTTOM: number;
  48048. /**
  48049. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48050. */
  48051. static readonly MODE_SIDEBYSIDE: number;
  48052. private _halfDome;
  48053. private _useDirectMapping;
  48054. /**
  48055. * The video texture being displayed on the sphere
  48056. */
  48057. protected _videoTexture: VideoTexture;
  48058. /**
  48059. * Gets the video texture being displayed on the sphere
  48060. */
  48061. readonly videoTexture: VideoTexture;
  48062. /**
  48063. * The skybox material
  48064. */
  48065. protected _material: BackgroundMaterial;
  48066. /**
  48067. * The surface used for the skybox
  48068. */
  48069. protected _mesh: Mesh;
  48070. /**
  48071. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48072. */
  48073. private _halfDomeMask;
  48074. /**
  48075. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48076. * Also see the options.resolution property.
  48077. */
  48078. fovMultiplier: number;
  48079. private _videoMode;
  48080. /**
  48081. * Gets or set the current video mode for the video. It can be:
  48082. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48083. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48084. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48085. */
  48086. videoMode: number;
  48087. /**
  48088. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48089. *
  48090. */
  48091. /**
  48092. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48093. */
  48094. halfDome: boolean;
  48095. /**
  48096. * Oberserver used in Stereoscopic VR Mode.
  48097. */
  48098. private _onBeforeCameraRenderObserver;
  48099. /**
  48100. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48101. * @param name Element's name, child elements will append suffixes for their own names.
  48102. * @param urlsOrVideo defines the url(s) or the video element to use
  48103. * @param options An object containing optional or exposed sub element properties
  48104. */
  48105. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48106. resolution?: number;
  48107. clickToPlay?: boolean;
  48108. autoPlay?: boolean;
  48109. loop?: boolean;
  48110. size?: number;
  48111. poster?: string;
  48112. faceForward?: boolean;
  48113. useDirectMapping?: boolean;
  48114. halfDomeMode?: boolean;
  48115. }, scene: Scene);
  48116. private _changeVideoMode;
  48117. /**
  48118. * Releases resources associated with this node.
  48119. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48120. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48121. */
  48122. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48123. }
  48124. }
  48125. declare module BABYLON {
  48126. /**
  48127. * This class can be used to get instrumentation data from a Babylon engine
  48128. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48129. */
  48130. export class EngineInstrumentation implements IDisposable {
  48131. /**
  48132. * Define the instrumented engine.
  48133. */
  48134. engine: Engine;
  48135. private _captureGPUFrameTime;
  48136. private _gpuFrameTimeToken;
  48137. private _gpuFrameTime;
  48138. private _captureShaderCompilationTime;
  48139. private _shaderCompilationTime;
  48140. private _onBeginFrameObserver;
  48141. private _onEndFrameObserver;
  48142. private _onBeforeShaderCompilationObserver;
  48143. private _onAfterShaderCompilationObserver;
  48144. /**
  48145. * Gets the perf counter used for GPU frame time
  48146. */
  48147. readonly gpuFrameTimeCounter: PerfCounter;
  48148. /**
  48149. * Gets the GPU frame time capture status
  48150. */
  48151. /**
  48152. * Enable or disable the GPU frame time capture
  48153. */
  48154. captureGPUFrameTime: boolean;
  48155. /**
  48156. * Gets the perf counter used for shader compilation time
  48157. */
  48158. readonly shaderCompilationTimeCounter: PerfCounter;
  48159. /**
  48160. * Gets the shader compilation time capture status
  48161. */
  48162. /**
  48163. * Enable or disable the shader compilation time capture
  48164. */
  48165. captureShaderCompilationTime: boolean;
  48166. /**
  48167. * Instantiates a new engine instrumentation.
  48168. * This class can be used to get instrumentation data from a Babylon engine
  48169. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48170. * @param engine Defines the engine to instrument
  48171. */
  48172. constructor(
  48173. /**
  48174. * Define the instrumented engine.
  48175. */
  48176. engine: Engine);
  48177. /**
  48178. * Dispose and release associated resources.
  48179. */
  48180. dispose(): void;
  48181. }
  48182. }
  48183. declare module BABYLON {
  48184. /**
  48185. * This class can be used to get instrumentation data from a Babylon engine
  48186. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48187. */
  48188. export class SceneInstrumentation implements IDisposable {
  48189. /**
  48190. * Defines the scene to instrument
  48191. */
  48192. scene: Scene;
  48193. private _captureActiveMeshesEvaluationTime;
  48194. private _activeMeshesEvaluationTime;
  48195. private _captureRenderTargetsRenderTime;
  48196. private _renderTargetsRenderTime;
  48197. private _captureFrameTime;
  48198. private _frameTime;
  48199. private _captureRenderTime;
  48200. private _renderTime;
  48201. private _captureInterFrameTime;
  48202. private _interFrameTime;
  48203. private _captureParticlesRenderTime;
  48204. private _particlesRenderTime;
  48205. private _captureSpritesRenderTime;
  48206. private _spritesRenderTime;
  48207. private _capturePhysicsTime;
  48208. private _physicsTime;
  48209. private _captureAnimationsTime;
  48210. private _animationsTime;
  48211. private _captureCameraRenderTime;
  48212. private _cameraRenderTime;
  48213. private _onBeforeActiveMeshesEvaluationObserver;
  48214. private _onAfterActiveMeshesEvaluationObserver;
  48215. private _onBeforeRenderTargetsRenderObserver;
  48216. private _onAfterRenderTargetsRenderObserver;
  48217. private _onAfterRenderObserver;
  48218. private _onBeforeDrawPhaseObserver;
  48219. private _onAfterDrawPhaseObserver;
  48220. private _onBeforeAnimationsObserver;
  48221. private _onBeforeParticlesRenderingObserver;
  48222. private _onAfterParticlesRenderingObserver;
  48223. private _onBeforeSpritesRenderingObserver;
  48224. private _onAfterSpritesRenderingObserver;
  48225. private _onBeforePhysicsObserver;
  48226. private _onAfterPhysicsObserver;
  48227. private _onAfterAnimationsObserver;
  48228. private _onBeforeCameraRenderObserver;
  48229. private _onAfterCameraRenderObserver;
  48230. /**
  48231. * Gets the perf counter used for active meshes evaluation time
  48232. */
  48233. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48234. /**
  48235. * Gets the active meshes evaluation time capture status
  48236. */
  48237. /**
  48238. * Enable or disable the active meshes evaluation time capture
  48239. */
  48240. captureActiveMeshesEvaluationTime: boolean;
  48241. /**
  48242. * Gets the perf counter used for render targets render time
  48243. */
  48244. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48245. /**
  48246. * Gets the render targets render time capture status
  48247. */
  48248. /**
  48249. * Enable or disable the render targets render time capture
  48250. */
  48251. captureRenderTargetsRenderTime: boolean;
  48252. /**
  48253. * Gets the perf counter used for particles render time
  48254. */
  48255. readonly particlesRenderTimeCounter: PerfCounter;
  48256. /**
  48257. * Gets the particles render time capture status
  48258. */
  48259. /**
  48260. * Enable or disable the particles render time capture
  48261. */
  48262. captureParticlesRenderTime: boolean;
  48263. /**
  48264. * Gets the perf counter used for sprites render time
  48265. */
  48266. readonly spritesRenderTimeCounter: PerfCounter;
  48267. /**
  48268. * Gets the sprites render time capture status
  48269. */
  48270. /**
  48271. * Enable or disable the sprites render time capture
  48272. */
  48273. captureSpritesRenderTime: boolean;
  48274. /**
  48275. * Gets the perf counter used for physics time
  48276. */
  48277. readonly physicsTimeCounter: PerfCounter;
  48278. /**
  48279. * Gets the physics time capture status
  48280. */
  48281. /**
  48282. * Enable or disable the physics time capture
  48283. */
  48284. capturePhysicsTime: boolean;
  48285. /**
  48286. * Gets the perf counter used for animations time
  48287. */
  48288. readonly animationsTimeCounter: PerfCounter;
  48289. /**
  48290. * Gets the animations time capture status
  48291. */
  48292. /**
  48293. * Enable or disable the animations time capture
  48294. */
  48295. captureAnimationsTime: boolean;
  48296. /**
  48297. * Gets the perf counter used for frame time capture
  48298. */
  48299. readonly frameTimeCounter: PerfCounter;
  48300. /**
  48301. * Gets the frame time capture status
  48302. */
  48303. /**
  48304. * Enable or disable the frame time capture
  48305. */
  48306. captureFrameTime: boolean;
  48307. /**
  48308. * Gets the perf counter used for inter-frames time capture
  48309. */
  48310. readonly interFrameTimeCounter: PerfCounter;
  48311. /**
  48312. * Gets the inter-frames time capture status
  48313. */
  48314. /**
  48315. * Enable or disable the inter-frames time capture
  48316. */
  48317. captureInterFrameTime: boolean;
  48318. /**
  48319. * Gets the perf counter used for render time capture
  48320. */
  48321. readonly renderTimeCounter: PerfCounter;
  48322. /**
  48323. * Gets the render time capture status
  48324. */
  48325. /**
  48326. * Enable or disable the render time capture
  48327. */
  48328. captureRenderTime: boolean;
  48329. /**
  48330. * Gets the perf counter used for camera render time capture
  48331. */
  48332. readonly cameraRenderTimeCounter: PerfCounter;
  48333. /**
  48334. * Gets the camera render time capture status
  48335. */
  48336. /**
  48337. * Enable or disable the camera render time capture
  48338. */
  48339. captureCameraRenderTime: boolean;
  48340. /**
  48341. * Gets the perf counter used for draw calls
  48342. */
  48343. readonly drawCallsCounter: PerfCounter;
  48344. /**
  48345. * Instantiates a new scene instrumentation.
  48346. * This class can be used to get instrumentation data from a Babylon engine
  48347. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48348. * @param scene Defines the scene to instrument
  48349. */
  48350. constructor(
  48351. /**
  48352. * Defines the scene to instrument
  48353. */
  48354. scene: Scene);
  48355. /**
  48356. * Dispose and release associated resources.
  48357. */
  48358. dispose(): void;
  48359. }
  48360. }
  48361. declare module BABYLON {
  48362. /** @hidden */
  48363. export var glowMapGenerationPixelShader: {
  48364. name: string;
  48365. shader: string;
  48366. };
  48367. }
  48368. declare module BABYLON {
  48369. /** @hidden */
  48370. export var glowMapGenerationVertexShader: {
  48371. name: string;
  48372. shader: string;
  48373. };
  48374. }
  48375. declare module BABYLON {
  48376. /**
  48377. * Effect layer options. This helps customizing the behaviour
  48378. * of the effect layer.
  48379. */
  48380. export interface IEffectLayerOptions {
  48381. /**
  48382. * Multiplication factor apply to the canvas size to compute the render target size
  48383. * used to generated the objects (the smaller the faster).
  48384. */
  48385. mainTextureRatio: number;
  48386. /**
  48387. * Enforces a fixed size texture to ensure effect stability across devices.
  48388. */
  48389. mainTextureFixedSize?: number;
  48390. /**
  48391. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48392. */
  48393. alphaBlendingMode: number;
  48394. /**
  48395. * The camera attached to the layer.
  48396. */
  48397. camera: Nullable<Camera>;
  48398. /**
  48399. * The rendering group to draw the layer in.
  48400. */
  48401. renderingGroupId: number;
  48402. }
  48403. /**
  48404. * The effect layer Helps adding post process effect blended with the main pass.
  48405. *
  48406. * This can be for instance use to generate glow or higlight effects on the scene.
  48407. *
  48408. * The effect layer class can not be used directly and is intented to inherited from to be
  48409. * customized per effects.
  48410. */
  48411. export abstract class EffectLayer {
  48412. private _vertexBuffers;
  48413. private _indexBuffer;
  48414. private _cachedDefines;
  48415. private _effectLayerMapGenerationEffect;
  48416. private _effectLayerOptions;
  48417. private _mergeEffect;
  48418. protected _scene: Scene;
  48419. protected _engine: Engine;
  48420. protected _maxSize: number;
  48421. protected _mainTextureDesiredSize: ISize;
  48422. protected _mainTexture: RenderTargetTexture;
  48423. protected _shouldRender: boolean;
  48424. protected _postProcesses: PostProcess[];
  48425. protected _textures: BaseTexture[];
  48426. protected _emissiveTextureAndColor: {
  48427. texture: Nullable<BaseTexture>;
  48428. color: Color4;
  48429. };
  48430. /**
  48431. * The name of the layer
  48432. */
  48433. name: string;
  48434. /**
  48435. * The clear color of the texture used to generate the glow map.
  48436. */
  48437. neutralColor: Color4;
  48438. /**
  48439. * Specifies wether the highlight layer is enabled or not.
  48440. */
  48441. isEnabled: boolean;
  48442. /**
  48443. * Gets the camera attached to the layer.
  48444. */
  48445. readonly camera: Nullable<Camera>;
  48446. /**
  48447. * Gets the rendering group id the layer should render in.
  48448. */
  48449. renderingGroupId: number;
  48450. /**
  48451. * An event triggered when the effect layer has been disposed.
  48452. */
  48453. onDisposeObservable: Observable<EffectLayer>;
  48454. /**
  48455. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48456. */
  48457. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48458. /**
  48459. * An event triggered when the generated texture is being merged in the scene.
  48460. */
  48461. onBeforeComposeObservable: Observable<EffectLayer>;
  48462. /**
  48463. * An event triggered when the generated texture has been merged in the scene.
  48464. */
  48465. onAfterComposeObservable: Observable<EffectLayer>;
  48466. /**
  48467. * An event triggered when the efffect layer changes its size.
  48468. */
  48469. onSizeChangedObservable: Observable<EffectLayer>;
  48470. /** @hidden */
  48471. static _SceneComponentInitialization: (scene: Scene) => void;
  48472. /**
  48473. * Instantiates a new effect Layer and references it in the scene.
  48474. * @param name The name of the layer
  48475. * @param scene The scene to use the layer in
  48476. */
  48477. constructor(
  48478. /** The Friendly of the effect in the scene */
  48479. name: string, scene: Scene);
  48480. /**
  48481. * Get the effect name of the layer.
  48482. * @return The effect name
  48483. */
  48484. abstract getEffectName(): string;
  48485. /**
  48486. * Checks for the readiness of the element composing the layer.
  48487. * @param subMesh the mesh to check for
  48488. * @param useInstances specify wether or not to use instances to render the mesh
  48489. * @return true if ready otherwise, false
  48490. */
  48491. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48492. /**
  48493. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48494. * @returns true if the effect requires stencil during the main canvas render pass.
  48495. */
  48496. abstract needStencil(): boolean;
  48497. /**
  48498. * Create the merge effect. This is the shader use to blit the information back
  48499. * to the main canvas at the end of the scene rendering.
  48500. * @returns The effect containing the shader used to merge the effect on the main canvas
  48501. */
  48502. protected abstract _createMergeEffect(): Effect;
  48503. /**
  48504. * Creates the render target textures and post processes used in the effect layer.
  48505. */
  48506. protected abstract _createTextureAndPostProcesses(): void;
  48507. /**
  48508. * Implementation specific of rendering the generating effect on the main canvas.
  48509. * @param effect The effect used to render through
  48510. */
  48511. protected abstract _internalRender(effect: Effect): void;
  48512. /**
  48513. * Sets the required values for both the emissive texture and and the main color.
  48514. */
  48515. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48516. /**
  48517. * Free any resources and references associated to a mesh.
  48518. * Internal use
  48519. * @param mesh The mesh to free.
  48520. */
  48521. abstract _disposeMesh(mesh: Mesh): void;
  48522. /**
  48523. * Serializes this layer (Glow or Highlight for example)
  48524. * @returns a serialized layer object
  48525. */
  48526. abstract serialize?(): any;
  48527. /**
  48528. * Initializes the effect layer with the required options.
  48529. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48530. */
  48531. protected _init(options: Partial<IEffectLayerOptions>): void;
  48532. /**
  48533. * Generates the index buffer of the full screen quad blending to the main canvas.
  48534. */
  48535. private _generateIndexBuffer;
  48536. /**
  48537. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48538. */
  48539. private _generateVertexBuffer;
  48540. /**
  48541. * Sets the main texture desired size which is the closest power of two
  48542. * of the engine canvas size.
  48543. */
  48544. private _setMainTextureSize;
  48545. /**
  48546. * Creates the main texture for the effect layer.
  48547. */
  48548. protected _createMainTexture(): void;
  48549. /**
  48550. * Adds specific effects defines.
  48551. * @param defines The defines to add specifics to.
  48552. */
  48553. protected _addCustomEffectDefines(defines: string[]): void;
  48554. /**
  48555. * Checks for the readiness of the element composing the layer.
  48556. * @param subMesh the mesh to check for
  48557. * @param useInstances specify wether or not to use instances to render the mesh
  48558. * @param emissiveTexture the associated emissive texture used to generate the glow
  48559. * @return true if ready otherwise, false
  48560. */
  48561. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48562. /**
  48563. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48564. */
  48565. render(): void;
  48566. /**
  48567. * Determine if a given mesh will be used in the current effect.
  48568. * @param mesh mesh to test
  48569. * @returns true if the mesh will be used
  48570. */
  48571. hasMesh(mesh: AbstractMesh): boolean;
  48572. /**
  48573. * Returns true if the layer contains information to display, otherwise false.
  48574. * @returns true if the glow layer should be rendered
  48575. */
  48576. shouldRender(): boolean;
  48577. /**
  48578. * Returns true if the mesh should render, otherwise false.
  48579. * @param mesh The mesh to render
  48580. * @returns true if it should render otherwise false
  48581. */
  48582. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48583. /**
  48584. * Returns true if the mesh can be rendered, otherwise false.
  48585. * @param mesh The mesh to render
  48586. * @param material The material used on the mesh
  48587. * @returns true if it can be rendered otherwise false
  48588. */
  48589. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48590. /**
  48591. * Returns true if the mesh should render, otherwise false.
  48592. * @param mesh The mesh to render
  48593. * @returns true if it should render otherwise false
  48594. */
  48595. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48596. /**
  48597. * Renders the submesh passed in parameter to the generation map.
  48598. */
  48599. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48600. /**
  48601. * Rebuild the required buffers.
  48602. * @hidden Internal use only.
  48603. */
  48604. _rebuild(): void;
  48605. /**
  48606. * Dispose only the render target textures and post process.
  48607. */
  48608. private _disposeTextureAndPostProcesses;
  48609. /**
  48610. * Dispose the highlight layer and free resources.
  48611. */
  48612. dispose(): void;
  48613. /**
  48614. * Gets the class name of the effect layer
  48615. * @returns the string with the class name of the effect layer
  48616. */
  48617. getClassName(): string;
  48618. /**
  48619. * Creates an effect layer from parsed effect layer data
  48620. * @param parsedEffectLayer defines effect layer data
  48621. * @param scene defines the current scene
  48622. * @param rootUrl defines the root URL containing the effect layer information
  48623. * @returns a parsed effect Layer
  48624. */
  48625. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48626. }
  48627. }
  48628. declare module BABYLON {
  48629. interface AbstractScene {
  48630. /**
  48631. * The list of effect layers (highlights/glow) added to the scene
  48632. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48633. * @see http://doc.babylonjs.com/how_to/glow_layer
  48634. */
  48635. effectLayers: Array<EffectLayer>;
  48636. /**
  48637. * Removes the given effect layer from this scene.
  48638. * @param toRemove defines the effect layer to remove
  48639. * @returns the index of the removed effect layer
  48640. */
  48641. removeEffectLayer(toRemove: EffectLayer): number;
  48642. /**
  48643. * Adds the given effect layer to this scene
  48644. * @param newEffectLayer defines the effect layer to add
  48645. */
  48646. addEffectLayer(newEffectLayer: EffectLayer): void;
  48647. }
  48648. /**
  48649. * Defines the layer scene component responsible to manage any effect layers
  48650. * in a given scene.
  48651. */
  48652. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48653. /**
  48654. * The component name helpfull to identify the component in the list of scene components.
  48655. */
  48656. readonly name: string;
  48657. /**
  48658. * The scene the component belongs to.
  48659. */
  48660. scene: Scene;
  48661. private _engine;
  48662. private _renderEffects;
  48663. private _needStencil;
  48664. private _previousStencilState;
  48665. /**
  48666. * Creates a new instance of the component for the given scene
  48667. * @param scene Defines the scene to register the component in
  48668. */
  48669. constructor(scene: Scene);
  48670. /**
  48671. * Registers the component in a given scene
  48672. */
  48673. register(): void;
  48674. /**
  48675. * Rebuilds the elements related to this component in case of
  48676. * context lost for instance.
  48677. */
  48678. rebuild(): void;
  48679. /**
  48680. * Serializes the component data to the specified json object
  48681. * @param serializationObject The object to serialize to
  48682. */
  48683. serialize(serializationObject: any): void;
  48684. /**
  48685. * Adds all the elements from the container to the scene
  48686. * @param container the container holding the elements
  48687. */
  48688. addFromContainer(container: AbstractScene): void;
  48689. /**
  48690. * Removes all the elements in the container from the scene
  48691. * @param container contains the elements to remove
  48692. * @param dispose if the removed element should be disposed (default: false)
  48693. */
  48694. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48695. /**
  48696. * Disposes the component and the associated ressources.
  48697. */
  48698. dispose(): void;
  48699. private _isReadyForMesh;
  48700. private _renderMainTexture;
  48701. private _setStencil;
  48702. private _setStencilBack;
  48703. private _draw;
  48704. private _drawCamera;
  48705. private _drawRenderingGroup;
  48706. }
  48707. }
  48708. declare module BABYLON {
  48709. /** @hidden */
  48710. export var glowMapMergePixelShader: {
  48711. name: string;
  48712. shader: string;
  48713. };
  48714. }
  48715. declare module BABYLON {
  48716. /** @hidden */
  48717. export var glowMapMergeVertexShader: {
  48718. name: string;
  48719. shader: string;
  48720. };
  48721. }
  48722. declare module BABYLON {
  48723. interface AbstractScene {
  48724. /**
  48725. * Return a the first highlight layer of the scene with a given name.
  48726. * @param name The name of the highlight layer to look for.
  48727. * @return The highlight layer if found otherwise null.
  48728. */
  48729. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48730. }
  48731. /**
  48732. * Glow layer options. This helps customizing the behaviour
  48733. * of the glow layer.
  48734. */
  48735. export interface IGlowLayerOptions {
  48736. /**
  48737. * Multiplication factor apply to the canvas size to compute the render target size
  48738. * used to generated the glowing objects (the smaller the faster).
  48739. */
  48740. mainTextureRatio: number;
  48741. /**
  48742. * Enforces a fixed size texture to ensure resize independant blur.
  48743. */
  48744. mainTextureFixedSize?: number;
  48745. /**
  48746. * How big is the kernel of the blur texture.
  48747. */
  48748. blurKernelSize: number;
  48749. /**
  48750. * The camera attached to the layer.
  48751. */
  48752. camera: Nullable<Camera>;
  48753. /**
  48754. * Enable MSAA by chosing the number of samples.
  48755. */
  48756. mainTextureSamples?: number;
  48757. /**
  48758. * The rendering group to draw the layer in.
  48759. */
  48760. renderingGroupId: number;
  48761. }
  48762. /**
  48763. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48764. *
  48765. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48766. * glowy meshes to your scene.
  48767. *
  48768. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48769. */
  48770. export class GlowLayer extends EffectLayer {
  48771. /**
  48772. * Effect Name of the layer.
  48773. */
  48774. static readonly EffectName: string;
  48775. /**
  48776. * The default blur kernel size used for the glow.
  48777. */
  48778. static DefaultBlurKernelSize: number;
  48779. /**
  48780. * The default texture size ratio used for the glow.
  48781. */
  48782. static DefaultTextureRatio: number;
  48783. /**
  48784. * Sets the kernel size of the blur.
  48785. */
  48786. /**
  48787. * Gets the kernel size of the blur.
  48788. */
  48789. blurKernelSize: number;
  48790. /**
  48791. * Sets the glow intensity.
  48792. */
  48793. /**
  48794. * Gets the glow intensity.
  48795. */
  48796. intensity: number;
  48797. private _options;
  48798. private _intensity;
  48799. private _horizontalBlurPostprocess1;
  48800. private _verticalBlurPostprocess1;
  48801. private _horizontalBlurPostprocess2;
  48802. private _verticalBlurPostprocess2;
  48803. private _blurTexture1;
  48804. private _blurTexture2;
  48805. private _postProcesses1;
  48806. private _postProcesses2;
  48807. private _includedOnlyMeshes;
  48808. private _excludedMeshes;
  48809. /**
  48810. * Callback used to let the user override the color selection on a per mesh basis
  48811. */
  48812. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48813. /**
  48814. * Callback used to let the user override the texture selection on a per mesh basis
  48815. */
  48816. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48817. /**
  48818. * Instantiates a new glow Layer and references it to the scene.
  48819. * @param name The name of the layer
  48820. * @param scene The scene to use the layer in
  48821. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48822. */
  48823. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48824. /**
  48825. * Get the effect name of the layer.
  48826. * @return The effect name
  48827. */
  48828. getEffectName(): string;
  48829. /**
  48830. * Create the merge effect. This is the shader use to blit the information back
  48831. * to the main canvas at the end of the scene rendering.
  48832. */
  48833. protected _createMergeEffect(): Effect;
  48834. /**
  48835. * Creates the render target textures and post processes used in the glow layer.
  48836. */
  48837. protected _createTextureAndPostProcesses(): void;
  48838. /**
  48839. * Checks for the readiness of the element composing the layer.
  48840. * @param subMesh the mesh to check for
  48841. * @param useInstances specify wether or not to use instances to render the mesh
  48842. * @param emissiveTexture the associated emissive texture used to generate the glow
  48843. * @return true if ready otherwise, false
  48844. */
  48845. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48846. /**
  48847. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48848. */
  48849. needStencil(): boolean;
  48850. /**
  48851. * Returns true if the mesh can be rendered, otherwise false.
  48852. * @param mesh The mesh to render
  48853. * @param material The material used on the mesh
  48854. * @returns true if it can be rendered otherwise false
  48855. */
  48856. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48857. /**
  48858. * Implementation specific of rendering the generating effect on the main canvas.
  48859. * @param effect The effect used to render through
  48860. */
  48861. protected _internalRender(effect: Effect): void;
  48862. /**
  48863. * Sets the required values for both the emissive texture and and the main color.
  48864. */
  48865. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48866. /**
  48867. * Returns true if the mesh should render, otherwise false.
  48868. * @param mesh The mesh to render
  48869. * @returns true if it should render otherwise false
  48870. */
  48871. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48872. /**
  48873. * Adds specific effects defines.
  48874. * @param defines The defines to add specifics to.
  48875. */
  48876. protected _addCustomEffectDefines(defines: string[]): void;
  48877. /**
  48878. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48879. * @param mesh The mesh to exclude from the glow layer
  48880. */
  48881. addExcludedMesh(mesh: Mesh): void;
  48882. /**
  48883. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48884. * @param mesh The mesh to remove
  48885. */
  48886. removeExcludedMesh(mesh: Mesh): void;
  48887. /**
  48888. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48889. * @param mesh The mesh to include in the glow layer
  48890. */
  48891. addIncludedOnlyMesh(mesh: Mesh): void;
  48892. /**
  48893. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48894. * @param mesh The mesh to remove
  48895. */
  48896. removeIncludedOnlyMesh(mesh: Mesh): void;
  48897. /**
  48898. * Determine if a given mesh will be used in the glow layer
  48899. * @param mesh The mesh to test
  48900. * @returns true if the mesh will be highlighted by the current glow layer
  48901. */
  48902. hasMesh(mesh: AbstractMesh): boolean;
  48903. /**
  48904. * Free any resources and references associated to a mesh.
  48905. * Internal use
  48906. * @param mesh The mesh to free.
  48907. * @hidden
  48908. */
  48909. _disposeMesh(mesh: Mesh): void;
  48910. /**
  48911. * Gets the class name of the effect layer
  48912. * @returns the string with the class name of the effect layer
  48913. */
  48914. getClassName(): string;
  48915. /**
  48916. * Serializes this glow layer
  48917. * @returns a serialized glow layer object
  48918. */
  48919. serialize(): any;
  48920. /**
  48921. * Creates a Glow Layer from parsed glow layer data
  48922. * @param parsedGlowLayer defines glow layer data
  48923. * @param scene defines the current scene
  48924. * @param rootUrl defines the root URL containing the glow layer information
  48925. * @returns a parsed Glow Layer
  48926. */
  48927. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48928. }
  48929. }
  48930. declare module BABYLON {
  48931. /** @hidden */
  48932. export var glowBlurPostProcessPixelShader: {
  48933. name: string;
  48934. shader: string;
  48935. };
  48936. }
  48937. declare module BABYLON {
  48938. interface AbstractScene {
  48939. /**
  48940. * Return a the first highlight layer of the scene with a given name.
  48941. * @param name The name of the highlight layer to look for.
  48942. * @return The highlight layer if found otherwise null.
  48943. */
  48944. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48945. }
  48946. /**
  48947. * Highlight layer options. This helps customizing the behaviour
  48948. * of the highlight layer.
  48949. */
  48950. export interface IHighlightLayerOptions {
  48951. /**
  48952. * Multiplication factor apply to the canvas size to compute the render target size
  48953. * used to generated the glowing objects (the smaller the faster).
  48954. */
  48955. mainTextureRatio: number;
  48956. /**
  48957. * Enforces a fixed size texture to ensure resize independant blur.
  48958. */
  48959. mainTextureFixedSize?: number;
  48960. /**
  48961. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48962. * of the picture to blur (the smaller the faster).
  48963. */
  48964. blurTextureSizeRatio: number;
  48965. /**
  48966. * How big in texel of the blur texture is the vertical blur.
  48967. */
  48968. blurVerticalSize: number;
  48969. /**
  48970. * How big in texel of the blur texture is the horizontal blur.
  48971. */
  48972. blurHorizontalSize: number;
  48973. /**
  48974. * Alpha blending mode used to apply the blur. Default is combine.
  48975. */
  48976. alphaBlendingMode: number;
  48977. /**
  48978. * The camera attached to the layer.
  48979. */
  48980. camera: Nullable<Camera>;
  48981. /**
  48982. * Should we display highlight as a solid stroke?
  48983. */
  48984. isStroke?: boolean;
  48985. /**
  48986. * The rendering group to draw the layer in.
  48987. */
  48988. renderingGroupId: number;
  48989. }
  48990. /**
  48991. * The highlight layer Helps adding a glow effect around a mesh.
  48992. *
  48993. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48994. * glowy meshes to your scene.
  48995. *
  48996. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48997. */
  48998. export class HighlightLayer extends EffectLayer {
  48999. name: string;
  49000. /**
  49001. * Effect Name of the highlight layer.
  49002. */
  49003. static readonly EffectName: string;
  49004. /**
  49005. * The neutral color used during the preparation of the glow effect.
  49006. * This is black by default as the blend operation is a blend operation.
  49007. */
  49008. static NeutralColor: Color4;
  49009. /**
  49010. * Stencil value used for glowing meshes.
  49011. */
  49012. static GlowingMeshStencilReference: number;
  49013. /**
  49014. * Stencil value used for the other meshes in the scene.
  49015. */
  49016. static NormalMeshStencilReference: number;
  49017. /**
  49018. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49019. */
  49020. innerGlow: boolean;
  49021. /**
  49022. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49023. */
  49024. outerGlow: boolean;
  49025. /**
  49026. * Specifies the horizontal size of the blur.
  49027. */
  49028. /**
  49029. * Gets the horizontal size of the blur.
  49030. */
  49031. blurHorizontalSize: number;
  49032. /**
  49033. * Specifies the vertical size of the blur.
  49034. */
  49035. /**
  49036. * Gets the vertical size of the blur.
  49037. */
  49038. blurVerticalSize: number;
  49039. /**
  49040. * An event triggered when the highlight layer is being blurred.
  49041. */
  49042. onBeforeBlurObservable: Observable<HighlightLayer>;
  49043. /**
  49044. * An event triggered when the highlight layer has been blurred.
  49045. */
  49046. onAfterBlurObservable: Observable<HighlightLayer>;
  49047. private _instanceGlowingMeshStencilReference;
  49048. private _options;
  49049. private _downSamplePostprocess;
  49050. private _horizontalBlurPostprocess;
  49051. private _verticalBlurPostprocess;
  49052. private _blurTexture;
  49053. private _meshes;
  49054. private _excludedMeshes;
  49055. /**
  49056. * Instantiates a new highlight Layer and references it to the scene..
  49057. * @param name The name of the layer
  49058. * @param scene The scene to use the layer in
  49059. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49060. */
  49061. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49062. /**
  49063. * Get the effect name of the layer.
  49064. * @return The effect name
  49065. */
  49066. getEffectName(): string;
  49067. /**
  49068. * Create the merge effect. This is the shader use to blit the information back
  49069. * to the main canvas at the end of the scene rendering.
  49070. */
  49071. protected _createMergeEffect(): Effect;
  49072. /**
  49073. * Creates the render target textures and post processes used in the highlight layer.
  49074. */
  49075. protected _createTextureAndPostProcesses(): void;
  49076. /**
  49077. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49078. */
  49079. needStencil(): boolean;
  49080. /**
  49081. * Checks for the readiness of the element composing the layer.
  49082. * @param subMesh the mesh to check for
  49083. * @param useInstances specify wether or not to use instances to render the mesh
  49084. * @param emissiveTexture the associated emissive texture used to generate the glow
  49085. * @return true if ready otherwise, false
  49086. */
  49087. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49088. /**
  49089. * Implementation specific of rendering the generating effect on the main canvas.
  49090. * @param effect The effect used to render through
  49091. */
  49092. protected _internalRender(effect: Effect): void;
  49093. /**
  49094. * Returns true if the layer contains information to display, otherwise false.
  49095. */
  49096. shouldRender(): boolean;
  49097. /**
  49098. * Returns true if the mesh should render, otherwise false.
  49099. * @param mesh The mesh to render
  49100. * @returns true if it should render otherwise false
  49101. */
  49102. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49103. /**
  49104. * Sets the required values for both the emissive texture and and the main color.
  49105. */
  49106. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49107. /**
  49108. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49109. * @param mesh The mesh to exclude from the highlight layer
  49110. */
  49111. addExcludedMesh(mesh: Mesh): void;
  49112. /**
  49113. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49114. * @param mesh The mesh to highlight
  49115. */
  49116. removeExcludedMesh(mesh: Mesh): void;
  49117. /**
  49118. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49119. * @param mesh mesh to test
  49120. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49121. */
  49122. hasMesh(mesh: AbstractMesh): boolean;
  49123. /**
  49124. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49125. * @param mesh The mesh to highlight
  49126. * @param color The color of the highlight
  49127. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49128. */
  49129. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49130. /**
  49131. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49132. * @param mesh The mesh to highlight
  49133. */
  49134. removeMesh(mesh: Mesh): void;
  49135. /**
  49136. * Force the stencil to the normal expected value for none glowing parts
  49137. */
  49138. private _defaultStencilReference;
  49139. /**
  49140. * Free any resources and references associated to a mesh.
  49141. * Internal use
  49142. * @param mesh The mesh to free.
  49143. * @hidden
  49144. */
  49145. _disposeMesh(mesh: Mesh): void;
  49146. /**
  49147. * Dispose the highlight layer and free resources.
  49148. */
  49149. dispose(): void;
  49150. /**
  49151. * Gets the class name of the effect layer
  49152. * @returns the string with the class name of the effect layer
  49153. */
  49154. getClassName(): string;
  49155. /**
  49156. * Serializes this Highlight layer
  49157. * @returns a serialized Highlight layer object
  49158. */
  49159. serialize(): any;
  49160. /**
  49161. * Creates a Highlight layer from parsed Highlight layer data
  49162. * @param parsedHightlightLayer defines the Highlight layer data
  49163. * @param scene defines the current scene
  49164. * @param rootUrl defines the root URL containing the Highlight layer information
  49165. * @returns a parsed Highlight layer
  49166. */
  49167. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49168. }
  49169. }
  49170. declare module BABYLON {
  49171. interface AbstractScene {
  49172. /**
  49173. * The list of layers (background and foreground) of the scene
  49174. */
  49175. layers: Array<Layer>;
  49176. }
  49177. /**
  49178. * Defines the layer scene component responsible to manage any layers
  49179. * in a given scene.
  49180. */
  49181. export class LayerSceneComponent implements ISceneComponent {
  49182. /**
  49183. * The component name helpfull to identify the component in the list of scene components.
  49184. */
  49185. readonly name: string;
  49186. /**
  49187. * The scene the component belongs to.
  49188. */
  49189. scene: Scene;
  49190. private _engine;
  49191. /**
  49192. * Creates a new instance of the component for the given scene
  49193. * @param scene Defines the scene to register the component in
  49194. */
  49195. constructor(scene: Scene);
  49196. /**
  49197. * Registers the component in a given scene
  49198. */
  49199. register(): void;
  49200. /**
  49201. * Rebuilds the elements related to this component in case of
  49202. * context lost for instance.
  49203. */
  49204. rebuild(): void;
  49205. /**
  49206. * Disposes the component and the associated ressources.
  49207. */
  49208. dispose(): void;
  49209. private _draw;
  49210. private _drawCameraPredicate;
  49211. private _drawCameraBackground;
  49212. private _drawCameraForeground;
  49213. private _drawRenderTargetPredicate;
  49214. private _drawRenderTargetBackground;
  49215. private _drawRenderTargetForeground;
  49216. /**
  49217. * Adds all the elements from the container to the scene
  49218. * @param container the container holding the elements
  49219. */
  49220. addFromContainer(container: AbstractScene): void;
  49221. /**
  49222. * Removes all the elements in the container from the scene
  49223. * @param container contains the elements to remove
  49224. * @param dispose if the removed element should be disposed (default: false)
  49225. */
  49226. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49227. }
  49228. }
  49229. declare module BABYLON {
  49230. /** @hidden */
  49231. export var layerPixelShader: {
  49232. name: string;
  49233. shader: string;
  49234. };
  49235. }
  49236. declare module BABYLON {
  49237. /** @hidden */
  49238. export var layerVertexShader: {
  49239. name: string;
  49240. shader: string;
  49241. };
  49242. }
  49243. declare module BABYLON {
  49244. /**
  49245. * This represents a full screen 2d layer.
  49246. * This can be useful to display a picture in the background of your scene for instance.
  49247. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49248. */
  49249. export class Layer {
  49250. /**
  49251. * Define the name of the layer.
  49252. */
  49253. name: string;
  49254. /**
  49255. * Define the texture the layer should display.
  49256. */
  49257. texture: Nullable<Texture>;
  49258. /**
  49259. * Is the layer in background or foreground.
  49260. */
  49261. isBackground: boolean;
  49262. /**
  49263. * Define the color of the layer (instead of texture).
  49264. */
  49265. color: Color4;
  49266. /**
  49267. * Define the scale of the layer in order to zoom in out of the texture.
  49268. */
  49269. scale: Vector2;
  49270. /**
  49271. * Define an offset for the layer in order to shift the texture.
  49272. */
  49273. offset: Vector2;
  49274. /**
  49275. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49276. */
  49277. alphaBlendingMode: number;
  49278. /**
  49279. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49280. * Alpha test will not mix with the background color in case of transparency.
  49281. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49282. */
  49283. alphaTest: boolean;
  49284. /**
  49285. * Define a mask to restrict the layer to only some of the scene cameras.
  49286. */
  49287. layerMask: number;
  49288. /**
  49289. * Define the list of render target the layer is visible into.
  49290. */
  49291. renderTargetTextures: RenderTargetTexture[];
  49292. /**
  49293. * Define if the layer is only used in renderTarget or if it also
  49294. * renders in the main frame buffer of the canvas.
  49295. */
  49296. renderOnlyInRenderTargetTextures: boolean;
  49297. private _scene;
  49298. private _vertexBuffers;
  49299. private _indexBuffer;
  49300. private _effect;
  49301. private _alphaTestEffect;
  49302. /**
  49303. * An event triggered when the layer is disposed.
  49304. */
  49305. onDisposeObservable: Observable<Layer>;
  49306. private _onDisposeObserver;
  49307. /**
  49308. * Back compatibility with callback before the onDisposeObservable existed.
  49309. * The set callback will be triggered when the layer has been disposed.
  49310. */
  49311. onDispose: () => void;
  49312. /**
  49313. * An event triggered before rendering the scene
  49314. */
  49315. onBeforeRenderObservable: Observable<Layer>;
  49316. private _onBeforeRenderObserver;
  49317. /**
  49318. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49319. * The set callback will be triggered just before rendering the layer.
  49320. */
  49321. onBeforeRender: () => void;
  49322. /**
  49323. * An event triggered after rendering the scene
  49324. */
  49325. onAfterRenderObservable: Observable<Layer>;
  49326. private _onAfterRenderObserver;
  49327. /**
  49328. * Back compatibility with callback before the onAfterRenderObservable existed.
  49329. * The set callback will be triggered just after rendering the layer.
  49330. */
  49331. onAfterRender: () => void;
  49332. /**
  49333. * Instantiates a new layer.
  49334. * This represents a full screen 2d layer.
  49335. * This can be useful to display a picture in the background of your scene for instance.
  49336. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49337. * @param name Define the name of the layer in the scene
  49338. * @param imgUrl Define the url of the texture to display in the layer
  49339. * @param scene Define the scene the layer belongs to
  49340. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49341. * @param color Defines a color for the layer
  49342. */
  49343. constructor(
  49344. /**
  49345. * Define the name of the layer.
  49346. */
  49347. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49348. private _createIndexBuffer;
  49349. /** @hidden */
  49350. _rebuild(): void;
  49351. /**
  49352. * Renders the layer in the scene.
  49353. */
  49354. render(): void;
  49355. /**
  49356. * Disposes and releases the associated ressources.
  49357. */
  49358. dispose(): void;
  49359. }
  49360. }
  49361. declare module BABYLON {
  49362. /** @hidden */
  49363. export var lensFlarePixelShader: {
  49364. name: string;
  49365. shader: string;
  49366. };
  49367. }
  49368. declare module BABYLON {
  49369. /** @hidden */
  49370. export var lensFlareVertexShader: {
  49371. name: string;
  49372. shader: string;
  49373. };
  49374. }
  49375. declare module BABYLON {
  49376. /**
  49377. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49378. * It is usually composed of several `lensFlare`.
  49379. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49380. */
  49381. export class LensFlareSystem {
  49382. /**
  49383. * Define the name of the lens flare system
  49384. */
  49385. name: string;
  49386. /**
  49387. * List of lens flares used in this system.
  49388. */
  49389. lensFlares: LensFlare[];
  49390. /**
  49391. * Define a limit from the border the lens flare can be visible.
  49392. */
  49393. borderLimit: number;
  49394. /**
  49395. * Define a viewport border we do not want to see the lens flare in.
  49396. */
  49397. viewportBorder: number;
  49398. /**
  49399. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49400. */
  49401. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49402. /**
  49403. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49404. */
  49405. layerMask: number;
  49406. /**
  49407. * Define the id of the lens flare system in the scene.
  49408. * (equal to name by default)
  49409. */
  49410. id: string;
  49411. private _scene;
  49412. private _emitter;
  49413. private _vertexBuffers;
  49414. private _indexBuffer;
  49415. private _effect;
  49416. private _positionX;
  49417. private _positionY;
  49418. private _isEnabled;
  49419. /** @hidden */
  49420. static _SceneComponentInitialization: (scene: Scene) => void;
  49421. /**
  49422. * Instantiates a lens flare system.
  49423. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49424. * It is usually composed of several `lensFlare`.
  49425. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49426. * @param name Define the name of the lens flare system in the scene
  49427. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49428. * @param scene Define the scene the lens flare system belongs to
  49429. */
  49430. constructor(
  49431. /**
  49432. * Define the name of the lens flare system
  49433. */
  49434. name: string, emitter: any, scene: Scene);
  49435. /**
  49436. * Define if the lens flare system is enabled.
  49437. */
  49438. isEnabled: boolean;
  49439. /**
  49440. * Get the scene the effects belongs to.
  49441. * @returns the scene holding the lens flare system
  49442. */
  49443. getScene(): Scene;
  49444. /**
  49445. * Get the emitter of the lens flare system.
  49446. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49447. * @returns the emitter of the lens flare system
  49448. */
  49449. getEmitter(): any;
  49450. /**
  49451. * Set the emitter of the lens flare system.
  49452. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49453. * @param newEmitter Define the new emitter of the system
  49454. */
  49455. setEmitter(newEmitter: any): void;
  49456. /**
  49457. * Get the lens flare system emitter position.
  49458. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49459. * @returns the position
  49460. */
  49461. getEmitterPosition(): Vector3;
  49462. /**
  49463. * @hidden
  49464. */
  49465. computeEffectivePosition(globalViewport: Viewport): boolean;
  49466. /** @hidden */
  49467. _isVisible(): boolean;
  49468. /**
  49469. * @hidden
  49470. */
  49471. render(): boolean;
  49472. /**
  49473. * Dispose and release the lens flare with its associated resources.
  49474. */
  49475. dispose(): void;
  49476. /**
  49477. * Parse a lens flare system from a JSON repressentation
  49478. * @param parsedLensFlareSystem Define the JSON to parse
  49479. * @param scene Define the scene the parsed system should be instantiated in
  49480. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49481. * @returns the parsed system
  49482. */
  49483. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49484. /**
  49485. * Serialize the current Lens Flare System into a JSON representation.
  49486. * @returns the serialized JSON
  49487. */
  49488. serialize(): any;
  49489. }
  49490. }
  49491. declare module BABYLON {
  49492. /**
  49493. * This represents one of the lens effect in a `lensFlareSystem`.
  49494. * It controls one of the indiviual texture used in the effect.
  49495. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49496. */
  49497. export class LensFlare {
  49498. /**
  49499. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49500. */
  49501. size: number;
  49502. /**
  49503. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  49504. */
  49505. position: number;
  49506. /**
  49507. * Define the lens color.
  49508. */
  49509. color: Color3;
  49510. /**
  49511. * Define the lens texture.
  49512. */
  49513. texture: Nullable<Texture>;
  49514. /**
  49515. * Define the alpha mode to render this particular lens.
  49516. */
  49517. alphaMode: number;
  49518. private _system;
  49519. /**
  49520. * Creates a new Lens Flare.
  49521. * This represents one of the lens effect in a `lensFlareSystem`.
  49522. * It controls one of the indiviual texture used in the effect.
  49523. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49524. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49525. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  49526. * @param color Define the lens color
  49527. * @param imgUrl Define the lens texture url
  49528. * @param system Define the `lensFlareSystem` this flare is part of
  49529. * @returns The newly created Lens Flare
  49530. */
  49531. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49532. /**
  49533. * Instantiates a new Lens Flare.
  49534. * This represents one of the lens effect in a `lensFlareSystem`.
  49535. * It controls one of the indiviual texture used in the effect.
  49536. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49537. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49538. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  49539. * @param color Define the lens color
  49540. * @param imgUrl Define the lens texture url
  49541. * @param system Define the `lensFlareSystem` this flare is part of
  49542. */
  49543. constructor(
  49544. /**
  49545. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49546. */
  49547. size: number,
  49548. /**
  49549. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  49550. */
  49551. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49552. /**
  49553. * Dispose and release the lens flare with its associated resources.
  49554. */
  49555. dispose(): void;
  49556. }
  49557. }
  49558. declare module BABYLON {
  49559. interface AbstractScene {
  49560. /**
  49561. * The list of lens flare system added to the scene
  49562. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49563. */
  49564. lensFlareSystems: Array<LensFlareSystem>;
  49565. /**
  49566. * Removes the given lens flare system from this scene.
  49567. * @param toRemove The lens flare system to remove
  49568. * @returns The index of the removed lens flare system
  49569. */
  49570. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49571. /**
  49572. * Adds the given lens flare system to this scene
  49573. * @param newLensFlareSystem The lens flare system to add
  49574. */
  49575. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49576. /**
  49577. * Gets a lens flare system using its name
  49578. * @param name defines the name to look for
  49579. * @returns the lens flare system or null if not found
  49580. */
  49581. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49582. /**
  49583. * Gets a lens flare system using its id
  49584. * @param id defines the id to look for
  49585. * @returns the lens flare system or null if not found
  49586. */
  49587. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49588. }
  49589. /**
  49590. * Defines the lens flare scene component responsible to manage any lens flares
  49591. * in a given scene.
  49592. */
  49593. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49594. /**
  49595. * The component name helpfull to identify the component in the list of scene components.
  49596. */
  49597. readonly name: string;
  49598. /**
  49599. * The scene the component belongs to.
  49600. */
  49601. scene: Scene;
  49602. /**
  49603. * Creates a new instance of the component for the given scene
  49604. * @param scene Defines the scene to register the component in
  49605. */
  49606. constructor(scene: Scene);
  49607. /**
  49608. * Registers the component in a given scene
  49609. */
  49610. register(): void;
  49611. /**
  49612. * Rebuilds the elements related to this component in case of
  49613. * context lost for instance.
  49614. */
  49615. rebuild(): void;
  49616. /**
  49617. * Adds all the elements from the container to the scene
  49618. * @param container the container holding the elements
  49619. */
  49620. addFromContainer(container: AbstractScene): void;
  49621. /**
  49622. * Removes all the elements in the container from the scene
  49623. * @param container contains the elements to remove
  49624. * @param dispose if the removed element should be disposed (default: false)
  49625. */
  49626. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49627. /**
  49628. * Serializes the component data to the specified json object
  49629. * @param serializationObject The object to serialize to
  49630. */
  49631. serialize(serializationObject: any): void;
  49632. /**
  49633. * Disposes the component and the associated ressources.
  49634. */
  49635. dispose(): void;
  49636. private _draw;
  49637. }
  49638. }
  49639. declare module BABYLON {
  49640. /**
  49641. * Defines the shadow generator component responsible to manage any shadow generators
  49642. * in a given scene.
  49643. */
  49644. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49645. /**
  49646. * The component name helpfull to identify the component in the list of scene components.
  49647. */
  49648. readonly name: string;
  49649. /**
  49650. * The scene the component belongs to.
  49651. */
  49652. scene: Scene;
  49653. /**
  49654. * Creates a new instance of the component for the given scene
  49655. * @param scene Defines the scene to register the component in
  49656. */
  49657. constructor(scene: Scene);
  49658. /**
  49659. * Registers the component in a given scene
  49660. */
  49661. register(): void;
  49662. /**
  49663. * Rebuilds the elements related to this component in case of
  49664. * context lost for instance.
  49665. */
  49666. rebuild(): void;
  49667. /**
  49668. * Serializes the component data to the specified json object
  49669. * @param serializationObject The object to serialize to
  49670. */
  49671. serialize(serializationObject: any): void;
  49672. /**
  49673. * Adds all the elements from the container to the scene
  49674. * @param container the container holding the elements
  49675. */
  49676. addFromContainer(container: AbstractScene): void;
  49677. /**
  49678. * Removes all the elements in the container from the scene
  49679. * @param container contains the elements to remove
  49680. * @param dispose if the removed element should be disposed (default: false)
  49681. */
  49682. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49683. /**
  49684. * Rebuilds the elements related to this component in case of
  49685. * context lost for instance.
  49686. */
  49687. dispose(): void;
  49688. private _gatherRenderTargets;
  49689. }
  49690. }
  49691. declare module BABYLON {
  49692. /**
  49693. * A point light is a light defined by an unique point in world space.
  49694. * The light is emitted in every direction from this point.
  49695. * A good example of a point light is a standard light bulb.
  49696. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49697. */
  49698. export class PointLight extends ShadowLight {
  49699. private _shadowAngle;
  49700. /**
  49701. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49702. * This specifies what angle the shadow will use to be created.
  49703. *
  49704. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49705. */
  49706. /**
  49707. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49708. * This specifies what angle the shadow will use to be created.
  49709. *
  49710. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49711. */
  49712. shadowAngle: number;
  49713. /**
  49714. * Gets the direction if it has been set.
  49715. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49716. */
  49717. /**
  49718. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49719. */
  49720. direction: Vector3;
  49721. /**
  49722. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49723. * A PointLight emits the light in every direction.
  49724. * It can cast shadows.
  49725. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49726. * ```javascript
  49727. * var pointLight = new PointLight("pl", camera.position, scene);
  49728. * ```
  49729. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49730. * @param name The light friendly name
  49731. * @param position The position of the point light in the scene
  49732. * @param scene The scene the lights belongs to
  49733. */
  49734. constructor(name: string, position: Vector3, scene: Scene);
  49735. /**
  49736. * Returns the string "PointLight"
  49737. * @returns the class name
  49738. */
  49739. getClassName(): string;
  49740. /**
  49741. * Returns the integer 0.
  49742. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49743. */
  49744. getTypeID(): number;
  49745. /**
  49746. * Specifies wether or not the shadowmap should be a cube texture.
  49747. * @returns true if the shadowmap needs to be a cube texture.
  49748. */
  49749. needCube(): boolean;
  49750. /**
  49751. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49752. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49753. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49754. */
  49755. getShadowDirection(faceIndex?: number): Vector3;
  49756. /**
  49757. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49758. * - fov = PI / 2
  49759. * - aspect ratio : 1.0
  49760. * - z-near and far equal to the active camera minZ and maxZ.
  49761. * Returns the PointLight.
  49762. */
  49763. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49764. protected _buildUniformLayout(): void;
  49765. /**
  49766. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49767. * @param effect The effect to update
  49768. * @param lightIndex The index of the light in the effect to update
  49769. * @returns The point light
  49770. */
  49771. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49772. /**
  49773. * Prepares the list of defines specific to the light type.
  49774. * @param defines the list of defines
  49775. * @param lightIndex defines the index of the light for the effect
  49776. */
  49777. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49778. }
  49779. }
  49780. declare module BABYLON {
  49781. /**
  49782. * Header information of HDR texture files.
  49783. */
  49784. export interface HDRInfo {
  49785. /**
  49786. * The height of the texture in pixels.
  49787. */
  49788. height: number;
  49789. /**
  49790. * The width of the texture in pixels.
  49791. */
  49792. width: number;
  49793. /**
  49794. * The index of the beginning of the data in the binary file.
  49795. */
  49796. dataPosition: number;
  49797. }
  49798. /**
  49799. * This groups tools to convert HDR texture to native colors array.
  49800. */
  49801. export class HDRTools {
  49802. private static Ldexp;
  49803. private static Rgbe2float;
  49804. private static readStringLine;
  49805. /**
  49806. * Reads header information from an RGBE texture stored in a native array.
  49807. * More information on this format are available here:
  49808. * https://en.wikipedia.org/wiki/RGBE_image_format
  49809. *
  49810. * @param uint8array The binary file stored in native array.
  49811. * @return The header information.
  49812. */
  49813. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49814. /**
  49815. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49816. * This RGBE texture needs to store the information as a panorama.
  49817. *
  49818. * More information on this format are available here:
  49819. * https://en.wikipedia.org/wiki/RGBE_image_format
  49820. *
  49821. * @param buffer The binary file stored in an array buffer.
  49822. * @param size The expected size of the extracted cubemap.
  49823. * @return The Cube Map information.
  49824. */
  49825. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49826. /**
  49827. * Returns the pixels data extracted from an RGBE texture.
  49828. * This pixels will be stored left to right up to down in the R G B order in one array.
  49829. *
  49830. * More information on this format are available here:
  49831. * https://en.wikipedia.org/wiki/RGBE_image_format
  49832. *
  49833. * @param uint8array The binary file stored in an array buffer.
  49834. * @param hdrInfo The header information of the file.
  49835. * @return The pixels data in RGB right to left up to down order.
  49836. */
  49837. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49838. private static RGBE_ReadPixels_RLE;
  49839. }
  49840. }
  49841. declare module BABYLON {
  49842. /**
  49843. * This represents a texture coming from an HDR input.
  49844. *
  49845. * The only supported format is currently panorama picture stored in RGBE format.
  49846. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49847. */
  49848. export class HDRCubeTexture extends BaseTexture {
  49849. private static _facesMapping;
  49850. private _generateHarmonics;
  49851. private _noMipmap;
  49852. private _textureMatrix;
  49853. private _size;
  49854. private _onLoad;
  49855. private _onError;
  49856. /**
  49857. * The texture URL.
  49858. */
  49859. url: string;
  49860. /**
  49861. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49862. */
  49863. coordinatesMode: number;
  49864. protected _isBlocking: boolean;
  49865. /**
  49866. * Sets wether or not the texture is blocking during loading.
  49867. */
  49868. /**
  49869. * Gets wether or not the texture is blocking during loading.
  49870. */
  49871. isBlocking: boolean;
  49872. protected _rotationY: number;
  49873. /**
  49874. * Sets texture matrix rotation angle around Y axis in radians.
  49875. */
  49876. /**
  49877. * Gets texture matrix rotation angle around Y axis radians.
  49878. */
  49879. rotationY: number;
  49880. /**
  49881. * Gets or sets the center of the bounding box associated with the cube texture
  49882. * It must define where the camera used to render the texture was set
  49883. */
  49884. boundingBoxPosition: Vector3;
  49885. private _boundingBoxSize;
  49886. /**
  49887. * Gets or sets the size of the bounding box associated with the cube texture
  49888. * When defined, the cubemap will switch to local mode
  49889. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49890. * @example https://www.babylonjs-playground.com/#RNASML
  49891. */
  49892. boundingBoxSize: Vector3;
  49893. /**
  49894. * Instantiates an HDRTexture from the following parameters.
  49895. *
  49896. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49897. * @param scene The scene the texture will be used in
  49898. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49899. * @param noMipmap Forces to not generate the mipmap if true
  49900. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49901. * @param gammaSpace 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)
  49902. * @param reserved Reserved flag for internal use.
  49903. */
  49904. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49905. /**
  49906. * Get the current class name of the texture useful for serialization or dynamic coding.
  49907. * @returns "HDRCubeTexture"
  49908. */
  49909. getClassName(): string;
  49910. /**
  49911. * Occurs when the file is raw .hdr file.
  49912. */
  49913. private loadTexture;
  49914. clone(): HDRCubeTexture;
  49915. delayLoad(): void;
  49916. /**
  49917. * Get the texture reflection matrix used to rotate/transform the reflection.
  49918. * @returns the reflection matrix
  49919. */
  49920. getReflectionTextureMatrix(): Matrix;
  49921. /**
  49922. * Set the texture reflection matrix used to rotate/transform the reflection.
  49923. * @param value Define the reflection matrix to set
  49924. */
  49925. setReflectionTextureMatrix(value: Matrix): void;
  49926. /**
  49927. * Parses a JSON representation of an HDR Texture in order to create the texture
  49928. * @param parsedTexture Define the JSON representation
  49929. * @param scene Define the scene the texture should be created in
  49930. * @param rootUrl Define the root url in case we need to load relative dependencies
  49931. * @returns the newly created texture after parsing
  49932. */
  49933. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49934. serialize(): any;
  49935. }
  49936. }
  49937. declare module BABYLON {
  49938. /**
  49939. * Class used to control physics engine
  49940. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49941. */
  49942. export class PhysicsEngine implements IPhysicsEngine {
  49943. private _physicsPlugin;
  49944. /**
  49945. * Global value used to control the smallest number supported by the simulation
  49946. */
  49947. static Epsilon: number;
  49948. private _impostors;
  49949. private _joints;
  49950. /**
  49951. * Gets the gravity vector used by the simulation
  49952. */
  49953. gravity: Vector3;
  49954. /**
  49955. * Factory used to create the default physics plugin.
  49956. * @returns The default physics plugin
  49957. */
  49958. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49959. /**
  49960. * Creates a new Physics Engine
  49961. * @param gravity defines the gravity vector used by the simulation
  49962. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49963. */
  49964. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49965. /**
  49966. * Sets the gravity vector used by the simulation
  49967. * @param gravity defines the gravity vector to use
  49968. */
  49969. setGravity(gravity: Vector3): void;
  49970. /**
  49971. * Set the time step of the physics engine.
  49972. * Default is 1/60.
  49973. * To slow it down, enter 1/600 for example.
  49974. * To speed it up, 1/30
  49975. * @param newTimeStep defines the new timestep to apply to this world.
  49976. */
  49977. setTimeStep(newTimeStep?: number): void;
  49978. /**
  49979. * Get the time step of the physics engine.
  49980. * @returns the current time step
  49981. */
  49982. getTimeStep(): number;
  49983. /**
  49984. * Release all resources
  49985. */
  49986. dispose(): void;
  49987. /**
  49988. * Gets the name of the current physics plugin
  49989. * @returns the name of the plugin
  49990. */
  49991. getPhysicsPluginName(): string;
  49992. /**
  49993. * Adding a new impostor for the impostor tracking.
  49994. * This will be done by the impostor itself.
  49995. * @param impostor the impostor to add
  49996. */
  49997. addImpostor(impostor: PhysicsImpostor): void;
  49998. /**
  49999. * Remove an impostor from the engine.
  50000. * This impostor and its mesh will not longer be updated by the physics engine.
  50001. * @param impostor the impostor to remove
  50002. */
  50003. removeImpostor(impostor: PhysicsImpostor): void;
  50004. /**
  50005. * Add a joint to the physics engine
  50006. * @param mainImpostor defines the main impostor to which the joint is added.
  50007. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50008. * @param joint defines the joint that will connect both impostors.
  50009. */
  50010. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50011. /**
  50012. * Removes a joint from the simulation
  50013. * @param mainImpostor defines the impostor used with the joint
  50014. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50015. * @param joint defines the joint to remove
  50016. */
  50017. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50018. /**
  50019. * Called by the scene. No need to call it.
  50020. * @param delta defines the timespam between frames
  50021. */
  50022. _step(delta: number): void;
  50023. /**
  50024. * Gets the current plugin used to run the simulation
  50025. * @returns current plugin
  50026. */
  50027. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50028. /**
  50029. * Gets the list of physic impostors
  50030. * @returns an array of PhysicsImpostor
  50031. */
  50032. getImpostors(): Array<PhysicsImpostor>;
  50033. /**
  50034. * Gets the impostor for a physics enabled object
  50035. * @param object defines the object impersonated by the impostor
  50036. * @returns the PhysicsImpostor or null if not found
  50037. */
  50038. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50039. /**
  50040. * Gets the impostor for a physics body object
  50041. * @param body defines physics body used by the impostor
  50042. * @returns the PhysicsImpostor or null if not found
  50043. */
  50044. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50045. /**
  50046. * Does a raycast in the physics world
  50047. * @param from when should the ray start?
  50048. * @param to when should the ray end?
  50049. * @returns PhysicsRaycastResult
  50050. */
  50051. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50052. }
  50053. }
  50054. declare module BABYLON {
  50055. /** @hidden */
  50056. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50057. private _useDeltaForWorldStep;
  50058. world: any;
  50059. name: string;
  50060. private _physicsMaterials;
  50061. private _fixedTimeStep;
  50062. private _cannonRaycastResult;
  50063. private _raycastResult;
  50064. private _physicsBodysToRemoveAfterStep;
  50065. BJSCANNON: any;
  50066. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50067. setGravity(gravity: Vector3): void;
  50068. setTimeStep(timeStep: number): void;
  50069. getTimeStep(): number;
  50070. executeStep(delta: number): void;
  50071. private _removeMarkedPhysicsBodiesFromWorld;
  50072. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50073. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50074. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50075. private _processChildMeshes;
  50076. removePhysicsBody(impostor: PhysicsImpostor): void;
  50077. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50078. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50079. private _addMaterial;
  50080. private _checkWithEpsilon;
  50081. private _createShape;
  50082. private _createHeightmap;
  50083. private _minus90X;
  50084. private _plus90X;
  50085. private _tmpPosition;
  50086. private _tmpDeltaPosition;
  50087. private _tmpUnityRotation;
  50088. private _updatePhysicsBodyTransformation;
  50089. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50090. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50091. isSupported(): boolean;
  50092. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50093. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50094. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50095. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50096. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50097. getBodyMass(impostor: PhysicsImpostor): number;
  50098. getBodyFriction(impostor: PhysicsImpostor): number;
  50099. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50100. getBodyRestitution(impostor: PhysicsImpostor): number;
  50101. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50102. sleepBody(impostor: PhysicsImpostor): void;
  50103. wakeUpBody(impostor: PhysicsImpostor): void;
  50104. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50105. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50106. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50107. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50108. getRadius(impostor: PhysicsImpostor): number;
  50109. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50110. dispose(): void;
  50111. private _extendNamespace;
  50112. /**
  50113. * Does a raycast in the physics world
  50114. * @param from when should the ray start?
  50115. * @param to when should the ray end?
  50116. * @returns PhysicsRaycastResult
  50117. */
  50118. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50119. }
  50120. }
  50121. declare module BABYLON {
  50122. /** @hidden */
  50123. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50124. world: any;
  50125. name: string;
  50126. BJSOIMO: any;
  50127. private _raycastResult;
  50128. constructor(iterations?: number, oimoInjection?: any);
  50129. setGravity(gravity: Vector3): void;
  50130. setTimeStep(timeStep: number): void;
  50131. getTimeStep(): number;
  50132. private _tmpImpostorsArray;
  50133. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50134. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50135. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50136. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50137. private _tmpPositionVector;
  50138. removePhysicsBody(impostor: PhysicsImpostor): void;
  50139. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50140. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50141. isSupported(): boolean;
  50142. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50143. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50144. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50145. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50146. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50147. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50148. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50149. getBodyMass(impostor: PhysicsImpostor): number;
  50150. getBodyFriction(impostor: PhysicsImpostor): number;
  50151. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50152. getBodyRestitution(impostor: PhysicsImpostor): number;
  50153. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50154. sleepBody(impostor: PhysicsImpostor): void;
  50155. wakeUpBody(impostor: PhysicsImpostor): void;
  50156. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50157. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50158. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50159. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50160. getRadius(impostor: PhysicsImpostor): number;
  50161. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50162. dispose(): void;
  50163. /**
  50164. * Does a raycast in the physics world
  50165. * @param from when should the ray start?
  50166. * @param to when should the ray end?
  50167. * @returns PhysicsRaycastResult
  50168. */
  50169. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50170. }
  50171. }
  50172. declare module BABYLON {
  50173. /**
  50174. * Class containing static functions to help procedurally build meshes
  50175. */
  50176. export class RibbonBuilder {
  50177. /**
  50178. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50179. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50180. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50181. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50182. * * 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
  50183. * * 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
  50184. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  50185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50186. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50187. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50188. * * 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
  50189. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50190. * * 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 if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  50191. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50193. * @param name defines the name of the mesh
  50194. * @param options defines the options used to create the mesh
  50195. * @param scene defines the hosting scene
  50196. * @returns the ribbon mesh
  50197. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50198. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50199. */
  50200. static CreateRibbon(name: string, options: {
  50201. pathArray: Vector3[][];
  50202. closeArray?: boolean;
  50203. closePath?: boolean;
  50204. offset?: number;
  50205. updatable?: boolean;
  50206. sideOrientation?: number;
  50207. frontUVs?: Vector4;
  50208. backUVs?: Vector4;
  50209. instance?: Mesh;
  50210. invertUV?: boolean;
  50211. uvs?: Vector2[];
  50212. colors?: Color4[];
  50213. }, scene?: Nullable<Scene>): Mesh;
  50214. }
  50215. }
  50216. declare module BABYLON {
  50217. /**
  50218. * Class containing static functions to help procedurally build meshes
  50219. */
  50220. export class ShapeBuilder {
  50221. /**
  50222. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50223. * * 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 extruded along the Z axis.
  50224. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50225. * * 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.
  50226. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50227. * * 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
  50228. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  50229. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50231. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50232. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50234. * @param name defines the name of the mesh
  50235. * @param options defines the options used to create the mesh
  50236. * @param scene defines the hosting scene
  50237. * @returns the extruded shape mesh
  50238. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50239. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50240. */
  50241. static ExtrudeShape(name: string, options: {
  50242. shape: Vector3[];
  50243. path: Vector3[];
  50244. scale?: number;
  50245. rotation?: number;
  50246. cap?: number;
  50247. updatable?: boolean;
  50248. sideOrientation?: number;
  50249. frontUVs?: Vector4;
  50250. backUVs?: Vector4;
  50251. instance?: Mesh;
  50252. invertUV?: boolean;
  50253. }, scene?: Nullable<Scene>): Mesh;
  50254. /**
  50255. * Creates an custom extruded shape mesh.
  50256. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50257. * * 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 extruded along the Z axis.
  50258. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50259. * * 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 and the distance of this point from the begining of the path
  50260. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50261. * * 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 and the distance of this point from the begining of the path
  50262. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50263. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50264. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50265. * * 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
  50266. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  50267. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50269. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50270. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50272. * @param name defines the name of the mesh
  50273. * @param options defines the options used to create the mesh
  50274. * @param scene defines the hosting scene
  50275. * @returns the custom extruded shape mesh
  50276. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50277. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50279. */
  50280. static ExtrudeShapeCustom(name: string, options: {
  50281. shape: Vector3[];
  50282. path: Vector3[];
  50283. scaleFunction?: any;
  50284. rotationFunction?: any;
  50285. ribbonCloseArray?: boolean;
  50286. ribbonClosePath?: boolean;
  50287. cap?: number;
  50288. updatable?: boolean;
  50289. sideOrientation?: number;
  50290. frontUVs?: Vector4;
  50291. backUVs?: Vector4;
  50292. instance?: Mesh;
  50293. invertUV?: boolean;
  50294. }, scene?: Nullable<Scene>): Mesh;
  50295. private static _ExtrudeShapeGeneric;
  50296. }
  50297. }
  50298. declare module BABYLON {
  50299. /**
  50300. * AmmoJS Physics plugin
  50301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50302. * @see https://github.com/kripken/ammo.js/
  50303. */
  50304. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50305. private _useDeltaForWorldStep;
  50306. /**
  50307. * Reference to the Ammo library
  50308. */
  50309. bjsAMMO: any;
  50310. /**
  50311. * Created ammoJS world which physics bodies are added to
  50312. */
  50313. world: any;
  50314. /**
  50315. * Name of the plugin
  50316. */
  50317. name: string;
  50318. private _timeStep;
  50319. private _fixedTimeStep;
  50320. private _maxSteps;
  50321. private _tmpQuaternion;
  50322. private _tmpAmmoTransform;
  50323. private _tmpAmmoQuaternion;
  50324. private _tmpAmmoConcreteContactResultCallback;
  50325. private _collisionConfiguration;
  50326. private _dispatcher;
  50327. private _overlappingPairCache;
  50328. private _solver;
  50329. private _softBodySolver;
  50330. private _tmpAmmoVectorA;
  50331. private _tmpAmmoVectorB;
  50332. private _tmpAmmoVectorC;
  50333. private _tmpAmmoVectorD;
  50334. private _tmpContactCallbackResult;
  50335. private _tmpAmmoVectorRCA;
  50336. private _tmpAmmoVectorRCB;
  50337. private _raycastResult;
  50338. private static readonly DISABLE_COLLISION_FLAG;
  50339. private static readonly KINEMATIC_FLAG;
  50340. private static readonly DISABLE_DEACTIVATION_FLAG;
  50341. /**
  50342. * Initializes the ammoJS plugin
  50343. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50344. * @param ammoInjection can be used to inject your own ammo reference
  50345. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50346. */
  50347. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50348. /**
  50349. * Sets the gravity of the physics world (m/(s^2))
  50350. * @param gravity Gravity to set
  50351. */
  50352. setGravity(gravity: Vector3): void;
  50353. /**
  50354. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50355. * @param timeStep timestep to use in seconds
  50356. */
  50357. setTimeStep(timeStep: number): void;
  50358. /**
  50359. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  50360. * @param fixedTimeStep fixedTimeStep to use in seconds
  50361. */
  50362. setFixedTimeStep(fixedTimeStep: number): void;
  50363. /**
  50364. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50365. * @param maxSteps the maximum number of steps by the physics engine per frame
  50366. */
  50367. setMaxSteps(maxSteps: number): void;
  50368. /**
  50369. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50370. * @returns the current timestep in seconds
  50371. */
  50372. getTimeStep(): number;
  50373. private _isImpostorInContact;
  50374. private _isImpostorPairInContact;
  50375. private _stepSimulation;
  50376. /**
  50377. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50378. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50379. * After the step the babylon meshes are set to the position of the physics imposters
  50380. * @param delta amount of time to step forward
  50381. * @param impostors array of imposters to update before/after the step
  50382. */
  50383. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50384. /**
  50385. * Update babylon mesh to match physics world object
  50386. * @param impostor imposter to match
  50387. */
  50388. private _afterSoftStep;
  50389. /**
  50390. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50391. * @param impostor imposter to match
  50392. */
  50393. private _ropeStep;
  50394. /**
  50395. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50396. * @param impostor imposter to match
  50397. */
  50398. private _softbodyOrClothStep;
  50399. private _tmpVector;
  50400. private _tmpMatrix;
  50401. /**
  50402. * Applies an impulse on the imposter
  50403. * @param impostor imposter to apply impulse to
  50404. * @param force amount of force to be applied to the imposter
  50405. * @param contactPoint the location to apply the impulse on the imposter
  50406. */
  50407. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50408. /**
  50409. * Applies a force on the imposter
  50410. * @param impostor imposter to apply force
  50411. * @param force amount of force to be applied to the imposter
  50412. * @param contactPoint the location to apply the force on the imposter
  50413. */
  50414. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50415. /**
  50416. * Creates a physics body using the plugin
  50417. * @param impostor the imposter to create the physics body on
  50418. */
  50419. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50420. /**
  50421. * Removes the physics body from the imposter and disposes of the body's memory
  50422. * @param impostor imposter to remove the physics body from
  50423. */
  50424. removePhysicsBody(impostor: PhysicsImpostor): void;
  50425. /**
  50426. * Generates a joint
  50427. * @param impostorJoint the imposter joint to create the joint with
  50428. */
  50429. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50430. /**
  50431. * Removes a joint
  50432. * @param impostorJoint the imposter joint to remove the joint from
  50433. */
  50434. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50435. private _addMeshVerts;
  50436. /**
  50437. * Initialise the soft body vertices to match its object's (mesh) vertices
  50438. * Softbody vertices (nodes) are in world space and to match this
  50439. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50440. * @param impostor to create the softbody for
  50441. */
  50442. private _softVertexData;
  50443. /**
  50444. * Create an impostor's soft body
  50445. * @param impostor to create the softbody for
  50446. */
  50447. private _createSoftbody;
  50448. /**
  50449. * Create cloth for an impostor
  50450. * @param impostor to create the softbody for
  50451. */
  50452. private _createCloth;
  50453. /**
  50454. * Create rope for an impostor
  50455. * @param impostor to create the softbody for
  50456. */
  50457. private _createRope;
  50458. private _addHullVerts;
  50459. private _createShape;
  50460. /**
  50461. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50462. * @param impostor imposter containing the physics body and babylon object
  50463. */
  50464. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50465. /**
  50466. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50467. * @param impostor imposter containing the physics body and babylon object
  50468. * @param newPosition new position
  50469. * @param newRotation new rotation
  50470. */
  50471. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50472. /**
  50473. * If this plugin is supported
  50474. * @returns true if its supported
  50475. */
  50476. isSupported(): boolean;
  50477. /**
  50478. * Sets the linear velocity of the physics body
  50479. * @param impostor imposter to set the velocity on
  50480. * @param velocity velocity to set
  50481. */
  50482. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50483. /**
  50484. * Sets the angular velocity of the physics body
  50485. * @param impostor imposter to set the velocity on
  50486. * @param velocity velocity to set
  50487. */
  50488. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50489. /**
  50490. * gets the linear velocity
  50491. * @param impostor imposter to get linear velocity from
  50492. * @returns linear velocity
  50493. */
  50494. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50495. /**
  50496. * gets the angular velocity
  50497. * @param impostor imposter to get angular velocity from
  50498. * @returns angular velocity
  50499. */
  50500. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50501. /**
  50502. * Sets the mass of physics body
  50503. * @param impostor imposter to set the mass on
  50504. * @param mass mass to set
  50505. */
  50506. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50507. /**
  50508. * Gets the mass of the physics body
  50509. * @param impostor imposter to get the mass from
  50510. * @returns mass
  50511. */
  50512. getBodyMass(impostor: PhysicsImpostor): number;
  50513. /**
  50514. * Gets friction of the impostor
  50515. * @param impostor impostor to get friction from
  50516. * @returns friction value
  50517. */
  50518. getBodyFriction(impostor: PhysicsImpostor): number;
  50519. /**
  50520. * Sets friction of the impostor
  50521. * @param impostor impostor to set friction on
  50522. * @param friction friction value
  50523. */
  50524. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50525. /**
  50526. * Gets restitution of the impostor
  50527. * @param impostor impostor to get restitution from
  50528. * @returns restitution value
  50529. */
  50530. getBodyRestitution(impostor: PhysicsImpostor): number;
  50531. /**
  50532. * Sets resitution of the impostor
  50533. * @param impostor impostor to set resitution on
  50534. * @param restitution resitution value
  50535. */
  50536. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50537. /**
  50538. * Gets pressure inside the impostor
  50539. * @param impostor impostor to get pressure from
  50540. * @returns pressure value
  50541. */
  50542. getBodyPressure(impostor: PhysicsImpostor): number;
  50543. /**
  50544. * Sets pressure inside a soft body impostor
  50545. * Cloth and rope must remain 0 pressure
  50546. * @param impostor impostor to set pressure on
  50547. * @param pressure pressure value
  50548. */
  50549. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50550. /**
  50551. * Gets stiffness of the impostor
  50552. * @param impostor impostor to get stiffness from
  50553. * @returns pressure value
  50554. */
  50555. getBodyStiffness(impostor: PhysicsImpostor): number;
  50556. /**
  50557. * Sets stiffness of the impostor
  50558. * @param impostor impostor to set stiffness on
  50559. * @param stiffness stiffness value from 0 to 1
  50560. */
  50561. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50562. /**
  50563. * Gets velocityIterations of the impostor
  50564. * @param impostor impostor to get velocity iterations from
  50565. * @returns velocityIterations value
  50566. */
  50567. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50568. /**
  50569. * Sets velocityIterations of the impostor
  50570. * @param impostor impostor to set velocity iterations on
  50571. * @param velocityIterations velocityIterations value
  50572. */
  50573. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50574. /**
  50575. * Gets positionIterations of the impostor
  50576. * @param impostor impostor to get position iterations from
  50577. * @returns positionIterations value
  50578. */
  50579. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50580. /**
  50581. * Sets positionIterations of the impostor
  50582. * @param impostor impostor to set position on
  50583. * @param positionIterations positionIterations value
  50584. */
  50585. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50586. /**
  50587. * Append an anchor to a cloth object
  50588. * @param impostor is the cloth impostor to add anchor to
  50589. * @param otherImpostor is the rigid impostor to anchor to
  50590. * @param width ratio across width from 0 to 1
  50591. * @param height ratio up height from 0 to 1
  50592. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50593. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50594. */
  50595. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50596. /**
  50597. * Append an hook to a rope object
  50598. * @param impostor is the rope impostor to add hook to
  50599. * @param otherImpostor is the rigid impostor to hook to
  50600. * @param length ratio along the rope from 0 to 1
  50601. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50602. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50603. */
  50604. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50605. /**
  50606. * Sleeps the physics body and stops it from being active
  50607. * @param impostor impostor to sleep
  50608. */
  50609. sleepBody(impostor: PhysicsImpostor): void;
  50610. /**
  50611. * Activates the physics body
  50612. * @param impostor impostor to activate
  50613. */
  50614. wakeUpBody(impostor: PhysicsImpostor): void;
  50615. /**
  50616. * Updates the distance parameters of the joint
  50617. * @param joint joint to update
  50618. * @param maxDistance maximum distance of the joint
  50619. * @param minDistance minimum distance of the joint
  50620. */
  50621. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50622. /**
  50623. * Sets a motor on the joint
  50624. * @param joint joint to set motor on
  50625. * @param speed speed of the motor
  50626. * @param maxForce maximum force of the motor
  50627. * @param motorIndex index of the motor
  50628. */
  50629. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50630. /**
  50631. * Sets the motors limit
  50632. * @param joint joint to set limit on
  50633. * @param upperLimit upper limit
  50634. * @param lowerLimit lower limit
  50635. */
  50636. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50637. /**
  50638. * Syncs the position and rotation of a mesh with the impostor
  50639. * @param mesh mesh to sync
  50640. * @param impostor impostor to update the mesh with
  50641. */
  50642. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50643. /**
  50644. * Gets the radius of the impostor
  50645. * @param impostor impostor to get radius from
  50646. * @returns the radius
  50647. */
  50648. getRadius(impostor: PhysicsImpostor): number;
  50649. /**
  50650. * Gets the box size of the impostor
  50651. * @param impostor impostor to get box size from
  50652. * @param result the resulting box size
  50653. */
  50654. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50655. /**
  50656. * Disposes of the impostor
  50657. */
  50658. dispose(): void;
  50659. /**
  50660. * Does a raycast in the physics world
  50661. * @param from when should the ray start?
  50662. * @param to when should the ray end?
  50663. * @returns PhysicsRaycastResult
  50664. */
  50665. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50666. }
  50667. }
  50668. declare module BABYLON {
  50669. interface AbstractScene {
  50670. /**
  50671. * The list of reflection probes added to the scene
  50672. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50673. */
  50674. reflectionProbes: Array<ReflectionProbe>;
  50675. /**
  50676. * Removes the given reflection probe from this scene.
  50677. * @param toRemove The reflection probe to remove
  50678. * @returns The index of the removed reflection probe
  50679. */
  50680. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50681. /**
  50682. * Adds the given reflection probe to this scene.
  50683. * @param newReflectionProbe The reflection probe to add
  50684. */
  50685. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50686. }
  50687. /**
  50688. * Class used to generate realtime reflection / refraction cube textures
  50689. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50690. */
  50691. export class ReflectionProbe {
  50692. /** defines the name of the probe */
  50693. name: string;
  50694. private _scene;
  50695. private _renderTargetTexture;
  50696. private _projectionMatrix;
  50697. private _viewMatrix;
  50698. private _target;
  50699. private _add;
  50700. private _attachedMesh;
  50701. private _invertYAxis;
  50702. /** Gets or sets probe position (center of the cube map) */
  50703. position: Vector3;
  50704. /**
  50705. * Creates a new reflection probe
  50706. * @param name defines the name of the probe
  50707. * @param size defines the texture resolution (for each face)
  50708. * @param scene defines the hosting scene
  50709. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50710. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50711. */
  50712. constructor(
  50713. /** defines the name of the probe */
  50714. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50715. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50716. samples: number;
  50717. /** Gets or sets the refresh rate to use (on every frame by default) */
  50718. refreshRate: number;
  50719. /**
  50720. * Gets the hosting scene
  50721. * @returns a Scene
  50722. */
  50723. getScene(): Scene;
  50724. /** Gets the internal CubeTexture used to render to */
  50725. readonly cubeTexture: RenderTargetTexture;
  50726. /** Gets the list of meshes to render */
  50727. readonly renderList: Nullable<AbstractMesh[]>;
  50728. /**
  50729. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50730. * @param mesh defines the mesh to attach to
  50731. */
  50732. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50733. /**
  50734. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50735. * @param renderingGroupId The rendering group id corresponding to its index
  50736. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50737. */
  50738. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50739. /**
  50740. * Clean all associated resources
  50741. */
  50742. dispose(): void;
  50743. /**
  50744. * Converts the reflection probe information to a readable string for debug purpose.
  50745. * @param fullDetails Supports for multiple levels of logging within scene loading
  50746. * @returns the human readable reflection probe info
  50747. */
  50748. toString(fullDetails?: boolean): string;
  50749. /**
  50750. * Get the class name of the relfection probe.
  50751. * @returns "ReflectionProbe"
  50752. */
  50753. getClassName(): string;
  50754. /**
  50755. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50756. * @returns The JSON representation of the texture
  50757. */
  50758. serialize(): any;
  50759. /**
  50760. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50761. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50762. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50763. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50764. * @returns The parsed reflection probe if successful
  50765. */
  50766. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50767. }
  50768. }
  50769. declare module BABYLON {
  50770. /** @hidden */
  50771. export var _BabylonLoaderRegistered: boolean;
  50772. }
  50773. declare module BABYLON {
  50774. /**
  50775. * The Physically based simple base material of BJS.
  50776. *
  50777. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50778. * It is used as the base class for both the specGloss and metalRough conventions.
  50779. */
  50780. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50781. /**
  50782. * Number of Simultaneous lights allowed on the material.
  50783. */
  50784. maxSimultaneousLights: number;
  50785. /**
  50786. * If sets to true, disables all the lights affecting the material.
  50787. */
  50788. disableLighting: boolean;
  50789. /**
  50790. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50791. */
  50792. environmentTexture: BaseTexture;
  50793. /**
  50794. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50795. */
  50796. invertNormalMapX: boolean;
  50797. /**
  50798. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50799. */
  50800. invertNormalMapY: boolean;
  50801. /**
  50802. * Normal map used in the model.
  50803. */
  50804. normalTexture: BaseTexture;
  50805. /**
  50806. * Emissivie color used to self-illuminate the model.
  50807. */
  50808. emissiveColor: Color3;
  50809. /**
  50810. * Emissivie texture used to self-illuminate the model.
  50811. */
  50812. emissiveTexture: BaseTexture;
  50813. /**
  50814. * Occlusion Channel Strenght.
  50815. */
  50816. occlusionStrength: number;
  50817. /**
  50818. * Occlusion Texture of the material (adding extra occlusion effects).
  50819. */
  50820. occlusionTexture: BaseTexture;
  50821. /**
  50822. * Defines the alpha limits in alpha test mode.
  50823. */
  50824. alphaCutOff: number;
  50825. /**
  50826. * Gets the current double sided mode.
  50827. */
  50828. /**
  50829. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50830. */
  50831. doubleSided: boolean;
  50832. /**
  50833. * Stores the pre-calculated light information of a mesh in a texture.
  50834. */
  50835. lightmapTexture: BaseTexture;
  50836. /**
  50837. * If true, the light map contains occlusion information instead of lighting info.
  50838. */
  50839. useLightmapAsShadowmap: boolean;
  50840. /**
  50841. * Instantiates a new PBRMaterial instance.
  50842. *
  50843. * @param name The material name
  50844. * @param scene The scene the material will be use in.
  50845. */
  50846. constructor(name: string, scene: Scene);
  50847. getClassName(): string;
  50848. }
  50849. }
  50850. declare module BABYLON {
  50851. /**
  50852. * The PBR material of BJS following the metal roughness convention.
  50853. *
  50854. * This fits to the PBR convention in the GLTF definition:
  50855. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50856. */
  50857. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50858. /**
  50859. * The base color has two different interpretations depending on the value of metalness.
  50860. * When the material is a metal, the base color is the specific measured reflectance value
  50861. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50862. * of the material.
  50863. */
  50864. baseColor: Color3;
  50865. /**
  50866. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50867. * well as opacity information in the alpha channel.
  50868. */
  50869. baseTexture: BaseTexture;
  50870. /**
  50871. * Specifies the metallic scalar value of the material.
  50872. * Can also be used to scale the metalness values of the metallic texture.
  50873. */
  50874. metallic: number;
  50875. /**
  50876. * Specifies the roughness scalar value of the material.
  50877. * Can also be used to scale the roughness values of the metallic texture.
  50878. */
  50879. roughness: number;
  50880. /**
  50881. * Texture containing both the metallic value in the B channel and the
  50882. * roughness value in the G channel to keep better precision.
  50883. */
  50884. metallicRoughnessTexture: BaseTexture;
  50885. /**
  50886. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50887. *
  50888. * @param name The material name
  50889. * @param scene The scene the material will be use in.
  50890. */
  50891. constructor(name: string, scene: Scene);
  50892. /**
  50893. * Return the currrent class name of the material.
  50894. */
  50895. getClassName(): string;
  50896. /**
  50897. * Makes a duplicate of the current material.
  50898. * @param name - name to use for the new material.
  50899. */
  50900. clone(name: string): PBRMetallicRoughnessMaterial;
  50901. /**
  50902. * Serialize the material to a parsable JSON object.
  50903. */
  50904. serialize(): any;
  50905. /**
  50906. * Parses a JSON object correponding to the serialize function.
  50907. */
  50908. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50909. }
  50910. }
  50911. declare module BABYLON {
  50912. /**
  50913. * The PBR material of BJS following the specular glossiness convention.
  50914. *
  50915. * This fits to the PBR convention in the GLTF definition:
  50916. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50917. */
  50918. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50919. /**
  50920. * Specifies the diffuse color of the material.
  50921. */
  50922. diffuseColor: Color3;
  50923. /**
  50924. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50925. * channel.
  50926. */
  50927. diffuseTexture: BaseTexture;
  50928. /**
  50929. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50930. */
  50931. specularColor: Color3;
  50932. /**
  50933. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50934. */
  50935. glossiness: number;
  50936. /**
  50937. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50938. */
  50939. specularGlossinessTexture: BaseTexture;
  50940. /**
  50941. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50942. *
  50943. * @param name The material name
  50944. * @param scene The scene the material will be use in.
  50945. */
  50946. constructor(name: string, scene: Scene);
  50947. /**
  50948. * Return the currrent class name of the material.
  50949. */
  50950. getClassName(): string;
  50951. /**
  50952. * Makes a duplicate of the current material.
  50953. * @param name - name to use for the new material.
  50954. */
  50955. clone(name: string): PBRSpecularGlossinessMaterial;
  50956. /**
  50957. * Serialize the material to a parsable JSON object.
  50958. */
  50959. serialize(): any;
  50960. /**
  50961. * Parses a JSON object correponding to the serialize function.
  50962. */
  50963. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50964. }
  50965. }
  50966. declare module BABYLON {
  50967. /**
  50968. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50969. * It can help converting any input color in a desired output one. This can then be used to create effects
  50970. * from sepia, black and white to sixties or futuristic rendering...
  50971. *
  50972. * The only supported format is currently 3dl.
  50973. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50974. */
  50975. export class ColorGradingTexture extends BaseTexture {
  50976. /**
  50977. * The current texture matrix. (will always be identity in color grading texture)
  50978. */
  50979. private _textureMatrix;
  50980. /**
  50981. * The texture URL.
  50982. */
  50983. url: string;
  50984. /**
  50985. * Empty line regex stored for GC.
  50986. */
  50987. private static _noneEmptyLineRegex;
  50988. private _engine;
  50989. /**
  50990. * Instantiates a ColorGradingTexture from the following parameters.
  50991. *
  50992. * @param url The location of the color gradind data (currently only supporting 3dl)
  50993. * @param scene The scene the texture will be used in
  50994. */
  50995. constructor(url: string, scene: Scene);
  50996. /**
  50997. * Returns the texture matrix used in most of the material.
  50998. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50999. */
  51000. getTextureMatrix(): Matrix;
  51001. /**
  51002. * Occurs when the file being loaded is a .3dl LUT file.
  51003. */
  51004. private load3dlTexture;
  51005. /**
  51006. * Starts the loading process of the texture.
  51007. */
  51008. private loadTexture;
  51009. /**
  51010. * Clones the color gradind texture.
  51011. */
  51012. clone(): ColorGradingTexture;
  51013. /**
  51014. * Called during delayed load for textures.
  51015. */
  51016. delayLoad(): void;
  51017. /**
  51018. * Parses a color grading texture serialized by Babylon.
  51019. * @param parsedTexture The texture information being parsedTexture
  51020. * @param scene The scene to load the texture in
  51021. * @param rootUrl The root url of the data assets to load
  51022. * @return A color gradind texture
  51023. */
  51024. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51025. /**
  51026. * Serializes the LUT texture to json format.
  51027. */
  51028. serialize(): any;
  51029. }
  51030. }
  51031. declare module BABYLON {
  51032. /**
  51033. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51034. */
  51035. export class EquiRectangularCubeTexture extends BaseTexture {
  51036. /** The six faces of the cube. */
  51037. private static _FacesMapping;
  51038. private _noMipmap;
  51039. private _onLoad;
  51040. private _onError;
  51041. /** The size of the cubemap. */
  51042. private _size;
  51043. /** The buffer of the image. */
  51044. private _buffer;
  51045. /** The width of the input image. */
  51046. private _width;
  51047. /** The height of the input image. */
  51048. private _height;
  51049. /** The URL to the image. */
  51050. url: string;
  51051. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51052. coordinatesMode: number;
  51053. /**
  51054. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51055. * @param url The location of the image
  51056. * @param scene The scene the texture will be used in
  51057. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51058. * @param noMipmap Forces to not generate the mipmap if true
  51059. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51060. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51061. * @param onLoad — defines a callback called when texture is loaded
  51062. * @param onError — defines a callback called if there is an error
  51063. */
  51064. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51065. /**
  51066. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51067. */
  51068. private loadImage;
  51069. /**
  51070. * Convert the image buffer into a cubemap and create a CubeTexture.
  51071. */
  51072. private loadTexture;
  51073. /**
  51074. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51075. * @param buffer The ArrayBuffer that should be converted.
  51076. * @returns The buffer as Float32Array.
  51077. */
  51078. private getFloat32ArrayFromArrayBuffer;
  51079. /**
  51080. * Get the current class name of the texture useful for serialization or dynamic coding.
  51081. * @returns "EquiRectangularCubeTexture"
  51082. */
  51083. getClassName(): string;
  51084. /**
  51085. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51086. * @returns A clone of the current EquiRectangularCubeTexture.
  51087. */
  51088. clone(): EquiRectangularCubeTexture;
  51089. }
  51090. }
  51091. declare module BABYLON {
  51092. /**
  51093. * Based on jsTGALoader - Javascript loader for TGA file
  51094. * By Vincent Thibault
  51095. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51096. */
  51097. export class TGATools {
  51098. private static _TYPE_INDEXED;
  51099. private static _TYPE_RGB;
  51100. private static _TYPE_GREY;
  51101. private static _TYPE_RLE_INDEXED;
  51102. private static _TYPE_RLE_RGB;
  51103. private static _TYPE_RLE_GREY;
  51104. private static _ORIGIN_MASK;
  51105. private static _ORIGIN_SHIFT;
  51106. private static _ORIGIN_BL;
  51107. private static _ORIGIN_BR;
  51108. private static _ORIGIN_UL;
  51109. private static _ORIGIN_UR;
  51110. /**
  51111. * Gets the header of a TGA file
  51112. * @param data defines the TGA data
  51113. * @returns the header
  51114. */
  51115. static GetTGAHeader(data: Uint8Array): any;
  51116. /**
  51117. * Uploads TGA content to a Babylon Texture
  51118. * @hidden
  51119. */
  51120. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51121. /** @hidden */
  51122. 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;
  51123. /** @hidden */
  51124. 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;
  51125. /** @hidden */
  51126. 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;
  51127. /** @hidden */
  51128. 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;
  51129. /** @hidden */
  51130. 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;
  51131. /** @hidden */
  51132. 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;
  51133. }
  51134. }
  51135. declare module BABYLON {
  51136. /**
  51137. * Implementation of the TGA Texture Loader.
  51138. * @hidden
  51139. */
  51140. export class _TGATextureLoader implements IInternalTextureLoader {
  51141. /**
  51142. * Defines wether the loader supports cascade loading the different faces.
  51143. */
  51144. readonly supportCascades: boolean;
  51145. /**
  51146. * This returns if the loader support the current file information.
  51147. * @param extension defines the file extension of the file being loaded
  51148. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51149. * @param fallback defines the fallback internal texture if any
  51150. * @param isBase64 defines whether the texture is encoded as a base64
  51151. * @param isBuffer defines whether the texture data are stored as a buffer
  51152. * @returns true if the loader can load the specified file
  51153. */
  51154. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51155. /**
  51156. * Transform the url before loading if required.
  51157. * @param rootUrl the url of the texture
  51158. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51159. * @returns the transformed texture
  51160. */
  51161. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51162. /**
  51163. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51164. * @param rootUrl the url of the texture
  51165. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51166. * @returns the fallback texture
  51167. */
  51168. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51169. /**
  51170. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51171. * @param data contains the texture data
  51172. * @param texture defines the BabylonJS internal texture
  51173. * @param createPolynomials will be true if polynomials have been requested
  51174. * @param onLoad defines the callback to trigger once the texture is ready
  51175. * @param onError defines the callback to trigger in case of error
  51176. */
  51177. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51178. /**
  51179. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51180. * @param data contains the texture data
  51181. * @param texture defines the BabylonJS internal texture
  51182. * @param callback defines the method to call once ready to upload
  51183. */
  51184. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51185. }
  51186. }
  51187. declare module BABYLON {
  51188. /**
  51189. * Info about the .basis files
  51190. */
  51191. class BasisFileInfo {
  51192. /**
  51193. * If the file has alpha
  51194. */
  51195. hasAlpha: boolean;
  51196. /**
  51197. * Info about each image of the basis file
  51198. */
  51199. images: Array<{
  51200. levels: Array<{
  51201. width: number;
  51202. height: number;
  51203. transcodedPixels: ArrayBufferView;
  51204. }>;
  51205. }>;
  51206. }
  51207. /**
  51208. * Result of transcoding a basis file
  51209. */
  51210. class TranscodeResult {
  51211. /**
  51212. * Info about the .basis file
  51213. */
  51214. fileInfo: BasisFileInfo;
  51215. /**
  51216. * Format to use when loading the file
  51217. */
  51218. format: number;
  51219. }
  51220. /**
  51221. * Configuration options for the Basis transcoder
  51222. */
  51223. export class BasisTranscodeConfiguration {
  51224. /**
  51225. * Supported compression formats used to determine the supported output format of the transcoder
  51226. */
  51227. supportedCompressionFormats?: {
  51228. /**
  51229. * etc1 compression format
  51230. */
  51231. etc1?: boolean;
  51232. /**
  51233. * s3tc compression format
  51234. */
  51235. s3tc?: boolean;
  51236. /**
  51237. * pvrtc compression format
  51238. */
  51239. pvrtc?: boolean;
  51240. /**
  51241. * etc2 compression format
  51242. */
  51243. etc2?: boolean;
  51244. };
  51245. /**
  51246. * If mipmap levels should be loaded for transcoded images (Default: true)
  51247. */
  51248. loadMipmapLevels?: boolean;
  51249. /**
  51250. * Index of a single image to load (Default: all images)
  51251. */
  51252. loadSingleImage?: number;
  51253. }
  51254. /**
  51255. * Used to load .Basis files
  51256. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51257. */
  51258. export class BasisTools {
  51259. private static _IgnoreSupportedFormats;
  51260. /**
  51261. * URL to use when loading the basis transcoder
  51262. */
  51263. static JSModuleURL: string;
  51264. /**
  51265. * URL to use when loading the wasm module for the transcoder
  51266. */
  51267. static WasmModuleURL: string;
  51268. /**
  51269. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51270. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51271. * @returns internal format corresponding to the Basis format
  51272. */
  51273. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51274. private static _WorkerPromise;
  51275. private static _Worker;
  51276. private static _actionId;
  51277. private static _CreateWorkerAsync;
  51278. /**
  51279. * Transcodes a loaded image file to compressed pixel data
  51280. * @param imageData image data to transcode
  51281. * @param config configuration options for the transcoding
  51282. * @returns a promise resulting in the transcoded image
  51283. */
  51284. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51285. /**
  51286. * Loads a texture from the transcode result
  51287. * @param texture texture load to
  51288. * @param transcodeResult the result of transcoding the basis file to load from
  51289. */
  51290. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51291. }
  51292. }
  51293. declare module BABYLON {
  51294. /**
  51295. * Loader for .basis file format
  51296. */
  51297. export class _BasisTextureLoader implements IInternalTextureLoader {
  51298. /**
  51299. * Defines whether the loader supports cascade loading the different faces.
  51300. */
  51301. readonly supportCascades: boolean;
  51302. /**
  51303. * This returns if the loader support the current file information.
  51304. * @param extension defines the file extension of the file being loaded
  51305. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51306. * @param fallback defines the fallback internal texture if any
  51307. * @param isBase64 defines whether the texture is encoded as a base64
  51308. * @param isBuffer defines whether the texture data are stored as a buffer
  51309. * @returns true if the loader can load the specified file
  51310. */
  51311. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51312. /**
  51313. * Transform the url before loading if required.
  51314. * @param rootUrl the url of the texture
  51315. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51316. * @returns the transformed texture
  51317. */
  51318. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51319. /**
  51320. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51321. * @param rootUrl the url of the texture
  51322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51323. * @returns the fallback texture
  51324. */
  51325. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51326. /**
  51327. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51328. * @param data contains the texture data
  51329. * @param texture defines the BabylonJS internal texture
  51330. * @param createPolynomials will be true if polynomials have been requested
  51331. * @param onLoad defines the callback to trigger once the texture is ready
  51332. * @param onError defines the callback to trigger in case of error
  51333. */
  51334. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51335. /**
  51336. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51337. * @param data contains the texture data
  51338. * @param texture defines the BabylonJS internal texture
  51339. * @param callback defines the method to call once ready to upload
  51340. */
  51341. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51342. }
  51343. }
  51344. declare module BABYLON {
  51345. /**
  51346. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  51347. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51348. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51349. */
  51350. export class CustomProceduralTexture extends ProceduralTexture {
  51351. private _animate;
  51352. private _time;
  51353. private _config;
  51354. private _texturePath;
  51355. /**
  51356. * Instantiates a new Custom Procedural Texture.
  51357. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  51358. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51359. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51360. * @param name Define the name of the texture
  51361. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51362. * @param size Define the size of the texture to create
  51363. * @param scene Define the scene the texture belongs to
  51364. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51365. * @param generateMipMaps Define if the texture should creates mip maps or not
  51366. */
  51367. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51368. private _loadJson;
  51369. /**
  51370. * Is the texture ready to be used ? (rendered at least once)
  51371. * @returns true if ready, otherwise, false.
  51372. */
  51373. isReady(): boolean;
  51374. /**
  51375. * Render the texture to its associated render target.
  51376. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51377. */
  51378. render(useCameraPostProcess?: boolean): void;
  51379. /**
  51380. * Update the list of dependant textures samplers in the shader.
  51381. */
  51382. updateTextures(): void;
  51383. /**
  51384. * Update the uniform values of the procedural texture in the shader.
  51385. */
  51386. updateShaderUniforms(): void;
  51387. /**
  51388. * Define if the texture animates or not.
  51389. */
  51390. animate: boolean;
  51391. }
  51392. }
  51393. declare module BABYLON {
  51394. /** @hidden */
  51395. export var noisePixelShader: {
  51396. name: string;
  51397. shader: string;
  51398. };
  51399. }
  51400. declare module BABYLON {
  51401. /**
  51402. * Class used to generate noise procedural textures
  51403. */
  51404. export class NoiseProceduralTexture extends ProceduralTexture {
  51405. private _time;
  51406. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51407. brightness: number;
  51408. /** Defines the number of octaves to process */
  51409. octaves: number;
  51410. /** Defines the level of persistence (0.8 by default) */
  51411. persistence: number;
  51412. /** Gets or sets animation speed factor (default is 1) */
  51413. animationSpeedFactor: number;
  51414. /**
  51415. * Creates a new NoiseProceduralTexture
  51416. * @param name defines the name fo the texture
  51417. * @param size defines the size of the texture (default is 256)
  51418. * @param scene defines the hosting scene
  51419. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51420. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51421. */
  51422. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51423. private _updateShaderUniforms;
  51424. protected _getDefines(): string;
  51425. /** Generate the current state of the procedural texture */
  51426. render(useCameraPostProcess?: boolean): void;
  51427. /**
  51428. * Serializes this noise procedural texture
  51429. * @returns a serialized noise procedural texture object
  51430. */
  51431. serialize(): any;
  51432. /**
  51433. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51434. * @param parsedTexture defines parsed texture data
  51435. * @param scene defines the current scene
  51436. * @param rootUrl defines the root URL containing noise procedural texture information
  51437. * @returns a parsed NoiseProceduralTexture
  51438. */
  51439. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51440. }
  51441. }
  51442. declare module BABYLON {
  51443. /**
  51444. * Raw cube texture where the raw buffers are passed in
  51445. */
  51446. export class RawCubeTexture extends CubeTexture {
  51447. /**
  51448. * Creates a cube texture where the raw buffers are passed in.
  51449. * @param scene defines the scene the texture is attached to
  51450. * @param data defines the array of data to use to create each face
  51451. * @param size defines the size of the textures
  51452. * @param format defines the format of the data
  51453. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51454. * @param generateMipMaps defines if the engine should generate the mip levels
  51455. * @param invertY defines if data must be stored with Y axis inverted
  51456. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51457. * @param compression defines the compression used (null by default)
  51458. */
  51459. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51460. /**
  51461. * Updates the raw cube texture.
  51462. * @param data defines the data to store
  51463. * @param format defines the data format
  51464. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51465. * @param invertY defines if data must be stored with Y axis inverted
  51466. * @param compression defines the compression used (null by default)
  51467. * @param level defines which level of the texture to update
  51468. */
  51469. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51470. /**
  51471. * Updates a raw cube texture with RGBD encoded data.
  51472. * @param data defines the array of data [mipmap][face] to use to create each face
  51473. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51474. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51475. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51476. * @returns a promsie that resolves when the operation is complete
  51477. */
  51478. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51479. /**
  51480. * Clones the raw cube texture.
  51481. * @return a new cube texture
  51482. */
  51483. clone(): CubeTexture;
  51484. /** @hidden */
  51485. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51486. }
  51487. }
  51488. declare module BABYLON {
  51489. /**
  51490. * Class used to store 3D textures containing user data
  51491. */
  51492. export class RawTexture3D extends Texture {
  51493. /** Gets or sets the texture format to use */
  51494. format: number;
  51495. private _engine;
  51496. /**
  51497. * Create a new RawTexture3D
  51498. * @param data defines the data of the texture
  51499. * @param width defines the width of the texture
  51500. * @param height defines the height of the texture
  51501. * @param depth defines the depth of the texture
  51502. * @param format defines the texture format to use
  51503. * @param scene defines the hosting scene
  51504. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51505. * @param invertY defines if texture must be stored with Y axis inverted
  51506. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51507. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51508. */
  51509. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51510. /** Gets or sets the texture format to use */
  51511. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51512. /**
  51513. * Update the texture with new data
  51514. * @param data defines the data to store in the texture
  51515. */
  51516. update(data: ArrayBufferView): void;
  51517. }
  51518. }
  51519. declare module BABYLON {
  51520. /**
  51521. * Creates a refraction texture used by refraction channel of the standard material.
  51522. * It is like a mirror but to see through a material.
  51523. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51524. */
  51525. export class RefractionTexture extends RenderTargetTexture {
  51526. /**
  51527. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51528. * It is possible to directly set the refractionPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  51529. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51530. */
  51531. refractionPlane: Plane;
  51532. /**
  51533. * Define how deep under the surface we should see.
  51534. */
  51535. depth: number;
  51536. /**
  51537. * Creates a refraction texture used by refraction channel of the standard material.
  51538. * It is like a mirror but to see through a material.
  51539. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51540. * @param name Define the texture name
  51541. * @param size Define the size of the underlying texture
  51542. * @param scene Define the scene the refraction belongs to
  51543. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51544. */
  51545. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51546. /**
  51547. * Clone the refraction texture.
  51548. * @returns the cloned texture
  51549. */
  51550. clone(): RefractionTexture;
  51551. /**
  51552. * Serialize the texture to a JSON representation you could use in Parse later on
  51553. * @returns the serialized JSON representation
  51554. */
  51555. serialize(): any;
  51556. }
  51557. }
  51558. declare module BABYLON {
  51559. /**
  51560. * Defines the options related to the creation of an HtmlElementTexture
  51561. */
  51562. export interface IHtmlElementTextureOptions {
  51563. /**
  51564. * Defines wether mip maps should be created or not.
  51565. */
  51566. generateMipMaps?: boolean;
  51567. /**
  51568. * Defines the sampling mode of the texture.
  51569. */
  51570. samplingMode?: number;
  51571. /**
  51572. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51573. */
  51574. engine: Nullable<Engine>;
  51575. /**
  51576. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51577. */
  51578. scene: Nullable<Scene>;
  51579. }
  51580. /**
  51581. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51582. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51583. * is automatically managed.
  51584. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51585. * in your application.
  51586. *
  51587. * As the update is not automatic, you need to call them manually.
  51588. */
  51589. export class HtmlElementTexture extends BaseTexture {
  51590. /**
  51591. * The texture URL.
  51592. */
  51593. element: HTMLVideoElement | HTMLCanvasElement;
  51594. private static readonly DefaultOptions;
  51595. private _textureMatrix;
  51596. private _engine;
  51597. private _isVideo;
  51598. private _generateMipMaps;
  51599. private _samplingMode;
  51600. /**
  51601. * Instantiates a HtmlElementTexture from the following parameters.
  51602. *
  51603. * @param name Defines the name of the texture
  51604. * @param element Defines the video or canvas the texture is filled with
  51605. * @param options Defines the other none mandatory texture creation options
  51606. */
  51607. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51608. private _createInternalTexture;
  51609. /**
  51610. * Returns the texture matrix used in most of the material.
  51611. */
  51612. getTextureMatrix(): Matrix;
  51613. /**
  51614. * Updates the content of the texture.
  51615. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51616. */
  51617. update(invertY?: Nullable<boolean>): void;
  51618. }
  51619. }
  51620. declare module BABYLON {
  51621. /**
  51622. * Enum used to define the target of a block
  51623. */
  51624. export enum NodeMaterialBlockTargets {
  51625. /** Vertex shader */
  51626. Vertex = 1,
  51627. /** Fragment shader */
  51628. Fragment = 2,
  51629. /** Neutral */
  51630. Neutral = 4,
  51631. /** Vertex and Fragment */
  51632. VertexAndFragment = 3
  51633. }
  51634. }
  51635. declare module BABYLON {
  51636. /**
  51637. * Defines the kind of connection point for node based material
  51638. */
  51639. export enum NodeMaterialBlockConnectionPointTypes {
  51640. /** Float */
  51641. Float = 1,
  51642. /** Int */
  51643. Int = 2,
  51644. /** Vector2 */
  51645. Vector2 = 4,
  51646. /** Vector3 */
  51647. Vector3 = 8,
  51648. /** Vector4 */
  51649. Vector4 = 16,
  51650. /** Color3 */
  51651. Color3 = 32,
  51652. /** Color4 */
  51653. Color4 = 64,
  51654. /** Matrix */
  51655. Matrix = 128,
  51656. /** Detect type based on connection */
  51657. AutoDetect = 1024,
  51658. /** Output type that will be defined by input type */
  51659. BasedOnInput = 2048
  51660. }
  51661. }
  51662. declare module BABYLON {
  51663. /**
  51664. * Root class for all node material optimizers
  51665. */
  51666. export class NodeMaterialOptimizer {
  51667. /**
  51668. * Function used to optimize a NodeMaterial graph
  51669. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51670. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51671. */
  51672. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51673. }
  51674. }
  51675. declare module BABYLON {
  51676. /**
  51677. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51678. */
  51679. export class TransformBlock extends NodeMaterialBlock {
  51680. /**
  51681. * Defines the value to use to complement W value to transform it to a Vector4
  51682. */
  51683. complementW: number;
  51684. /**
  51685. * Defines the value to use to complement z value to transform it to a Vector4
  51686. */
  51687. complementZ: number;
  51688. /**
  51689. * Creates a new TransformBlock
  51690. * @param name defines the block name
  51691. */
  51692. constructor(name: string);
  51693. /**
  51694. * Gets the current class name
  51695. * @returns the class name
  51696. */
  51697. getClassName(): string;
  51698. /**
  51699. * Gets the vector input
  51700. */
  51701. readonly vector: NodeMaterialConnectionPoint;
  51702. /**
  51703. * Gets the output component
  51704. */
  51705. readonly output: NodeMaterialConnectionPoint;
  51706. /**
  51707. * Gets the matrix transform input
  51708. */
  51709. readonly transform: NodeMaterialConnectionPoint;
  51710. protected _buildBlock(state: NodeMaterialBuildState): this;
  51711. serialize(): any;
  51712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51713. }
  51714. }
  51715. declare module BABYLON {
  51716. /**
  51717. * Block used to output the vertex position
  51718. */
  51719. export class VertexOutputBlock extends NodeMaterialBlock {
  51720. /**
  51721. * Creates a new VertexOutputBlock
  51722. * @param name defines the block name
  51723. */
  51724. constructor(name: string);
  51725. /**
  51726. * Gets the current class name
  51727. * @returns the class name
  51728. */
  51729. getClassName(): string;
  51730. /**
  51731. * Gets the vector input component
  51732. */
  51733. readonly vector: NodeMaterialConnectionPoint;
  51734. protected _buildBlock(state: NodeMaterialBuildState): this;
  51735. }
  51736. }
  51737. declare module BABYLON {
  51738. /**
  51739. * Block used to output the final color
  51740. */
  51741. export class FragmentOutputBlock extends NodeMaterialBlock {
  51742. /**
  51743. * Create a new FragmentOutputBlock
  51744. * @param name defines the block name
  51745. */
  51746. constructor(name: string);
  51747. /**
  51748. * Gets the current class name
  51749. * @returns the class name
  51750. */
  51751. getClassName(): string;
  51752. /**
  51753. * Gets the rgba input component
  51754. */
  51755. readonly rgba: NodeMaterialConnectionPoint;
  51756. /**
  51757. * Gets the rgb input component
  51758. */
  51759. readonly rgb: NodeMaterialConnectionPoint;
  51760. /**
  51761. * Gets the a input component
  51762. */
  51763. readonly a: NodeMaterialConnectionPoint;
  51764. protected _buildBlock(state: NodeMaterialBuildState): this;
  51765. }
  51766. }
  51767. declare module BABYLON {
  51768. /**
  51769. * Enum used to define well known values e.g. values automatically provided by the system
  51770. */
  51771. export enum NodeMaterialWellKnownValues {
  51772. /** World */
  51773. World = 1,
  51774. /** View */
  51775. View = 2,
  51776. /** Projection */
  51777. Projection = 3,
  51778. /** ViewProjection */
  51779. ViewProjection = 4,
  51780. /** WorldView */
  51781. WorldView = 5,
  51782. /** WorldViewProjection */
  51783. WorldViewProjection = 6,
  51784. /** CameraPosition */
  51785. CameraPosition = 7,
  51786. /** Fog Color */
  51787. FogColor = 8
  51788. }
  51789. }
  51790. declare module BABYLON {
  51791. /**
  51792. * Block used to read a reflection texture from a sampler
  51793. */
  51794. export class ReflectionTextureBlock extends NodeMaterialBlock {
  51795. private _define3DName;
  51796. private _defineCubicName;
  51797. private _defineExplicitName;
  51798. private _defineProjectionName;
  51799. private _defineLocalCubicName;
  51800. private _defineSphericalName;
  51801. private _definePlanarName;
  51802. private _defineEquirectangularName;
  51803. private _defineMirroredEquirectangularFixedName;
  51804. private _defineEquirectangularFixedName;
  51805. private _defineSkyboxName;
  51806. private _cubeSamplerName;
  51807. private _2DSamplerName;
  51808. private _positionUVWName;
  51809. private _directionWName;
  51810. private _reflectionCoordsName;
  51811. private _reflection2DCoordsName;
  51812. private _reflectionColorName;
  51813. private _reflectionMatrixName;
  51814. /**
  51815. * Gets or sets the texture associated with the node
  51816. */
  51817. texture: Nullable<BaseTexture>;
  51818. /**
  51819. * Create a new TextureBlock
  51820. * @param name defines the block name
  51821. */
  51822. constructor(name: string);
  51823. /**
  51824. * Gets the current class name
  51825. * @returns the class name
  51826. */
  51827. getClassName(): string;
  51828. /**
  51829. * Gets the world position input component
  51830. */
  51831. readonly position: NodeMaterialConnectionPoint;
  51832. /**
  51833. * Gets the world position input component
  51834. */
  51835. readonly worldPosition: NodeMaterialConnectionPoint;
  51836. /**
  51837. * Gets the world normal input component
  51838. */
  51839. readonly worldNormal: NodeMaterialConnectionPoint;
  51840. /**
  51841. * Gets the world input component
  51842. */
  51843. readonly world: NodeMaterialConnectionPoint;
  51844. /**
  51845. * Gets the camera (or eye) position component
  51846. */
  51847. readonly cameraPosition: NodeMaterialConnectionPoint;
  51848. /**
  51849. * Gets the view input component
  51850. */
  51851. readonly view: NodeMaterialConnectionPoint;
  51852. /**
  51853. * Gets the rgb output component
  51854. */
  51855. readonly rgb: NodeMaterialConnectionPoint;
  51856. /**
  51857. * Gets the r output component
  51858. */
  51859. readonly r: NodeMaterialConnectionPoint;
  51860. /**
  51861. * Gets the g output component
  51862. */
  51863. readonly g: NodeMaterialConnectionPoint;
  51864. /**
  51865. * Gets the b output component
  51866. */
  51867. readonly b: NodeMaterialConnectionPoint;
  51868. autoConfigure(): void;
  51869. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51870. isReady(): boolean;
  51871. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51872. private _injectVertexCode;
  51873. private _writeOutput;
  51874. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51875. serialize(): any;
  51876. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51877. }
  51878. }
  51879. declare module BABYLON {
  51880. /**
  51881. * Interface used to configure the node material editor
  51882. */
  51883. export interface INodeMaterialEditorOptions {
  51884. /** Define the URl to load node editor script */
  51885. editorURL?: string;
  51886. }
  51887. /** @hidden */
  51888. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51889. /** BONES */
  51890. NUM_BONE_INFLUENCERS: number;
  51891. BonesPerMesh: number;
  51892. BONETEXTURE: boolean;
  51893. /** MORPH TARGETS */
  51894. MORPHTARGETS: boolean;
  51895. MORPHTARGETS_NORMAL: boolean;
  51896. MORPHTARGETS_TANGENT: boolean;
  51897. MORPHTARGETS_UV: boolean;
  51898. NUM_MORPH_INFLUENCERS: number;
  51899. /** IMAGE PROCESSING */
  51900. IMAGEPROCESSING: boolean;
  51901. VIGNETTE: boolean;
  51902. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51903. VIGNETTEBLENDMODEOPAQUE: boolean;
  51904. TONEMAPPING: boolean;
  51905. TONEMAPPING_ACES: boolean;
  51906. CONTRAST: boolean;
  51907. EXPOSURE: boolean;
  51908. COLORCURVES: boolean;
  51909. COLORGRADING: boolean;
  51910. COLORGRADING3D: boolean;
  51911. SAMPLER3DGREENDEPTH: boolean;
  51912. SAMPLER3DBGRMAP: boolean;
  51913. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51914. constructor();
  51915. setValue(name: string, value: boolean): void;
  51916. }
  51917. /**
  51918. * Class used to configure NodeMaterial
  51919. */
  51920. export interface INodeMaterialOptions {
  51921. /**
  51922. * Defines if blocks should emit comments
  51923. */
  51924. emitComments: boolean;
  51925. }
  51926. /**
  51927. * Class used to create a node based material built by assembling shader blocks
  51928. */
  51929. export class NodeMaterial extends PushMaterial {
  51930. private static _BuildIdGenerator;
  51931. private _options;
  51932. private _vertexCompilationState;
  51933. private _fragmentCompilationState;
  51934. private _sharedData;
  51935. private _buildId;
  51936. private _buildWasSuccessful;
  51937. private _cachedWorldViewMatrix;
  51938. private _cachedWorldViewProjectionMatrix;
  51939. private _optimizers;
  51940. private _animationFrame;
  51941. /** Define the URl to load node editor script */
  51942. static EditorURL: string;
  51943. private BJSNODEMATERIALEDITOR;
  51944. /** Get the inspector from bundle or global */
  51945. private _getGlobalNodeMaterialEditor;
  51946. /**
  51947. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  51948. */
  51949. ignoreAlpha: boolean;
  51950. /**
  51951. * Defines the maximum number of lights that can be used in the material
  51952. */
  51953. maxSimultaneousLights: number;
  51954. /**
  51955. * Observable raised when the material is built
  51956. */
  51957. onBuildObservable: Observable<NodeMaterial>;
  51958. /**
  51959. * Gets or sets the root nodes of the material vertex shader
  51960. */
  51961. _vertexOutputNodes: NodeMaterialBlock[];
  51962. /**
  51963. * Gets or sets the root nodes of the material fragment (pixel) shader
  51964. */
  51965. _fragmentOutputNodes: NodeMaterialBlock[];
  51966. /** Gets or sets options to control the node material overall behavior */
  51967. options: INodeMaterialOptions;
  51968. /**
  51969. * Default configuration related to image processing available in the standard Material.
  51970. */
  51971. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51972. /**
  51973. * Gets the image processing configuration used either in this material.
  51974. */
  51975. /**
  51976. * Sets the Default image processing configuration used either in the this material.
  51977. *
  51978. * If sets to null, the scene one is in use.
  51979. */
  51980. imageProcessingConfiguration: ImageProcessingConfiguration;
  51981. /**
  51982. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  51983. */
  51984. attachedBlocks: NodeMaterialBlock[];
  51985. /**
  51986. * Create a new node based material
  51987. * @param name defines the material name
  51988. * @param scene defines the hosting scene
  51989. * @param options defines creation option
  51990. */
  51991. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51992. /**
  51993. * Gets the current class name of the material e.g. "NodeMaterial"
  51994. * @returns the class name
  51995. */
  51996. getClassName(): string;
  51997. /**
  51998. * Keep track of the image processing observer to allow dispose and replace.
  51999. */
  52000. private _imageProcessingObserver;
  52001. /**
  52002. * Attaches a new image processing configuration to the Standard Material.
  52003. * @param configuration
  52004. */
  52005. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52006. /**
  52007. * Get a block by its name
  52008. * @param name defines the name of the block to retrieve
  52009. * @returns the required block or null if not found
  52010. */
  52011. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52012. /**
  52013. * Gets the list of input blocks attached to this material
  52014. * @returns an array of InputBlocks
  52015. */
  52016. getInputBlocks(): InputBlock[];
  52017. /**
  52018. * Adds a new optimizer to the list of optimizers
  52019. * @param optimizer defines the optimizers to add
  52020. * @returns the current material
  52021. */
  52022. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52023. /**
  52024. * Remove an optimizer from the list of optimizers
  52025. * @param optimizer defines the optimizers to remove
  52026. * @returns the current material
  52027. */
  52028. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52029. /**
  52030. * Add a new block to the list of output nodes
  52031. * @param node defines the node to add
  52032. * @returns the current material
  52033. */
  52034. addOutputNode(node: NodeMaterialBlock): this;
  52035. /**
  52036. * Remove a block from the list of root nodes
  52037. * @param node defines the node to remove
  52038. * @returns the current material
  52039. */
  52040. removeOutputNode(node: NodeMaterialBlock): this;
  52041. private _addVertexOutputNode;
  52042. private _removeVertexOutputNode;
  52043. private _addFragmentOutputNode;
  52044. private _removeFragmentOutputNode;
  52045. /**
  52046. * Specifies if the material will require alpha blending
  52047. * @returns a boolean specifying if alpha blending is needed
  52048. */
  52049. needAlphaBlending(): boolean;
  52050. /**
  52051. * Specifies if this material should be rendered in alpha test mode
  52052. * @returns a boolean specifying if an alpha test is needed.
  52053. */
  52054. needAlphaTesting(): boolean;
  52055. private _initializeBlock;
  52056. private _resetDualBlocks;
  52057. /**
  52058. * Build the material and generates the inner effect
  52059. * @param verbose defines if the build should log activity
  52060. */
  52061. build(verbose?: boolean): void;
  52062. /**
  52063. * Runs an otpimization phase to try to improve the shader code
  52064. */
  52065. optimize(): void;
  52066. private _prepareDefinesForAttributes;
  52067. /**
  52068. * Get if the submesh is ready to be used and all its information available.
  52069. * Child classes can use it to update shaders
  52070. * @param mesh defines the mesh to check
  52071. * @param subMesh defines which submesh to check
  52072. * @param useInstances specifies that instances should be used
  52073. * @returns a boolean indicating that the submesh is ready or not
  52074. */
  52075. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52076. /**
  52077. * Get a string representing the shaders built by the current node graph
  52078. */
  52079. readonly compiledShaders: string;
  52080. /**
  52081. * Binds the world matrix to the material
  52082. * @param world defines the world transformation matrix
  52083. */
  52084. bindOnlyWorldMatrix(world: Matrix): void;
  52085. /**
  52086. * Binds the submesh to this material by preparing the effect and shader to draw
  52087. * @param world defines the world transformation matrix
  52088. * @param mesh defines the mesh containing the submesh
  52089. * @param subMesh defines the submesh to bind the material to
  52090. */
  52091. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52092. /**
  52093. * Gets the active textures from the material
  52094. * @returns an array of textures
  52095. */
  52096. getActiveTextures(): BaseTexture[];
  52097. /**
  52098. * Gets the list of texture blocks
  52099. * @returns an array of texture blocks
  52100. */
  52101. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52102. /**
  52103. * Specifies if the material uses a texture
  52104. * @param texture defines the texture to check against the material
  52105. * @returns a boolean specifying if the material uses the texture
  52106. */
  52107. hasTexture(texture: BaseTexture): boolean;
  52108. /**
  52109. * Disposes the material
  52110. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52111. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52112. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52113. */
  52114. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52115. /** Creates the node editor window. */
  52116. private _createNodeEditor;
  52117. /**
  52118. * Launch the node material editor
  52119. * @param config Define the configuration of the editor
  52120. * @return a promise fulfilled when the node editor is visible
  52121. */
  52122. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52123. /**
  52124. * Clear the current material
  52125. */
  52126. clear(): void;
  52127. /**
  52128. * Clear the current material and set it to a default state
  52129. */
  52130. setToDefault(): void;
  52131. /**
  52132. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52133. * @param url defines the url to load from
  52134. * @returns a promise that will fullfil when the material is fully loaded
  52135. */
  52136. loadAsync(url: string): Promise<unknown>;
  52137. private _gatherBlocks;
  52138. /**
  52139. * Serializes this material in a JSON representation
  52140. * @returns the serialized material object
  52141. */
  52142. serialize(): any;
  52143. private _restoreConnections;
  52144. /**
  52145. * Clear the current graph and load a new one from a serialization object
  52146. * @param source defines the JSON representation of the material
  52147. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52148. */
  52149. loadFromSerialization(source: any, rootUrl?: string): void;
  52150. /**
  52151. * Creates a node material from parsed material data
  52152. * @param source defines the JSON representation of the material
  52153. * @param scene defines the hosting scene
  52154. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52155. * @returns a new node material
  52156. */
  52157. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52158. /**
  52159. * Creates a new node material set to default basic configuration
  52160. * @param name defines the name of the material
  52161. * @param scene defines the hosting scene
  52162. * @returns a new NodeMaterial
  52163. */
  52164. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52165. }
  52166. }
  52167. declare module BABYLON {
  52168. /**
  52169. * Block used to read a texture from a sampler
  52170. */
  52171. export class TextureBlock extends NodeMaterialBlock {
  52172. private _defineName;
  52173. private _samplerName;
  52174. private _transformedUVName;
  52175. private _textureTransformName;
  52176. private _textureInfoName;
  52177. private _mainUVName;
  52178. private _mainUVDefineName;
  52179. /**
  52180. * Gets or sets the texture associated with the node
  52181. */
  52182. texture: Nullable<BaseTexture>;
  52183. /**
  52184. * Create a new TextureBlock
  52185. * @param name defines the block name
  52186. */
  52187. constructor(name: string);
  52188. /**
  52189. * Gets the current class name
  52190. * @returns the class name
  52191. */
  52192. getClassName(): string;
  52193. /**
  52194. * Gets the uv input component
  52195. */
  52196. readonly uv: NodeMaterialConnectionPoint;
  52197. /**
  52198. * Gets the rgba output component
  52199. */
  52200. readonly rgba: NodeMaterialConnectionPoint;
  52201. /**
  52202. * Gets the rgb output component
  52203. */
  52204. readonly rgb: NodeMaterialConnectionPoint;
  52205. /**
  52206. * Gets the r output component
  52207. */
  52208. readonly r: NodeMaterialConnectionPoint;
  52209. /**
  52210. * Gets the g output component
  52211. */
  52212. readonly g: NodeMaterialConnectionPoint;
  52213. /**
  52214. * Gets the b output component
  52215. */
  52216. readonly b: NodeMaterialConnectionPoint;
  52217. /**
  52218. * Gets the a output component
  52219. */
  52220. readonly a: NodeMaterialConnectionPoint;
  52221. autoConfigure(): void;
  52222. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52224. isReady(): boolean;
  52225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52226. private _injectVertexCode;
  52227. private _writeOutput;
  52228. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52229. serialize(): any;
  52230. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52231. }
  52232. }
  52233. declare module BABYLON {
  52234. /**
  52235. * Class used to store shared data between 2 NodeMaterialBuildState
  52236. */
  52237. export class NodeMaterialBuildStateSharedData {
  52238. /**
  52239. * Gets the list of emitted varyings
  52240. */
  52241. temps: string[];
  52242. /**
  52243. * Gets the list of emitted varyings
  52244. */
  52245. varyings: string[];
  52246. /**
  52247. * Gets the varying declaration string
  52248. */
  52249. varyingDeclaration: string;
  52250. /**
  52251. * Input blocks
  52252. */
  52253. inputBlocks: InputBlock[];
  52254. /**
  52255. * Input blocks
  52256. */
  52257. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52258. /**
  52259. * Bindable blocks (Blocks that need to set data to the effect)
  52260. */
  52261. bindableBlocks: NodeMaterialBlock[];
  52262. /**
  52263. * List of blocks that can provide a compilation fallback
  52264. */
  52265. blocksWithFallbacks: NodeMaterialBlock[];
  52266. /**
  52267. * List of blocks that can provide a define update
  52268. */
  52269. blocksWithDefines: NodeMaterialBlock[];
  52270. /**
  52271. * List of blocks that can provide a repeatable content
  52272. */
  52273. repeatableContentBlocks: NodeMaterialBlock[];
  52274. /**
  52275. * List of blocks that can provide a dynamic list of uniforms
  52276. */
  52277. dynamicUniformBlocks: NodeMaterialBlock[];
  52278. /**
  52279. * List of blocks that can block the isReady function for the material
  52280. */
  52281. blockingBlocks: NodeMaterialBlock[];
  52282. /**
  52283. * Gets the list of animated inputs
  52284. */
  52285. animatedInputs: InputBlock[];
  52286. /**
  52287. * Build Id used to avoid multiple recompilations
  52288. */
  52289. buildId: number;
  52290. /** List of emitted variables */
  52291. variableNames: {
  52292. [key: string]: number;
  52293. };
  52294. /** List of emitted defines */
  52295. defineNames: {
  52296. [key: string]: number;
  52297. };
  52298. /** Should emit comments? */
  52299. emitComments: boolean;
  52300. /** Emit build activity */
  52301. verbose: boolean;
  52302. /**
  52303. * Gets the compilation hints emitted at compilation time
  52304. */
  52305. hints: {
  52306. needWorldViewMatrix: boolean;
  52307. needWorldViewProjectionMatrix: boolean;
  52308. needAlphaBlending: boolean;
  52309. needAlphaTesting: boolean;
  52310. };
  52311. /**
  52312. * List of compilation checks
  52313. */
  52314. checks: {
  52315. emitVertex: boolean;
  52316. emitFragment: boolean;
  52317. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52318. };
  52319. /** Creates a new shared data */
  52320. constructor();
  52321. /**
  52322. * Emits console errors and exceptions if there is a failing check
  52323. */
  52324. emitErrors(): void;
  52325. }
  52326. }
  52327. declare module BABYLON {
  52328. /**
  52329. * Class used to store node based material build state
  52330. */
  52331. export class NodeMaterialBuildState {
  52332. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52333. supportUniformBuffers: boolean;
  52334. /**
  52335. * Gets the list of emitted attributes
  52336. */
  52337. attributes: string[];
  52338. /**
  52339. * Gets the list of emitted uniforms
  52340. */
  52341. uniforms: string[];
  52342. /**
  52343. * Gets the list of emitted uniform buffers
  52344. */
  52345. uniformBuffers: string[];
  52346. /**
  52347. * Gets the list of emitted samplers
  52348. */
  52349. samplers: string[];
  52350. /**
  52351. * Gets the list of emitted functions
  52352. */
  52353. functions: {
  52354. [key: string]: string;
  52355. };
  52356. /**
  52357. * Gets the target of the compilation state
  52358. */
  52359. target: NodeMaterialBlockTargets;
  52360. /**
  52361. * Gets the list of emitted counters
  52362. */
  52363. counters: {
  52364. [key: string]: number;
  52365. };
  52366. /**
  52367. * Shared data between multiple NodeMaterialBuildState instances
  52368. */
  52369. sharedData: NodeMaterialBuildStateSharedData;
  52370. /** @hidden */
  52371. _vertexState: NodeMaterialBuildState;
  52372. /** @hidden */
  52373. _attributeDeclaration: string;
  52374. /** @hidden */
  52375. _uniformDeclaration: string;
  52376. /** @hidden */
  52377. _samplerDeclaration: string;
  52378. /** @hidden */
  52379. _varyingTransfer: string;
  52380. private _repeatableContentAnchorIndex;
  52381. /** @hidden */
  52382. _builtCompilationString: string;
  52383. /**
  52384. * Gets the emitted compilation strings
  52385. */
  52386. compilationString: string;
  52387. /**
  52388. * Finalize the compilation strings
  52389. * @param state defines the current compilation state
  52390. */
  52391. finalize(state: NodeMaterialBuildState): void;
  52392. /** @hidden */
  52393. readonly _repeatableContentAnchor: string;
  52394. /** @hidden */
  52395. _getFreeVariableName(prefix: string): string;
  52396. /** @hidden */
  52397. _getFreeDefineName(prefix: string): string;
  52398. /** @hidden */
  52399. _excludeVariableName(name: string): void;
  52400. /** @hidden */
  52401. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52402. /** @hidden */
  52403. _emitFunction(name: string, code: string, comments: string): void;
  52404. /** @hidden */
  52405. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52406. replaceStrings?: {
  52407. search: RegExp;
  52408. replace: string;
  52409. }[];
  52410. repeatKey?: string;
  52411. }): string;
  52412. /** @hidden */
  52413. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52414. repeatKey?: string;
  52415. removeAttributes?: boolean;
  52416. removeUniforms?: boolean;
  52417. removeVaryings?: boolean;
  52418. removeIfDef?: boolean;
  52419. replaceStrings?: {
  52420. search: RegExp;
  52421. replace: string;
  52422. }[];
  52423. }, storeKey?: string): void;
  52424. /** @hidden */
  52425. _registerTempVariable(name: string): boolean;
  52426. /** @hidden */
  52427. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52428. /** @hidden */
  52429. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52430. }
  52431. }
  52432. declare module BABYLON {
  52433. /**
  52434. * Defines a block that can be used inside a node based material
  52435. */
  52436. export class NodeMaterialBlock {
  52437. private _buildId;
  52438. private _buildTarget;
  52439. private _target;
  52440. private _isFinalMerger;
  52441. private _isInput;
  52442. /** @hidden */
  52443. _inputs: NodeMaterialConnectionPoint[];
  52444. /** @hidden */
  52445. _outputs: NodeMaterialConnectionPoint[];
  52446. /**
  52447. * Gets or sets the name of the block
  52448. */
  52449. name: string;
  52450. /**
  52451. * Gets or sets the unique id of the node
  52452. */
  52453. uniqueId: number;
  52454. /**
  52455. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52456. */
  52457. readonly isFinalMerger: boolean;
  52458. /**
  52459. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52460. */
  52461. readonly isInput: boolean;
  52462. /**
  52463. * Gets or sets the build Id
  52464. */
  52465. buildId: number;
  52466. /**
  52467. * Gets or sets the target of the block
  52468. */
  52469. target: NodeMaterialBlockTargets;
  52470. /**
  52471. * Gets the list of input points
  52472. */
  52473. readonly inputs: NodeMaterialConnectionPoint[];
  52474. /** Gets the list of output points */
  52475. readonly outputs: NodeMaterialConnectionPoint[];
  52476. /**
  52477. * Find an input by its name
  52478. * @param name defines the name of the input to look for
  52479. * @returns the input or null if not found
  52480. */
  52481. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52482. /**
  52483. * Find an output by its name
  52484. * @param name defines the name of the outputto look for
  52485. * @returns the output or null if not found
  52486. */
  52487. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52488. /**
  52489. * Creates a new NodeMaterialBlock
  52490. * @param name defines the block name
  52491. * @param target defines the target of that block (Vertex by default)
  52492. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52493. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52494. */
  52495. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52496. /**
  52497. * Initialize the block and prepare the context for build
  52498. * @param state defines the state that will be used for the build
  52499. */
  52500. initialize(state: NodeMaterialBuildState): void;
  52501. /**
  52502. * Bind data to effect. Will only be called for blocks with isBindable === true
  52503. * @param effect defines the effect to bind data to
  52504. * @param nodeMaterial defines the hosting NodeMaterial
  52505. * @param mesh defines the mesh that will be rendered
  52506. */
  52507. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52508. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52509. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52510. protected _writeFloat(value: number): string;
  52511. /**
  52512. * Gets the current class name e.g. "NodeMaterialBlock"
  52513. * @returns the class name
  52514. */
  52515. getClassName(): string;
  52516. /**
  52517. * Register a new input. Must be called inside a block constructor
  52518. * @param name defines the connection point name
  52519. * @param type defines the connection point type
  52520. * @param isOptional defines a boolean indicating that this input can be omitted
  52521. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  52522. * @returns the current block
  52523. */
  52524. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52525. /**
  52526. * Register a new output. Must be called inside a block constructor
  52527. * @param name defines the connection point name
  52528. * @param type defines the connection point type
  52529. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  52530. * @returns the current block
  52531. */
  52532. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52533. /**
  52534. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52535. * @param forOutput defines an optional connection point to check compatibility with
  52536. * @returns the first available input or null
  52537. */
  52538. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52539. /**
  52540. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52541. * @param forBlock defines an optional block to check compatibility with
  52542. * @returns the first available input or null
  52543. */
  52544. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52545. /**
  52546. * Gets the sibling of the given output
  52547. * @param current defines the current output
  52548. * @returns the next output in the list or null
  52549. */
  52550. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52551. /**
  52552. * Connect current block with another block
  52553. * @param other defines the block to connect with
  52554. * @param options define the various options to help pick the right connections
  52555. * @returns the current block
  52556. */
  52557. connectTo(other: NodeMaterialBlock, options?: {
  52558. input?: string;
  52559. output?: string;
  52560. outputSwizzle?: string;
  52561. }): this | undefined;
  52562. protected _buildBlock(state: NodeMaterialBuildState): void;
  52563. /**
  52564. * Add uniforms, samplers and uniform buffers at compilation time
  52565. * @param state defines the state to update
  52566. * @param nodeMaterial defines the node material requesting the update
  52567. * @param defines defines the material defines to update
  52568. */
  52569. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52570. /**
  52571. * Add potential fallbacks if shader compilation fails
  52572. * @param mesh defines the mesh to be rendered
  52573. * @param fallbacks defines the current prioritized list of fallbacks
  52574. */
  52575. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52576. /**
  52577. * Update defines for shader compilation
  52578. * @param mesh defines the mesh to be rendered
  52579. * @param nodeMaterial defines the node material requesting the update
  52580. * @param defines defines the material defines to update
  52581. * @param useInstances specifies that instances should be used
  52582. */
  52583. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52584. /**
  52585. * Initialize defines for shader compilation
  52586. * @param mesh defines the mesh to be rendered
  52587. * @param nodeMaterial defines the node material requesting the update
  52588. * @param defines defines the material defines to be prepared
  52589. * @param useInstances specifies that instances should be used
  52590. */
  52591. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52592. /**
  52593. * Lets the block try to connect some inputs automatically
  52594. * @param material defines the hosting NodeMaterial
  52595. */
  52596. autoConfigure(material: NodeMaterial): void;
  52597. /**
  52598. * Function called when a block is declared as repeatable content generator
  52599. * @param vertexShaderState defines the current compilation state for the vertex shader
  52600. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52601. * @param mesh defines the mesh to be rendered
  52602. * @param defines defines the material defines to update
  52603. */
  52604. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52605. /**
  52606. * Checks if the block is ready
  52607. * @param mesh defines the mesh to be rendered
  52608. * @param nodeMaterial defines the node material requesting the update
  52609. * @param defines defines the material defines to update
  52610. * @param useInstances specifies that instances should be used
  52611. * @returns true if the block is ready
  52612. */
  52613. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52614. private _processBuild;
  52615. /**
  52616. * Compile the current node and generate the shader code
  52617. * @param state defines the current compilation state (uniforms, samplers, current string)
  52618. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  52619. * @returns true if already built
  52620. */
  52621. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  52622. /**
  52623. * Clone the current block to a new identical block
  52624. * @param scene defines the hosting scene
  52625. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52626. * @returns a copy of the current block
  52627. */
  52628. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  52629. /**
  52630. * Serializes this block in a JSON representation
  52631. * @returns the serialized block object
  52632. */
  52633. serialize(): any;
  52634. /** @hidden */
  52635. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52636. }
  52637. }
  52638. declare module BABYLON {
  52639. /**
  52640. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52641. */
  52642. export enum NodeMaterialBlockConnectionPointMode {
  52643. /** Value is an uniform */
  52644. Uniform = 0,
  52645. /** Value is a mesh attribute */
  52646. Attribute = 1,
  52647. /** Value is a varying between vertex and fragment shaders */
  52648. Varying = 2,
  52649. /** Mode is undefined */
  52650. Undefined = 3
  52651. }
  52652. }
  52653. declare module BABYLON {
  52654. /**
  52655. * Enum defining the type of animations supported by InputBlock
  52656. */
  52657. export enum AnimatedInputBlockTypes {
  52658. /** No animation */
  52659. None = 0,
  52660. /** Time based animation. Will only work for floats */
  52661. Time = 1
  52662. }
  52663. }
  52664. declare module BABYLON {
  52665. /**
  52666. * Block used to expose an input value
  52667. */
  52668. export class InputBlock extends NodeMaterialBlock {
  52669. private _mode;
  52670. private _associatedVariableName;
  52671. private _storedValue;
  52672. private _valueCallback;
  52673. private _type;
  52674. private _animationType;
  52675. /** @hidden */
  52676. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52677. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  52678. visibleInInspector: boolean;
  52679. /**
  52680. * Gets or sets the connection point type (default is float)
  52681. */
  52682. readonly type: NodeMaterialBlockConnectionPointTypes;
  52683. /**
  52684. * Creates a new InputBlock
  52685. * @param name defines the block name
  52686. * @param target defines the target of that block (Vertex by default)
  52687. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52688. */
  52689. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52690. /**
  52691. * Gets the output component
  52692. */
  52693. readonly output: NodeMaterialConnectionPoint;
  52694. /**
  52695. * Set the source of this connection point to a vertex attribute
  52696. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52697. * @returns the current connection point
  52698. */
  52699. setAsAttribute(attributeName?: string): InputBlock;
  52700. /**
  52701. * Set the source of this connection point to a well known value
  52702. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  52703. * @returns the current connection point
  52704. */
  52705. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  52706. /**
  52707. * Gets or sets the value of that point.
  52708. * Please note that this value will be ignored if valueCallback is defined
  52709. */
  52710. value: any;
  52711. /**
  52712. * Gets or sets a callback used to get the value of that point.
  52713. * Please note that setting this value will force the connection point to ignore the value property
  52714. */
  52715. valueCallback: () => any;
  52716. /**
  52717. * Gets or sets the associated variable name in the shader
  52718. */
  52719. associatedVariableName: string;
  52720. /** Gets or sets the type of animation applied to the input */
  52721. animationType: AnimatedInputBlockTypes;
  52722. /**
  52723. * Gets a boolean indicating that this connection point not defined yet
  52724. */
  52725. readonly isUndefined: boolean;
  52726. /**
  52727. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52728. * In this case the connection point name must be the name of the uniform to use.
  52729. * Can only be set on inputs
  52730. */
  52731. isUniform: boolean;
  52732. /**
  52733. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52734. * In this case the connection point name must be the name of the attribute to use
  52735. * Can only be set on inputs
  52736. */
  52737. isAttribute: boolean;
  52738. /**
  52739. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52740. * Can only be set on exit points
  52741. */
  52742. isVarying: boolean;
  52743. /**
  52744. * Gets a boolean indicating that the current connection point is a well known value
  52745. */
  52746. readonly isWellKnownValue: boolean;
  52747. /**
  52748. * Gets or sets the current well known value or null if not defined as well know value
  52749. */
  52750. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52751. /**
  52752. * Gets the current class name
  52753. * @returns the class name
  52754. */
  52755. getClassName(): string;
  52756. /**
  52757. * Animate the input if animationType !== None
  52758. * @param scene defines the rendering scene
  52759. */
  52760. animate(scene: Scene): void;
  52761. private _emitDefine;
  52762. /**
  52763. * Set the input block to its default value (based on its type)
  52764. */
  52765. setDefaultValue(): void;
  52766. private _emit;
  52767. /** @hidden */
  52768. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52769. /** @hidden */
  52770. _transmit(effect: Effect, scene: Scene): void;
  52771. protected _buildBlock(state: NodeMaterialBuildState): void;
  52772. serialize(): any;
  52773. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52774. }
  52775. }
  52776. declare module BABYLON {
  52777. /**
  52778. * Defines a connection point for a block
  52779. */
  52780. export class NodeMaterialConnectionPoint {
  52781. /** @hidden */
  52782. _ownerBlock: NodeMaterialBlock;
  52783. /** @hidden */
  52784. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52785. private _endpoints;
  52786. private _associatedVariableName;
  52787. /** @hidden */
  52788. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52789. private _type;
  52790. /** @hidden */
  52791. _enforceAssociatedVariableName: boolean;
  52792. /**
  52793. * Gets or sets the additional types supported byt this connection point
  52794. */
  52795. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52796. /**
  52797. * Gets or sets the associated variable name in the shader
  52798. */
  52799. associatedVariableName: string;
  52800. /**
  52801. * Gets or sets the connection point type (default is float)
  52802. */
  52803. type: NodeMaterialBlockConnectionPointTypes;
  52804. /**
  52805. * Gets or sets the connection point name
  52806. */
  52807. name: string;
  52808. /**
  52809. * Gets or sets a boolean indicating that this connection point can be omitted
  52810. */
  52811. isOptional: boolean;
  52812. /**
  52813. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52814. */
  52815. define: string;
  52816. /** Gets or sets the target of that connection point */
  52817. target: NodeMaterialBlockTargets;
  52818. /**
  52819. * Gets a boolean indicating that the current point is connected
  52820. */
  52821. readonly isConnected: boolean;
  52822. /**
  52823. * Gets a boolean indicating that the current point is connected to an input block
  52824. */
  52825. readonly isConnectedToInputBlock: boolean;
  52826. /**
  52827. * Gets a the connected input block (if any)
  52828. */
  52829. readonly connectInputBlock: Nullable<InputBlock>;
  52830. /** Get the other side of the connection (if any) */
  52831. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52832. /** Get the block that owns this connection point */
  52833. readonly ownerBlock: NodeMaterialBlock;
  52834. /** Get the block connected on the other side of this connection (if any) */
  52835. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52836. /** Get the block connected on the endpoints of this connection (if any) */
  52837. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52838. /** Gets the list of connected endpoints */
  52839. readonly endpoints: NodeMaterialConnectionPoint[];
  52840. /** Gets a boolean indicating if that output point is connected to at least one input */
  52841. readonly hasEndpoints: boolean;
  52842. /**
  52843. * Creates a new connection point
  52844. * @param name defines the connection point name
  52845. * @param ownerBlock defines the block hosting this connection point
  52846. */
  52847. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52848. /**
  52849. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52850. * @returns the class name
  52851. */
  52852. getClassName(): string;
  52853. /**
  52854. * Gets an boolean indicating if the current point can be connected to another point
  52855. * @param connectionPoint defines the other connection point
  52856. * @returns true if the connection is possible
  52857. */
  52858. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52859. /**
  52860. * Connect this point to another connection point
  52861. * @param connectionPoint defines the other connection point
  52862. * @returns the current connection point
  52863. */
  52864. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52865. /**
  52866. * Disconnect this point from one of his endpoint
  52867. * @param endpoint defines the other connection point
  52868. * @returns the current connection point
  52869. */
  52870. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52871. /**
  52872. * Serializes this point in a JSON representation
  52873. * @returns the serialized point object
  52874. */
  52875. serialize(): any;
  52876. }
  52877. }
  52878. declare module BABYLON {
  52879. /**
  52880. * Block used to add support for vertex skinning (bones)
  52881. */
  52882. export class BonesBlock extends NodeMaterialBlock {
  52883. /**
  52884. * Creates a new BonesBlock
  52885. * @param name defines the block name
  52886. */
  52887. constructor(name: string);
  52888. /**
  52889. * Initialize the block and prepare the context for build
  52890. * @param state defines the state that will be used for the build
  52891. */
  52892. initialize(state: NodeMaterialBuildState): void;
  52893. /**
  52894. * Gets the current class name
  52895. * @returns the class name
  52896. */
  52897. getClassName(): string;
  52898. /**
  52899. * Gets the matrix indices input component
  52900. */
  52901. readonly matricesIndices: NodeMaterialConnectionPoint;
  52902. /**
  52903. * Gets the matrix weights input component
  52904. */
  52905. readonly matricesWeights: NodeMaterialConnectionPoint;
  52906. /**
  52907. * Gets the extra matrix indices input component
  52908. */
  52909. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52910. /**
  52911. * Gets the extra matrix weights input component
  52912. */
  52913. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52914. /**
  52915. * Gets the world input component
  52916. */
  52917. readonly world: NodeMaterialConnectionPoint;
  52918. /**
  52919. * Gets the output component
  52920. */
  52921. readonly output: NodeMaterialConnectionPoint;
  52922. autoConfigure(): void;
  52923. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52924. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52926. protected _buildBlock(state: NodeMaterialBuildState): this;
  52927. }
  52928. }
  52929. declare module BABYLON {
  52930. /**
  52931. * Block used to add support for instances
  52932. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  52933. */
  52934. export class InstancesBlock extends NodeMaterialBlock {
  52935. /**
  52936. * Creates a new InstancesBlock
  52937. * @param name defines the block name
  52938. */
  52939. constructor(name: string);
  52940. /**
  52941. * Gets the current class name
  52942. * @returns the class name
  52943. */
  52944. getClassName(): string;
  52945. /**
  52946. * Gets the first world row input component
  52947. */
  52948. readonly world0: NodeMaterialConnectionPoint;
  52949. /**
  52950. * Gets the second world row input component
  52951. */
  52952. readonly world1: NodeMaterialConnectionPoint;
  52953. /**
  52954. * Gets the third world row input component
  52955. */
  52956. readonly world2: NodeMaterialConnectionPoint;
  52957. /**
  52958. * Gets the forth world row input component
  52959. */
  52960. readonly world3: NodeMaterialConnectionPoint;
  52961. /**
  52962. * Gets the world input component
  52963. */
  52964. readonly world: NodeMaterialConnectionPoint;
  52965. /**
  52966. * Gets the output component
  52967. */
  52968. readonly output: NodeMaterialConnectionPoint;
  52969. autoConfigure(): void;
  52970. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52971. protected _buildBlock(state: NodeMaterialBuildState): this;
  52972. }
  52973. }
  52974. declare module BABYLON {
  52975. /**
  52976. * Block used to add morph targets support to vertex shader
  52977. */
  52978. export class MorphTargetsBlock extends NodeMaterialBlock {
  52979. private _repeatableContentAnchor;
  52980. private _repeatebleContentGenerated;
  52981. /**
  52982. * Create a new MorphTargetsBlock
  52983. * @param name defines the block name
  52984. */
  52985. constructor(name: string);
  52986. /**
  52987. * Gets the current class name
  52988. * @returns the class name
  52989. */
  52990. getClassName(): string;
  52991. /**
  52992. * Gets the position input component
  52993. */
  52994. readonly position: NodeMaterialConnectionPoint;
  52995. /**
  52996. * Gets the normal input component
  52997. */
  52998. readonly normal: NodeMaterialConnectionPoint;
  52999. /**
  53000. * Gets the tangent input component
  53001. */
  53002. readonly tangent: NodeMaterialConnectionPoint;
  53003. /**
  53004. * Gets the tangent input component
  53005. */
  53006. readonly uv: NodeMaterialConnectionPoint;
  53007. /**
  53008. * Gets the position output component
  53009. */
  53010. readonly positionOutput: NodeMaterialConnectionPoint;
  53011. /**
  53012. * Gets the normal output component
  53013. */
  53014. readonly normalOutput: NodeMaterialConnectionPoint;
  53015. /**
  53016. * Gets the tangent output component
  53017. */
  53018. readonly tangentOutput: NodeMaterialConnectionPoint;
  53019. /**
  53020. * Gets the tangent output component
  53021. */
  53022. readonly uvOutput: NodeMaterialConnectionPoint;
  53023. initialize(state: NodeMaterialBuildState): void;
  53024. autoConfigure(): void;
  53025. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53026. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53027. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53028. protected _buildBlock(state: NodeMaterialBuildState): this;
  53029. }
  53030. }
  53031. declare module BABYLON {
  53032. /**
  53033. * Block used to add an alpha test in the fragment shader
  53034. */
  53035. export class AlphaTestBlock extends NodeMaterialBlock {
  53036. /**
  53037. * Gets or sets the alpha value where alpha testing happens
  53038. */
  53039. alphaCutOff: number;
  53040. /**
  53041. * Create a new AlphaTestBlock
  53042. * @param name defines the block name
  53043. */
  53044. constructor(name: string);
  53045. /**
  53046. * Gets the current class name
  53047. * @returns the class name
  53048. */
  53049. getClassName(): string;
  53050. /**
  53051. * Gets the color input component
  53052. */
  53053. readonly color: NodeMaterialConnectionPoint;
  53054. /**
  53055. * Gets the alpha input component
  53056. */
  53057. readonly alpha: NodeMaterialConnectionPoint;
  53058. protected _buildBlock(state: NodeMaterialBuildState): this;
  53059. }
  53060. }
  53061. declare module BABYLON {
  53062. /**
  53063. * Block used to compute fresnel value
  53064. */
  53065. export class FresnelBlock extends NodeMaterialBlock {
  53066. /**
  53067. * Create a new FresnelBlock
  53068. * @param name defines the block name
  53069. */
  53070. constructor(name: string);
  53071. /**
  53072. * Gets the current class name
  53073. * @returns the class name
  53074. */
  53075. getClassName(): string;
  53076. /**
  53077. * Gets the world position input component
  53078. */
  53079. readonly worldPosition: NodeMaterialConnectionPoint;
  53080. /**
  53081. * Gets the world normal input component
  53082. */
  53083. readonly worldNormal: NodeMaterialConnectionPoint;
  53084. /**
  53085. * Gets the camera (or eye) position component
  53086. */
  53087. readonly cameraPosition: NodeMaterialConnectionPoint;
  53088. /**
  53089. * Gets the bias input component
  53090. */
  53091. readonly bias: NodeMaterialConnectionPoint;
  53092. /**
  53093. * Gets the camera (or eye) position component
  53094. */
  53095. readonly power: NodeMaterialConnectionPoint;
  53096. /**
  53097. * Gets the fresnel output component
  53098. */
  53099. readonly fresnel: NodeMaterialConnectionPoint;
  53100. autoConfigure(material: NodeMaterial): void;
  53101. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53102. }
  53103. }
  53104. declare module BABYLON {
  53105. /**
  53106. * Block used to add image processing support to fragment shader
  53107. */
  53108. export class ImageProcessingBlock extends NodeMaterialBlock {
  53109. /**
  53110. * Create a new ImageProcessingBlock
  53111. * @param name defines the block name
  53112. */
  53113. constructor(name: string);
  53114. /**
  53115. * Gets the current class name
  53116. * @returns the class name
  53117. */
  53118. getClassName(): string;
  53119. /**
  53120. * Gets the color input component
  53121. */
  53122. readonly color: NodeMaterialConnectionPoint;
  53123. /**
  53124. * Gets the output component
  53125. */
  53126. readonly output: NodeMaterialConnectionPoint;
  53127. /**
  53128. * Initialize the block and prepare the context for build
  53129. * @param state defines the state that will be used for the build
  53130. */
  53131. initialize(state: NodeMaterialBuildState): void;
  53132. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53133. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53134. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53135. protected _buildBlock(state: NodeMaterialBuildState): this;
  53136. }
  53137. }
  53138. declare module BABYLON {
  53139. /**
  53140. * Block used to add support for scene fog
  53141. */
  53142. export class FogBlock extends NodeMaterialBlock {
  53143. private _fogDistanceName;
  53144. private _fogParameters;
  53145. /**
  53146. * Create a new FogBlock
  53147. * @param name defines the block name
  53148. */
  53149. constructor(name: string);
  53150. /**
  53151. * Gets the current class name
  53152. * @returns the class name
  53153. */
  53154. getClassName(): string;
  53155. /**
  53156. * Gets the world position input component
  53157. */
  53158. readonly worldPosition: NodeMaterialConnectionPoint;
  53159. /**
  53160. * Gets the view input component
  53161. */
  53162. readonly view: NodeMaterialConnectionPoint;
  53163. /**
  53164. * Gets the color input component
  53165. */
  53166. readonly color: NodeMaterialConnectionPoint;
  53167. /**
  53168. * Gets the fog color input component
  53169. */
  53170. readonly fogColor: NodeMaterialConnectionPoint;
  53171. /**
  53172. * Gets the output component
  53173. */
  53174. readonly output: NodeMaterialConnectionPoint;
  53175. autoConfigure(): void;
  53176. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53177. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53178. protected _buildBlock(state: NodeMaterialBuildState): this;
  53179. }
  53180. }
  53181. declare module BABYLON {
  53182. /**
  53183. * Block used to add light in the fragment shader
  53184. */
  53185. export class LightBlock extends NodeMaterialBlock {
  53186. private _lightId;
  53187. /**
  53188. * Gets or sets the light associated with this block
  53189. */
  53190. light: Nullable<Light>;
  53191. /**
  53192. * Create a new LightBlock
  53193. * @param name defines the block name
  53194. */
  53195. constructor(name: string);
  53196. /**
  53197. * Gets the current class name
  53198. * @returns the class name
  53199. */
  53200. getClassName(): string;
  53201. /**
  53202. * Gets the world position input component
  53203. */
  53204. readonly worldPosition: NodeMaterialConnectionPoint;
  53205. /**
  53206. * Gets the world normal input component
  53207. */
  53208. readonly worldNormal: NodeMaterialConnectionPoint;
  53209. /**
  53210. * Gets the camera (or eye) position component
  53211. */
  53212. readonly cameraPosition: NodeMaterialConnectionPoint;
  53213. /**
  53214. * Gets the diffuse output component
  53215. */
  53216. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53217. /**
  53218. * Gets the specular output component
  53219. */
  53220. readonly specularOutput: NodeMaterialConnectionPoint;
  53221. autoConfigure(): void;
  53222. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53223. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53224. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53225. private _injectVertexCode;
  53226. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53227. serialize(): any;
  53228. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53229. }
  53230. }
  53231. declare module BABYLON {
  53232. /**
  53233. * Block used to multiply 2 values
  53234. */
  53235. export class MultiplyBlock extends NodeMaterialBlock {
  53236. /**
  53237. * Creates a new MultiplyBlock
  53238. * @param name defines the block name
  53239. */
  53240. constructor(name: string);
  53241. /**
  53242. * Gets the current class name
  53243. * @returns the class name
  53244. */
  53245. getClassName(): string;
  53246. /**
  53247. * Gets the left operand input component
  53248. */
  53249. readonly left: NodeMaterialConnectionPoint;
  53250. /**
  53251. * Gets the right operand input component
  53252. */
  53253. readonly right: NodeMaterialConnectionPoint;
  53254. /**
  53255. * Gets the output component
  53256. */
  53257. readonly output: NodeMaterialConnectionPoint;
  53258. protected _buildBlock(state: NodeMaterialBuildState): this;
  53259. }
  53260. }
  53261. declare module BABYLON {
  53262. /**
  53263. * Block used to add 2 vectors
  53264. */
  53265. export class AddBlock extends NodeMaterialBlock {
  53266. /**
  53267. * Creates a new AddBlock
  53268. * @param name defines the block name
  53269. */
  53270. constructor(name: string);
  53271. /**
  53272. * Gets the current class name
  53273. * @returns the class name
  53274. */
  53275. getClassName(): string;
  53276. /**
  53277. * Gets the left operand input component
  53278. */
  53279. readonly left: NodeMaterialConnectionPoint;
  53280. /**
  53281. * Gets the right operand input component
  53282. */
  53283. readonly right: NodeMaterialConnectionPoint;
  53284. /**
  53285. * Gets the output component
  53286. */
  53287. readonly output: NodeMaterialConnectionPoint;
  53288. protected _buildBlock(state: NodeMaterialBuildState): this;
  53289. }
  53290. }
  53291. declare module BABYLON {
  53292. /**
  53293. * Block used to scale a vector by a float
  53294. */
  53295. export class ScaleBlock extends NodeMaterialBlock {
  53296. /**
  53297. * Creates a new ScaleBlock
  53298. * @param name defines the block name
  53299. */
  53300. constructor(name: string);
  53301. /**
  53302. * Gets the current class name
  53303. * @returns the class name
  53304. */
  53305. getClassName(): string;
  53306. /**
  53307. * Gets the input component
  53308. */
  53309. readonly input: NodeMaterialConnectionPoint;
  53310. /**
  53311. * Gets the factor input component
  53312. */
  53313. readonly factor: NodeMaterialConnectionPoint;
  53314. /**
  53315. * Gets the output component
  53316. */
  53317. readonly output: NodeMaterialConnectionPoint;
  53318. protected _buildBlock(state: NodeMaterialBuildState): this;
  53319. }
  53320. }
  53321. declare module BABYLON {
  53322. /**
  53323. * Block used to clamp a float
  53324. */
  53325. export class ClampBlock extends NodeMaterialBlock {
  53326. /** Gets or sets the minimum range */
  53327. minimum: number;
  53328. /** Gets or sets the maximum range */
  53329. maximum: number;
  53330. /**
  53331. * Creates a new ClampBlock
  53332. * @param name defines the block name
  53333. */
  53334. constructor(name: string);
  53335. /**
  53336. * Gets the current class name
  53337. * @returns the class name
  53338. */
  53339. getClassName(): string;
  53340. /**
  53341. * Gets the value input component
  53342. */
  53343. readonly value: NodeMaterialConnectionPoint;
  53344. /**
  53345. * Gets the output component
  53346. */
  53347. readonly output: NodeMaterialConnectionPoint;
  53348. protected _buildBlock(state: NodeMaterialBuildState): this;
  53349. }
  53350. }
  53351. declare module BABYLON {
  53352. /**
  53353. * Block used to apply a cross product between 2 vectors
  53354. */
  53355. export class CrossBlock extends NodeMaterialBlock {
  53356. /**
  53357. * Creates a new CrossBlock
  53358. * @param name defines the block name
  53359. */
  53360. constructor(name: string);
  53361. /**
  53362. * Gets the current class name
  53363. * @returns the class name
  53364. */
  53365. getClassName(): string;
  53366. /**
  53367. * Gets the left operand input component
  53368. */
  53369. readonly left: NodeMaterialConnectionPoint;
  53370. /**
  53371. * Gets the right operand input component
  53372. */
  53373. readonly right: NodeMaterialConnectionPoint;
  53374. /**
  53375. * Gets the output component
  53376. */
  53377. readonly output: NodeMaterialConnectionPoint;
  53378. protected _buildBlock(state: NodeMaterialBuildState): this;
  53379. }
  53380. }
  53381. declare module BABYLON {
  53382. /**
  53383. * Block used to apply a dot product between 2 vectors
  53384. */
  53385. export class DotBlock extends NodeMaterialBlock {
  53386. /**
  53387. * Creates a new DotBlock
  53388. * @param name defines the block name
  53389. */
  53390. constructor(name: string);
  53391. /**
  53392. * Gets the current class name
  53393. * @returns the class name
  53394. */
  53395. getClassName(): string;
  53396. /**
  53397. * Gets the left operand input component
  53398. */
  53399. readonly left: NodeMaterialConnectionPoint;
  53400. /**
  53401. * Gets the right operand input component
  53402. */
  53403. readonly right: NodeMaterialConnectionPoint;
  53404. /**
  53405. * Gets the output component
  53406. */
  53407. readonly output: NodeMaterialConnectionPoint;
  53408. protected _buildBlock(state: NodeMaterialBuildState): this;
  53409. }
  53410. }
  53411. declare module BABYLON {
  53412. /**
  53413. * Block used to remap a float from a range to a new one
  53414. */
  53415. export class RemapBlock extends NodeMaterialBlock {
  53416. /**
  53417. * Gets or sets the source range
  53418. */
  53419. sourceRange: Vector2;
  53420. /**
  53421. * Gets or sets the target range
  53422. */
  53423. targetRange: Vector2;
  53424. /**
  53425. * Creates a new RemapBlock
  53426. * @param name defines the block name
  53427. */
  53428. constructor(name: string);
  53429. /**
  53430. * Gets the current class name
  53431. * @returns the class name
  53432. */
  53433. getClassName(): string;
  53434. /**
  53435. * Gets the input component
  53436. */
  53437. readonly input: NodeMaterialConnectionPoint;
  53438. /**
  53439. * Gets the output component
  53440. */
  53441. readonly output: NodeMaterialConnectionPoint;
  53442. protected _buildBlock(state: NodeMaterialBuildState): this;
  53443. }
  53444. }
  53445. declare module BABYLON {
  53446. /**
  53447. * Block used to normalize a vector
  53448. */
  53449. export class NormalizeBlock extends NodeMaterialBlock {
  53450. /**
  53451. * Creates a new NormalizeBlock
  53452. * @param name defines the block name
  53453. */
  53454. constructor(name: string);
  53455. /**
  53456. * Gets the current class name
  53457. * @returns the class name
  53458. */
  53459. getClassName(): string;
  53460. /**
  53461. * Gets the input component
  53462. */
  53463. readonly input: NodeMaterialConnectionPoint;
  53464. /**
  53465. * Gets the output component
  53466. */
  53467. readonly output: NodeMaterialConnectionPoint;
  53468. protected _buildBlock(state: NodeMaterialBuildState): this;
  53469. }
  53470. }
  53471. declare module BABYLON {
  53472. /**
  53473. * Operations supported by the Trigonometry block
  53474. */
  53475. export enum TrigonometryBlockOperations {
  53476. /** Cos */
  53477. Cos = 0,
  53478. /** Sin */
  53479. Sin = 1,
  53480. /** Abs */
  53481. Abs = 2,
  53482. /** Exp */
  53483. Exp = 3,
  53484. /** Exp2 */
  53485. Exp2 = 4
  53486. }
  53487. /**
  53488. * Block used to apply trigonometry operation to floats
  53489. */
  53490. export class TrigonometryBlock extends NodeMaterialBlock {
  53491. /**
  53492. * Gets or sets the operation applied by the block
  53493. */
  53494. operation: TrigonometryBlockOperations;
  53495. /**
  53496. * Creates a new TrigonometryBlock
  53497. * @param name defines the block name
  53498. */
  53499. constructor(name: string);
  53500. /**
  53501. * Gets the current class name
  53502. * @returns the class name
  53503. */
  53504. getClassName(): string;
  53505. /**
  53506. * Gets the input component
  53507. */
  53508. readonly input: NodeMaterialConnectionPoint;
  53509. /**
  53510. * Gets the output component
  53511. */
  53512. readonly output: NodeMaterialConnectionPoint;
  53513. protected _buildBlock(state: NodeMaterialBuildState): this;
  53514. }
  53515. }
  53516. declare module BABYLON {
  53517. /**
  53518. * Block used to create a Color3/4 out of individual inputs (one for each component)
  53519. */
  53520. export class ColorMergerBlock extends NodeMaterialBlock {
  53521. /**
  53522. * Create a new ColorMergerBlock
  53523. * @param name defines the block name
  53524. */
  53525. constructor(name: string);
  53526. /**
  53527. * Gets the current class name
  53528. * @returns the class name
  53529. */
  53530. getClassName(): string;
  53531. /**
  53532. * Gets the r component (input)
  53533. */
  53534. readonly r: NodeMaterialConnectionPoint;
  53535. /**
  53536. * Gets the g component (input)
  53537. */
  53538. readonly g: NodeMaterialConnectionPoint;
  53539. /**
  53540. * Gets the b component (input)
  53541. */
  53542. readonly b: NodeMaterialConnectionPoint;
  53543. /**
  53544. * Gets the a component (input)
  53545. */
  53546. readonly a: NodeMaterialConnectionPoint;
  53547. /**
  53548. * Gets the rgba component (output)
  53549. */
  53550. readonly rgba: NodeMaterialConnectionPoint;
  53551. /**
  53552. * Gets the rgb component (output)
  53553. */
  53554. readonly rgb: NodeMaterialConnectionPoint;
  53555. protected _buildBlock(state: NodeMaterialBuildState): this;
  53556. }
  53557. }
  53558. declare module BABYLON {
  53559. /**
  53560. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  53561. */
  53562. export class VectorMergerBlock extends NodeMaterialBlock {
  53563. /**
  53564. * Create a new VectorMergerBlock
  53565. * @param name defines the block name
  53566. */
  53567. constructor(name: string);
  53568. /**
  53569. * Gets the current class name
  53570. * @returns the class name
  53571. */
  53572. getClassName(): string;
  53573. /**
  53574. * Gets the x component (input)
  53575. */
  53576. readonly x: NodeMaterialConnectionPoint;
  53577. /**
  53578. * Gets the y component (input)
  53579. */
  53580. readonly y: NodeMaterialConnectionPoint;
  53581. /**
  53582. * Gets the z component (input)
  53583. */
  53584. readonly z: NodeMaterialConnectionPoint;
  53585. /**
  53586. * Gets the w component (input)
  53587. */
  53588. readonly w: NodeMaterialConnectionPoint;
  53589. /**
  53590. * Gets the xyzw component (output)
  53591. */
  53592. readonly xyzw: NodeMaterialConnectionPoint;
  53593. /**
  53594. * Gets the xyz component (output)
  53595. */
  53596. readonly xyz: NodeMaterialConnectionPoint;
  53597. /**
  53598. * Gets the xy component (output)
  53599. */
  53600. readonly xy: NodeMaterialConnectionPoint;
  53601. protected _buildBlock(state: NodeMaterialBuildState): this;
  53602. }
  53603. }
  53604. declare module BABYLON {
  53605. /**
  53606. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  53607. */
  53608. export class ColorSplitterBlock extends NodeMaterialBlock {
  53609. /**
  53610. * Create a new ColorSplitterBlock
  53611. * @param name defines the block name
  53612. */
  53613. constructor(name: string);
  53614. /**
  53615. * Gets the current class name
  53616. * @returns the class name
  53617. */
  53618. getClassName(): string;
  53619. /**
  53620. * Gets the rgba component (input)
  53621. */
  53622. readonly rgba: NodeMaterialConnectionPoint;
  53623. /**
  53624. * Gets the rgb component (input)
  53625. */
  53626. readonly rgbIn: NodeMaterialConnectionPoint;
  53627. /**
  53628. * Gets the rgb component (output)
  53629. */
  53630. readonly rgbOut: NodeMaterialConnectionPoint;
  53631. /**
  53632. * Gets the r component (output)
  53633. */
  53634. readonly r: NodeMaterialConnectionPoint;
  53635. /**
  53636. * Gets the g component (output)
  53637. */
  53638. readonly g: NodeMaterialConnectionPoint;
  53639. /**
  53640. * Gets the b component (output)
  53641. */
  53642. readonly b: NodeMaterialConnectionPoint;
  53643. /**
  53644. * Gets the a component (output)
  53645. */
  53646. readonly a: NodeMaterialConnectionPoint;
  53647. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53648. }
  53649. }
  53650. declare module BABYLON {
  53651. /**
  53652. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  53653. */
  53654. export class VectorSplitterBlock extends NodeMaterialBlock {
  53655. /**
  53656. * Create a new VectorSplitterBlock
  53657. * @param name defines the block name
  53658. */
  53659. constructor(name: string);
  53660. /**
  53661. * Gets the current class name
  53662. * @returns the class name
  53663. */
  53664. getClassName(): string;
  53665. /**
  53666. * Gets the xyzw component (input)
  53667. */
  53668. readonly xyzw: NodeMaterialConnectionPoint;
  53669. /**
  53670. * Gets the xyz component (input)
  53671. */
  53672. readonly xyzIn: NodeMaterialConnectionPoint;
  53673. /**
  53674. * Gets the xy component (input)
  53675. */
  53676. readonly xyIn: NodeMaterialConnectionPoint;
  53677. /**
  53678. * Gets the xyz component (output)
  53679. */
  53680. readonly xyzOut: NodeMaterialConnectionPoint;
  53681. /**
  53682. * Gets the xy component (output)
  53683. */
  53684. readonly xyOut: NodeMaterialConnectionPoint;
  53685. /**
  53686. * Gets the x component (output)
  53687. */
  53688. readonly x: NodeMaterialConnectionPoint;
  53689. /**
  53690. * Gets the y component (output)
  53691. */
  53692. readonly y: NodeMaterialConnectionPoint;
  53693. /**
  53694. * Gets the z component (output)
  53695. */
  53696. readonly z: NodeMaterialConnectionPoint;
  53697. /**
  53698. * Gets the w component (output)
  53699. */
  53700. readonly w: NodeMaterialConnectionPoint;
  53701. protected _buildBlock(state: NodeMaterialBuildState): this;
  53702. }
  53703. }
  53704. declare module BABYLON {
  53705. /**
  53706. * Block used to lerp 2 values
  53707. */
  53708. export class LerpBlock extends NodeMaterialBlock {
  53709. /**
  53710. * Creates a new LerpBlock
  53711. * @param name defines the block name
  53712. */
  53713. constructor(name: string);
  53714. /**
  53715. * Gets the current class name
  53716. * @returns the class name
  53717. */
  53718. getClassName(): string;
  53719. /**
  53720. * Gets the left operand input component
  53721. */
  53722. readonly left: NodeMaterialConnectionPoint;
  53723. /**
  53724. * Gets the right operand input component
  53725. */
  53726. readonly right: NodeMaterialConnectionPoint;
  53727. /**
  53728. * Gets the gradient operand input component
  53729. */
  53730. readonly gradient: NodeMaterialConnectionPoint;
  53731. /**
  53732. * Gets the output component
  53733. */
  53734. readonly output: NodeMaterialConnectionPoint;
  53735. protected _buildBlock(state: NodeMaterialBuildState): this;
  53736. }
  53737. }
  53738. declare module BABYLON {
  53739. /**
  53740. * Block used to divide 2 vectors
  53741. */
  53742. export class DivideBlock extends NodeMaterialBlock {
  53743. /**
  53744. * Creates a new DivideBlock
  53745. * @param name defines the block name
  53746. */
  53747. constructor(name: string);
  53748. /**
  53749. * Gets the current class name
  53750. * @returns the class name
  53751. */
  53752. getClassName(): string;
  53753. /**
  53754. * Gets the left operand input component
  53755. */
  53756. readonly left: NodeMaterialConnectionPoint;
  53757. /**
  53758. * Gets the right operand input component
  53759. */
  53760. readonly right: NodeMaterialConnectionPoint;
  53761. /**
  53762. * Gets the output component
  53763. */
  53764. readonly output: NodeMaterialConnectionPoint;
  53765. protected _buildBlock(state: NodeMaterialBuildState): this;
  53766. }
  53767. }
  53768. declare module BABYLON {
  53769. /**
  53770. * Block used to subtract 2 vectors
  53771. */
  53772. export class SubtractBlock extends NodeMaterialBlock {
  53773. /**
  53774. * Creates a new SubtractBlock
  53775. * @param name defines the block name
  53776. */
  53777. constructor(name: string);
  53778. /**
  53779. * Gets the current class name
  53780. * @returns the class name
  53781. */
  53782. getClassName(): string;
  53783. /**
  53784. * Gets the left operand input component
  53785. */
  53786. readonly left: NodeMaterialConnectionPoint;
  53787. /**
  53788. * Gets the right operand input component
  53789. */
  53790. readonly right: NodeMaterialConnectionPoint;
  53791. /**
  53792. * Gets the output component
  53793. */
  53794. readonly output: NodeMaterialConnectionPoint;
  53795. protected _buildBlock(state: NodeMaterialBuildState): this;
  53796. }
  53797. }
  53798. declare module BABYLON {
  53799. /**
  53800. * Effect Render Options
  53801. */
  53802. export interface IEffectRendererOptions {
  53803. /**
  53804. * Defines the vertices positions.
  53805. */
  53806. positions?: number[];
  53807. /**
  53808. * Defines the indices.
  53809. */
  53810. indices?: number[];
  53811. }
  53812. /**
  53813. * Helper class to render one or more effects
  53814. */
  53815. export class EffectRenderer {
  53816. private engine;
  53817. private static _DefaultOptions;
  53818. private _vertexBuffers;
  53819. private _indexBuffer;
  53820. private _ringBufferIndex;
  53821. private _ringScreenBuffer;
  53822. private _fullscreenViewport;
  53823. private _getNextFrameBuffer;
  53824. /**
  53825. * Creates an effect renderer
  53826. * @param engine the engine to use for rendering
  53827. * @param options defines the options of the effect renderer
  53828. */
  53829. constructor(engine: Engine, options?: IEffectRendererOptions);
  53830. /**
  53831. * Sets the current viewport in normalized coordinates 0-1
  53832. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  53833. */
  53834. setViewport(viewport?: Viewport): void;
  53835. /**
  53836. * Sets the current effect wrapper to use during draw.
  53837. * The effect needs to be ready before calling this api.
  53838. * This also sets the default full screen position attribute.
  53839. * @param effectWrapper Defines the effect to draw with
  53840. */
  53841. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  53842. /**
  53843. * Draws a full screen quad.
  53844. */
  53845. draw(): void;
  53846. /**
  53847. * renders one or more effects to a specified texture
  53848. * @param effectWrappers list of effects to renderer
  53849. * @param outputTexture texture to draw to, if null it will render to the screen
  53850. */
  53851. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  53852. /**
  53853. * Disposes of the effect renderer
  53854. */
  53855. dispose(): void;
  53856. }
  53857. /**
  53858. * Options to create an EffectWrapper
  53859. */
  53860. interface EffectWrapperCreationOptions {
  53861. /**
  53862. * Engine to use to create the effect
  53863. */
  53864. engine: Engine;
  53865. /**
  53866. * Fragment shader for the effect
  53867. */
  53868. fragmentShader: string;
  53869. /**
  53870. * Vertex shader for the effect
  53871. */
  53872. vertexShader?: string;
  53873. /**
  53874. * Attributes to use in the shader
  53875. */
  53876. attributeNames?: Array<string>;
  53877. /**
  53878. * Uniforms to use in the shader
  53879. */
  53880. uniformNames?: Array<string>;
  53881. /**
  53882. * Texture sampler names to use in the shader
  53883. */
  53884. samplerNames?: Array<string>;
  53885. /**
  53886. * The friendly name of the effect displayed in Spector.
  53887. */
  53888. name?: string;
  53889. }
  53890. /**
  53891. * Wraps an effect to be used for rendering
  53892. */
  53893. export class EffectWrapper {
  53894. /**
  53895. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  53896. */
  53897. onApplyObservable: Observable<{}>;
  53898. /**
  53899. * The underlying effect
  53900. */
  53901. effect: Effect;
  53902. /**
  53903. * Creates an effect to be renderer
  53904. * @param creationOptions options to create the effect
  53905. */
  53906. constructor(creationOptions: EffectWrapperCreationOptions);
  53907. /**
  53908. * Disposes of the effect wrapper
  53909. */
  53910. dispose(): void;
  53911. }
  53912. }
  53913. declare module BABYLON {
  53914. /**
  53915. * Helper class to push actions to a pool of workers.
  53916. */
  53917. export class WorkerPool implements IDisposable {
  53918. private _workerInfos;
  53919. private _pendingActions;
  53920. /**
  53921. * Constructor
  53922. * @param workers Array of workers to use for actions
  53923. */
  53924. constructor(workers: Array<Worker>);
  53925. /**
  53926. * Terminates all workers and clears any pending actions.
  53927. */
  53928. dispose(): void;
  53929. /**
  53930. * Pushes an action to the worker pool. If all the workers are active, the action will be
  53931. * pended until a worker has completed its action.
  53932. * @param action The action to perform. Call onComplete when the action is complete.
  53933. */
  53934. push(action: (worker: Worker, onComplete: () => void) => void): void;
  53935. private _execute;
  53936. }
  53937. }
  53938. declare module BABYLON {
  53939. /**
  53940. * Configuration for Draco compression
  53941. */
  53942. export interface IDracoCompressionConfiguration {
  53943. /**
  53944. * Configuration for the decoder.
  53945. */
  53946. decoder: {
  53947. /**
  53948. * The url to the WebAssembly module.
  53949. */
  53950. wasmUrl?: string;
  53951. /**
  53952. * The url to the WebAssembly binary.
  53953. */
  53954. wasmBinaryUrl?: string;
  53955. /**
  53956. * The url to the fallback JavaScript module.
  53957. */
  53958. fallbackUrl?: string;
  53959. };
  53960. }
  53961. /**
  53962. * Draco compression (https://google.github.io/draco/)
  53963. *
  53964. * This class wraps the Draco module.
  53965. *
  53966. * **Encoder**
  53967. *
  53968. * The encoder is not currently implemented.
  53969. *
  53970. * **Decoder**
  53971. *
  53972. * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.
  53973. *
  53974. * To update the configuration, use the following code:
  53975. * ```javascript
  53976. * DracoCompression.Configuration = {
  53977. * decoder: {
  53978. * wasmUrl: "<url to the WebAssembly library>",
  53979. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  53980. * fallbackUrl: "<url to the fallback JavaScript library>",
  53981. * }
  53982. * };
  53983. * ```
  53984. *
  53985. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  53986. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  53987. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  53988. *
  53989. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  53990. * ```javascript
  53991. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  53992. * ```
  53993. *
  53994. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  53995. */
  53996. export class DracoCompression implements IDisposable {
  53997. private _workerPoolPromise?;
  53998. private _decoderModulePromise?;
  53999. /**
  54000. * The configuration. Defaults to the following urls:
  54001. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54002. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54003. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54004. */
  54005. static Configuration: IDracoCompressionConfiguration;
  54006. /**
  54007. * Returns true if the decoder configuration is available.
  54008. */
  54009. static readonly DecoderAvailable: boolean;
  54010. /**
  54011. * Default number of workers to create when creating the draco compression object.
  54012. */
  54013. static DefaultNumWorkers: number;
  54014. private static GetDefaultNumWorkers;
  54015. private static _Default;
  54016. /**
  54017. * Default instance for the draco compression object.
  54018. */
  54019. static readonly Default: DracoCompression;
  54020. /**
  54021. * Constructor
  54022. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54023. */
  54024. constructor(numWorkers?: number);
  54025. /**
  54026. * Stop all async operations and release resources.
  54027. */
  54028. dispose(): void;
  54029. /**
  54030. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54031. * @returns a promise that resolves when ready
  54032. */
  54033. whenReadyAsync(): Promise<void>;
  54034. /**
  54035. * Decode Draco compressed mesh data to vertex data.
  54036. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54037. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54038. * @returns A promise that resolves with the decoded vertex data
  54039. */
  54040. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54041. [kind: string]: number;
  54042. }): Promise<VertexData>;
  54043. }
  54044. }
  54045. declare module BABYLON {
  54046. /**
  54047. * Class for building Constructive Solid Geometry
  54048. */
  54049. export class CSG {
  54050. private polygons;
  54051. /**
  54052. * The world matrix
  54053. */
  54054. matrix: Matrix;
  54055. /**
  54056. * Stores the position
  54057. */
  54058. position: Vector3;
  54059. /**
  54060. * Stores the rotation
  54061. */
  54062. rotation: Vector3;
  54063. /**
  54064. * Stores the rotation quaternion
  54065. */
  54066. rotationQuaternion: Nullable<Quaternion>;
  54067. /**
  54068. * Stores the scaling vector
  54069. */
  54070. scaling: Vector3;
  54071. /**
  54072. * Convert the Mesh to CSG
  54073. * @param mesh The Mesh to convert to CSG
  54074. * @returns A new CSG from the Mesh
  54075. */
  54076. static FromMesh(mesh: Mesh): CSG;
  54077. /**
  54078. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54079. * @param polygons Polygons used to construct a CSG solid
  54080. */
  54081. private static FromPolygons;
  54082. /**
  54083. * Clones, or makes a deep copy, of the CSG
  54084. * @returns A new CSG
  54085. */
  54086. clone(): CSG;
  54087. /**
  54088. * Unions this CSG with another CSG
  54089. * @param csg The CSG to union against this CSG
  54090. * @returns The unioned CSG
  54091. */
  54092. union(csg: CSG): CSG;
  54093. /**
  54094. * Unions this CSG with another CSG in place
  54095. * @param csg The CSG to union against this CSG
  54096. */
  54097. unionInPlace(csg: CSG): void;
  54098. /**
  54099. * Subtracts this CSG with another CSG
  54100. * @param csg The CSG to subtract against this CSG
  54101. * @returns A new CSG
  54102. */
  54103. subtract(csg: CSG): CSG;
  54104. /**
  54105. * Subtracts this CSG with another CSG in place
  54106. * @param csg The CSG to subtact against this CSG
  54107. */
  54108. subtractInPlace(csg: CSG): void;
  54109. /**
  54110. * Intersect this CSG with another CSG
  54111. * @param csg The CSG to intersect against this CSG
  54112. * @returns A new CSG
  54113. */
  54114. intersect(csg: CSG): CSG;
  54115. /**
  54116. * Intersects this CSG with another CSG in place
  54117. * @param csg The CSG to intersect against this CSG
  54118. */
  54119. intersectInPlace(csg: CSG): void;
  54120. /**
  54121. * Return a new CSG solid with solid and empty space switched. This solid is
  54122. * not modified.
  54123. * @returns A new CSG solid with solid and empty space switched
  54124. */
  54125. inverse(): CSG;
  54126. /**
  54127. * Inverses the CSG in place
  54128. */
  54129. inverseInPlace(): void;
  54130. /**
  54131. * This is used to keep meshes transformations so they can be restored
  54132. * when we build back a Babylon Mesh
  54133. * NB : All CSG operations are performed in world coordinates
  54134. * @param csg The CSG to copy the transform attributes from
  54135. * @returns This CSG
  54136. */
  54137. copyTransformAttributes(csg: CSG): CSG;
  54138. /**
  54139. * Build Raw mesh from CSG
  54140. * Coordinates here are in world space
  54141. * @param name The name of the mesh geometry
  54142. * @param scene The Scene
  54143. * @param keepSubMeshes Specifies if the submeshes should be kept
  54144. * @returns A new Mesh
  54145. */
  54146. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54147. /**
  54148. * Build Mesh from CSG taking material and transforms into account
  54149. * @param name The name of the Mesh
  54150. * @param material The material of the Mesh
  54151. * @param scene The Scene
  54152. * @param keepSubMeshes Specifies if submeshes should be kept
  54153. * @returns The new Mesh
  54154. */
  54155. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54156. }
  54157. }
  54158. declare module BABYLON {
  54159. /**
  54160. * Class used to create a trail following a mesh
  54161. */
  54162. export class TrailMesh extends Mesh {
  54163. private _generator;
  54164. private _autoStart;
  54165. private _running;
  54166. private _diameter;
  54167. private _length;
  54168. private _sectionPolygonPointsCount;
  54169. private _sectionVectors;
  54170. private _sectionNormalVectors;
  54171. private _beforeRenderObserver;
  54172. /**
  54173. * @constructor
  54174. * @param name The value used by scene.getMeshByName() to do a lookup.
  54175. * @param generator The mesh to generate a trail.
  54176. * @param scene The scene to add this mesh to.
  54177. * @param diameter Diameter of trailing mesh. Default is 1.
  54178. * @param length Length of trailing mesh. Default is 60.
  54179. * @param autoStart Automatically start trailing mesh. Default true.
  54180. */
  54181. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54182. /**
  54183. * "TrailMesh"
  54184. * @returns "TrailMesh"
  54185. */
  54186. getClassName(): string;
  54187. private _createMesh;
  54188. /**
  54189. * Start trailing mesh.
  54190. */
  54191. start(): void;
  54192. /**
  54193. * Stop trailing mesh.
  54194. */
  54195. stop(): void;
  54196. /**
  54197. * Update trailing mesh geometry.
  54198. */
  54199. update(): void;
  54200. /**
  54201. * Returns a new TrailMesh object.
  54202. * @param name is a string, the name given to the new mesh
  54203. * @param newGenerator use new generator object for cloned trail mesh
  54204. * @returns a new mesh
  54205. */
  54206. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54207. /**
  54208. * Serializes this trail mesh
  54209. * @param serializationObject object to write serialization to
  54210. */
  54211. serialize(serializationObject: any): void;
  54212. /**
  54213. * Parses a serialized trail mesh
  54214. * @param parsedMesh the serialized mesh
  54215. * @param scene the scene to create the trail mesh in
  54216. * @returns the created trail mesh
  54217. */
  54218. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54219. }
  54220. }
  54221. declare module BABYLON {
  54222. /**
  54223. * Class containing static functions to help procedurally build meshes
  54224. */
  54225. export class TiledBoxBuilder {
  54226. /**
  54227. * Creates a box mesh
  54228. * faceTiles sets the pattern, tile size and number of tiles for a face * * 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)
  54229. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54231. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54233. * @param name defines the name of the mesh
  54234. * @param options defines the options used to create the mesh
  54235. * @param scene defines the hosting scene
  54236. * @returns the box mesh
  54237. */
  54238. static CreateTiledBox(name: string, options: {
  54239. pattern?: number;
  54240. width?: number;
  54241. height?: number;
  54242. depth?: number;
  54243. tileSize?: number;
  54244. tileWidth?: number;
  54245. tileHeight?: number;
  54246. alignHorizontal?: number;
  54247. alignVertical?: number;
  54248. faceUV?: Vector4[];
  54249. faceColors?: Color4[];
  54250. sideOrientation?: number;
  54251. updatable?: boolean;
  54252. }, scene?: Nullable<Scene>): Mesh;
  54253. }
  54254. }
  54255. declare module BABYLON {
  54256. /**
  54257. * Class containing static functions to help procedurally build meshes
  54258. */
  54259. export class TorusKnotBuilder {
  54260. /**
  54261. * Creates a torus knot mesh
  54262. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54263. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54264. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54265. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54267. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54269. * @param name defines the name of the mesh
  54270. * @param options defines the options used to create the mesh
  54271. * @param scene defines the hosting scene
  54272. * @returns the torus knot mesh
  54273. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54274. */
  54275. static CreateTorusKnot(name: string, options: {
  54276. radius?: number;
  54277. tube?: number;
  54278. radialSegments?: number;
  54279. tubularSegments?: number;
  54280. p?: number;
  54281. q?: number;
  54282. updatable?: boolean;
  54283. sideOrientation?: number;
  54284. frontUVs?: Vector4;
  54285. backUVs?: Vector4;
  54286. }, scene: any): Mesh;
  54287. }
  54288. }
  54289. declare module BABYLON {
  54290. /**
  54291. * Polygon
  54292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54293. */
  54294. export class Polygon {
  54295. /**
  54296. * Creates a rectangle
  54297. * @param xmin bottom X coord
  54298. * @param ymin bottom Y coord
  54299. * @param xmax top X coord
  54300. * @param ymax top Y coord
  54301. * @returns points that make the resulting rectation
  54302. */
  54303. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54304. /**
  54305. * Creates a circle
  54306. * @param radius radius of circle
  54307. * @param cx scale in x
  54308. * @param cy scale in y
  54309. * @param numberOfSides number of sides that make up the circle
  54310. * @returns points that make the resulting circle
  54311. */
  54312. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54313. /**
  54314. * Creates a polygon from input string
  54315. * @param input Input polygon data
  54316. * @returns the parsed points
  54317. */
  54318. static Parse(input: string): Vector2[];
  54319. /**
  54320. * Starts building a polygon from x and y coordinates
  54321. * @param x x coordinate
  54322. * @param y y coordinate
  54323. * @returns the started path2
  54324. */
  54325. static StartingAt(x: number, y: number): Path2;
  54326. }
  54327. /**
  54328. * Builds a polygon
  54329. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54330. */
  54331. export class PolygonMeshBuilder {
  54332. private _points;
  54333. private _outlinepoints;
  54334. private _holes;
  54335. private _name;
  54336. private _scene;
  54337. private _epoints;
  54338. private _eholes;
  54339. private _addToepoint;
  54340. /**
  54341. * Babylon reference to the earcut plugin.
  54342. */
  54343. bjsEarcut: any;
  54344. /**
  54345. * Creates a PolygonMeshBuilder
  54346. * @param name name of the builder
  54347. * @param contours Path of the polygon
  54348. * @param scene scene to add to when creating the mesh
  54349. * @param earcutInjection can be used to inject your own earcut reference
  54350. */
  54351. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54352. /**
  54353. * Adds a whole within the polygon
  54354. * @param hole Array of points defining the hole
  54355. * @returns this
  54356. */
  54357. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54358. /**
  54359. * Creates the polygon
  54360. * @param updatable If the mesh should be updatable
  54361. * @param depth The depth of the mesh created
  54362. * @returns the created mesh
  54363. */
  54364. build(updatable?: boolean, depth?: number): Mesh;
  54365. /**
  54366. * Creates the polygon
  54367. * @param depth The depth of the mesh created
  54368. * @returns the created VertexData
  54369. */
  54370. buildVertexData(depth?: number): VertexData;
  54371. /**
  54372. * Adds a side to the polygon
  54373. * @param positions points that make the polygon
  54374. * @param normals normals of the polygon
  54375. * @param uvs uvs of the polygon
  54376. * @param indices indices of the polygon
  54377. * @param bounds bounds of the polygon
  54378. * @param points points of the polygon
  54379. * @param depth depth of the polygon
  54380. * @param flip flip of the polygon
  54381. */
  54382. private addSide;
  54383. }
  54384. }
  54385. declare module BABYLON {
  54386. /**
  54387. * Class containing static functions to help procedurally build meshes
  54388. */
  54389. export class PolygonBuilder {
  54390. /**
  54391. * Creates a polygon mesh
  54392. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54393. * * 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
  54394. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54396. * * 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)
  54397. * * Remember you can only change the shape positions, not their number when updating a polygon
  54398. * @param name defines the name of the mesh
  54399. * @param options defines the options used to create the mesh
  54400. * @param scene defines the hosting scene
  54401. * @param earcutInjection can be used to inject your own earcut reference
  54402. * @returns the polygon mesh
  54403. */
  54404. static CreatePolygon(name: string, options: {
  54405. shape: Vector3[];
  54406. holes?: Vector3[][];
  54407. depth?: number;
  54408. faceUV?: Vector4[];
  54409. faceColors?: Color4[];
  54410. updatable?: boolean;
  54411. sideOrientation?: number;
  54412. frontUVs?: Vector4;
  54413. backUVs?: Vector4;
  54414. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54415. /**
  54416. * Creates an extruded polygon mesh, with depth in the Y direction.
  54417. * * 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)
  54418. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54419. * @param name defines the name of the mesh
  54420. * @param options defines the options used to create the mesh
  54421. * @param scene defines the hosting scene
  54422. * @param earcutInjection can be used to inject your own earcut reference
  54423. * @returns the polygon mesh
  54424. */
  54425. static ExtrudePolygon(name: string, options: {
  54426. shape: Vector3[];
  54427. holes?: Vector3[][];
  54428. depth?: number;
  54429. faceUV?: Vector4[];
  54430. faceColors?: Color4[];
  54431. updatable?: boolean;
  54432. sideOrientation?: number;
  54433. frontUVs?: Vector4;
  54434. backUVs?: Vector4;
  54435. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54436. }
  54437. }
  54438. declare module BABYLON {
  54439. /**
  54440. * Class containing static functions to help procedurally build meshes
  54441. */
  54442. export class LatheBuilder {
  54443. /**
  54444. * Creates lathe mesh.
  54445. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54446. * * 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 rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  54447. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54448. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54449. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54450. * * 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
  54451. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54452. * * 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
  54453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54454. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54455. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54457. * @param name defines the name of the mesh
  54458. * @param options defines the options used to create the mesh
  54459. * @param scene defines the hosting scene
  54460. * @returns the lathe mesh
  54461. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54462. */
  54463. static CreateLathe(name: string, options: {
  54464. shape: Vector3[];
  54465. radius?: number;
  54466. tessellation?: number;
  54467. clip?: number;
  54468. arc?: number;
  54469. closed?: boolean;
  54470. updatable?: boolean;
  54471. sideOrientation?: number;
  54472. frontUVs?: Vector4;
  54473. backUVs?: Vector4;
  54474. cap?: number;
  54475. invertUV?: boolean;
  54476. }, scene?: Nullable<Scene>): Mesh;
  54477. }
  54478. }
  54479. declare module BABYLON {
  54480. /**
  54481. * Class containing static functions to help procedurally build meshes
  54482. */
  54483. export class TiledPlaneBuilder {
  54484. /**
  54485. * Creates a tiled plane mesh
  54486. * * The parameter `pattern` will, depending on value, do nothing or
  54487. * * * flip (reflect about central vertical) alternate tiles across and up
  54488. * * * flip every tile on alternate rows
  54489. * * * rotate (180 degs) alternate tiles across and up
  54490. * * * rotate every tile on alternate rows
  54491. * * * flip and rotate alternate tiles across and up
  54492. * * * flip and rotate every tile on alternate rows
  54493. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54494. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54495. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54497. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  54498. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  54499. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54500. * @param name defines the name of the mesh
  54501. * @param options defines the options used to create the mesh
  54502. * @param scene defines the hosting scene
  54503. * @returns the box mesh
  54504. */
  54505. static CreateTiledPlane(name: string, options: {
  54506. pattern?: number;
  54507. tileSize?: number;
  54508. tileWidth?: number;
  54509. tileHeight?: number;
  54510. size?: number;
  54511. width?: number;
  54512. height?: number;
  54513. alignHorizontal?: number;
  54514. alignVertical?: number;
  54515. sideOrientation?: number;
  54516. frontUVs?: Vector4;
  54517. backUVs?: Vector4;
  54518. updatable?: boolean;
  54519. }, scene?: Nullable<Scene>): Mesh;
  54520. }
  54521. }
  54522. declare module BABYLON {
  54523. /**
  54524. * Class containing static functions to help procedurally build meshes
  54525. */
  54526. export class TubeBuilder {
  54527. /**
  54528. * Creates a tube mesh.
  54529. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54530. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54531. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54532. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54533. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54534. * * 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. It must return a radius value (positive float)
  54535. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54536. * * 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
  54537. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  54538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54539. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54540. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54542. * @param name defines the name of the mesh
  54543. * @param options defines the options used to create the mesh
  54544. * @param scene defines the hosting scene
  54545. * @returns the tube mesh
  54546. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54547. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54548. */
  54549. static CreateTube(name: string, options: {
  54550. path: Vector3[];
  54551. radius?: number;
  54552. tessellation?: number;
  54553. radiusFunction?: {
  54554. (i: number, distance: number): number;
  54555. };
  54556. cap?: number;
  54557. arc?: number;
  54558. updatable?: boolean;
  54559. sideOrientation?: number;
  54560. frontUVs?: Vector4;
  54561. backUVs?: Vector4;
  54562. instance?: Mesh;
  54563. invertUV?: boolean;
  54564. }, scene?: Nullable<Scene>): Mesh;
  54565. }
  54566. }
  54567. declare module BABYLON {
  54568. /**
  54569. * Class containing static functions to help procedurally build meshes
  54570. */
  54571. export class IcoSphereBuilder {
  54572. /**
  54573. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54574. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54575. * * 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 of `radius`)
  54576. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54577. * * 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
  54578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54579. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54581. * @param name defines the name of the mesh
  54582. * @param options defines the options used to create the mesh
  54583. * @param scene defines the hosting scene
  54584. * @returns the icosahedron mesh
  54585. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54586. */
  54587. static CreateIcoSphere(name: string, options: {
  54588. radius?: number;
  54589. radiusX?: number;
  54590. radiusY?: number;
  54591. radiusZ?: number;
  54592. flat?: boolean;
  54593. subdivisions?: number;
  54594. sideOrientation?: number;
  54595. frontUVs?: Vector4;
  54596. backUVs?: Vector4;
  54597. updatable?: boolean;
  54598. }, scene?: Nullable<Scene>): Mesh;
  54599. }
  54600. }
  54601. declare module BABYLON {
  54602. /**
  54603. * Class containing static functions to help procedurally build meshes
  54604. */
  54605. export class DecalBuilder {
  54606. /**
  54607. * Creates a decal mesh.
  54608. * 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
  54609. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54610. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54611. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54612. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54613. * @param name defines the name of the mesh
  54614. * @param sourceMesh defines the mesh where the decal must be applied
  54615. * @param options defines the options used to create the mesh
  54616. * @param scene defines the hosting scene
  54617. * @returns the decal mesh
  54618. * @see https://doc.babylonjs.com/how_to/decals
  54619. */
  54620. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54621. position?: Vector3;
  54622. normal?: Vector3;
  54623. size?: Vector3;
  54624. angle?: number;
  54625. }): Mesh;
  54626. }
  54627. }
  54628. declare module BABYLON {
  54629. /**
  54630. * Class containing static functions to help procedurally build meshes
  54631. */
  54632. export class MeshBuilder {
  54633. /**
  54634. * Creates a box mesh
  54635. * * The parameter `size` sets the size (float) of each box side (default 1)
  54636. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54637. * * 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)
  54638. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54640. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54642. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54643. * @param name defines the name of the mesh
  54644. * @param options defines the options used to create the mesh
  54645. * @param scene defines the hosting scene
  54646. * @returns the box mesh
  54647. */
  54648. static CreateBox(name: string, options: {
  54649. size?: number;
  54650. width?: number;
  54651. height?: number;
  54652. depth?: number;
  54653. faceUV?: Vector4[];
  54654. faceColors?: Color4[];
  54655. sideOrientation?: number;
  54656. frontUVs?: Vector4;
  54657. backUVs?: Vector4;
  54658. updatable?: boolean;
  54659. }, scene?: Nullable<Scene>): Mesh;
  54660. /**
  54661. * Creates a tiled box mesh
  54662. * * faceTiles sets the pattern, tile size and number of tiles for a face
  54663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54664. * @param name defines the name of the mesh
  54665. * @param options defines the options used to create the mesh
  54666. * @param scene defines the hosting scene
  54667. * @returns the tiled box mesh
  54668. */
  54669. static CreateTiledBox(name: string, options: {
  54670. pattern?: number;
  54671. size?: number;
  54672. width?: number;
  54673. height?: number;
  54674. depth: number;
  54675. tileSize?: number;
  54676. tileWidth?: number;
  54677. tileHeight?: number;
  54678. faceUV?: Vector4[];
  54679. faceColors?: Color4[];
  54680. alignHorizontal?: number;
  54681. alignVertical?: number;
  54682. sideOrientation?: number;
  54683. updatable?: boolean;
  54684. }, scene?: Nullable<Scene>): Mesh;
  54685. /**
  54686. * Creates a sphere mesh
  54687. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54688. * * 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 of `diameter`)
  54689. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54690. * * 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
  54691. * * 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)
  54692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54693. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54695. * @param name defines the name of the mesh
  54696. * @param options defines the options used to create the mesh
  54697. * @param scene defines the hosting scene
  54698. * @returns the sphere mesh
  54699. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54700. */
  54701. static CreateSphere(name: string, options: {
  54702. segments?: number;
  54703. diameter?: number;
  54704. diameterX?: number;
  54705. diameterY?: number;
  54706. diameterZ?: number;
  54707. arc?: number;
  54708. slice?: number;
  54709. sideOrientation?: number;
  54710. frontUVs?: Vector4;
  54711. backUVs?: Vector4;
  54712. updatable?: boolean;
  54713. }, scene?: Nullable<Scene>): Mesh;
  54714. /**
  54715. * Creates a plane polygonal mesh. By default, this is a disc
  54716. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  54717. * * 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
  54718. * * 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
  54719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54720. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54722. * @param name defines the name of the mesh
  54723. * @param options defines the options used to create the mesh
  54724. * @param scene defines the hosting scene
  54725. * @returns the plane polygonal mesh
  54726. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  54727. */
  54728. static CreateDisc(name: string, options: {
  54729. radius?: number;
  54730. tessellation?: number;
  54731. arc?: number;
  54732. updatable?: boolean;
  54733. sideOrientation?: number;
  54734. frontUVs?: Vector4;
  54735. backUVs?: Vector4;
  54736. }, scene?: Nullable<Scene>): Mesh;
  54737. /**
  54738. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54739. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54740. * * 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 of `radius`)
  54741. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54742. * * 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
  54743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54744. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54746. * @param name defines the name of the mesh
  54747. * @param options defines the options used to create the mesh
  54748. * @param scene defines the hosting scene
  54749. * @returns the icosahedron mesh
  54750. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54751. */
  54752. static CreateIcoSphere(name: string, options: {
  54753. radius?: number;
  54754. radiusX?: number;
  54755. radiusY?: number;
  54756. radiusZ?: number;
  54757. flat?: boolean;
  54758. subdivisions?: number;
  54759. sideOrientation?: number;
  54760. frontUVs?: Vector4;
  54761. backUVs?: Vector4;
  54762. updatable?: boolean;
  54763. }, scene?: Nullable<Scene>): Mesh;
  54764. /**
  54765. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54766. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54767. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54768. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54769. * * 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
  54770. * * 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
  54771. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  54772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54773. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54774. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54775. * * 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
  54776. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54777. * * 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 if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  54778. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54780. * @param name defines the name of the mesh
  54781. * @param options defines the options used to create the mesh
  54782. * @param scene defines the hosting scene
  54783. * @returns the ribbon mesh
  54784. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54785. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54786. */
  54787. static CreateRibbon(name: string, options: {
  54788. pathArray: Vector3[][];
  54789. closeArray?: boolean;
  54790. closePath?: boolean;
  54791. offset?: number;
  54792. updatable?: boolean;
  54793. sideOrientation?: number;
  54794. frontUVs?: Vector4;
  54795. backUVs?: Vector4;
  54796. instance?: Mesh;
  54797. invertUV?: boolean;
  54798. uvs?: Vector2[];
  54799. colors?: Color4[];
  54800. }, scene?: Nullable<Scene>): Mesh;
  54801. /**
  54802. * Creates a cylinder or a cone mesh
  54803. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  54804. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  54805. * * 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.
  54806. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  54807. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  54808. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  54809. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  54810. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  54811. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  54812. * * 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).
  54813. * * 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
  54814. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  54815. * * 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
  54816. * * 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.
  54817. * * If `enclose` is false, a ring surface is one element.
  54818. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  54819. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  54820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54821. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54823. * @param name defines the name of the mesh
  54824. * @param options defines the options used to create the mesh
  54825. * @param scene defines the hosting scene
  54826. * @returns the cylinder mesh
  54827. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  54828. */
  54829. static CreateCylinder(name: string, options: {
  54830. height?: number;
  54831. diameterTop?: number;
  54832. diameterBottom?: number;
  54833. diameter?: number;
  54834. tessellation?: number;
  54835. subdivisions?: number;
  54836. arc?: number;
  54837. faceColors?: Color4[];
  54838. faceUV?: Vector4[];
  54839. updatable?: boolean;
  54840. hasRings?: boolean;
  54841. enclose?: boolean;
  54842. cap?: number;
  54843. sideOrientation?: number;
  54844. frontUVs?: Vector4;
  54845. backUVs?: Vector4;
  54846. }, scene?: Nullable<Scene>): Mesh;
  54847. /**
  54848. * Creates a torus mesh
  54849. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  54850. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  54851. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  54852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54853. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54855. * @param name defines the name of the mesh
  54856. * @param options defines the options used to create the mesh
  54857. * @param scene defines the hosting scene
  54858. * @returns the torus mesh
  54859. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  54860. */
  54861. static CreateTorus(name: string, options: {
  54862. diameter?: number;
  54863. thickness?: number;
  54864. tessellation?: number;
  54865. updatable?: boolean;
  54866. sideOrientation?: number;
  54867. frontUVs?: Vector4;
  54868. backUVs?: Vector4;
  54869. }, scene?: Nullable<Scene>): Mesh;
  54870. /**
  54871. * Creates a torus knot mesh
  54872. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54873. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54874. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54875. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54877. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54879. * @param name defines the name of the mesh
  54880. * @param options defines the options used to create the mesh
  54881. * @param scene defines the hosting scene
  54882. * @returns the torus knot mesh
  54883. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54884. */
  54885. static CreateTorusKnot(name: string, options: {
  54886. radius?: number;
  54887. tube?: number;
  54888. radialSegments?: number;
  54889. tubularSegments?: number;
  54890. p?: number;
  54891. q?: number;
  54892. updatable?: boolean;
  54893. sideOrientation?: number;
  54894. frontUVs?: Vector4;
  54895. backUVs?: Vector4;
  54896. }, scene?: Nullable<Scene>): Mesh;
  54897. /**
  54898. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54899. * * 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
  54900. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54901. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54902. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54903. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54904. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54905. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  54906. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54909. * @param name defines the name of the new line system
  54910. * @param options defines the options used to create the line system
  54911. * @param scene defines the hosting scene
  54912. * @returns a new line system mesh
  54913. */
  54914. static CreateLineSystem(name: string, options: {
  54915. lines: Vector3[][];
  54916. updatable?: boolean;
  54917. instance?: Nullable<LinesMesh>;
  54918. colors?: Nullable<Color4[][]>;
  54919. useVertexAlpha?: boolean;
  54920. }, scene: Nullable<Scene>): LinesMesh;
  54921. /**
  54922. * Creates a line mesh
  54923. * 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
  54924. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54925. * * The parameter `points` is an array successive Vector3
  54926. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  54927. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54928. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54929. * * When updating an instance, remember that only point positions can change, not the number of points
  54930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54931. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54932. * @param name defines the name of the new line system
  54933. * @param options defines the options used to create the line system
  54934. * @param scene defines the hosting scene
  54935. * @returns a new line mesh
  54936. */
  54937. static CreateLines(name: string, options: {
  54938. points: Vector3[];
  54939. updatable?: boolean;
  54940. instance?: Nullable<LinesMesh>;
  54941. colors?: Color4[];
  54942. useVertexAlpha?: boolean;
  54943. }, scene?: Nullable<Scene>): LinesMesh;
  54944. /**
  54945. * Creates a dashed line mesh
  54946. * * 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
  54947. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54948. * * The parameter `points` is an array successive Vector3
  54949. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54950. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54951. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54952. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  54953. * * When updating an instance, remember that only point positions can change, not the number of points
  54954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54955. * @param name defines the name of the mesh
  54956. * @param options defines the options used to create the mesh
  54957. * @param scene defines the hosting scene
  54958. * @returns the dashed line mesh
  54959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54960. */
  54961. static CreateDashedLines(name: string, options: {
  54962. points: Vector3[];
  54963. dashSize?: number;
  54964. gapSize?: number;
  54965. dashNb?: number;
  54966. updatable?: boolean;
  54967. instance?: LinesMesh;
  54968. }, scene?: Nullable<Scene>): LinesMesh;
  54969. /**
  54970. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54971. * * 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 extruded along the Z axis.
  54972. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54973. * * 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.
  54974. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54975. * * 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
  54976. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  54977. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54979. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54980. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54982. * @param name defines the name of the mesh
  54983. * @param options defines the options used to create the mesh
  54984. * @param scene defines the hosting scene
  54985. * @returns the extruded shape mesh
  54986. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54987. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54988. */
  54989. static ExtrudeShape(name: string, options: {
  54990. shape: Vector3[];
  54991. path: Vector3[];
  54992. scale?: number;
  54993. rotation?: number;
  54994. cap?: number;
  54995. updatable?: boolean;
  54996. sideOrientation?: number;
  54997. frontUVs?: Vector4;
  54998. backUVs?: Vector4;
  54999. instance?: Mesh;
  55000. invertUV?: boolean;
  55001. }, scene?: Nullable<Scene>): Mesh;
  55002. /**
  55003. * Creates an custom extruded shape mesh.
  55004. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55005. * * 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 extruded along the Z axis.
  55006. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55007. * * 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 and the distance of this point from the begining of the path
  55008. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55009. * * 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 and the distance of this point from the begining of the path
  55010. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55011. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55012. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55013. * * 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
  55014. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  55015. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55017. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55018. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55020. * @param name defines the name of the mesh
  55021. * @param options defines the options used to create the mesh
  55022. * @param scene defines the hosting scene
  55023. * @returns the custom extruded shape mesh
  55024. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55025. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55026. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55027. */
  55028. static ExtrudeShapeCustom(name: string, options: {
  55029. shape: Vector3[];
  55030. path: Vector3[];
  55031. scaleFunction?: any;
  55032. rotationFunction?: any;
  55033. ribbonCloseArray?: boolean;
  55034. ribbonClosePath?: boolean;
  55035. cap?: number;
  55036. updatable?: boolean;
  55037. sideOrientation?: number;
  55038. frontUVs?: Vector4;
  55039. backUVs?: Vector4;
  55040. instance?: Mesh;
  55041. invertUV?: boolean;
  55042. }, scene?: Nullable<Scene>): Mesh;
  55043. /**
  55044. * Creates lathe mesh.
  55045. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55046. * * 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 rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  55047. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55048. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55049. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55050. * * 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
  55051. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55052. * * 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
  55053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55054. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55055. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55057. * @param name defines the name of the mesh
  55058. * @param options defines the options used to create the mesh
  55059. * @param scene defines the hosting scene
  55060. * @returns the lathe mesh
  55061. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55062. */
  55063. static CreateLathe(name: string, options: {
  55064. shape: Vector3[];
  55065. radius?: number;
  55066. tessellation?: number;
  55067. clip?: number;
  55068. arc?: number;
  55069. closed?: boolean;
  55070. updatable?: boolean;
  55071. sideOrientation?: number;
  55072. frontUVs?: Vector4;
  55073. backUVs?: Vector4;
  55074. cap?: number;
  55075. invertUV?: boolean;
  55076. }, scene?: Nullable<Scene>): Mesh;
  55077. /**
  55078. * Creates a tiled plane mesh
  55079. * * You can set a limited pattern arrangement with the tiles
  55080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55081. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55083. * @param name defines the name of the mesh
  55084. * @param options defines the options used to create the mesh
  55085. * @param scene defines the hosting scene
  55086. * @returns the plane mesh
  55087. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55088. */
  55089. static CreateTiledPlane(name: string, options: {
  55090. pattern?: number;
  55091. tileSize?: number;
  55092. tileWidth?: number;
  55093. tileHeight?: number;
  55094. size?: number;
  55095. width?: number;
  55096. height?: number;
  55097. alignHorizontal?: number;
  55098. alignVertical?: number;
  55099. sideOrientation?: number;
  55100. frontUVs?: Vector4;
  55101. backUVs?: Vector4;
  55102. updatable?: boolean;
  55103. }, scene?: Nullable<Scene>): Mesh;
  55104. /**
  55105. * Creates a plane mesh
  55106. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55107. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55108. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55109. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55110. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55112. * @param name defines the name of the mesh
  55113. * @param options defines the options used to create the mesh
  55114. * @param scene defines the hosting scene
  55115. * @returns the plane mesh
  55116. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55117. */
  55118. static CreatePlane(name: string, options: {
  55119. size?: number;
  55120. width?: number;
  55121. height?: number;
  55122. sideOrientation?: number;
  55123. frontUVs?: Vector4;
  55124. backUVs?: Vector4;
  55125. updatable?: boolean;
  55126. sourcePlane?: Plane;
  55127. }, scene?: Nullable<Scene>): Mesh;
  55128. /**
  55129. * Creates a ground mesh
  55130. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55131. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55133. * @param name defines the name of the mesh
  55134. * @param options defines the options used to create the mesh
  55135. * @param scene defines the hosting scene
  55136. * @returns the ground mesh
  55137. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55138. */
  55139. static CreateGround(name: string, options: {
  55140. width?: number;
  55141. height?: number;
  55142. subdivisions?: number;
  55143. subdivisionsX?: number;
  55144. subdivisionsY?: number;
  55145. updatable?: boolean;
  55146. }, scene?: Nullable<Scene>): Mesh;
  55147. /**
  55148. * Creates a tiled ground mesh
  55149. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55150. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55151. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  55152. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  55153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55154. * @param name defines the name of the mesh
  55155. * @param options defines the options used to create the mesh
  55156. * @param scene defines the hosting scene
  55157. * @returns the tiled ground mesh
  55158. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55159. */
  55160. static CreateTiledGround(name: string, options: {
  55161. xmin: number;
  55162. zmin: number;
  55163. xmax: number;
  55164. zmax: number;
  55165. subdivisions?: {
  55166. w: number;
  55167. h: number;
  55168. };
  55169. precision?: {
  55170. w: number;
  55171. h: number;
  55172. };
  55173. updatable?: boolean;
  55174. }, scene?: Nullable<Scene>): Mesh;
  55175. /**
  55176. * Creates a ground mesh from a height map
  55177. * * The parameter `url` sets the URL of the height map image resource.
  55178. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55179. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55180. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55181. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55182. * * 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.
  55183. * * 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).
  55184. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55186. * @param name defines the name of the mesh
  55187. * @param url defines the url to the height map
  55188. * @param options defines the options used to create the mesh
  55189. * @param scene defines the hosting scene
  55190. * @returns the ground mesh
  55191. * @see https://doc.babylonjs.com/babylon101/height_map
  55192. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55193. */
  55194. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55195. width?: number;
  55196. height?: number;
  55197. subdivisions?: number;
  55198. minHeight?: number;
  55199. maxHeight?: number;
  55200. colorFilter?: Color3;
  55201. alphaFilter?: number;
  55202. updatable?: boolean;
  55203. onReady?: (mesh: GroundMesh) => void;
  55204. }, scene?: Nullable<Scene>): GroundMesh;
  55205. /**
  55206. * Creates a polygon mesh
  55207. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55208. * * 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
  55209. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55211. * * 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)
  55212. * * Remember you can only change the shape positions, not their number when updating a polygon
  55213. * @param name defines the name of the mesh
  55214. * @param options defines the options used to create the mesh
  55215. * @param scene defines the hosting scene
  55216. * @param earcutInjection can be used to inject your own earcut reference
  55217. * @returns the polygon mesh
  55218. */
  55219. static CreatePolygon(name: string, options: {
  55220. shape: Vector3[];
  55221. holes?: Vector3[][];
  55222. depth?: number;
  55223. faceUV?: Vector4[];
  55224. faceColors?: Color4[];
  55225. updatable?: boolean;
  55226. sideOrientation?: number;
  55227. frontUVs?: Vector4;
  55228. backUVs?: Vector4;
  55229. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55230. /**
  55231. * Creates an extruded polygon mesh, with depth in the Y direction.
  55232. * * 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)
  55233. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55234. * @param name defines the name of the mesh
  55235. * @param options defines the options used to create the mesh
  55236. * @param scene defines the hosting scene
  55237. * @param earcutInjection can be used to inject your own earcut reference
  55238. * @returns the polygon mesh
  55239. */
  55240. static ExtrudePolygon(name: string, options: {
  55241. shape: Vector3[];
  55242. holes?: Vector3[][];
  55243. depth?: number;
  55244. faceUV?: Vector4[];
  55245. faceColors?: Color4[];
  55246. updatable?: boolean;
  55247. sideOrientation?: number;
  55248. frontUVs?: Vector4;
  55249. backUVs?: Vector4;
  55250. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55251. /**
  55252. * Creates a tube mesh.
  55253. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55254. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55255. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55256. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55257. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55258. * * 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. It must return a radius value (positive float)
  55259. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55260. * * 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
  55261. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  55262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55263. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55264. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55266. * @param name defines the name of the mesh
  55267. * @param options defines the options used to create the mesh
  55268. * @param scene defines the hosting scene
  55269. * @returns the tube mesh
  55270. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55271. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55272. */
  55273. static CreateTube(name: string, options: {
  55274. path: Vector3[];
  55275. radius?: number;
  55276. tessellation?: number;
  55277. radiusFunction?: {
  55278. (i: number, distance: number): number;
  55279. };
  55280. cap?: number;
  55281. arc?: number;
  55282. updatable?: boolean;
  55283. sideOrientation?: number;
  55284. frontUVs?: Vector4;
  55285. backUVs?: Vector4;
  55286. instance?: Mesh;
  55287. invertUV?: boolean;
  55288. }, scene?: Nullable<Scene>): Mesh;
  55289. /**
  55290. * Creates a polyhedron mesh
  55291. * * 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 to choose the wanted type
  55292. * * The parameter `size` (positive float, default 1) sets the polygon size
  55293. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55294. * * 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`
  55295. * * 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
  55296. * * 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)`)
  55297. * * 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 : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55298. * * 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
  55299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55300. * * 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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55302. * @param name defines the name of the mesh
  55303. * @param options defines the options used to create the mesh
  55304. * @param scene defines the hosting scene
  55305. * @returns the polyhedron mesh
  55306. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55307. */
  55308. static CreatePolyhedron(name: string, options: {
  55309. type?: number;
  55310. size?: number;
  55311. sizeX?: number;
  55312. sizeY?: number;
  55313. sizeZ?: number;
  55314. custom?: any;
  55315. faceUV?: Vector4[];
  55316. faceColors?: Color4[];
  55317. flat?: boolean;
  55318. updatable?: boolean;
  55319. sideOrientation?: number;
  55320. frontUVs?: Vector4;
  55321. backUVs?: Vector4;
  55322. }, scene?: Nullable<Scene>): Mesh;
  55323. /**
  55324. * Creates a decal mesh.
  55325. * 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
  55326. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55327. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55328. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55329. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55330. * @param name defines the name of the mesh
  55331. * @param sourceMesh defines the mesh where the decal must be applied
  55332. * @param options defines the options used to create the mesh
  55333. * @param scene defines the hosting scene
  55334. * @returns the decal mesh
  55335. * @see https://doc.babylonjs.com/how_to/decals
  55336. */
  55337. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55338. position?: Vector3;
  55339. normal?: Vector3;
  55340. size?: Vector3;
  55341. angle?: number;
  55342. }): Mesh;
  55343. }
  55344. }
  55345. declare module BABYLON {
  55346. /**
  55347. * A simplifier interface for future simplification implementations
  55348. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55349. */
  55350. export interface ISimplifier {
  55351. /**
  55352. * Simplification of a given mesh according to the given settings.
  55353. * Since this requires computation, it is assumed that the function runs async.
  55354. * @param settings The settings of the simplification, including quality and distance
  55355. * @param successCallback A callback that will be called after the mesh was simplified.
  55356. * @param errorCallback in case of an error, this callback will be called. optional.
  55357. */
  55358. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55359. }
  55360. /**
  55361. * Expected simplification settings.
  55362. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55363. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55364. */
  55365. export interface ISimplificationSettings {
  55366. /**
  55367. * Gets or sets the expected quality
  55368. */
  55369. quality: number;
  55370. /**
  55371. * Gets or sets the distance when this optimized version should be used
  55372. */
  55373. distance: number;
  55374. /**
  55375. * Gets an already optimized mesh
  55376. */
  55377. optimizeMesh?: boolean;
  55378. }
  55379. /**
  55380. * Class used to specify simplification options
  55381. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55382. */
  55383. export class SimplificationSettings implements ISimplificationSettings {
  55384. /** expected quality */
  55385. quality: number;
  55386. /** distance when this optimized version should be used */
  55387. distance: number;
  55388. /** already optimized mesh */
  55389. optimizeMesh?: boolean | undefined;
  55390. /**
  55391. * Creates a SimplificationSettings
  55392. * @param quality expected quality
  55393. * @param distance distance when this optimized version should be used
  55394. * @param optimizeMesh already optimized mesh
  55395. */
  55396. constructor(
  55397. /** expected quality */
  55398. quality: number,
  55399. /** distance when this optimized version should be used */
  55400. distance: number,
  55401. /** already optimized mesh */
  55402. optimizeMesh?: boolean | undefined);
  55403. }
  55404. /**
  55405. * Interface used to define a simplification task
  55406. */
  55407. export interface ISimplificationTask {
  55408. /**
  55409. * Array of settings
  55410. */
  55411. settings: Array<ISimplificationSettings>;
  55412. /**
  55413. * Simplification type
  55414. */
  55415. simplificationType: SimplificationType;
  55416. /**
  55417. * Mesh to simplify
  55418. */
  55419. mesh: Mesh;
  55420. /**
  55421. * Callback called on success
  55422. */
  55423. successCallback?: () => void;
  55424. /**
  55425. * Defines if parallel processing can be used
  55426. */
  55427. parallelProcessing: boolean;
  55428. }
  55429. /**
  55430. * Queue used to order the simplification tasks
  55431. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55432. */
  55433. export class SimplificationQueue {
  55434. private _simplificationArray;
  55435. /**
  55436. * Gets a boolean indicating that the process is still running
  55437. */
  55438. running: boolean;
  55439. /**
  55440. * Creates a new queue
  55441. */
  55442. constructor();
  55443. /**
  55444. * Adds a new simplification task
  55445. * @param task defines a task to add
  55446. */
  55447. addTask(task: ISimplificationTask): void;
  55448. /**
  55449. * Execute next task
  55450. */
  55451. executeNext(): void;
  55452. /**
  55453. * Execute a simplification task
  55454. * @param task defines the task to run
  55455. */
  55456. runSimplification(task: ISimplificationTask): void;
  55457. private getSimplifier;
  55458. }
  55459. /**
  55460. * The implemented types of simplification
  55461. * At the moment only Quadratic Error Decimation is implemented
  55462. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55463. */
  55464. export enum SimplificationType {
  55465. /** Quadratic error decimation */
  55466. QUADRATIC = 0
  55467. }
  55468. }
  55469. declare module BABYLON {
  55470. interface Scene {
  55471. /** @hidden (Backing field) */
  55472. _simplificationQueue: SimplificationQueue;
  55473. /**
  55474. * Gets or sets the simplification queue attached to the scene
  55475. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55476. */
  55477. simplificationQueue: SimplificationQueue;
  55478. }
  55479. interface Mesh {
  55480. /**
  55481. * Simplify the mesh according to the given array of settings.
  55482. * Function will return immediately and will simplify async
  55483. * @param settings a collection of simplification settings
  55484. * @param parallelProcessing should all levels calculate parallel or one after the other
  55485. * @param simplificationType the type of simplification to run
  55486. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  55487. * @returns the current mesh
  55488. */
  55489. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  55490. }
  55491. /**
  55492. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55493. * created in a scene
  55494. */
  55495. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55496. /**
  55497. * The component name helpfull to identify the component in the list of scene components.
  55498. */
  55499. readonly name: string;
  55500. /**
  55501. * The scene the component belongs to.
  55502. */
  55503. scene: Scene;
  55504. /**
  55505. * Creates a new instance of the component for the given scene
  55506. * @param scene Defines the scene to register the component in
  55507. */
  55508. constructor(scene: Scene);
  55509. /**
  55510. * Registers the component in a given scene
  55511. */
  55512. register(): void;
  55513. /**
  55514. * Rebuilds the elements related to this component in case of
  55515. * context lost for instance.
  55516. */
  55517. rebuild(): void;
  55518. /**
  55519. * Disposes the component and the associated ressources
  55520. */
  55521. dispose(): void;
  55522. private _beforeCameraUpdate;
  55523. }
  55524. }
  55525. declare module BABYLON {
  55526. /**
  55527. * Navigation plugin interface to add navigation constrained by a navigation mesh
  55528. */
  55529. export interface INavigationEnginePlugin {
  55530. /**
  55531. * plugin name
  55532. */
  55533. name: string;
  55534. /**
  55535. * Creates a navigation mesh
  55536. * @param meshes array of all the geometry used to compute the navigatio mesh
  55537. * @param parameters bunch of parameters used to filter geometry
  55538. */
  55539. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55540. /**
  55541. * Create a navigation mesh debug mesh
  55542. * @param scene is where the mesh will be added
  55543. * @returns debug display mesh
  55544. */
  55545. createDebugNavMesh(scene: Scene): Mesh;
  55546. /**
  55547. * Get a navigation mesh constrained position, closest to the parameter position
  55548. * @param position world position
  55549. * @returns the closest point to position constrained by the navigation mesh
  55550. */
  55551. getClosestPoint(position: Vector3): Vector3;
  55552. /**
  55553. * Get a navigation mesh constrained position, within a particular radius
  55554. * @param position world position
  55555. * @param maxRadius the maximum distance to the constrained world position
  55556. * @returns the closest point to position constrained by the navigation mesh
  55557. */
  55558. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55559. /**
  55560. * Compute the final position from a segment made of destination-position
  55561. * @param position world position
  55562. * @param destination world position
  55563. * @returns the resulting point along the navmesh
  55564. */
  55565. moveAlong(position: Vector3, destination: Vector3): Vector3;
  55566. /**
  55567. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55568. * @param start world position
  55569. * @param end world position
  55570. * @returns array containing world position composing the path
  55571. */
  55572. computePath(start: Vector3, end: Vector3): Vector3[];
  55573. /**
  55574. * If this plugin is supported
  55575. * @returns true if plugin is supported
  55576. */
  55577. isSupported(): boolean;
  55578. /**
  55579. * Create a new Crowd so you can add agents
  55580. * @param maxAgents the maximum agent count in the crowd
  55581. * @param maxAgentRadius the maximum radius an agent can have
  55582. * @param scene to attach the crowd to
  55583. * @returns the crowd you can add agents to
  55584. */
  55585. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55586. /**
  55587. * Release all resources
  55588. */
  55589. dispose(): void;
  55590. }
  55591. /**
  55592. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  55593. */
  55594. export interface ICrowd {
  55595. /**
  55596. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55597. * You can attach anything to that node. The node position is updated in the scene update tick.
  55598. * @param pos world position that will be constrained by the navigation mesh
  55599. * @param parameters agent parameters
  55600. * @param transform hooked to the agent that will be update by the scene
  55601. * @returns agent index
  55602. */
  55603. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55604. /**
  55605. * Returns the agent position in world space
  55606. * @param index agent index returned by addAgent
  55607. * @returns world space position
  55608. */
  55609. getAgentPosition(index: number): Vector3;
  55610. /**
  55611. * Gets the agent velocity in world space
  55612. * @param index agent index returned by addAgent
  55613. * @returns world space velocity
  55614. */
  55615. getAgentVelocity(index: number): Vector3;
  55616. /**
  55617. * remove a particular agent previously created
  55618. * @param index agent index returned by addAgent
  55619. */
  55620. removeAgent(index: number): void;
  55621. /**
  55622. * get the list of all agents attached to this crowd
  55623. * @returns list of agent indices
  55624. */
  55625. getAgents(): number[];
  55626. /**
  55627. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55628. * @param deltaTime in seconds
  55629. */
  55630. update(deltaTime: number): void;
  55631. /**
  55632. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55633. * @param index agent index returned by addAgent
  55634. * @param destination targeted world position
  55635. */
  55636. agentGoto(index: number, destination: Vector3): void;
  55637. /**
  55638. * Release all resources
  55639. */
  55640. dispose(): void;
  55641. }
  55642. /**
  55643. * Configures an agent
  55644. */
  55645. export interface IAgentParameters {
  55646. /**
  55647. * Agent radius. [Limit: >= 0]
  55648. */
  55649. radius: number;
  55650. /**
  55651. * Agent height. [Limit: > 0]
  55652. */
  55653. height: number;
  55654. /**
  55655. * Maximum allowed acceleration. [Limit: >= 0]
  55656. */
  55657. maxAcceleration: number;
  55658. /**
  55659. * Maximum allowed speed. [Limit: >= 0]
  55660. */
  55661. maxSpeed: number;
  55662. /**
  55663. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  55664. */
  55665. collisionQueryRange: number;
  55666. /**
  55667. * The path visibility optimization range. [Limit: > 0]
  55668. */
  55669. pathOptimizationRange: number;
  55670. /**
  55671. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  55672. */
  55673. separationWeight: number;
  55674. }
  55675. /**
  55676. * Configures the navigation mesh creation
  55677. */
  55678. export interface INavMeshParameters {
  55679. /**
  55680. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  55681. */
  55682. cs: number;
  55683. /**
  55684. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  55685. */
  55686. ch: number;
  55687. /**
  55688. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  55689. */
  55690. walkableSlopeAngle: number;
  55691. /**
  55692. * Minimum floor to 'ceiling' height that will still allow the floor area to
  55693. * be considered walkable. [Limit: >= 3] [Units: vx]
  55694. */
  55695. walkableHeight: number;
  55696. /**
  55697. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  55698. */
  55699. walkableClimb: number;
  55700. /**
  55701. * The distance to erode/shrink the walkable area of the heightfield away from
  55702. * obstructions. [Limit: >=0] [Units: vx]
  55703. */
  55704. walkableRadius: number;
  55705. /**
  55706. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  55707. */
  55708. maxEdgeLen: number;
  55709. /**
  55710. * The maximum distance a simplfied contour's border edges should deviate
  55711. * the original raw contour. [Limit: >=0] [Units: vx]
  55712. */
  55713. maxSimplificationError: number;
  55714. /**
  55715. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  55716. */
  55717. minRegionArea: number;
  55718. /**
  55719. * Any regions with a span count smaller than this value will, if possible,
  55720. * be merged with larger regions. [Limit: >=0] [Units: vx]
  55721. */
  55722. mergeRegionArea: number;
  55723. /**
  55724. * The maximum number of vertices allowed for polygons generated during the
  55725. * contour to polygon conversion process. [Limit: >= 3]
  55726. */
  55727. maxVertsPerPoly: number;
  55728. /**
  55729. * Sets the sampling distance to use when generating the detail mesh.
  55730. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  55731. */
  55732. detailSampleDist: number;
  55733. /**
  55734. * The maximum distance the detail mesh surface should deviate from heightfield
  55735. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  55736. */
  55737. detailSampleMaxError: number;
  55738. }
  55739. }
  55740. declare module BABYLON {
  55741. /**
  55742. * RecastJS navigation plugin
  55743. */
  55744. export class RecastJSPlugin implements INavigationEnginePlugin {
  55745. /**
  55746. * Reference to the Recast library
  55747. */
  55748. bjsRECAST: any;
  55749. /**
  55750. * plugin name
  55751. */
  55752. name: string;
  55753. /**
  55754. * the first navmesh created. We might extend this to support multiple navmeshes
  55755. */
  55756. navMesh: any;
  55757. /**
  55758. * Initializes the recastJS plugin
  55759. * @param recastInjection can be used to inject your own recast reference
  55760. */
  55761. constructor(recastInjection?: any);
  55762. /**
  55763. * Creates a navigation mesh
  55764. * @param meshes array of all the geometry used to compute the navigatio mesh
  55765. * @param parameters bunch of parameters used to filter geometry
  55766. */
  55767. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55768. /**
  55769. * Create a navigation mesh debug mesh
  55770. * @param scene is where the mesh will be added
  55771. * @returns debug display mesh
  55772. */
  55773. createDebugNavMesh(scene: Scene): Mesh;
  55774. /**
  55775. * Get a navigation mesh constrained position, closest to the parameter position
  55776. * @param position world position
  55777. * @returns the closest point to position constrained by the navigation mesh
  55778. */
  55779. getClosestPoint(position: Vector3): Vector3;
  55780. /**
  55781. * Get a navigation mesh constrained position, within a particular radius
  55782. * @param position world position
  55783. * @param maxRadius the maximum distance to the constrained world position
  55784. * @returns the closest point to position constrained by the navigation mesh
  55785. */
  55786. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55787. /**
  55788. * Compute the final position from a segment made of destination-position
  55789. * @param position world position
  55790. * @param destination world position
  55791. * @returns the resulting point along the navmesh
  55792. */
  55793. moveAlong(position: Vector3, destination: Vector3): Vector3;
  55794. /**
  55795. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55796. * @param start world position
  55797. * @param end world position
  55798. * @returns array containing world position composing the path
  55799. */
  55800. computePath(start: Vector3, end: Vector3): Vector3[];
  55801. /**
  55802. * Create a new Crowd so you can add agents
  55803. * @param maxAgents the maximum agent count in the crowd
  55804. * @param maxAgentRadius the maximum radius an agent can have
  55805. * @param scene to attach the crowd to
  55806. * @returns the crowd you can add agents to
  55807. */
  55808. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55809. /**
  55810. * Disposes
  55811. */
  55812. dispose(): void;
  55813. /**
  55814. * If this plugin is supported
  55815. * @returns true if plugin is supported
  55816. */
  55817. isSupported(): boolean;
  55818. }
  55819. /**
  55820. * Recast detour crowd implementation
  55821. */
  55822. export class RecastJSCrowd implements ICrowd {
  55823. /**
  55824. * Recast/detour plugin
  55825. */
  55826. bjsRECASTPlugin: RecastJSPlugin;
  55827. /**
  55828. * Link to the detour crowd
  55829. */
  55830. recastCrowd: any;
  55831. /**
  55832. * One transform per agent
  55833. */
  55834. transforms: TransformNode[];
  55835. /**
  55836. * All agents created
  55837. */
  55838. agents: number[];
  55839. /**
  55840. * Link to the scene is kept to unregister the crowd from the scene
  55841. */
  55842. private _scene;
  55843. /**
  55844. * Observer for crowd updates
  55845. */
  55846. private _onBeforeAnimationsObserver;
  55847. /**
  55848. * Constructor
  55849. * @param plugin recastJS plugin
  55850. * @param maxAgents the maximum agent count in the crowd
  55851. * @param maxAgentRadius the maximum radius an agent can have
  55852. * @param scene to attach the crowd to
  55853. * @returns the crowd you can add agents to
  55854. */
  55855. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  55856. /**
  55857. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55858. * You can attach anything to that node. The node position is updated in the scene update tick.
  55859. * @param pos world position that will be constrained by the navigation mesh
  55860. * @param parameters agent parameters
  55861. * @param transform hooked to the agent that will be update by the scene
  55862. * @returns agent index
  55863. */
  55864. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55865. /**
  55866. * Returns the agent position in world space
  55867. * @param index agent index returned by addAgent
  55868. * @returns world space position
  55869. */
  55870. getAgentPosition(index: number): Vector3;
  55871. /**
  55872. * Returns the agent velocity in world space
  55873. * @param index agent index returned by addAgent
  55874. * @returns world space velocity
  55875. */
  55876. getAgentVelocity(index: number): Vector3;
  55877. /**
  55878. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55879. * @param index agent index returned by addAgent
  55880. * @param destination targeted world position
  55881. */
  55882. agentGoto(index: number, destination: Vector3): void;
  55883. /**
  55884. * remove a particular agent previously created
  55885. * @param index agent index returned by addAgent
  55886. */
  55887. removeAgent(index: number): void;
  55888. /**
  55889. * get the list of all agents attached to this crowd
  55890. * @returns list of agent indices
  55891. */
  55892. getAgents(): number[];
  55893. /**
  55894. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55895. * @param deltaTime in seconds
  55896. */
  55897. update(deltaTime: number): void;
  55898. /**
  55899. * Release all resources
  55900. */
  55901. dispose(): void;
  55902. }
  55903. }
  55904. declare module BABYLON {
  55905. /**
  55906. * Class used to enable access to IndexedDB
  55907. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  55908. */
  55909. export class Database implements IOfflineProvider {
  55910. private _callbackManifestChecked;
  55911. private _currentSceneUrl;
  55912. private _db;
  55913. private _enableSceneOffline;
  55914. private _enableTexturesOffline;
  55915. private _manifestVersionFound;
  55916. private _mustUpdateRessources;
  55917. private _hasReachedQuota;
  55918. private _isSupported;
  55919. private _idbFactory;
  55920. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  55921. private static IsUASupportingBlobStorage;
  55922. /**
  55923. * Gets a boolean indicating if Database storate is enabled (off by default)
  55924. */
  55925. static IDBStorageEnabled: boolean;
  55926. /**
  55927. * Gets a boolean indicating if scene must be saved in the database
  55928. */
  55929. readonly enableSceneOffline: boolean;
  55930. /**
  55931. * Gets a boolean indicating if textures must be saved in the database
  55932. */
  55933. readonly enableTexturesOffline: boolean;
  55934. /**
  55935. * Creates a new Database
  55936. * @param urlToScene defines the url to load the scene
  55937. * @param callbackManifestChecked defines the callback to use when manifest is checked
  55938. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  55939. */
  55940. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  55941. private static _ParseURL;
  55942. private static _ReturnFullUrlLocation;
  55943. private _checkManifestFile;
  55944. /**
  55945. * Open the database and make it available
  55946. * @param successCallback defines the callback to call on success
  55947. * @param errorCallback defines the callback to call on error
  55948. */
  55949. open(successCallback: () => void, errorCallback: () => void): void;
  55950. /**
  55951. * Loads an image from the database
  55952. * @param url defines the url to load from
  55953. * @param image defines the target DOM image
  55954. */
  55955. loadImage(url: string, image: HTMLImageElement): void;
  55956. private _loadImageFromDBAsync;
  55957. private _saveImageIntoDBAsync;
  55958. private _checkVersionFromDB;
  55959. private _loadVersionFromDBAsync;
  55960. private _saveVersionIntoDBAsync;
  55961. /**
  55962. * Loads a file from database
  55963. * @param url defines the URL to load from
  55964. * @param sceneLoaded defines a callback to call on success
  55965. * @param progressCallBack defines a callback to call when progress changed
  55966. * @param errorCallback defines a callback to call on error
  55967. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  55968. */
  55969. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  55970. private _loadFileAsync;
  55971. private _saveFileAsync;
  55972. /**
  55973. * Validates if xhr data is correct
  55974. * @param xhr defines the request to validate
  55975. * @param dataType defines the expected data type
  55976. * @returns true if data is correct
  55977. */
  55978. private static _ValidateXHRData;
  55979. }
  55980. }
  55981. declare module BABYLON {
  55982. /** @hidden */
  55983. export var gpuUpdateParticlesPixelShader: {
  55984. name: string;
  55985. shader: string;
  55986. };
  55987. }
  55988. declare module BABYLON {
  55989. /** @hidden */
  55990. export var gpuUpdateParticlesVertexShader: {
  55991. name: string;
  55992. shader: string;
  55993. };
  55994. }
  55995. declare module BABYLON {
  55996. /** @hidden */
  55997. export var clipPlaneFragmentDeclaration2: {
  55998. name: string;
  55999. shader: string;
  56000. };
  56001. }
  56002. declare module BABYLON {
  56003. /** @hidden */
  56004. export var gpuRenderParticlesPixelShader: {
  56005. name: string;
  56006. shader: string;
  56007. };
  56008. }
  56009. declare module BABYLON {
  56010. /** @hidden */
  56011. export var clipPlaneVertexDeclaration2: {
  56012. name: string;
  56013. shader: string;
  56014. };
  56015. }
  56016. declare module BABYLON {
  56017. /** @hidden */
  56018. export var gpuRenderParticlesVertexShader: {
  56019. name: string;
  56020. shader: string;
  56021. };
  56022. }
  56023. declare module BABYLON {
  56024. /**
  56025. * This represents a GPU particle system in Babylon
  56026. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56027. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56028. */
  56029. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56030. /**
  56031. * The layer mask we are rendering the particles through.
  56032. */
  56033. layerMask: number;
  56034. private _capacity;
  56035. private _activeCount;
  56036. private _currentActiveCount;
  56037. private _accumulatedCount;
  56038. private _renderEffect;
  56039. private _updateEffect;
  56040. private _buffer0;
  56041. private _buffer1;
  56042. private _spriteBuffer;
  56043. private _updateVAO;
  56044. private _renderVAO;
  56045. private _targetIndex;
  56046. private _sourceBuffer;
  56047. private _targetBuffer;
  56048. private _engine;
  56049. private _currentRenderId;
  56050. private _started;
  56051. private _stopped;
  56052. private _timeDelta;
  56053. private _randomTexture;
  56054. private _randomTexture2;
  56055. private _attributesStrideSize;
  56056. private _updateEffectOptions;
  56057. private _randomTextureSize;
  56058. private _actualFrame;
  56059. private readonly _rawTextureWidth;
  56060. /**
  56061. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56062. */
  56063. static readonly IsSupported: boolean;
  56064. /**
  56065. * An event triggered when the system is disposed.
  56066. */
  56067. onDisposeObservable: Observable<GPUParticleSystem>;
  56068. /**
  56069. * Gets the maximum number of particles active at the same time.
  56070. * @returns The max number of active particles.
  56071. */
  56072. getCapacity(): number;
  56073. /**
  56074. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56075. * to override the particles.
  56076. */
  56077. forceDepthWrite: boolean;
  56078. /**
  56079. * Gets or set the number of active particles
  56080. */
  56081. activeParticleCount: number;
  56082. private _preWarmDone;
  56083. /**
  56084. * Is this system ready to be used/rendered
  56085. * @return true if the system is ready
  56086. */
  56087. isReady(): boolean;
  56088. /**
  56089. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56090. * @returns True if it has been started, otherwise false.
  56091. */
  56092. isStarted(): boolean;
  56093. /**
  56094. * Starts the particle system and begins to emit
  56095. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56096. */
  56097. start(delay?: number): void;
  56098. /**
  56099. * Stops the particle system.
  56100. */
  56101. stop(): void;
  56102. /**
  56103. * Remove all active particles
  56104. */
  56105. reset(): void;
  56106. /**
  56107. * Returns the string "GPUParticleSystem"
  56108. * @returns a string containing the class name
  56109. */
  56110. getClassName(): string;
  56111. private _colorGradientsTexture;
  56112. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56113. /**
  56114. * Adds a new color gradient
  56115. * @param gradient defines the gradient to use (between 0 and 1)
  56116. * @param color1 defines the color to affect to the specified gradient
  56117. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56118. * @returns the current particle system
  56119. */
  56120. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56121. /**
  56122. * Remove a specific color gradient
  56123. * @param gradient defines the gradient to remove
  56124. * @returns the current particle system
  56125. */
  56126. removeColorGradient(gradient: number): GPUParticleSystem;
  56127. private _angularSpeedGradientsTexture;
  56128. private _sizeGradientsTexture;
  56129. private _velocityGradientsTexture;
  56130. private _limitVelocityGradientsTexture;
  56131. private _dragGradientsTexture;
  56132. private _addFactorGradient;
  56133. /**
  56134. * Adds a new size gradient
  56135. * @param gradient defines the gradient to use (between 0 and 1)
  56136. * @param factor defines the size factor to affect to the specified gradient
  56137. * @returns the current particle system
  56138. */
  56139. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56140. /**
  56141. * Remove a specific size gradient
  56142. * @param gradient defines the gradient to remove
  56143. * @returns the current particle system
  56144. */
  56145. removeSizeGradient(gradient: number): GPUParticleSystem;
  56146. /**
  56147. * Adds a new angular speed gradient
  56148. * @param gradient defines the gradient to use (between 0 and 1)
  56149. * @param factor defines the angular speed to affect to the specified gradient
  56150. * @returns the current particle system
  56151. */
  56152. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56153. /**
  56154. * Remove a specific angular speed gradient
  56155. * @param gradient defines the gradient to remove
  56156. * @returns the current particle system
  56157. */
  56158. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56159. /**
  56160. * Adds a new velocity gradient
  56161. * @param gradient defines the gradient to use (between 0 and 1)
  56162. * @param factor defines the velocity to affect to the specified gradient
  56163. * @returns the current particle system
  56164. */
  56165. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56166. /**
  56167. * Remove a specific velocity gradient
  56168. * @param gradient defines the gradient to remove
  56169. * @returns the current particle system
  56170. */
  56171. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56172. /**
  56173. * Adds a new limit velocity gradient
  56174. * @param gradient defines the gradient to use (between 0 and 1)
  56175. * @param factor defines the limit velocity value to affect to the specified gradient
  56176. * @returns the current particle system
  56177. */
  56178. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56179. /**
  56180. * Remove a specific limit velocity gradient
  56181. * @param gradient defines the gradient to remove
  56182. * @returns the current particle system
  56183. */
  56184. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56185. /**
  56186. * Adds a new drag gradient
  56187. * @param gradient defines the gradient to use (between 0 and 1)
  56188. * @param factor defines the drag value to affect to the specified gradient
  56189. * @returns the current particle system
  56190. */
  56191. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56192. /**
  56193. * Remove a specific drag gradient
  56194. * @param gradient defines the gradient to remove
  56195. * @returns the current particle system
  56196. */
  56197. removeDragGradient(gradient: number): GPUParticleSystem;
  56198. /**
  56199. * Not supported by GPUParticleSystem
  56200. * @param gradient defines the gradient to use (between 0 and 1)
  56201. * @param factor defines the emit rate value to affect to the specified gradient
  56202. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56203. * @returns the current particle system
  56204. */
  56205. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56206. /**
  56207. * Not supported by GPUParticleSystem
  56208. * @param gradient defines the gradient to remove
  56209. * @returns the current particle system
  56210. */
  56211. removeEmitRateGradient(gradient: number): IParticleSystem;
  56212. /**
  56213. * Not supported by GPUParticleSystem
  56214. * @param gradient defines the gradient to use (between 0 and 1)
  56215. * @param factor defines the start size value to affect to the specified gradient
  56216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56217. * @returns the current particle system
  56218. */
  56219. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56220. /**
  56221. * Not supported by GPUParticleSystem
  56222. * @param gradient defines the gradient to remove
  56223. * @returns the current particle system
  56224. */
  56225. removeStartSizeGradient(gradient: number): IParticleSystem;
  56226. /**
  56227. * Not supported by GPUParticleSystem
  56228. * @param gradient defines the gradient to use (between 0 and 1)
  56229. * @param min defines the color remap minimal range
  56230. * @param max defines the color remap maximal range
  56231. * @returns the current particle system
  56232. */
  56233. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56234. /**
  56235. * Not supported by GPUParticleSystem
  56236. * @param gradient defines the gradient to remove
  56237. * @returns the current particle system
  56238. */
  56239. removeColorRemapGradient(): IParticleSystem;
  56240. /**
  56241. * Not supported by GPUParticleSystem
  56242. * @param gradient defines the gradient to use (between 0 and 1)
  56243. * @param min defines the alpha remap minimal range
  56244. * @param max defines the alpha remap maximal range
  56245. * @returns the current particle system
  56246. */
  56247. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56248. /**
  56249. * Not supported by GPUParticleSystem
  56250. * @param gradient defines the gradient to remove
  56251. * @returns the current particle system
  56252. */
  56253. removeAlphaRemapGradient(): IParticleSystem;
  56254. /**
  56255. * Not supported by GPUParticleSystem
  56256. * @param gradient defines the gradient to use (between 0 and 1)
  56257. * @param color defines the color to affect to the specified gradient
  56258. * @returns the current particle system
  56259. */
  56260. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56261. /**
  56262. * Not supported by GPUParticleSystem
  56263. * @param gradient defines the gradient to remove
  56264. * @returns the current particle system
  56265. */
  56266. removeRampGradient(): IParticleSystem;
  56267. /**
  56268. * Not supported by GPUParticleSystem
  56269. * @returns the list of ramp gradients
  56270. */
  56271. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56272. /**
  56273. * Not supported by GPUParticleSystem
  56274. * Gets or sets a boolean indicating that ramp gradients must be used
  56275. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56276. */
  56277. useRampGradients: boolean;
  56278. /**
  56279. * Not supported by GPUParticleSystem
  56280. * @param gradient defines the gradient to use (between 0 and 1)
  56281. * @param factor defines the life time factor to affect to the specified gradient
  56282. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56283. * @returns the current particle system
  56284. */
  56285. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56286. /**
  56287. * Not supported by GPUParticleSystem
  56288. * @param gradient defines the gradient to remove
  56289. * @returns the current particle system
  56290. */
  56291. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56292. /**
  56293. * Instantiates a GPU particle system.
  56294. * 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.
  56295. * @param name The name of the particle system
  56296. * @param options The options used to create the system
  56297. * @param scene The scene the particle system belongs to
  56298. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56299. */
  56300. constructor(name: string, options: Partial<{
  56301. capacity: number;
  56302. randomTextureSize: number;
  56303. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56304. protected _reset(): void;
  56305. private _createUpdateVAO;
  56306. private _createRenderVAO;
  56307. private _initialize;
  56308. /** @hidden */
  56309. _recreateUpdateEffect(): void;
  56310. /** @hidden */
  56311. _recreateRenderEffect(): void;
  56312. /**
  56313. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56314. * @param preWarm defines if we are in the pre-warmimg phase
  56315. */
  56316. animate(preWarm?: boolean): void;
  56317. private _createFactorGradientTexture;
  56318. private _createSizeGradientTexture;
  56319. private _createAngularSpeedGradientTexture;
  56320. private _createVelocityGradientTexture;
  56321. private _createLimitVelocityGradientTexture;
  56322. private _createDragGradientTexture;
  56323. private _createColorGradientTexture;
  56324. /**
  56325. * Renders the particle system in its current state
  56326. * @param preWarm defines if the system should only update the particles but not render them
  56327. * @returns the current number of particles
  56328. */
  56329. render(preWarm?: boolean): number;
  56330. /**
  56331. * Rebuilds the particle system
  56332. */
  56333. rebuild(): void;
  56334. private _releaseBuffers;
  56335. private _releaseVAOs;
  56336. /**
  56337. * Disposes the particle system and free the associated resources
  56338. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56339. */
  56340. dispose(disposeTexture?: boolean): void;
  56341. /**
  56342. * Clones the particle system.
  56343. * @param name The name of the cloned object
  56344. * @param newEmitter The new emitter to use
  56345. * @returns the cloned particle system
  56346. */
  56347. clone(name: string, newEmitter: any): GPUParticleSystem;
  56348. /**
  56349. * Serializes the particle system to a JSON object.
  56350. * @returns the JSON object
  56351. */
  56352. serialize(): any;
  56353. /**
  56354. * Parses a JSON object to create a GPU particle system.
  56355. * @param parsedParticleSystem The JSON object to parse
  56356. * @param scene The scene to create the particle system in
  56357. * @param rootUrl The root url to use to load external dependencies like texture
  56358. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56359. * @returns the parsed GPU particle system
  56360. */
  56361. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56362. }
  56363. }
  56364. declare module BABYLON {
  56365. /**
  56366. * Represents a set of particle systems working together to create a specific effect
  56367. */
  56368. export class ParticleSystemSet implements IDisposable {
  56369. private _emitterCreationOptions;
  56370. private _emitterNode;
  56371. /**
  56372. * Gets the particle system list
  56373. */
  56374. systems: IParticleSystem[];
  56375. /**
  56376. * Gets the emitter node used with this set
  56377. */
  56378. readonly emitterNode: Nullable<TransformNode>;
  56379. /**
  56380. * Creates a new emitter mesh as a sphere
  56381. * @param options defines the options used to create the sphere
  56382. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56383. * @param scene defines the hosting scene
  56384. */
  56385. setEmitterAsSphere(options: {
  56386. diameter: number;
  56387. segments: number;
  56388. color: Color3;
  56389. }, renderingGroupId: number, scene: Scene): void;
  56390. /**
  56391. * Starts all particle systems of the set
  56392. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56393. */
  56394. start(emitter?: AbstractMesh): void;
  56395. /**
  56396. * Release all associated resources
  56397. */
  56398. dispose(): void;
  56399. /**
  56400. * Serialize the set into a JSON compatible object
  56401. * @returns a JSON compatible representation of the set
  56402. */
  56403. serialize(): any;
  56404. /**
  56405. * Parse a new ParticleSystemSet from a serialized source
  56406. * @param data defines a JSON compatible representation of the set
  56407. * @param scene defines the hosting scene
  56408. * @param gpu defines if we want GPU particles or CPU particles
  56409. * @returns a new ParticleSystemSet
  56410. */
  56411. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56412. }
  56413. }
  56414. declare module BABYLON {
  56415. /**
  56416. * This class is made for on one-liner static method to help creating particle system set.
  56417. */
  56418. export class ParticleHelper {
  56419. /**
  56420. * Gets or sets base Assets URL
  56421. */
  56422. static BaseAssetsUrl: string;
  56423. /**
  56424. * Create a default particle system that you can tweak
  56425. * @param emitter defines the emitter to use
  56426. * @param capacity defines the system capacity (default is 500 particles)
  56427. * @param scene defines the hosting scene
  56428. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56429. * @returns the new Particle system
  56430. */
  56431. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56432. /**
  56433. * This is the main static method (one-liner) of this helper to create different particle systems
  56434. * @param type This string represents the type to the particle system to create
  56435. * @param scene The scene where the particle system should live
  56436. * @param gpu If the system will use gpu
  56437. * @returns the ParticleSystemSet created
  56438. */
  56439. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56440. /**
  56441. * Static function used to export a particle system to a ParticleSystemSet variable.
  56442. * Please note that the emitter shape is not exported
  56443. * @param systems defines the particle systems to export
  56444. * @returns the created particle system set
  56445. */
  56446. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56447. }
  56448. }
  56449. declare module BABYLON {
  56450. interface Engine {
  56451. /**
  56452. * Create an effect to use with particle systems.
  56453. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56454. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56455. * @param uniformsNames defines a list of attribute names
  56456. * @param samplers defines an array of string used to represent textures
  56457. * @param defines defines the string containing the defines to use to compile the shaders
  56458. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56459. * @param onCompiled defines a function to call when the effect creation is successful
  56460. * @param onError defines a function to call when the effect creation has failed
  56461. * @returns the new Effect
  56462. */
  56463. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56464. }
  56465. interface Mesh {
  56466. /**
  56467. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56468. * @returns an array of IParticleSystem
  56469. */
  56470. getEmittedParticleSystems(): IParticleSystem[];
  56471. /**
  56472. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56473. * @returns an array of IParticleSystem
  56474. */
  56475. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56476. }
  56477. /**
  56478. * @hidden
  56479. */
  56480. export var _IDoNeedToBeInTheBuild: number;
  56481. }
  56482. declare module BABYLON {
  56483. interface Scene {
  56484. /** @hidden (Backing field) */
  56485. _physicsEngine: Nullable<IPhysicsEngine>;
  56486. /**
  56487. * Gets the current physics engine
  56488. * @returns a IPhysicsEngine or null if none attached
  56489. */
  56490. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56491. /**
  56492. * Enables physics to the current scene
  56493. * @param gravity defines the scene's gravity for the physics engine
  56494. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56495. * @return a boolean indicating if the physics engine was initialized
  56496. */
  56497. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56498. /**
  56499. * Disables and disposes the physics engine associated with the scene
  56500. */
  56501. disablePhysicsEngine(): void;
  56502. /**
  56503. * Gets a boolean indicating if there is an active physics engine
  56504. * @returns a boolean indicating if there is an active physics engine
  56505. */
  56506. isPhysicsEnabled(): boolean;
  56507. /**
  56508. * Deletes a physics compound impostor
  56509. * @param compound defines the compound to delete
  56510. */
  56511. deleteCompoundImpostor(compound: any): void;
  56512. /**
  56513. * An event triggered when physic simulation is about to be run
  56514. */
  56515. onBeforePhysicsObservable: Observable<Scene>;
  56516. /**
  56517. * An event triggered when physic simulation has been done
  56518. */
  56519. onAfterPhysicsObservable: Observable<Scene>;
  56520. }
  56521. interface AbstractMesh {
  56522. /** @hidden */
  56523. _physicsImpostor: Nullable<PhysicsImpostor>;
  56524. /**
  56525. * Gets or sets impostor used for physic simulation
  56526. * @see http://doc.babylonjs.com/features/physics_engine
  56527. */
  56528. physicsImpostor: Nullable<PhysicsImpostor>;
  56529. /**
  56530. * Gets the current physics impostor
  56531. * @see http://doc.babylonjs.com/features/physics_engine
  56532. * @returns a physics impostor or null
  56533. */
  56534. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56535. /** Apply a physic impulse to the mesh
  56536. * @param force defines the force to apply
  56537. * @param contactPoint defines where to apply the force
  56538. * @returns the current mesh
  56539. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56540. */
  56541. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56542. /**
  56543. * Creates a physic joint between two meshes
  56544. * @param otherMesh defines the other mesh to use
  56545. * @param pivot1 defines the pivot to use on this mesh
  56546. * @param pivot2 defines the pivot to use on the other mesh
  56547. * @param options defines additional options (can be plugin dependent)
  56548. * @returns the current mesh
  56549. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56550. */
  56551. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56552. /** @hidden */
  56553. _disposePhysicsObserver: Nullable<Observer<Node>>;
  56554. }
  56555. /**
  56556. * Defines the physics engine scene component responsible to manage a physics engine
  56557. */
  56558. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56559. /**
  56560. * The component name helpful to identify the component in the list of scene components.
  56561. */
  56562. readonly name: string;
  56563. /**
  56564. * The scene the component belongs to.
  56565. */
  56566. scene: Scene;
  56567. /**
  56568. * Creates a new instance of the component for the given scene
  56569. * @param scene Defines the scene to register the component in
  56570. */
  56571. constructor(scene: Scene);
  56572. /**
  56573. * Registers the component in a given scene
  56574. */
  56575. register(): void;
  56576. /**
  56577. * Rebuilds the elements related to this component in case of
  56578. * context lost for instance.
  56579. */
  56580. rebuild(): void;
  56581. /**
  56582. * Disposes the component and the associated ressources
  56583. */
  56584. dispose(): void;
  56585. }
  56586. }
  56587. declare module BABYLON {
  56588. /**
  56589. * A helper for physics simulations
  56590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56591. */
  56592. export class PhysicsHelper {
  56593. private _scene;
  56594. private _physicsEngine;
  56595. /**
  56596. * Initializes the Physics helper
  56597. * @param scene Babylon.js scene
  56598. */
  56599. constructor(scene: Scene);
  56600. /**
  56601. * Applies a radial explosion impulse
  56602. * @param origin the origin of the explosion
  56603. * @param radiusOrEventOptions the radius or the options of radial explosion
  56604. * @param strength the explosion strength
  56605. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56606. * @returns A physics radial explosion event, or null
  56607. */
  56608. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56609. /**
  56610. * Applies a radial explosion force
  56611. * @param origin the origin of the explosion
  56612. * @param radiusOrEventOptions the radius or the options of radial explosion
  56613. * @param strength the explosion strength
  56614. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56615. * @returns A physics radial explosion event, or null
  56616. */
  56617. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56618. /**
  56619. * Creates a gravitational field
  56620. * @param origin the origin of the explosion
  56621. * @param radiusOrEventOptions the radius or the options of radial explosion
  56622. * @param strength the explosion strength
  56623. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56624. * @returns A physics gravitational field event, or null
  56625. */
  56626. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56627. /**
  56628. * Creates a physics updraft event
  56629. * @param origin the origin of the updraft
  56630. * @param radiusOrEventOptions the radius or the options of the updraft
  56631. * @param strength the strength of the updraft
  56632. * @param height the height of the updraft
  56633. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56634. * @returns A physics updraft event, or null
  56635. */
  56636. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56637. /**
  56638. * Creates a physics vortex event
  56639. * @param origin the of the vortex
  56640. * @param radiusOrEventOptions the radius or the options of the vortex
  56641. * @param strength the strength of the vortex
  56642. * @param height the height of the vortex
  56643. * @returns a Physics vortex event, or null
  56644. * A physics vortex event or null
  56645. */
  56646. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56647. }
  56648. /**
  56649. * Represents a physics radial explosion event
  56650. */
  56651. class PhysicsRadialExplosionEvent {
  56652. private _scene;
  56653. private _options;
  56654. private _sphere;
  56655. private _dataFetched;
  56656. /**
  56657. * Initializes a radial explosioin event
  56658. * @param _scene BabylonJS scene
  56659. * @param _options The options for the vortex event
  56660. */
  56661. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56662. /**
  56663. * Returns the data related to the radial explosion event (sphere).
  56664. * @returns The radial explosion event data
  56665. */
  56666. getData(): PhysicsRadialExplosionEventData;
  56667. /**
  56668. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56669. * @param impostor A physics imposter
  56670. * @param origin the origin of the explosion
  56671. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56672. */
  56673. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56674. /**
  56675. * Triggers affecterd impostors callbacks
  56676. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56677. */
  56678. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56679. /**
  56680. * Disposes the sphere.
  56681. * @param force Specifies if the sphere should be disposed by force
  56682. */
  56683. dispose(force?: boolean): void;
  56684. /*** Helpers ***/
  56685. private _prepareSphere;
  56686. private _intersectsWithSphere;
  56687. }
  56688. /**
  56689. * Represents a gravitational field event
  56690. */
  56691. class PhysicsGravitationalFieldEvent {
  56692. private _physicsHelper;
  56693. private _scene;
  56694. private _origin;
  56695. private _options;
  56696. private _tickCallback;
  56697. private _sphere;
  56698. private _dataFetched;
  56699. /**
  56700. * Initializes the physics gravitational field event
  56701. * @param _physicsHelper A physics helper
  56702. * @param _scene BabylonJS scene
  56703. * @param _origin The origin position of the gravitational field event
  56704. * @param _options The options for the vortex event
  56705. */
  56706. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56707. /**
  56708. * Returns the data related to the gravitational field event (sphere).
  56709. * @returns A gravitational field event
  56710. */
  56711. getData(): PhysicsGravitationalFieldEventData;
  56712. /**
  56713. * Enables the gravitational field.
  56714. */
  56715. enable(): void;
  56716. /**
  56717. * Disables the gravitational field.
  56718. */
  56719. disable(): void;
  56720. /**
  56721. * Disposes the sphere.
  56722. * @param force The force to dispose from the gravitational field event
  56723. */
  56724. dispose(force?: boolean): void;
  56725. private _tick;
  56726. }
  56727. /**
  56728. * Represents a physics updraft event
  56729. */
  56730. class PhysicsUpdraftEvent {
  56731. private _scene;
  56732. private _origin;
  56733. private _options;
  56734. private _physicsEngine;
  56735. private _originTop;
  56736. private _originDirection;
  56737. private _tickCallback;
  56738. private _cylinder;
  56739. private _cylinderPosition;
  56740. private _dataFetched;
  56741. /**
  56742. * Initializes the physics updraft event
  56743. * @param _scene BabylonJS scene
  56744. * @param _origin The origin position of the updraft
  56745. * @param _options The options for the updraft event
  56746. */
  56747. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56748. /**
  56749. * Returns the data related to the updraft event (cylinder).
  56750. * @returns A physics updraft event
  56751. */
  56752. getData(): PhysicsUpdraftEventData;
  56753. /**
  56754. * Enables the updraft.
  56755. */
  56756. enable(): void;
  56757. /**
  56758. * Disables the updraft.
  56759. */
  56760. disable(): void;
  56761. /**
  56762. * Disposes the cylinder.
  56763. * @param force Specifies if the updraft should be disposed by force
  56764. */
  56765. dispose(force?: boolean): void;
  56766. private getImpostorHitData;
  56767. private _tick;
  56768. /*** Helpers ***/
  56769. private _prepareCylinder;
  56770. private _intersectsWithCylinder;
  56771. }
  56772. /**
  56773. * Represents a physics vortex event
  56774. */
  56775. class PhysicsVortexEvent {
  56776. private _scene;
  56777. private _origin;
  56778. private _options;
  56779. private _physicsEngine;
  56780. private _originTop;
  56781. private _tickCallback;
  56782. private _cylinder;
  56783. private _cylinderPosition;
  56784. private _dataFetched;
  56785. /**
  56786. * Initializes the physics vortex event
  56787. * @param _scene The BabylonJS scene
  56788. * @param _origin The origin position of the vortex
  56789. * @param _options The options for the vortex event
  56790. */
  56791. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  56792. /**
  56793. * Returns the data related to the vortex event (cylinder).
  56794. * @returns The physics vortex event data
  56795. */
  56796. getData(): PhysicsVortexEventData;
  56797. /**
  56798. * Enables the vortex.
  56799. */
  56800. enable(): void;
  56801. /**
  56802. * Disables the cortex.
  56803. */
  56804. disable(): void;
  56805. /**
  56806. * Disposes the sphere.
  56807. * @param force
  56808. */
  56809. dispose(force?: boolean): void;
  56810. private getImpostorHitData;
  56811. private _tick;
  56812. /*** Helpers ***/
  56813. private _prepareCylinder;
  56814. private _intersectsWithCylinder;
  56815. }
  56816. /**
  56817. * Options fot the radial explosion event
  56818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56819. */
  56820. export class PhysicsRadialExplosionEventOptions {
  56821. /**
  56822. * The radius of the sphere for the radial explosion.
  56823. */
  56824. radius: number;
  56825. /**
  56826. * The strenth of the explosion.
  56827. */
  56828. strength: number;
  56829. /**
  56830. * The strenght of the force in correspondence to the distance of the affected object
  56831. */
  56832. falloff: PhysicsRadialImpulseFalloff;
  56833. /**
  56834. * Sphere options for the radial explosion.
  56835. */
  56836. sphere: {
  56837. segments: number;
  56838. diameter: number;
  56839. };
  56840. /**
  56841. * Sphere options for the radial explosion.
  56842. */
  56843. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  56844. }
  56845. /**
  56846. * Options fot the updraft event
  56847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56848. */
  56849. export class PhysicsUpdraftEventOptions {
  56850. /**
  56851. * The radius of the cylinder for the vortex
  56852. */
  56853. radius: number;
  56854. /**
  56855. * The strenth of the updraft.
  56856. */
  56857. strength: number;
  56858. /**
  56859. * The height of the cylinder for the updraft.
  56860. */
  56861. height: number;
  56862. /**
  56863. * The mode for the the updraft.
  56864. */
  56865. updraftMode: PhysicsUpdraftMode;
  56866. }
  56867. /**
  56868. * Options fot the vortex event
  56869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56870. */
  56871. export class PhysicsVortexEventOptions {
  56872. /**
  56873. * The radius of the cylinder for the vortex
  56874. */
  56875. radius: number;
  56876. /**
  56877. * The strenth of the vortex.
  56878. */
  56879. strength: number;
  56880. /**
  56881. * The height of the cylinder for the vortex.
  56882. */
  56883. height: number;
  56884. /**
  56885. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  56886. */
  56887. centripetalForceThreshold: number;
  56888. /**
  56889. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  56890. */
  56891. centripetalForceMultiplier: number;
  56892. /**
  56893. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  56894. */
  56895. centrifugalForceMultiplier: number;
  56896. /**
  56897. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  56898. */
  56899. updraftForceMultiplier: number;
  56900. }
  56901. /**
  56902. * The strenght of the force in correspondence to the distance of the affected object
  56903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56904. */
  56905. export enum PhysicsRadialImpulseFalloff {
  56906. /** Defines that impulse is constant in strength across it's whole radius */
  56907. Constant = 0,
  56908. /** Defines that impulse gets weaker if it's further from the origin */
  56909. Linear = 1
  56910. }
  56911. /**
  56912. * The strength of the force in correspondence to the distance of the affected object
  56913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56914. */
  56915. export enum PhysicsUpdraftMode {
  56916. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  56917. Center = 0,
  56918. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  56919. Perpendicular = 1
  56920. }
  56921. /**
  56922. * Interface for a physics hit data
  56923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56924. */
  56925. export interface PhysicsHitData {
  56926. /**
  56927. * The force applied at the contact point
  56928. */
  56929. force: Vector3;
  56930. /**
  56931. * The contact point
  56932. */
  56933. contactPoint: Vector3;
  56934. /**
  56935. * The distance from the origin to the contact point
  56936. */
  56937. distanceFromOrigin: number;
  56938. }
  56939. /**
  56940. * Interface for radial explosion event data
  56941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56942. */
  56943. export interface PhysicsRadialExplosionEventData {
  56944. /**
  56945. * A sphere used for the radial explosion event
  56946. */
  56947. sphere: Mesh;
  56948. }
  56949. /**
  56950. * Interface for gravitational field event data
  56951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56952. */
  56953. export interface PhysicsGravitationalFieldEventData {
  56954. /**
  56955. * A sphere mesh used for the gravitational field event
  56956. */
  56957. sphere: Mesh;
  56958. }
  56959. /**
  56960. * Interface for updraft event data
  56961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56962. */
  56963. export interface PhysicsUpdraftEventData {
  56964. /**
  56965. * A cylinder used for the updraft event
  56966. */
  56967. cylinder: Mesh;
  56968. }
  56969. /**
  56970. * Interface for vortex event data
  56971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56972. */
  56973. export interface PhysicsVortexEventData {
  56974. /**
  56975. * A cylinder used for the vortex event
  56976. */
  56977. cylinder: Mesh;
  56978. }
  56979. /**
  56980. * Interface for an affected physics impostor
  56981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56982. */
  56983. export interface PhysicsAffectedImpostorWithData {
  56984. /**
  56985. * The impostor affected by the effect
  56986. */
  56987. impostor: PhysicsImpostor;
  56988. /**
  56989. * The data about the hit/horce from the explosion
  56990. */
  56991. hitData: PhysicsHitData;
  56992. }
  56993. }
  56994. declare module BABYLON {
  56995. /** @hidden */
  56996. export var blackAndWhitePixelShader: {
  56997. name: string;
  56998. shader: string;
  56999. };
  57000. }
  57001. declare module BABYLON {
  57002. /**
  57003. * Post process used to render in black and white
  57004. */
  57005. export class BlackAndWhitePostProcess extends PostProcess {
  57006. /**
  57007. * Linear about to convert he result to black and white (default: 1)
  57008. */
  57009. degree: number;
  57010. /**
  57011. * Creates a black and white post process
  57012. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57013. * @param name The name of the effect.
  57014. * @param options The required width/height ratio to downsize to before computing the render pass.
  57015. * @param camera The camera to apply the render pass to.
  57016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57017. * @param engine The engine which the post process will be applied. (default: current engine)
  57018. * @param reusable If the post process can be reused on the same frame. (default: false)
  57019. */
  57020. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57021. }
  57022. }
  57023. declare module BABYLON {
  57024. /**
  57025. * This represents a set of one or more post processes in Babylon.
  57026. * A post process can be used to apply a shader to a texture after it is rendered.
  57027. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57028. */
  57029. export class PostProcessRenderEffect {
  57030. private _postProcesses;
  57031. private _getPostProcesses;
  57032. private _singleInstance;
  57033. private _cameras;
  57034. private _indicesForCamera;
  57035. /**
  57036. * Name of the effect
  57037. * @hidden
  57038. */
  57039. _name: string;
  57040. /**
  57041. * Instantiates a post process render effect.
  57042. * A post process can be used to apply a shader to a texture after it is rendered.
  57043. * @param engine The engine the effect is tied to
  57044. * @param name The name of the effect
  57045. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57046. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57047. */
  57048. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57049. /**
  57050. * Checks if all the post processes in the effect are supported.
  57051. */
  57052. readonly isSupported: boolean;
  57053. /**
  57054. * Updates the current state of the effect
  57055. * @hidden
  57056. */
  57057. _update(): void;
  57058. /**
  57059. * Attaches the effect on cameras
  57060. * @param cameras The camera to attach to.
  57061. * @hidden
  57062. */
  57063. _attachCameras(cameras: Camera): void;
  57064. /**
  57065. * Attaches the effect on cameras
  57066. * @param cameras The camera to attach to.
  57067. * @hidden
  57068. */
  57069. _attachCameras(cameras: Camera[]): void;
  57070. /**
  57071. * Detaches the effect on cameras
  57072. * @param cameras The camera to detatch from.
  57073. * @hidden
  57074. */
  57075. _detachCameras(cameras: Camera): void;
  57076. /**
  57077. * Detatches the effect on cameras
  57078. * @param cameras The camera to detatch from.
  57079. * @hidden
  57080. */
  57081. _detachCameras(cameras: Camera[]): void;
  57082. /**
  57083. * Enables the effect on given cameras
  57084. * @param cameras The camera to enable.
  57085. * @hidden
  57086. */
  57087. _enable(cameras: Camera): void;
  57088. /**
  57089. * Enables the effect on given cameras
  57090. * @param cameras The camera to enable.
  57091. * @hidden
  57092. */
  57093. _enable(cameras: Nullable<Camera[]>): void;
  57094. /**
  57095. * Disables the effect on the given cameras
  57096. * @param cameras The camera to disable.
  57097. * @hidden
  57098. */
  57099. _disable(cameras: Camera): void;
  57100. /**
  57101. * Disables the effect on the given cameras
  57102. * @param cameras The camera to disable.
  57103. * @hidden
  57104. */
  57105. _disable(cameras: Nullable<Camera[]>): void;
  57106. /**
  57107. * Gets a list of the post processes contained in the effect.
  57108. * @param camera The camera to get the post processes on.
  57109. * @returns The list of the post processes in the effect.
  57110. */
  57111. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57112. }
  57113. }
  57114. declare module BABYLON {
  57115. /** @hidden */
  57116. export var extractHighlightsPixelShader: {
  57117. name: string;
  57118. shader: string;
  57119. };
  57120. }
  57121. declare module BABYLON {
  57122. /**
  57123. * The extract highlights post process sets all pixels to black except pixels above the specified luminance threshold. Used as the first step for a bloom effect.
  57124. */
  57125. export class ExtractHighlightsPostProcess extends PostProcess {
  57126. /**
  57127. * The luminance threshold, pixels below this value will be set to black.
  57128. */
  57129. threshold: number;
  57130. /** @hidden */
  57131. _exposure: number;
  57132. /**
  57133. * Post process which has the input texture to be used when performing highlight extraction
  57134. * @hidden
  57135. */
  57136. _inputPostProcess: Nullable<PostProcess>;
  57137. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57138. }
  57139. }
  57140. declare module BABYLON {
  57141. /** @hidden */
  57142. export var bloomMergePixelShader: {
  57143. name: string;
  57144. shader: string;
  57145. };
  57146. }
  57147. declare module BABYLON {
  57148. /**
  57149. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57150. */
  57151. export class BloomMergePostProcess extends PostProcess {
  57152. /** Weight of the bloom to be added to the original input. */
  57153. weight: number;
  57154. /**
  57155. * Creates a new instance of @see BloomMergePostProcess
  57156. * @param name The name of the effect.
  57157. * @param originalFromInput Post process which's input will be used for the merge.
  57158. * @param blurred Blurred highlights post process which's output will be used.
  57159. * @param weight Weight of the bloom to be added to the original input.
  57160. * @param options The required width/height ratio to downsize to before computing the render pass.
  57161. * @param camera The camera to apply the render pass to.
  57162. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57163. * @param engine The engine which the post process will be applied. (default: current engine)
  57164. * @param reusable If the post process can be reused on the same frame. (default: false)
  57165. * @param textureType Type of textures used when performing the post process. (default: 0)
  57166. * @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)
  57167. */
  57168. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57169. /** Weight of the bloom to be added to the original input. */
  57170. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57171. }
  57172. }
  57173. declare module BABYLON {
  57174. /**
  57175. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57176. */
  57177. export class BloomEffect extends PostProcessRenderEffect {
  57178. private bloomScale;
  57179. /**
  57180. * @hidden Internal
  57181. */
  57182. _effects: Array<PostProcess>;
  57183. /**
  57184. * @hidden Internal
  57185. */
  57186. _downscale: ExtractHighlightsPostProcess;
  57187. private _blurX;
  57188. private _blurY;
  57189. private _merge;
  57190. /**
  57191. * The luminance threshold to find bright areas of the image to bloom.
  57192. */
  57193. threshold: number;
  57194. /**
  57195. * The strength of the bloom.
  57196. */
  57197. weight: number;
  57198. /**
  57199. * Specifies the size of the bloom blur kernel, relative to the final output size
  57200. */
  57201. kernel: number;
  57202. /**
  57203. * Creates a new instance of @see BloomEffect
  57204. * @param scene The scene the effect belongs to.
  57205. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57206. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57207. * @param bloomWeight The the strength of bloom.
  57208. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57209. * @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)
  57210. */
  57211. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57212. /**
  57213. * Disposes each of the internal effects for a given camera.
  57214. * @param camera The camera to dispose the effect on.
  57215. */
  57216. disposeEffects(camera: Camera): void;
  57217. /**
  57218. * @hidden Internal
  57219. */
  57220. _updateEffects(): void;
  57221. /**
  57222. * Internal
  57223. * @returns if all the contained post processes are ready.
  57224. * @hidden
  57225. */
  57226. _isReady(): boolean;
  57227. }
  57228. }
  57229. declare module BABYLON {
  57230. /** @hidden */
  57231. export var chromaticAberrationPixelShader: {
  57232. name: string;
  57233. shader: string;
  57234. };
  57235. }
  57236. declare module BABYLON {
  57237. /**
  57238. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57239. */
  57240. export class ChromaticAberrationPostProcess extends PostProcess {
  57241. /**
  57242. * The amount of seperation of rgb channels (default: 30)
  57243. */
  57244. aberrationAmount: number;
  57245. /**
  57246. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57247. */
  57248. radialIntensity: number;
  57249. /**
  57250. * 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))
  57251. */
  57252. direction: Vector2;
  57253. /**
  57254. * 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))
  57255. */
  57256. centerPosition: Vector2;
  57257. /**
  57258. * Creates a new instance ChromaticAberrationPostProcess
  57259. * @param name The name of the effect.
  57260. * @param screenWidth The width of the screen to apply the effect on.
  57261. * @param screenHeight The height of the screen to apply the effect on.
  57262. * @param options The required width/height ratio to downsize to before computing the render pass.
  57263. * @param camera The camera to apply the render pass to.
  57264. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57265. * @param engine The engine which the post process will be applied. (default: current engine)
  57266. * @param reusable If the post process can be reused on the same frame. (default: false)
  57267. * @param textureType Type of textures used when performing the post process. (default: 0)
  57268. * @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)
  57269. */
  57270. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57271. }
  57272. }
  57273. declare module BABYLON {
  57274. /** @hidden */
  57275. export var circleOfConfusionPixelShader: {
  57276. name: string;
  57277. shader: string;
  57278. };
  57279. }
  57280. declare module BABYLON {
  57281. /**
  57282. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57283. */
  57284. export class CircleOfConfusionPostProcess extends PostProcess {
  57285. /**
  57286. * 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.
  57287. */
  57288. lensSize: number;
  57289. /**
  57290. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57291. */
  57292. fStop: number;
  57293. /**
  57294. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57295. */
  57296. focusDistance: number;
  57297. /**
  57298. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57299. */
  57300. focalLength: number;
  57301. private _depthTexture;
  57302. /**
  57303. * Creates a new instance CircleOfConfusionPostProcess
  57304. * @param name The name of the effect.
  57305. * @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.
  57306. * @param options The required width/height ratio to downsize to before computing the render pass.
  57307. * @param camera The camera to apply the render pass to.
  57308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57309. * @param engine The engine which the post process will be applied. (default: current engine)
  57310. * @param reusable If the post process can be reused on the same frame. (default: false)
  57311. * @param textureType Type of textures used when performing the post process. (default: 0)
  57312. * @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)
  57313. */
  57314. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57315. /**
  57316. * 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.
  57317. */
  57318. depthTexture: RenderTargetTexture;
  57319. }
  57320. }
  57321. declare module BABYLON {
  57322. /** @hidden */
  57323. export var colorCorrectionPixelShader: {
  57324. name: string;
  57325. shader: string;
  57326. };
  57327. }
  57328. declare module BABYLON {
  57329. /**
  57330. *
  57331. * This post-process allows the modification of rendered colors by using
  57332. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57333. *
  57334. * The object needs to be provided an url to a texture containing the color
  57335. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57336. * Use an image editing software to tweak the LUT to match your needs.
  57337. *
  57338. * For an example of a color LUT, see here:
  57339. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57340. * For explanations on color grading, see here:
  57341. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57342. *
  57343. */
  57344. export class ColorCorrectionPostProcess extends PostProcess {
  57345. private _colorTableTexture;
  57346. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57347. }
  57348. }
  57349. declare module BABYLON {
  57350. /** @hidden */
  57351. export var convolutionPixelShader: {
  57352. name: string;
  57353. shader: string;
  57354. };
  57355. }
  57356. declare module BABYLON {
  57357. /**
  57358. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57359. * input texture to perform effects such as edge detection or sharpening
  57360. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57361. */
  57362. export class ConvolutionPostProcess extends PostProcess {
  57363. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57364. kernel: number[];
  57365. /**
  57366. * Creates a new instance ConvolutionPostProcess
  57367. * @param name The name of the effect.
  57368. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57369. * @param options The required width/height ratio to downsize to before computing the render pass.
  57370. * @param camera The camera to apply the render pass to.
  57371. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57372. * @param engine The engine which the post process will be applied. (default: current engine)
  57373. * @param reusable If the post process can be reused on the same frame. (default: false)
  57374. * @param textureType Type of textures used when performing the post process. (default: 0)
  57375. */
  57376. constructor(name: string,
  57377. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57378. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57379. /**
  57380. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57381. */
  57382. static EdgeDetect0Kernel: number[];
  57383. /**
  57384. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57385. */
  57386. static EdgeDetect1Kernel: number[];
  57387. /**
  57388. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57389. */
  57390. static EdgeDetect2Kernel: number[];
  57391. /**
  57392. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57393. */
  57394. static SharpenKernel: number[];
  57395. /**
  57396. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57397. */
  57398. static EmbossKernel: number[];
  57399. /**
  57400. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57401. */
  57402. static GaussianKernel: number[];
  57403. }
  57404. }
  57405. declare module BABYLON {
  57406. /**
  57407. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57408. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57409. * based on samples that have a large difference in distance than the center pixel.
  57410. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57411. */
  57412. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57413. direction: Vector2;
  57414. /**
  57415. * Creates a new instance CircleOfConfusionPostProcess
  57416. * @param name The name of the effect.
  57417. * @param scene The scene the effect belongs to.
  57418. * @param direction The direction the blur should be applied.
  57419. * @param kernel The size of the kernel used to blur.
  57420. * @param options The required width/height ratio to downsize to before computing the render pass.
  57421. * @param camera The camera to apply the render pass to.
  57422. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57423. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57425. * @param engine The engine which the post process will be applied. (default: current engine)
  57426. * @param reusable If the post process can be reused on the same frame. (default: false)
  57427. * @param textureType Type of textures used when performing the post process. (default: 0)
  57428. * @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)
  57429. */
  57430. 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);
  57431. }
  57432. }
  57433. declare module BABYLON {
  57434. /** @hidden */
  57435. export var depthOfFieldMergePixelShader: {
  57436. name: string;
  57437. shader: string;
  57438. };
  57439. }
  57440. declare module BABYLON {
  57441. /**
  57442. * Options to be set when merging outputs from the default pipeline.
  57443. */
  57444. export class DepthOfFieldMergePostProcessOptions {
  57445. /**
  57446. * The original image to merge on top of
  57447. */
  57448. originalFromInput: PostProcess;
  57449. /**
  57450. * Parameters to perform the merge of the depth of field effect
  57451. */
  57452. depthOfField?: {
  57453. circleOfConfusion: PostProcess;
  57454. blurSteps: Array<PostProcess>;
  57455. };
  57456. /**
  57457. * Parameters to perform the merge of bloom effect
  57458. */
  57459. bloom?: {
  57460. blurred: PostProcess;
  57461. weight: number;
  57462. };
  57463. }
  57464. /**
  57465. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57466. */
  57467. export class DepthOfFieldMergePostProcess extends PostProcess {
  57468. private blurSteps;
  57469. /**
  57470. * Creates a new instance of DepthOfFieldMergePostProcess
  57471. * @param name The name of the effect.
  57472. * @param originalFromInput Post process which's input will be used for the merge.
  57473. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57474. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57475. * @param options The required width/height ratio to downsize to before computing the render pass.
  57476. * @param camera The camera to apply the render pass to.
  57477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57478. * @param engine The engine which the post process will be applied. (default: current engine)
  57479. * @param reusable If the post process can be reused on the same frame. (default: false)
  57480. * @param textureType Type of textures used when performing the post process. (default: 0)
  57481. * @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)
  57482. */
  57483. constructor(name: string, originalFromInput: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57484. /**
  57485. * Updates the effect with the current post process compile time values and recompiles the shader.
  57486. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57487. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57488. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57489. * @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
  57490. * @param onCompiled Called when the shader has been compiled.
  57491. * @param onError Called if there is an error when compiling a shader.
  57492. */
  57493. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57494. }
  57495. }
  57496. declare module BABYLON {
  57497. /**
  57498. * Specifies the level of max blur that should be applied when using the depth of field effect
  57499. */
  57500. export enum DepthOfFieldEffectBlurLevel {
  57501. /**
  57502. * Subtle blur
  57503. */
  57504. Low = 0,
  57505. /**
  57506. * Medium blur
  57507. */
  57508. Medium = 1,
  57509. /**
  57510. * Large blur
  57511. */
  57512. High = 2
  57513. }
  57514. /**
  57515. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57516. */
  57517. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57518. private _circleOfConfusion;
  57519. /**
  57520. * @hidden Internal, blurs from high to low
  57521. */
  57522. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57523. private _depthOfFieldBlurY;
  57524. private _dofMerge;
  57525. /**
  57526. * @hidden Internal post processes in depth of field effect
  57527. */
  57528. _effects: Array<PostProcess>;
  57529. /**
  57530. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57531. */
  57532. focalLength: number;
  57533. /**
  57534. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57535. */
  57536. fStop: number;
  57537. /**
  57538. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57539. */
  57540. focusDistance: number;
  57541. /**
  57542. * 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.
  57543. */
  57544. lensSize: number;
  57545. /**
  57546. * Creates a new instance DepthOfFieldEffect
  57547. * @param scene The scene the effect belongs to.
  57548. * @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.
  57549. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57550. * @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)
  57551. */
  57552. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57553. /**
  57554. * Get the current class name of the current effet
  57555. * @returns "DepthOfFieldEffect"
  57556. */
  57557. getClassName(): string;
  57558. /**
  57559. * 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.
  57560. */
  57561. depthTexture: RenderTargetTexture;
  57562. /**
  57563. * Disposes each of the internal effects for a given camera.
  57564. * @param camera The camera to dispose the effect on.
  57565. */
  57566. disposeEffects(camera: Camera): void;
  57567. /**
  57568. * @hidden Internal
  57569. */
  57570. _updateEffects(): void;
  57571. /**
  57572. * Internal
  57573. * @returns if all the contained post processes are ready.
  57574. * @hidden
  57575. */
  57576. _isReady(): boolean;
  57577. }
  57578. }
  57579. declare module BABYLON {
  57580. /** @hidden */
  57581. export var displayPassPixelShader: {
  57582. name: string;
  57583. shader: string;
  57584. };
  57585. }
  57586. declare module BABYLON {
  57587. /**
  57588. * DisplayPassPostProcess which produces an output the same as it's input
  57589. */
  57590. export class DisplayPassPostProcess extends PostProcess {
  57591. /**
  57592. * Creates the DisplayPassPostProcess
  57593. * @param name The name of the effect.
  57594. * @param options The required width/height ratio to downsize to before computing the render pass.
  57595. * @param camera The camera to apply the render pass to.
  57596. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57597. * @param engine The engine which the post process will be applied. (default: current engine)
  57598. * @param reusable If the post process can be reused on the same frame. (default: false)
  57599. */
  57600. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57601. }
  57602. }
  57603. declare module BABYLON {
  57604. /** @hidden */
  57605. export var filterPixelShader: {
  57606. name: string;
  57607. shader: string;
  57608. };
  57609. }
  57610. declare module BABYLON {
  57611. /**
  57612. * Applies a kernel filter to the image
  57613. */
  57614. export class FilterPostProcess extends PostProcess {
  57615. /** The matrix to be applied to the image */
  57616. kernelMatrix: Matrix;
  57617. /**
  57618. *
  57619. * @param name The name of the effect.
  57620. * @param kernelMatrix The matrix to be applied to the image
  57621. * @param options The required width/height ratio to downsize to before computing the render pass.
  57622. * @param camera The camera to apply the render pass to.
  57623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57624. * @param engine The engine which the post process will be applied. (default: current engine)
  57625. * @param reusable If the post process can be reused on the same frame. (default: false)
  57626. */
  57627. constructor(name: string,
  57628. /** The matrix to be applied to the image */
  57629. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57630. }
  57631. }
  57632. declare module BABYLON {
  57633. /** @hidden */
  57634. export var fxaaPixelShader: {
  57635. name: string;
  57636. shader: string;
  57637. };
  57638. }
  57639. declare module BABYLON {
  57640. /** @hidden */
  57641. export var fxaaVertexShader: {
  57642. name: string;
  57643. shader: string;
  57644. };
  57645. }
  57646. declare module BABYLON {
  57647. /**
  57648. * Fxaa post process
  57649. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57650. */
  57651. export class FxaaPostProcess extends PostProcess {
  57652. /** @hidden */
  57653. texelWidth: number;
  57654. /** @hidden */
  57655. texelHeight: number;
  57656. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57657. private _getDefines;
  57658. }
  57659. }
  57660. declare module BABYLON {
  57661. /** @hidden */
  57662. export var grainPixelShader: {
  57663. name: string;
  57664. shader: string;
  57665. };
  57666. }
  57667. declare module BABYLON {
  57668. /**
  57669. * The GrainPostProcess adds noise to the image at mid luminance levels
  57670. */
  57671. export class GrainPostProcess extends PostProcess {
  57672. /**
  57673. * The intensity of the grain added (default: 30)
  57674. */
  57675. intensity: number;
  57676. /**
  57677. * If the grain should be randomized on every frame
  57678. */
  57679. animated: boolean;
  57680. /**
  57681. * Creates a new instance of @see GrainPostProcess
  57682. * @param name The name of the effect.
  57683. * @param options The required width/height ratio to downsize to before computing the render pass.
  57684. * @param camera The camera to apply the render pass to.
  57685. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57686. * @param engine The engine which the post process will be applied. (default: current engine)
  57687. * @param reusable If the post process can be reused on the same frame. (default: false)
  57688. * @param textureType Type of textures used when performing the post process. (default: 0)
  57689. * @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)
  57690. */
  57691. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57692. }
  57693. }
  57694. declare module BABYLON {
  57695. /** @hidden */
  57696. export var highlightsPixelShader: {
  57697. name: string;
  57698. shader: string;
  57699. };
  57700. }
  57701. declare module BABYLON {
  57702. /**
  57703. * Extracts highlights from the image
  57704. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57705. */
  57706. export class HighlightsPostProcess extends PostProcess {
  57707. /**
  57708. * Extracts highlights from the image
  57709. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57710. * @param name The name of the effect.
  57711. * @param options The required width/height ratio to downsize to before computing the render pass.
  57712. * @param camera The camera to apply the render pass to.
  57713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57714. * @param engine The engine which the post process will be applied. (default: current engine)
  57715. * @param reusable If the post process can be reused on the same frame. (default: false)
  57716. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  57717. */
  57718. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57719. }
  57720. }
  57721. declare module BABYLON {
  57722. /** @hidden */
  57723. export var mrtFragmentDeclaration: {
  57724. name: string;
  57725. shader: string;
  57726. };
  57727. }
  57728. declare module BABYLON {
  57729. /** @hidden */
  57730. export var geometryPixelShader: {
  57731. name: string;
  57732. shader: string;
  57733. };
  57734. }
  57735. declare module BABYLON {
  57736. /** @hidden */
  57737. export var geometryVertexShader: {
  57738. name: string;
  57739. shader: string;
  57740. };
  57741. }
  57742. declare module BABYLON {
  57743. /** @hidden */
  57744. interface ISavedTransformationMatrix {
  57745. world: Matrix;
  57746. viewProjection: Matrix;
  57747. }
  57748. /**
  57749. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  57750. */
  57751. export class GeometryBufferRenderer {
  57752. /**
  57753. * Constant used to retrieve the position texture index in the G-Buffer textures array
  57754. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  57755. */
  57756. static readonly POSITION_TEXTURE_TYPE: number;
  57757. /**
  57758. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  57759. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  57760. */
  57761. static readonly VELOCITY_TEXTURE_TYPE: number;
  57762. /**
  57763. * Dictionary used to store the previous transformation matrices of each rendered mesh
  57764. * in order to compute objects velocities when enableVelocity is set to "true"
  57765. * @hidden
  57766. */
  57767. _previousTransformationMatrices: {
  57768. [index: number]: ISavedTransformationMatrix;
  57769. };
  57770. /**
  57771. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  57772. * in order to compute objects velocities when enableVelocity is set to "true"
  57773. * @hidden
  57774. */
  57775. _previousBonesTransformationMatrices: {
  57776. [index: number]: Float32Array;
  57777. };
  57778. /**
  57779. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  57780. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  57781. */
  57782. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  57783. private _scene;
  57784. private _multiRenderTarget;
  57785. private _ratio;
  57786. private _enablePosition;
  57787. private _enableVelocity;
  57788. private _positionIndex;
  57789. private _velocityIndex;
  57790. protected _effect: Effect;
  57791. protected _cachedDefines: string;
  57792. /**
  57793. * Set the render list (meshes to be rendered) used in the G buffer.
  57794. */
  57795. renderList: Mesh[];
  57796. /**
  57797. * Gets wether or not G buffer are supported by the running hardware.
  57798. * This requires draw buffer supports
  57799. */
  57800. readonly isSupported: boolean;
  57801. /**
  57802. * Returns the index of the given texture type in the G-Buffer textures array
  57803. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  57804. * @returns the index of the given texture type in the G-Buffer textures array
  57805. */
  57806. getTextureIndex(textureType: number): number;
  57807. /**
  57808. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  57809. */
  57810. /**
  57811. * Sets whether or not objects positions are enabled for the G buffer.
  57812. */
  57813. enablePosition: boolean;
  57814. /**
  57815. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  57816. */
  57817. /**
  57818. * Sets wether or not objects velocities are enabled for the G buffer.
  57819. */
  57820. enableVelocity: boolean;
  57821. /**
  57822. * Gets the scene associated with the buffer.
  57823. */
  57824. readonly scene: Scene;
  57825. /**
  57826. * Gets the ratio used by the buffer during its creation.
  57827. * How big is the buffer related to the main canvas.
  57828. */
  57829. readonly ratio: number;
  57830. /** @hidden */
  57831. static _SceneComponentInitialization: (scene: Scene) => void;
  57832. /**
  57833. * Creates a new G Buffer for the scene
  57834. * @param scene The scene the buffer belongs to
  57835. * @param ratio How big is the buffer related to the main canvas.
  57836. */
  57837. constructor(scene: Scene, ratio?: number);
  57838. /**
  57839. * Checks wether everything is ready to render a submesh to the G buffer.
  57840. * @param subMesh the submesh to check readiness for
  57841. * @param useInstances is the mesh drawn using instance or not
  57842. * @returns true if ready otherwise false
  57843. */
  57844. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57845. /**
  57846. * Gets the current underlying G Buffer.
  57847. * @returns the buffer
  57848. */
  57849. getGBuffer(): MultiRenderTarget;
  57850. /**
  57851. * Gets the number of samples used to render the buffer (anti aliasing).
  57852. */
  57853. /**
  57854. * Sets the number of samples used to render the buffer (anti aliasing).
  57855. */
  57856. samples: number;
  57857. /**
  57858. * Disposes the renderer and frees up associated resources.
  57859. */
  57860. dispose(): void;
  57861. protected _createRenderTargets(): void;
  57862. private _copyBonesTransformationMatrices;
  57863. }
  57864. }
  57865. declare module BABYLON {
  57866. interface Scene {
  57867. /** @hidden (Backing field) */
  57868. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57869. /**
  57870. * Gets or Sets the current geometry buffer associated to the scene.
  57871. */
  57872. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57873. /**
  57874. * Enables a GeometryBufferRender and associates it with the scene
  57875. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  57876. * @returns the GeometryBufferRenderer
  57877. */
  57878. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  57879. /**
  57880. * Disables the GeometryBufferRender associated with the scene
  57881. */
  57882. disableGeometryBufferRenderer(): void;
  57883. }
  57884. /**
  57885. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  57886. * in several rendering techniques.
  57887. */
  57888. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  57889. /**
  57890. * The component name helpful to identify the component in the list of scene components.
  57891. */
  57892. readonly name: string;
  57893. /**
  57894. * The scene the component belongs to.
  57895. */
  57896. scene: Scene;
  57897. /**
  57898. * Creates a new instance of the component for the given scene
  57899. * @param scene Defines the scene to register the component in
  57900. */
  57901. constructor(scene: Scene);
  57902. /**
  57903. * Registers the component in a given scene
  57904. */
  57905. register(): void;
  57906. /**
  57907. * Rebuilds the elements related to this component in case of
  57908. * context lost for instance.
  57909. */
  57910. rebuild(): void;
  57911. /**
  57912. * Disposes the component and the associated ressources
  57913. */
  57914. dispose(): void;
  57915. private _gatherRenderTargets;
  57916. }
  57917. }
  57918. declare module BABYLON {
  57919. /** @hidden */
  57920. export var motionBlurPixelShader: {
  57921. name: string;
  57922. shader: string;
  57923. };
  57924. }
  57925. declare module BABYLON {
  57926. /**
  57927. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  57928. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  57929. * As an example, all you have to do is to create the post-process:
  57930. * var mb = new BABYLON.MotionBlurPostProcess(
  57931. * 'mb', // The name of the effect.
  57932. * scene, // The scene containing the objects to blur according to their velocity.
  57933. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  57934. * camera // The camera to apply the render pass to.
  57935. * );
  57936. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  57937. */
  57938. export class MotionBlurPostProcess extends PostProcess {
  57939. /**
  57940. * Defines how much the image is blurred by the movement. Default value is equal to 1
  57941. */
  57942. motionStrength: number;
  57943. /**
  57944. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  57945. */
  57946. /**
  57947. * Sets the number of iterations to be used for motion blur quality
  57948. */
  57949. motionBlurSamples: number;
  57950. private _motionBlurSamples;
  57951. private _geometryBufferRenderer;
  57952. /**
  57953. * Creates a new instance MotionBlurPostProcess
  57954. * @param name The name of the effect.
  57955. * @param scene The scene containing the objects to blur according to their velocity.
  57956. * @param options The required width/height ratio to downsize to before computing the render pass.
  57957. * @param camera The camera to apply the render pass to.
  57958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57959. * @param engine The engine which the post process will be applied. (default: current engine)
  57960. * @param reusable If the post process can be reused on the same frame. (default: false)
  57961. * @param textureType Type of textures used when performing the post process. (default: 0)
  57962. * @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)
  57963. */
  57964. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57965. /**
  57966. * Excludes the given skinned mesh from computing bones velocities.
  57967. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  57968. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  57969. */
  57970. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57971. /**
  57972. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  57973. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  57974. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  57975. */
  57976. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57977. /**
  57978. * Disposes the post process.
  57979. * @param camera The camera to dispose the post process on.
  57980. */
  57981. dispose(camera?: Camera): void;
  57982. }
  57983. }
  57984. declare module BABYLON {
  57985. /** @hidden */
  57986. export var refractionPixelShader: {
  57987. name: string;
  57988. shader: string;
  57989. };
  57990. }
  57991. declare module BABYLON {
  57992. /**
  57993. * Post process which applies a refractin texture
  57994. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57995. */
  57996. export class RefractionPostProcess extends PostProcess {
  57997. /** the base color of the refraction (used to taint the rendering) */
  57998. color: Color3;
  57999. /** simulated refraction depth */
  58000. depth: number;
  58001. /** the coefficient of the base color (0 to remove base color tainting) */
  58002. colorLevel: number;
  58003. private _refTexture;
  58004. private _ownRefractionTexture;
  58005. /**
  58006. * Gets or sets the refraction texture
  58007. * Please note that you are responsible for disposing the texture if you set it manually
  58008. */
  58009. refractionTexture: Texture;
  58010. /**
  58011. * Initializes the RefractionPostProcess
  58012. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58013. * @param name The name of the effect.
  58014. * @param refractionTextureUrl Url of the refraction texture to use
  58015. * @param color the base color of the refraction (used to taint the rendering)
  58016. * @param depth simulated refraction depth
  58017. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58018. * @param camera The camera to apply the render pass to.
  58019. * @param options The required width/height ratio to downsize to before computing the render pass.
  58020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58021. * @param engine The engine which the post process will be applied. (default: current engine)
  58022. * @param reusable If the post process can be reused on the same frame. (default: false)
  58023. */
  58024. constructor(name: string, refractionTextureUrl: string,
  58025. /** the base color of the refraction (used to taint the rendering) */
  58026. color: Color3,
  58027. /** simulated refraction depth */
  58028. depth: number,
  58029. /** the coefficient of the base color (0 to remove base color tainting) */
  58030. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58031. /**
  58032. * Disposes of the post process
  58033. * @param camera Camera to dispose post process on
  58034. */
  58035. dispose(camera: Camera): void;
  58036. }
  58037. }
  58038. declare module BABYLON {
  58039. /** @hidden */
  58040. export var sharpenPixelShader: {
  58041. name: string;
  58042. shader: string;
  58043. };
  58044. }
  58045. declare module BABYLON {
  58046. /**
  58047. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58048. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58049. */
  58050. export class SharpenPostProcess extends PostProcess {
  58051. /**
  58052. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58053. */
  58054. colorAmount: number;
  58055. /**
  58056. * How much sharpness should be applied (default: 0.3)
  58057. */
  58058. edgeAmount: number;
  58059. /**
  58060. * Creates a new instance ConvolutionPostProcess
  58061. * @param name The name of the effect.
  58062. * @param options The required width/height ratio to downsize to before computing the render pass.
  58063. * @param camera The camera to apply the render pass to.
  58064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58065. * @param engine The engine which the post process will be applied. (default: current engine)
  58066. * @param reusable If the post process can be reused on the same frame. (default: false)
  58067. * @param textureType Type of textures used when performing the post process. (default: 0)
  58068. * @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)
  58069. */
  58070. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58071. }
  58072. }
  58073. declare module BABYLON {
  58074. /**
  58075. * PostProcessRenderPipeline
  58076. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58077. */
  58078. export class PostProcessRenderPipeline {
  58079. private engine;
  58080. private _renderEffects;
  58081. private _renderEffectsForIsolatedPass;
  58082. /**
  58083. * List of inspectable custom properties (used by the Inspector)
  58084. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58085. */
  58086. inspectableCustomProperties: IInspectable[];
  58087. /**
  58088. * @hidden
  58089. */
  58090. protected _cameras: Camera[];
  58091. /** @hidden */
  58092. _name: string;
  58093. /**
  58094. * Gets pipeline name
  58095. */
  58096. readonly name: string;
  58097. /**
  58098. * Initializes a PostProcessRenderPipeline
  58099. * @param engine engine to add the pipeline to
  58100. * @param name name of the pipeline
  58101. */
  58102. constructor(engine: Engine, name: string);
  58103. /**
  58104. * Gets the class name
  58105. * @returns "PostProcessRenderPipeline"
  58106. */
  58107. getClassName(): string;
  58108. /**
  58109. * If all the render effects in the pipeline are supported
  58110. */
  58111. readonly isSupported: boolean;
  58112. /**
  58113. * Adds an effect to the pipeline
  58114. * @param renderEffect the effect to add
  58115. */
  58116. addEffect(renderEffect: PostProcessRenderEffect): void;
  58117. /** @hidden */
  58118. _rebuild(): void;
  58119. /** @hidden */
  58120. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58121. /** @hidden */
  58122. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58123. /** @hidden */
  58124. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58125. /** @hidden */
  58126. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58127. /** @hidden */
  58128. _attachCameras(cameras: Camera, unique: boolean): void;
  58129. /** @hidden */
  58130. _attachCameras(cameras: Camera[], unique: boolean): void;
  58131. /** @hidden */
  58132. _detachCameras(cameras: Camera): void;
  58133. /** @hidden */
  58134. _detachCameras(cameras: Nullable<Camera[]>): void;
  58135. /** @hidden */
  58136. _update(): void;
  58137. /** @hidden */
  58138. _reset(): void;
  58139. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58140. /**
  58141. * Disposes of the pipeline
  58142. */
  58143. dispose(): void;
  58144. }
  58145. }
  58146. declare module BABYLON {
  58147. /**
  58148. * PostProcessRenderPipelineManager class
  58149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58150. */
  58151. export class PostProcessRenderPipelineManager {
  58152. private _renderPipelines;
  58153. /**
  58154. * Initializes a PostProcessRenderPipelineManager
  58155. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58156. */
  58157. constructor();
  58158. /**
  58159. * Gets the list of supported render pipelines
  58160. */
  58161. readonly supportedPipelines: PostProcessRenderPipeline[];
  58162. /**
  58163. * Adds a pipeline to the manager
  58164. * @param renderPipeline The pipeline to add
  58165. */
  58166. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58167. /**
  58168. * Attaches a camera to the pipeline
  58169. * @param renderPipelineName The name of the pipeline to attach to
  58170. * @param cameras the camera to attach
  58171. * @param unique if the camera can be attached multiple times to the pipeline
  58172. */
  58173. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58174. /**
  58175. * Detaches a camera from the pipeline
  58176. * @param renderPipelineName The name of the pipeline to detach from
  58177. * @param cameras the camera to detach
  58178. */
  58179. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58180. /**
  58181. * Enables an effect by name on a pipeline
  58182. * @param renderPipelineName the name of the pipeline to enable the effect in
  58183. * @param renderEffectName the name of the effect to enable
  58184. * @param cameras the cameras that the effect should be enabled on
  58185. */
  58186. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58187. /**
  58188. * Disables an effect by name on a pipeline
  58189. * @param renderPipelineName the name of the pipeline to disable the effect in
  58190. * @param renderEffectName the name of the effect to disable
  58191. * @param cameras the cameras that the effect should be disabled on
  58192. */
  58193. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58194. /**
  58195. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58196. */
  58197. update(): void;
  58198. /** @hidden */
  58199. _rebuild(): void;
  58200. /**
  58201. * Disposes of the manager and pipelines
  58202. */
  58203. dispose(): void;
  58204. }
  58205. }
  58206. declare module BABYLON {
  58207. interface Scene {
  58208. /** @hidden (Backing field) */
  58209. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58210. /**
  58211. * Gets the postprocess render pipeline manager
  58212. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58213. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58214. */
  58215. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58216. }
  58217. /**
  58218. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58219. */
  58220. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58221. /**
  58222. * The component name helpfull to identify the component in the list of scene components.
  58223. */
  58224. readonly name: string;
  58225. /**
  58226. * The scene the component belongs to.
  58227. */
  58228. scene: Scene;
  58229. /**
  58230. * Creates a new instance of the component for the given scene
  58231. * @param scene Defines the scene to register the component in
  58232. */
  58233. constructor(scene: Scene);
  58234. /**
  58235. * Registers the component in a given scene
  58236. */
  58237. register(): void;
  58238. /**
  58239. * Rebuilds the elements related to this component in case of
  58240. * context lost for instance.
  58241. */
  58242. rebuild(): void;
  58243. /**
  58244. * Disposes the component and the associated ressources
  58245. */
  58246. dispose(): void;
  58247. private _gatherRenderTargets;
  58248. }
  58249. }
  58250. declare module BABYLON {
  58251. /**
  58252. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58253. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58254. */
  58255. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58256. private _scene;
  58257. private _camerasToBeAttached;
  58258. /**
  58259. * ID of the sharpen post process,
  58260. */
  58261. private readonly SharpenPostProcessId;
  58262. /**
  58263. * @ignore
  58264. * ID of the image processing post process;
  58265. */
  58266. readonly ImageProcessingPostProcessId: string;
  58267. /**
  58268. * @ignore
  58269. * ID of the Fast Approximate Anti-Aliasing post process;
  58270. */
  58271. readonly FxaaPostProcessId: string;
  58272. /**
  58273. * ID of the chromatic aberration post process,
  58274. */
  58275. private readonly ChromaticAberrationPostProcessId;
  58276. /**
  58277. * ID of the grain post process
  58278. */
  58279. private readonly GrainPostProcessId;
  58280. /**
  58281. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58282. */
  58283. sharpen: SharpenPostProcess;
  58284. private _sharpenEffect;
  58285. private bloom;
  58286. /**
  58287. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58288. */
  58289. depthOfField: DepthOfFieldEffect;
  58290. /**
  58291. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58292. */
  58293. fxaa: FxaaPostProcess;
  58294. /**
  58295. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58296. */
  58297. imageProcessing: ImageProcessingPostProcess;
  58298. /**
  58299. * Chromatic aberration post process which will shift rgb colors in the image
  58300. */
  58301. chromaticAberration: ChromaticAberrationPostProcess;
  58302. private _chromaticAberrationEffect;
  58303. /**
  58304. * Grain post process which add noise to the image
  58305. */
  58306. grain: GrainPostProcess;
  58307. private _grainEffect;
  58308. /**
  58309. * Glow post process which adds a glow to emissive areas of the image
  58310. */
  58311. private _glowLayer;
  58312. /**
  58313. * Animations which can be used to tweak settings over a period of time
  58314. */
  58315. animations: Animation[];
  58316. private _imageProcessingConfigurationObserver;
  58317. private _sharpenEnabled;
  58318. private _bloomEnabled;
  58319. private _depthOfFieldEnabled;
  58320. private _depthOfFieldBlurLevel;
  58321. private _fxaaEnabled;
  58322. private _imageProcessingEnabled;
  58323. private _defaultPipelineTextureType;
  58324. private _bloomScale;
  58325. private _chromaticAberrationEnabled;
  58326. private _grainEnabled;
  58327. private _buildAllowed;
  58328. /**
  58329. * Gets active scene
  58330. */
  58331. readonly scene: Scene;
  58332. /**
  58333. * Enable or disable the sharpen process from the pipeline
  58334. */
  58335. sharpenEnabled: boolean;
  58336. private _resizeObserver;
  58337. private _hardwareScaleLevel;
  58338. private _bloomKernel;
  58339. /**
  58340. * Specifies the size of the bloom blur kernel, relative to the final output size
  58341. */
  58342. bloomKernel: number;
  58343. /**
  58344. * Specifies the weight of the bloom in the final rendering
  58345. */
  58346. private _bloomWeight;
  58347. /**
  58348. * Specifies the luma threshold for the area that will be blurred by the bloom
  58349. */
  58350. private _bloomThreshold;
  58351. private _hdr;
  58352. /**
  58353. * The strength of the bloom.
  58354. */
  58355. bloomWeight: number;
  58356. /**
  58357. * The strength of the bloom.
  58358. */
  58359. bloomThreshold: number;
  58360. /**
  58361. * The scale of the bloom, lower value will provide better performance.
  58362. */
  58363. bloomScale: number;
  58364. /**
  58365. * Enable or disable the bloom from the pipeline
  58366. */
  58367. bloomEnabled: boolean;
  58368. private _rebuildBloom;
  58369. /**
  58370. * If the depth of field is enabled.
  58371. */
  58372. depthOfFieldEnabled: boolean;
  58373. /**
  58374. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58375. */
  58376. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58377. /**
  58378. * If the anti aliasing is enabled.
  58379. */
  58380. fxaaEnabled: boolean;
  58381. private _samples;
  58382. /**
  58383. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58384. */
  58385. samples: number;
  58386. /**
  58387. * If image processing is enabled.
  58388. */
  58389. imageProcessingEnabled: boolean;
  58390. /**
  58391. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58392. */
  58393. glowLayerEnabled: boolean;
  58394. /**
  58395. * Gets the glow layer (or null if not defined)
  58396. */
  58397. readonly glowLayer: Nullable<GlowLayer>;
  58398. /**
  58399. * Enable or disable the chromaticAberration process from the pipeline
  58400. */
  58401. chromaticAberrationEnabled: boolean;
  58402. /**
  58403. * Enable or disable the grain process from the pipeline
  58404. */
  58405. grainEnabled: boolean;
  58406. /**
  58407. * @constructor
  58408. * @param name - The rendering pipeline name (default: "")
  58409. * @param hdr - If high dynamic range textures should be used (default: true)
  58410. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58411. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58412. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58413. */
  58414. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58415. /**
  58416. * Get the class name
  58417. * @returns "DefaultRenderingPipeline"
  58418. */
  58419. getClassName(): string;
  58420. /**
  58421. * Force the compilation of the entire pipeline.
  58422. */
  58423. prepare(): void;
  58424. private _hasCleared;
  58425. private _prevPostProcess;
  58426. private _prevPrevPostProcess;
  58427. private _setAutoClearAndTextureSharing;
  58428. private _depthOfFieldSceneObserver;
  58429. private _buildPipeline;
  58430. private _disposePostProcesses;
  58431. /**
  58432. * Adds a camera to the pipeline
  58433. * @param camera the camera to be added
  58434. */
  58435. addCamera(camera: Camera): void;
  58436. /**
  58437. * Removes a camera from the pipeline
  58438. * @param camera the camera to remove
  58439. */
  58440. removeCamera(camera: Camera): void;
  58441. /**
  58442. * Dispose of the pipeline and stop all post processes
  58443. */
  58444. dispose(): void;
  58445. /**
  58446. * Serialize the rendering pipeline (Used when exporting)
  58447. * @returns the serialized object
  58448. */
  58449. serialize(): any;
  58450. /**
  58451. * Parse the serialized pipeline
  58452. * @param source Source pipeline.
  58453. * @param scene The scene to load the pipeline to.
  58454. * @param rootUrl The URL of the serialized pipeline.
  58455. * @returns An instantiated pipeline from the serialized object.
  58456. */
  58457. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58458. }
  58459. }
  58460. declare module BABYLON {
  58461. /** @hidden */
  58462. export var lensHighlightsPixelShader: {
  58463. name: string;
  58464. shader: string;
  58465. };
  58466. }
  58467. declare module BABYLON {
  58468. /** @hidden */
  58469. export var depthOfFieldPixelShader: {
  58470. name: string;
  58471. shader: string;
  58472. };
  58473. }
  58474. declare module BABYLON {
  58475. /**
  58476. * BABYLON.JS Chromatic Aberration GLSL Shader
  58477. * Author: Olivier Guyot
  58478. * Separates very slightly R, G and B colors on the edges of the screen
  58479. * Inspired by Francois Tarlier & Martins Upitis
  58480. */
  58481. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58482. /**
  58483. * @ignore
  58484. * The chromatic aberration PostProcess id in the pipeline
  58485. */
  58486. LensChromaticAberrationEffect: string;
  58487. /**
  58488. * @ignore
  58489. * The highlights enhancing PostProcess id in the pipeline
  58490. */
  58491. HighlightsEnhancingEffect: string;
  58492. /**
  58493. * @ignore
  58494. * The depth-of-field PostProcess id in the pipeline
  58495. */
  58496. LensDepthOfFieldEffect: string;
  58497. private _scene;
  58498. private _depthTexture;
  58499. private _grainTexture;
  58500. private _chromaticAberrationPostProcess;
  58501. private _highlightsPostProcess;
  58502. private _depthOfFieldPostProcess;
  58503. private _edgeBlur;
  58504. private _grainAmount;
  58505. private _chromaticAberration;
  58506. private _distortion;
  58507. private _highlightsGain;
  58508. private _highlightsThreshold;
  58509. private _dofDistance;
  58510. private _dofAperture;
  58511. private _dofDarken;
  58512. private _dofPentagon;
  58513. private _blurNoise;
  58514. /**
  58515. * @constructor
  58516. *
  58517. * Effect parameters are as follow:
  58518. * {
  58519. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58520. * edge_blur: number; // from 0 to x (1 for realism)
  58521. * distortion: number; // from 0 to x (1 for realism)
  58522. * grain_amount: number; // from 0 to 1
  58523. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58524. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58525. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58526. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58527. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58528. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58529. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58530. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58531. * }
  58532. * Note: if an effect parameter is unset, effect is disabled
  58533. *
  58534. * @param name The rendering pipeline name
  58535. * @param parameters - An object containing all parameters (see above)
  58536. * @param scene The scene linked to this pipeline
  58537. * @param 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)
  58538. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58539. */
  58540. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58541. /**
  58542. * Get the class name
  58543. * @returns "LensRenderingPipeline"
  58544. */
  58545. getClassName(): string;
  58546. /**
  58547. * Gets associated scene
  58548. */
  58549. readonly scene: Scene;
  58550. /**
  58551. * Gets or sets the edge blur
  58552. */
  58553. edgeBlur: number;
  58554. /**
  58555. * Gets or sets the grain amount
  58556. */
  58557. grainAmount: number;
  58558. /**
  58559. * Gets or sets the chromatic aberration amount
  58560. */
  58561. chromaticAberration: number;
  58562. /**
  58563. * Gets or sets the depth of field aperture
  58564. */
  58565. dofAperture: number;
  58566. /**
  58567. * Gets or sets the edge distortion
  58568. */
  58569. edgeDistortion: number;
  58570. /**
  58571. * Gets or sets the depth of field distortion
  58572. */
  58573. dofDistortion: number;
  58574. /**
  58575. * Gets or sets the darken out of focus amount
  58576. */
  58577. darkenOutOfFocus: number;
  58578. /**
  58579. * Gets or sets a boolean indicating if blur noise is enabled
  58580. */
  58581. blurNoise: boolean;
  58582. /**
  58583. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  58584. */
  58585. pentagonBokeh: boolean;
  58586. /**
  58587. * Gets or sets the highlight grain amount
  58588. */
  58589. highlightsGain: number;
  58590. /**
  58591. * Gets or sets the highlight threshold
  58592. */
  58593. highlightsThreshold: number;
  58594. /**
  58595. * Sets the amount of blur at the edges
  58596. * @param amount blur amount
  58597. */
  58598. setEdgeBlur(amount: number): void;
  58599. /**
  58600. * Sets edge blur to 0
  58601. */
  58602. disableEdgeBlur(): void;
  58603. /**
  58604. * Sets the amout of grain
  58605. * @param amount Amount of grain
  58606. */
  58607. setGrainAmount(amount: number): void;
  58608. /**
  58609. * Set grain amount to 0
  58610. */
  58611. disableGrain(): void;
  58612. /**
  58613. * Sets the chromatic aberration amount
  58614. * @param amount amount of chromatic aberration
  58615. */
  58616. setChromaticAberration(amount: number): void;
  58617. /**
  58618. * Sets chromatic aberration amount to 0
  58619. */
  58620. disableChromaticAberration(): void;
  58621. /**
  58622. * Sets the EdgeDistortion amount
  58623. * @param amount amount of EdgeDistortion
  58624. */
  58625. setEdgeDistortion(amount: number): void;
  58626. /**
  58627. * Sets edge distortion to 0
  58628. */
  58629. disableEdgeDistortion(): void;
  58630. /**
  58631. * Sets the FocusDistance amount
  58632. * @param amount amount of FocusDistance
  58633. */
  58634. setFocusDistance(amount: number): void;
  58635. /**
  58636. * Disables depth of field
  58637. */
  58638. disableDepthOfField(): void;
  58639. /**
  58640. * Sets the Aperture amount
  58641. * @param amount amount of Aperture
  58642. */
  58643. setAperture(amount: number): void;
  58644. /**
  58645. * Sets the DarkenOutOfFocus amount
  58646. * @param amount amount of DarkenOutOfFocus
  58647. */
  58648. setDarkenOutOfFocus(amount: number): void;
  58649. private _pentagonBokehIsEnabled;
  58650. /**
  58651. * Creates a pentagon bokeh effect
  58652. */
  58653. enablePentagonBokeh(): void;
  58654. /**
  58655. * Disables the pentagon bokeh effect
  58656. */
  58657. disablePentagonBokeh(): void;
  58658. /**
  58659. * Enables noise blur
  58660. */
  58661. enableNoiseBlur(): void;
  58662. /**
  58663. * Disables noise blur
  58664. */
  58665. disableNoiseBlur(): void;
  58666. /**
  58667. * Sets the HighlightsGain amount
  58668. * @param amount amount of HighlightsGain
  58669. */
  58670. setHighlightsGain(amount: number): void;
  58671. /**
  58672. * Sets the HighlightsThreshold amount
  58673. * @param amount amount of HighlightsThreshold
  58674. */
  58675. setHighlightsThreshold(amount: number): void;
  58676. /**
  58677. * Disables highlights
  58678. */
  58679. disableHighlights(): void;
  58680. /**
  58681. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  58682. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  58683. */
  58684. dispose(disableDepthRender?: boolean): void;
  58685. private _createChromaticAberrationPostProcess;
  58686. private _createHighlightsPostProcess;
  58687. private _createDepthOfFieldPostProcess;
  58688. private _createGrainTexture;
  58689. }
  58690. }
  58691. declare module BABYLON {
  58692. /** @hidden */
  58693. export var ssao2PixelShader: {
  58694. name: string;
  58695. shader: string;
  58696. };
  58697. }
  58698. declare module BABYLON {
  58699. /** @hidden */
  58700. export var ssaoCombinePixelShader: {
  58701. name: string;
  58702. shader: string;
  58703. };
  58704. }
  58705. declare module BABYLON {
  58706. /**
  58707. * Render pipeline to produce ssao effect
  58708. */
  58709. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  58710. /**
  58711. * @ignore
  58712. * The PassPostProcess id in the pipeline that contains the original scene color
  58713. */
  58714. SSAOOriginalSceneColorEffect: string;
  58715. /**
  58716. * @ignore
  58717. * The SSAO PostProcess id in the pipeline
  58718. */
  58719. SSAORenderEffect: string;
  58720. /**
  58721. * @ignore
  58722. * The horizontal blur PostProcess id in the pipeline
  58723. */
  58724. SSAOBlurHRenderEffect: string;
  58725. /**
  58726. * @ignore
  58727. * The vertical blur PostProcess id in the pipeline
  58728. */
  58729. SSAOBlurVRenderEffect: string;
  58730. /**
  58731. * @ignore
  58732. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58733. */
  58734. SSAOCombineRenderEffect: string;
  58735. /**
  58736. * The output strength of the SSAO post-process. Default value is 1.0.
  58737. */
  58738. totalStrength: number;
  58739. /**
  58740. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  58741. */
  58742. maxZ: number;
  58743. /**
  58744. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  58745. */
  58746. minZAspect: number;
  58747. private _samples;
  58748. /**
  58749. * Number of samples used for the SSAO calculations. Default value is 8
  58750. */
  58751. samples: number;
  58752. private _textureSamples;
  58753. /**
  58754. * Number of samples to use for antialiasing
  58755. */
  58756. textureSamples: number;
  58757. /**
  58758. * Ratio object used for SSAO ratio and blur ratio
  58759. */
  58760. private _ratio;
  58761. /**
  58762. * Dynamically generated sphere sampler.
  58763. */
  58764. private _sampleSphere;
  58765. /**
  58766. * Blur filter offsets
  58767. */
  58768. private _samplerOffsets;
  58769. private _expensiveBlur;
  58770. /**
  58771. * If bilateral blur should be used
  58772. */
  58773. expensiveBlur: boolean;
  58774. /**
  58775. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  58776. */
  58777. radius: number;
  58778. /**
  58779. * The base color of the SSAO post-process
  58780. * The final result is "base + ssao" between [0, 1]
  58781. */
  58782. base: number;
  58783. /**
  58784. * Support test.
  58785. */
  58786. static readonly IsSupported: boolean;
  58787. private _scene;
  58788. private _depthTexture;
  58789. private _normalTexture;
  58790. private _randomTexture;
  58791. private _originalColorPostProcess;
  58792. private _ssaoPostProcess;
  58793. private _blurHPostProcess;
  58794. private _blurVPostProcess;
  58795. private _ssaoCombinePostProcess;
  58796. private _firstUpdate;
  58797. /**
  58798. * Gets active scene
  58799. */
  58800. readonly scene: Scene;
  58801. /**
  58802. * @constructor
  58803. * @param name The rendering pipeline name
  58804. * @param scene The scene linked to this pipeline
  58805. * @param 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 }
  58806. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58807. */
  58808. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58809. /**
  58810. * Get the class name
  58811. * @returns "SSAO2RenderingPipeline"
  58812. */
  58813. getClassName(): string;
  58814. /**
  58815. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58816. */
  58817. dispose(disableGeometryBufferRenderer?: boolean): void;
  58818. private _createBlurPostProcess;
  58819. /** @hidden */
  58820. _rebuild(): void;
  58821. private _bits;
  58822. private _radicalInverse_VdC;
  58823. private _hammersley;
  58824. private _hemisphereSample_uniform;
  58825. private _generateHemisphere;
  58826. private _createSSAOPostProcess;
  58827. private _createSSAOCombinePostProcess;
  58828. private _createRandomTexture;
  58829. /**
  58830. * Serialize the rendering pipeline (Used when exporting)
  58831. * @returns the serialized object
  58832. */
  58833. serialize(): any;
  58834. /**
  58835. * Parse the serialized pipeline
  58836. * @param source Source pipeline.
  58837. * @param scene The scene to load the pipeline to.
  58838. * @param rootUrl The URL of the serialized pipeline.
  58839. * @returns An instantiated pipeline from the serialized object.
  58840. */
  58841. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  58842. }
  58843. }
  58844. declare module BABYLON {
  58845. /** @hidden */
  58846. export var ssaoPixelShader: {
  58847. name: string;
  58848. shader: string;
  58849. };
  58850. }
  58851. declare module BABYLON {
  58852. /**
  58853. * Render pipeline to produce ssao effect
  58854. */
  58855. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  58856. /**
  58857. * @ignore
  58858. * The PassPostProcess id in the pipeline that contains the original scene color
  58859. */
  58860. SSAOOriginalSceneColorEffect: string;
  58861. /**
  58862. * @ignore
  58863. * The SSAO PostProcess id in the pipeline
  58864. */
  58865. SSAORenderEffect: string;
  58866. /**
  58867. * @ignore
  58868. * The horizontal blur PostProcess id in the pipeline
  58869. */
  58870. SSAOBlurHRenderEffect: string;
  58871. /**
  58872. * @ignore
  58873. * The vertical blur PostProcess id in the pipeline
  58874. */
  58875. SSAOBlurVRenderEffect: string;
  58876. /**
  58877. * @ignore
  58878. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58879. */
  58880. SSAOCombineRenderEffect: string;
  58881. /**
  58882. * The output strength of the SSAO post-process. Default value is 1.0.
  58883. */
  58884. totalStrength: number;
  58885. /**
  58886. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  58887. */
  58888. radius: number;
  58889. /**
  58890. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  58891. * Must not be equal to fallOff and superior to fallOff.
  58892. * Default value is 0.0075
  58893. */
  58894. area: number;
  58895. /**
  58896. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  58897. * Must not be equal to area and inferior to area.
  58898. * Default value is 0.000001
  58899. */
  58900. fallOff: number;
  58901. /**
  58902. * The base color of the SSAO post-process
  58903. * The final result is "base + ssao" between [0, 1]
  58904. */
  58905. base: number;
  58906. private _scene;
  58907. private _depthTexture;
  58908. private _randomTexture;
  58909. private _originalColorPostProcess;
  58910. private _ssaoPostProcess;
  58911. private _blurHPostProcess;
  58912. private _blurVPostProcess;
  58913. private _ssaoCombinePostProcess;
  58914. private _firstUpdate;
  58915. /**
  58916. * Gets active scene
  58917. */
  58918. readonly scene: Scene;
  58919. /**
  58920. * @constructor
  58921. * @param name - The rendering pipeline name
  58922. * @param scene - The scene linked to this pipeline
  58923. * @param 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 }
  58924. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  58925. */
  58926. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58927. /**
  58928. * Get the class name
  58929. * @returns "SSAORenderingPipeline"
  58930. */
  58931. getClassName(): string;
  58932. /**
  58933. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58934. */
  58935. dispose(disableDepthRender?: boolean): void;
  58936. private _createBlurPostProcess;
  58937. /** @hidden */
  58938. _rebuild(): void;
  58939. private _createSSAOPostProcess;
  58940. private _createSSAOCombinePostProcess;
  58941. private _createRandomTexture;
  58942. }
  58943. }
  58944. declare module BABYLON {
  58945. /** @hidden */
  58946. export var standardPixelShader: {
  58947. name: string;
  58948. shader: string;
  58949. };
  58950. }
  58951. declare module BABYLON {
  58952. /**
  58953. * Standard rendering pipeline
  58954. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58955. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  58956. */
  58957. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58958. /**
  58959. * Public members
  58960. */
  58961. /**
  58962. * Post-process which contains the original scene color before the pipeline applies all the effects
  58963. */
  58964. originalPostProcess: Nullable<PostProcess>;
  58965. /**
  58966. * Post-process used to down scale an image x4
  58967. */
  58968. downSampleX4PostProcess: Nullable<PostProcess>;
  58969. /**
  58970. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  58971. */
  58972. brightPassPostProcess: Nullable<PostProcess>;
  58973. /**
  58974. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  58975. */
  58976. blurHPostProcesses: PostProcess[];
  58977. /**
  58978. * Post-process array storing all the vertical blur post-processes used by the pipeline
  58979. */
  58980. blurVPostProcesses: PostProcess[];
  58981. /**
  58982. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  58983. */
  58984. textureAdderPostProcess: Nullable<PostProcess>;
  58985. /**
  58986. * Post-process used to create volumetric lighting effect
  58987. */
  58988. volumetricLightPostProcess: Nullable<PostProcess>;
  58989. /**
  58990. * Post-process used to smooth the previous volumetric light post-process on the X axis
  58991. */
  58992. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  58993. /**
  58994. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  58995. */
  58996. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  58997. /**
  58998. * Post-process used to merge the volumetric light effect and the real scene color
  58999. */
  59000. volumetricLightMergePostProces: Nullable<PostProcess>;
  59001. /**
  59002. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59003. */
  59004. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59005. /**
  59006. * Base post-process used to calculate the average luminance of the final image for HDR
  59007. */
  59008. luminancePostProcess: Nullable<PostProcess>;
  59009. /**
  59010. * Post-processes used to create down sample post-processes in order to get
  59011. * the average luminance of the final image for HDR
  59012. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59013. */
  59014. luminanceDownSamplePostProcesses: PostProcess[];
  59015. /**
  59016. * Post-process used to create a HDR effect (light adaptation)
  59017. */
  59018. hdrPostProcess: Nullable<PostProcess>;
  59019. /**
  59020. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59021. */
  59022. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59023. /**
  59024. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59025. */
  59026. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59027. /**
  59028. * Post-process used to merge the final HDR post-process and the real scene color
  59029. */
  59030. hdrFinalPostProcess: Nullable<PostProcess>;
  59031. /**
  59032. * Post-process used to create a lens flare effect
  59033. */
  59034. lensFlarePostProcess: Nullable<PostProcess>;
  59035. /**
  59036. * Post-process that merges the result of the lens flare post-process and the real scene color
  59037. */
  59038. lensFlareComposePostProcess: Nullable<PostProcess>;
  59039. /**
  59040. * Post-process used to create a motion blur effect
  59041. */
  59042. motionBlurPostProcess: Nullable<PostProcess>;
  59043. /**
  59044. * Post-process used to create a depth of field effect
  59045. */
  59046. depthOfFieldPostProcess: Nullable<PostProcess>;
  59047. /**
  59048. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59049. */
  59050. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59051. /**
  59052. * Represents the brightness threshold in order to configure the illuminated surfaces
  59053. */
  59054. brightThreshold: number;
  59055. /**
  59056. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59057. */
  59058. blurWidth: number;
  59059. /**
  59060. * Sets if the blur for highlighted surfaces must be only horizontal
  59061. */
  59062. horizontalBlur: boolean;
  59063. /**
  59064. * Gets the overall exposure used by the pipeline
  59065. */
  59066. /**
  59067. * Sets the overall exposure used by the pipeline
  59068. */
  59069. exposure: number;
  59070. /**
  59071. * Texture used typically to simulate "dirty" on camera lens
  59072. */
  59073. lensTexture: Nullable<Texture>;
  59074. /**
  59075. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59076. */
  59077. volumetricLightCoefficient: number;
  59078. /**
  59079. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59080. */
  59081. volumetricLightPower: number;
  59082. /**
  59083. * Used the set the blur intensity to smooth the volumetric lights
  59084. */
  59085. volumetricLightBlurScale: number;
  59086. /**
  59087. * Light (spot or directional) used to generate the volumetric lights rays
  59088. * The source light must have a shadow generate so the pipeline can get its
  59089. * depth map
  59090. */
  59091. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59092. /**
  59093. * For eye adaptation, represents the minimum luminance the eye can see
  59094. */
  59095. hdrMinimumLuminance: number;
  59096. /**
  59097. * For eye adaptation, represents the decrease luminance speed
  59098. */
  59099. hdrDecreaseRate: number;
  59100. /**
  59101. * For eye adaptation, represents the increase luminance speed
  59102. */
  59103. hdrIncreaseRate: number;
  59104. /**
  59105. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59106. */
  59107. /**
  59108. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59109. */
  59110. hdrAutoExposure: boolean;
  59111. /**
  59112. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59113. */
  59114. lensColorTexture: Nullable<Texture>;
  59115. /**
  59116. * The overall strengh for the lens flare effect
  59117. */
  59118. lensFlareStrength: number;
  59119. /**
  59120. * Dispersion coefficient for lens flare ghosts
  59121. */
  59122. lensFlareGhostDispersal: number;
  59123. /**
  59124. * Main lens flare halo width
  59125. */
  59126. lensFlareHaloWidth: number;
  59127. /**
  59128. * Based on the lens distortion effect, defines how much the lens flare result
  59129. * is distorted
  59130. */
  59131. lensFlareDistortionStrength: number;
  59132. /**
  59133. * Lens star texture must be used to simulate rays on the flares and is available
  59134. * in the documentation
  59135. */
  59136. lensStarTexture: Nullable<Texture>;
  59137. /**
  59138. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59139. * flare effect by taking account of the dirt texture
  59140. */
  59141. lensFlareDirtTexture: Nullable<Texture>;
  59142. /**
  59143. * Represents the focal length for the depth of field effect
  59144. */
  59145. depthOfFieldDistance: number;
  59146. /**
  59147. * Represents the blur intensity for the blurred part of the depth of field effect
  59148. */
  59149. depthOfFieldBlurWidth: number;
  59150. /**
  59151. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59152. */
  59153. /**
  59154. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59155. */
  59156. motionStrength: number;
  59157. /**
  59158. * Gets wether or not the motion blur post-process is object based or screen based.
  59159. */
  59160. /**
  59161. * Sets wether or not the motion blur post-process should be object based or screen based
  59162. */
  59163. objectBasedMotionBlur: boolean;
  59164. /**
  59165. * List of animations for the pipeline (IAnimatable implementation)
  59166. */
  59167. animations: Animation[];
  59168. /**
  59169. * Private members
  59170. */
  59171. private _scene;
  59172. private _currentDepthOfFieldSource;
  59173. private _basePostProcess;
  59174. private _fixedExposure;
  59175. private _currentExposure;
  59176. private _hdrAutoExposure;
  59177. private _hdrCurrentLuminance;
  59178. private _motionStrength;
  59179. private _isObjectBasedMotionBlur;
  59180. private _floatTextureType;
  59181. private _camerasToBeAttached;
  59182. private _ratio;
  59183. private _bloomEnabled;
  59184. private _depthOfFieldEnabled;
  59185. private _vlsEnabled;
  59186. private _lensFlareEnabled;
  59187. private _hdrEnabled;
  59188. private _motionBlurEnabled;
  59189. private _fxaaEnabled;
  59190. private _motionBlurSamples;
  59191. private _volumetricLightStepsCount;
  59192. private _samples;
  59193. /**
  59194. * @ignore
  59195. * Specifies if the bloom pipeline is enabled
  59196. */
  59197. BloomEnabled: boolean;
  59198. /**
  59199. * @ignore
  59200. * Specifies if the depth of field pipeline is enabed
  59201. */
  59202. DepthOfFieldEnabled: boolean;
  59203. /**
  59204. * @ignore
  59205. * Specifies if the lens flare pipeline is enabed
  59206. */
  59207. LensFlareEnabled: boolean;
  59208. /**
  59209. * @ignore
  59210. * Specifies if the HDR pipeline is enabled
  59211. */
  59212. HDREnabled: boolean;
  59213. /**
  59214. * @ignore
  59215. * Specifies if the volumetric lights scattering effect is enabled
  59216. */
  59217. VLSEnabled: boolean;
  59218. /**
  59219. * @ignore
  59220. * Specifies if the motion blur effect is enabled
  59221. */
  59222. MotionBlurEnabled: boolean;
  59223. /**
  59224. * Specifies if anti-aliasing is enabled
  59225. */
  59226. fxaaEnabled: boolean;
  59227. /**
  59228. * Specifies the number of steps used to calculate the volumetric lights
  59229. * Typically in interval [50, 200]
  59230. */
  59231. volumetricLightStepsCount: number;
  59232. /**
  59233. * Specifies the number of samples used for the motion blur effect
  59234. * Typically in interval [16, 64]
  59235. */
  59236. motionBlurSamples: number;
  59237. /**
  59238. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59239. */
  59240. samples: number;
  59241. /**
  59242. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59243. * @constructor
  59244. * @param name The rendering pipeline name
  59245. * @param scene The scene linked to this pipeline
  59246. * @param 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)
  59247. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59248. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59249. */
  59250. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59251. private _buildPipeline;
  59252. private _createDownSampleX4PostProcess;
  59253. private _createBrightPassPostProcess;
  59254. private _createBlurPostProcesses;
  59255. private _createTextureAdderPostProcess;
  59256. private _createVolumetricLightPostProcess;
  59257. private _createLuminancePostProcesses;
  59258. private _createHdrPostProcess;
  59259. private _createLensFlarePostProcess;
  59260. private _createDepthOfFieldPostProcess;
  59261. private _createMotionBlurPostProcess;
  59262. private _getDepthTexture;
  59263. private _disposePostProcesses;
  59264. /**
  59265. * Dispose of the pipeline and stop all post processes
  59266. */
  59267. dispose(): void;
  59268. /**
  59269. * Serialize the rendering pipeline (Used when exporting)
  59270. * @returns the serialized object
  59271. */
  59272. serialize(): any;
  59273. /**
  59274. * Parse the serialized pipeline
  59275. * @param source Source pipeline.
  59276. * @param scene The scene to load the pipeline to.
  59277. * @param rootUrl The URL of the serialized pipeline.
  59278. * @returns An instantiated pipeline from the serialized object.
  59279. */
  59280. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59281. /**
  59282. * Luminance steps
  59283. */
  59284. static LuminanceSteps: number;
  59285. }
  59286. }
  59287. declare module BABYLON {
  59288. /** @hidden */
  59289. export var tonemapPixelShader: {
  59290. name: string;
  59291. shader: string;
  59292. };
  59293. }
  59294. declare module BABYLON {
  59295. /** Defines operator used for tonemapping */
  59296. export enum TonemappingOperator {
  59297. /** Hable */
  59298. Hable = 0,
  59299. /** Reinhard */
  59300. Reinhard = 1,
  59301. /** HejiDawson */
  59302. HejiDawson = 2,
  59303. /** Photographic */
  59304. Photographic = 3
  59305. }
  59306. /**
  59307. * Defines a post process to apply tone mapping
  59308. */
  59309. export class TonemapPostProcess extends PostProcess {
  59310. private _operator;
  59311. /** Defines the required exposure adjustement */
  59312. exposureAdjustment: number;
  59313. /**
  59314. * Creates a new TonemapPostProcess
  59315. * @param name defines the name of the postprocess
  59316. * @param _operator defines the operator to use
  59317. * @param exposureAdjustment defines the required exposure adjustement
  59318. * @param camera defines the camera to use (can be null)
  59319. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59320. * @param engine defines the hosting engine (can be ignore if camera is set)
  59321. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59322. */
  59323. constructor(name: string, _operator: TonemappingOperator,
  59324. /** Defines the required exposure adjustement */
  59325. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59326. }
  59327. }
  59328. declare module BABYLON {
  59329. /** @hidden */
  59330. export var depthVertexShader: {
  59331. name: string;
  59332. shader: string;
  59333. };
  59334. }
  59335. declare module BABYLON {
  59336. /** @hidden */
  59337. export var volumetricLightScatteringPixelShader: {
  59338. name: string;
  59339. shader: string;
  59340. };
  59341. }
  59342. declare module BABYLON {
  59343. /** @hidden */
  59344. export var volumetricLightScatteringPassVertexShader: {
  59345. name: string;
  59346. shader: string;
  59347. };
  59348. }
  59349. declare module BABYLON {
  59350. /** @hidden */
  59351. export var volumetricLightScatteringPassPixelShader: {
  59352. name: string;
  59353. shader: string;
  59354. };
  59355. }
  59356. declare module BABYLON {
  59357. /**
  59358. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59359. */
  59360. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59361. private _volumetricLightScatteringPass;
  59362. private _volumetricLightScatteringRTT;
  59363. private _viewPort;
  59364. private _screenCoordinates;
  59365. private _cachedDefines;
  59366. /**
  59367. * If not undefined, the mesh position is computed from the attached node position
  59368. */
  59369. attachedNode: {
  59370. position: Vector3;
  59371. };
  59372. /**
  59373. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59374. */
  59375. customMeshPosition: Vector3;
  59376. /**
  59377. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59378. */
  59379. useCustomMeshPosition: boolean;
  59380. /**
  59381. * If the post-process should inverse the light scattering direction
  59382. */
  59383. invert: boolean;
  59384. /**
  59385. * The internal mesh used by the post-process
  59386. */
  59387. mesh: Mesh;
  59388. /**
  59389. * @hidden
  59390. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59391. */
  59392. useDiffuseColor: boolean;
  59393. /**
  59394. * Array containing the excluded meshes not rendered in the internal pass
  59395. */
  59396. excludedMeshes: AbstractMesh[];
  59397. /**
  59398. * Controls the overall intensity of the post-process
  59399. */
  59400. exposure: number;
  59401. /**
  59402. * Dissipates each sample's contribution in range [0, 1]
  59403. */
  59404. decay: number;
  59405. /**
  59406. * Controls the overall intensity of each sample
  59407. */
  59408. weight: number;
  59409. /**
  59410. * Controls the density of each sample
  59411. */
  59412. density: number;
  59413. /**
  59414. * @constructor
  59415. * @param name The post-process name
  59416. * @param 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)
  59417. * @param camera The camera that the post-process will be attached to
  59418. * @param mesh The mesh used to create the light scattering
  59419. * @param samples The post-process quality, default 100
  59420. * @param samplingModeThe post-process filtering mode
  59421. * @param engine The babylon engine
  59422. * @param reusable If the post-process is reusable
  59423. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59424. */
  59425. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59426. /**
  59427. * Returns the string "VolumetricLightScatteringPostProcess"
  59428. * @returns "VolumetricLightScatteringPostProcess"
  59429. */
  59430. getClassName(): string;
  59431. private _isReady;
  59432. /**
  59433. * Sets the new light position for light scattering effect
  59434. * @param position The new custom light position
  59435. */
  59436. setCustomMeshPosition(position: Vector3): void;
  59437. /**
  59438. * Returns the light position for light scattering effect
  59439. * @return Vector3 The custom light position
  59440. */
  59441. getCustomMeshPosition(): Vector3;
  59442. /**
  59443. * Disposes the internal assets and detaches the post-process from the camera
  59444. */
  59445. dispose(camera: Camera): void;
  59446. /**
  59447. * Returns the render target texture used by the post-process
  59448. * @return the render target texture used by the post-process
  59449. */
  59450. getPass(): RenderTargetTexture;
  59451. private _meshExcluded;
  59452. private _createPass;
  59453. private _updateMeshScreenCoordinates;
  59454. /**
  59455. * Creates a default mesh for the Volumeric Light Scattering post-process
  59456. * @param name The mesh name
  59457. * @param scene The scene where to create the mesh
  59458. * @return the default mesh
  59459. */
  59460. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59461. }
  59462. }
  59463. declare module BABYLON {
  59464. interface Scene {
  59465. /** @hidden (Backing field) */
  59466. _boundingBoxRenderer: BoundingBoxRenderer;
  59467. /** @hidden (Backing field) */
  59468. _forceShowBoundingBoxes: boolean;
  59469. /**
  59470. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  59471. */
  59472. forceShowBoundingBoxes: boolean;
  59473. /**
  59474. * Gets the bounding box renderer associated with the scene
  59475. * @returns a BoundingBoxRenderer
  59476. */
  59477. getBoundingBoxRenderer(): BoundingBoxRenderer;
  59478. }
  59479. interface AbstractMesh {
  59480. /** @hidden (Backing field) */
  59481. _showBoundingBox: boolean;
  59482. /**
  59483. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  59484. */
  59485. showBoundingBox: boolean;
  59486. }
  59487. /**
  59488. * Component responsible of rendering the bounding box of the meshes in a scene.
  59489. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  59490. */
  59491. export class BoundingBoxRenderer implements ISceneComponent {
  59492. /**
  59493. * The component name helpfull to identify the component in the list of scene components.
  59494. */
  59495. readonly name: string;
  59496. /**
  59497. * The scene the component belongs to.
  59498. */
  59499. scene: Scene;
  59500. /**
  59501. * Color of the bounding box lines placed in front of an object
  59502. */
  59503. frontColor: Color3;
  59504. /**
  59505. * Color of the bounding box lines placed behind an object
  59506. */
  59507. backColor: Color3;
  59508. /**
  59509. * Defines if the renderer should show the back lines or not
  59510. */
  59511. showBackLines: boolean;
  59512. /**
  59513. * @hidden
  59514. */
  59515. renderList: SmartArray<BoundingBox>;
  59516. private _colorShader;
  59517. private _vertexBuffers;
  59518. private _indexBuffer;
  59519. private _fillIndexBuffer;
  59520. private _fillIndexData;
  59521. /**
  59522. * Instantiates a new bounding box renderer in a scene.
  59523. * @param scene the scene the renderer renders in
  59524. */
  59525. constructor(scene: Scene);
  59526. /**
  59527. * Registers the component in a given scene
  59528. */
  59529. register(): void;
  59530. private _evaluateSubMesh;
  59531. private _activeMesh;
  59532. private _prepareRessources;
  59533. private _createIndexBuffer;
  59534. /**
  59535. * Rebuilds the elements related to this component in case of
  59536. * context lost for instance.
  59537. */
  59538. rebuild(): void;
  59539. /**
  59540. * @hidden
  59541. */
  59542. reset(): void;
  59543. /**
  59544. * Render the bounding boxes of a specific rendering group
  59545. * @param renderingGroupId defines the rendering group to render
  59546. */
  59547. render(renderingGroupId: number): void;
  59548. /**
  59549. * In case of occlusion queries, we can render the occlusion bounding box through this method
  59550. * @param mesh Define the mesh to render the occlusion bounding box for
  59551. */
  59552. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  59553. /**
  59554. * Dispose and release the resources attached to this renderer.
  59555. */
  59556. dispose(): void;
  59557. }
  59558. }
  59559. declare module BABYLON {
  59560. /** @hidden */
  59561. export var depthPixelShader: {
  59562. name: string;
  59563. shader: string;
  59564. };
  59565. }
  59566. declare module BABYLON {
  59567. /**
  59568. * This represents a depth renderer in Babylon.
  59569. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59570. */
  59571. export class DepthRenderer {
  59572. private _scene;
  59573. private _depthMap;
  59574. private _effect;
  59575. private readonly _storeNonLinearDepth;
  59576. private readonly _clearColor;
  59577. /** Get if the depth renderer is using packed depth or not */
  59578. readonly isPacked: boolean;
  59579. private _cachedDefines;
  59580. private _camera;
  59581. /**
  59582. * Specifiess that the depth renderer will only be used within
  59583. * the camera it is created for.
  59584. * This can help forcing its rendering during the camera processing.
  59585. */
  59586. useOnlyInActiveCamera: boolean;
  59587. /** @hidden */
  59588. static _SceneComponentInitialization: (scene: Scene) => void;
  59589. /**
  59590. * Instantiates a depth renderer
  59591. * @param scene The scene the renderer belongs to
  59592. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59593. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59594. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59595. */
  59596. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59597. /**
  59598. * Creates the depth rendering effect and checks if the effect is ready.
  59599. * @param subMesh The submesh to be used to render the depth map of
  59600. * @param useInstances If multiple world instances should be used
  59601. * @returns if the depth renderer is ready to render the depth map
  59602. */
  59603. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59604. /**
  59605. * Gets the texture which the depth map will be written to.
  59606. * @returns The depth map texture
  59607. */
  59608. getDepthMap(): RenderTargetTexture;
  59609. /**
  59610. * Disposes of the depth renderer.
  59611. */
  59612. dispose(): void;
  59613. }
  59614. }
  59615. declare module BABYLON {
  59616. interface Scene {
  59617. /** @hidden (Backing field) */
  59618. _depthRenderer: {
  59619. [id: string]: DepthRenderer;
  59620. };
  59621. /**
  59622. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  59623. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  59624. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59625. * @returns the created depth renderer
  59626. */
  59627. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  59628. /**
  59629. * Disables a depth renderer for a given camera
  59630. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  59631. */
  59632. disableDepthRenderer(camera?: Nullable<Camera>): void;
  59633. }
  59634. /**
  59635. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  59636. * in several rendering techniques.
  59637. */
  59638. export class DepthRendererSceneComponent implements ISceneComponent {
  59639. /**
  59640. * The component name helpfull to identify the component in the list of scene components.
  59641. */
  59642. readonly name: string;
  59643. /**
  59644. * The scene the component belongs to.
  59645. */
  59646. scene: Scene;
  59647. /**
  59648. * Creates a new instance of the component for the given scene
  59649. * @param scene Defines the scene to register the component in
  59650. */
  59651. constructor(scene: Scene);
  59652. /**
  59653. * Registers the component in a given scene
  59654. */
  59655. register(): void;
  59656. /**
  59657. * Rebuilds the elements related to this component in case of
  59658. * context lost for instance.
  59659. */
  59660. rebuild(): void;
  59661. /**
  59662. * Disposes the component and the associated ressources
  59663. */
  59664. dispose(): void;
  59665. private _gatherRenderTargets;
  59666. private _gatherActiveCameraRenderTargets;
  59667. }
  59668. }
  59669. declare module BABYLON {
  59670. /** @hidden */
  59671. export var outlinePixelShader: {
  59672. name: string;
  59673. shader: string;
  59674. };
  59675. }
  59676. declare module BABYLON {
  59677. /** @hidden */
  59678. export var outlineVertexShader: {
  59679. name: string;
  59680. shader: string;
  59681. };
  59682. }
  59683. declare module BABYLON {
  59684. interface Scene {
  59685. /** @hidden */
  59686. _outlineRenderer: OutlineRenderer;
  59687. /**
  59688. * Gets the outline renderer associated with the scene
  59689. * @returns a OutlineRenderer
  59690. */
  59691. getOutlineRenderer(): OutlineRenderer;
  59692. }
  59693. interface AbstractMesh {
  59694. /** @hidden (Backing field) */
  59695. _renderOutline: boolean;
  59696. /**
  59697. * Gets or sets a boolean indicating if the outline must be rendered as well
  59698. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  59699. */
  59700. renderOutline: boolean;
  59701. /** @hidden (Backing field) */
  59702. _renderOverlay: boolean;
  59703. /**
  59704. * Gets or sets a boolean indicating if the overlay must be rendered as well
  59705. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  59706. */
  59707. renderOverlay: boolean;
  59708. }
  59709. /**
  59710. * This class is responsible to draw bothe outline/overlay of meshes.
  59711. * It should not be used directly but through the available method on mesh.
  59712. */
  59713. export class OutlineRenderer implements ISceneComponent {
  59714. /**
  59715. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  59716. */
  59717. private static _StencilReference;
  59718. /**
  59719. * The name of the component. Each component must have a unique name.
  59720. */
  59721. name: string;
  59722. /**
  59723. * The scene the component belongs to.
  59724. */
  59725. scene: Scene;
  59726. /**
  59727. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  59728. */
  59729. zOffset: number;
  59730. private _engine;
  59731. private _effect;
  59732. private _cachedDefines;
  59733. private _savedDepthWrite;
  59734. /**
  59735. * Instantiates a new outline renderer. (There could be only one per scene).
  59736. * @param scene Defines the scene it belongs to
  59737. */
  59738. constructor(scene: Scene);
  59739. /**
  59740. * Register the component to one instance of a scene.
  59741. */
  59742. register(): void;
  59743. /**
  59744. * Rebuilds the elements related to this component in case of
  59745. * context lost for instance.
  59746. */
  59747. rebuild(): void;
  59748. /**
  59749. * Disposes the component and the associated ressources.
  59750. */
  59751. dispose(): void;
  59752. /**
  59753. * Renders the outline in the canvas.
  59754. * @param subMesh Defines the sumesh to render
  59755. * @param batch Defines the batch of meshes in case of instances
  59756. * @param useOverlay Defines if the rendering is for the overlay or the outline
  59757. */
  59758. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  59759. /**
  59760. * Returns whether or not the outline renderer is ready for a given submesh.
  59761. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  59762. * @param subMesh Defines the submesh to check readyness for
  59763. * @param useInstances Defines wheter wee are trying to render instances or not
  59764. * @returns true if ready otherwise false
  59765. */
  59766. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59767. private _beforeRenderingMesh;
  59768. private _afterRenderingMesh;
  59769. }
  59770. }
  59771. declare module BABYLON {
  59772. /**
  59773. * Class used to manage multiple sprites of different sizes on the same spritesheet
  59774. * @see http://doc.babylonjs.com/babylon101/sprites
  59775. */
  59776. export class SpritePackedManager extends SpriteManager {
  59777. /** defines the packed manager's name */
  59778. name: string;
  59779. /**
  59780. * Creates a new sprite manager from a packed sprite sheet
  59781. * @param name defines the manager's name
  59782. * @param imgUrl defines the sprite sheet url
  59783. * @param capacity defines the maximum allowed number of sprites
  59784. * @param scene defines the hosting scene
  59785. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  59786. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  59787. * @param samplingMode defines the smapling mode to use with spritesheet
  59788. * @param fromPacked set to true; do not alter
  59789. */
  59790. constructor(
  59791. /** defines the packed manager's name */
  59792. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  59793. }
  59794. }
  59795. declare module BABYLON {
  59796. /**
  59797. * Defines the list of states available for a task inside a AssetsManager
  59798. */
  59799. export enum AssetTaskState {
  59800. /**
  59801. * Initialization
  59802. */
  59803. INIT = 0,
  59804. /**
  59805. * Running
  59806. */
  59807. RUNNING = 1,
  59808. /**
  59809. * Done
  59810. */
  59811. DONE = 2,
  59812. /**
  59813. * Error
  59814. */
  59815. ERROR = 3
  59816. }
  59817. /**
  59818. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  59819. */
  59820. export abstract class AbstractAssetTask {
  59821. /**
  59822. * Task name
  59823. */ name: string;
  59824. /**
  59825. * Callback called when the task is successful
  59826. */
  59827. onSuccess: (task: any) => void;
  59828. /**
  59829. * Callback called when the task is not successful
  59830. */
  59831. onError: (task: any, message?: string, exception?: any) => void;
  59832. /**
  59833. * Creates a new AssetsManager
  59834. * @param name defines the name of the task
  59835. */
  59836. constructor(
  59837. /**
  59838. * Task name
  59839. */ name: string);
  59840. private _isCompleted;
  59841. private _taskState;
  59842. private _errorObject;
  59843. /**
  59844. * Get if the task is completed
  59845. */
  59846. readonly isCompleted: boolean;
  59847. /**
  59848. * Gets the current state of the task
  59849. */
  59850. readonly taskState: AssetTaskState;
  59851. /**
  59852. * Gets the current error object (if task is in error)
  59853. */
  59854. readonly errorObject: {
  59855. message?: string;
  59856. exception?: any;
  59857. };
  59858. /**
  59859. * Internal only
  59860. * @hidden
  59861. */
  59862. _setErrorObject(message?: string, exception?: any): void;
  59863. /**
  59864. * Execute the current task
  59865. * @param scene defines the scene where you want your assets to be loaded
  59866. * @param onSuccess is a callback called when the task is successfully executed
  59867. * @param onError is a callback called if an error occurs
  59868. */
  59869. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59870. /**
  59871. * Execute the current task
  59872. * @param scene defines the scene where you want your assets to be loaded
  59873. * @param onSuccess is a callback called when the task is successfully executed
  59874. * @param onError is a callback called if an error occurs
  59875. */
  59876. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59877. /**
  59878. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  59879. * This can be used with failed tasks that have the reason for failure fixed.
  59880. */
  59881. reset(): void;
  59882. private onErrorCallback;
  59883. private onDoneCallback;
  59884. }
  59885. /**
  59886. * Define the interface used by progress events raised during assets loading
  59887. */
  59888. export interface IAssetsProgressEvent {
  59889. /**
  59890. * Defines the number of remaining tasks to process
  59891. */
  59892. remainingCount: number;
  59893. /**
  59894. * Defines the total number of tasks
  59895. */
  59896. totalCount: number;
  59897. /**
  59898. * Defines the task that was just processed
  59899. */
  59900. task: AbstractAssetTask;
  59901. }
  59902. /**
  59903. * Class used to share progress information about assets loading
  59904. */
  59905. export class AssetsProgressEvent implements IAssetsProgressEvent {
  59906. /**
  59907. * Defines the number of remaining tasks to process
  59908. */
  59909. remainingCount: number;
  59910. /**
  59911. * Defines the total number of tasks
  59912. */
  59913. totalCount: number;
  59914. /**
  59915. * Defines the task that was just processed
  59916. */
  59917. task: AbstractAssetTask;
  59918. /**
  59919. * Creates a AssetsProgressEvent
  59920. * @param remainingCount defines the number of remaining tasks to process
  59921. * @param totalCount defines the total number of tasks
  59922. * @param task defines the task that was just processed
  59923. */
  59924. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  59925. }
  59926. /**
  59927. * Define a task used by AssetsManager to load meshes
  59928. */
  59929. export class MeshAssetTask extends AbstractAssetTask {
  59930. /**
  59931. * Defines the name of the task
  59932. */
  59933. name: string;
  59934. /**
  59935. * Defines the list of mesh's names you want to load
  59936. */
  59937. meshesNames: any;
  59938. /**
  59939. * Defines the root url to use as a base to load your meshes and associated resources
  59940. */
  59941. rootUrl: string;
  59942. /**
  59943. * Defines the filename of the scene to load from
  59944. */
  59945. sceneFilename: string;
  59946. /**
  59947. * Gets the list of loaded meshes
  59948. */
  59949. loadedMeshes: Array<AbstractMesh>;
  59950. /**
  59951. * Gets the list of loaded particle systems
  59952. */
  59953. loadedParticleSystems: Array<IParticleSystem>;
  59954. /**
  59955. * Gets the list of loaded skeletons
  59956. */
  59957. loadedSkeletons: Array<Skeleton>;
  59958. /**
  59959. * Gets the list of loaded animation groups
  59960. */
  59961. loadedAnimationGroups: Array<AnimationGroup>;
  59962. /**
  59963. * Callback called when the task is successful
  59964. */
  59965. onSuccess: (task: MeshAssetTask) => void;
  59966. /**
  59967. * Callback called when the task is successful
  59968. */
  59969. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  59970. /**
  59971. * Creates a new MeshAssetTask
  59972. * @param name defines the name of the task
  59973. * @param meshesNames defines the list of mesh's names you want to load
  59974. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  59975. * @param sceneFilename defines the filename of the scene to load from
  59976. */
  59977. constructor(
  59978. /**
  59979. * Defines the name of the task
  59980. */
  59981. name: string,
  59982. /**
  59983. * Defines the list of mesh's names you want to load
  59984. */
  59985. meshesNames: any,
  59986. /**
  59987. * Defines the root url to use as a base to load your meshes and associated resources
  59988. */
  59989. rootUrl: string,
  59990. /**
  59991. * Defines the filename of the scene to load from
  59992. */
  59993. sceneFilename: string);
  59994. /**
  59995. * Execute the current task
  59996. * @param scene defines the scene where you want your assets to be loaded
  59997. * @param onSuccess is a callback called when the task is successfully executed
  59998. * @param onError is a callback called if an error occurs
  59999. */
  60000. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60001. }
  60002. /**
  60003. * Define a task used by AssetsManager to load text content
  60004. */
  60005. export class TextFileAssetTask extends AbstractAssetTask {
  60006. /**
  60007. * Defines the name of the task
  60008. */
  60009. name: string;
  60010. /**
  60011. * Defines the location of the file to load
  60012. */
  60013. url: string;
  60014. /**
  60015. * Gets the loaded text string
  60016. */
  60017. text: string;
  60018. /**
  60019. * Callback called when the task is successful
  60020. */
  60021. onSuccess: (task: TextFileAssetTask) => void;
  60022. /**
  60023. * Callback called when the task is successful
  60024. */
  60025. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60026. /**
  60027. * Creates a new TextFileAssetTask object
  60028. * @param name defines the name of the task
  60029. * @param url defines the location of the file to load
  60030. */
  60031. constructor(
  60032. /**
  60033. * Defines the name of the task
  60034. */
  60035. name: string,
  60036. /**
  60037. * Defines the location of the file to load
  60038. */
  60039. url: string);
  60040. /**
  60041. * Execute the current task
  60042. * @param scene defines the scene where you want your assets to be loaded
  60043. * @param onSuccess is a callback called when the task is successfully executed
  60044. * @param onError is a callback called if an error occurs
  60045. */
  60046. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60047. }
  60048. /**
  60049. * Define a task used by AssetsManager to load binary data
  60050. */
  60051. export class BinaryFileAssetTask extends AbstractAssetTask {
  60052. /**
  60053. * Defines the name of the task
  60054. */
  60055. name: string;
  60056. /**
  60057. * Defines the location of the file to load
  60058. */
  60059. url: string;
  60060. /**
  60061. * Gets the lodaded data (as an array buffer)
  60062. */
  60063. data: ArrayBuffer;
  60064. /**
  60065. * Callback called when the task is successful
  60066. */
  60067. onSuccess: (task: BinaryFileAssetTask) => void;
  60068. /**
  60069. * Callback called when the task is successful
  60070. */
  60071. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60072. /**
  60073. * Creates a new BinaryFileAssetTask object
  60074. * @param name defines the name of the new task
  60075. * @param url defines the location of the file to load
  60076. */
  60077. constructor(
  60078. /**
  60079. * Defines the name of the task
  60080. */
  60081. name: string,
  60082. /**
  60083. * Defines the location of the file to load
  60084. */
  60085. url: string);
  60086. /**
  60087. * Execute the current task
  60088. * @param scene defines the scene where you want your assets to be loaded
  60089. * @param onSuccess is a callback called when the task is successfully executed
  60090. * @param onError is a callback called if an error occurs
  60091. */
  60092. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60093. }
  60094. /**
  60095. * Define a task used by AssetsManager to load images
  60096. */
  60097. export class ImageAssetTask extends AbstractAssetTask {
  60098. /**
  60099. * Defines the name of the task
  60100. */
  60101. name: string;
  60102. /**
  60103. * Defines the location of the image to load
  60104. */
  60105. url: string;
  60106. /**
  60107. * Gets the loaded images
  60108. */
  60109. image: HTMLImageElement;
  60110. /**
  60111. * Callback called when the task is successful
  60112. */
  60113. onSuccess: (task: ImageAssetTask) => void;
  60114. /**
  60115. * Callback called when the task is successful
  60116. */
  60117. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60118. /**
  60119. * Creates a new ImageAssetTask
  60120. * @param name defines the name of the task
  60121. * @param url defines the location of the image to load
  60122. */
  60123. constructor(
  60124. /**
  60125. * Defines the name of the task
  60126. */
  60127. name: string,
  60128. /**
  60129. * Defines the location of the image to load
  60130. */
  60131. url: string);
  60132. /**
  60133. * Execute the current task
  60134. * @param scene defines the scene where you want your assets to be loaded
  60135. * @param onSuccess is a callback called when the task is successfully executed
  60136. * @param onError is a callback called if an error occurs
  60137. */
  60138. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60139. }
  60140. /**
  60141. * Defines the interface used by texture loading tasks
  60142. */
  60143. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60144. /**
  60145. * Gets the loaded texture
  60146. */
  60147. texture: TEX;
  60148. }
  60149. /**
  60150. * Define a task used by AssetsManager to load 2D textures
  60151. */
  60152. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60153. /**
  60154. * Defines the name of the task
  60155. */
  60156. name: string;
  60157. /**
  60158. * Defines the location of the file to load
  60159. */
  60160. url: string;
  60161. /**
  60162. * Defines if mipmap should not be generated (default is false)
  60163. */
  60164. noMipmap?: boolean | undefined;
  60165. /**
  60166. * Defines if texture must be inverted on Y axis (default is false)
  60167. */
  60168. invertY?: boolean | undefined;
  60169. /**
  60170. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60171. */
  60172. samplingMode: number;
  60173. /**
  60174. * Gets the loaded texture
  60175. */
  60176. texture: Texture;
  60177. /**
  60178. * Callback called when the task is successful
  60179. */
  60180. onSuccess: (task: TextureAssetTask) => void;
  60181. /**
  60182. * Callback called when the task is successful
  60183. */
  60184. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60185. /**
  60186. * Creates a new TextureAssetTask object
  60187. * @param name defines the name of the task
  60188. * @param url defines the location of the file to load
  60189. * @param noMipmap defines if mipmap should not be generated (default is false)
  60190. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60191. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60192. */
  60193. constructor(
  60194. /**
  60195. * Defines the name of the task
  60196. */
  60197. name: string,
  60198. /**
  60199. * Defines the location of the file to load
  60200. */
  60201. url: string,
  60202. /**
  60203. * Defines if mipmap should not be generated (default is false)
  60204. */
  60205. noMipmap?: boolean | undefined,
  60206. /**
  60207. * Defines if texture must be inverted on Y axis (default is false)
  60208. */
  60209. invertY?: boolean | undefined,
  60210. /**
  60211. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60212. */
  60213. samplingMode?: number);
  60214. /**
  60215. * Execute the current task
  60216. * @param scene defines the scene where you want your assets to be loaded
  60217. * @param onSuccess is a callback called when the task is successfully executed
  60218. * @param onError is a callback called if an error occurs
  60219. */
  60220. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60221. }
  60222. /**
  60223. * Define a task used by AssetsManager to load cube textures
  60224. */
  60225. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60226. /**
  60227. * Defines the name of the task
  60228. */
  60229. name: string;
  60230. /**
  60231. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60232. */
  60233. url: string;
  60234. /**
  60235. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60236. */
  60237. extensions?: string[] | undefined;
  60238. /**
  60239. * Defines if mipmaps should not be generated (default is false)
  60240. */
  60241. noMipmap?: boolean | undefined;
  60242. /**
  60243. * Defines the explicit list of files (undefined by default)
  60244. */
  60245. files?: string[] | undefined;
  60246. /**
  60247. * Gets the loaded texture
  60248. */
  60249. texture: CubeTexture;
  60250. /**
  60251. * Callback called when the task is successful
  60252. */
  60253. onSuccess: (task: CubeTextureAssetTask) => void;
  60254. /**
  60255. * Callback called when the task is successful
  60256. */
  60257. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60258. /**
  60259. * Creates a new CubeTextureAssetTask
  60260. * @param name defines the name of the task
  60261. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60262. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60263. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60264. * @param files defines the explicit list of files (undefined by default)
  60265. */
  60266. constructor(
  60267. /**
  60268. * Defines the name of the task
  60269. */
  60270. name: string,
  60271. /**
  60272. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60273. */
  60274. url: string,
  60275. /**
  60276. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60277. */
  60278. extensions?: string[] | undefined,
  60279. /**
  60280. * Defines if mipmaps should not be generated (default is false)
  60281. */
  60282. noMipmap?: boolean | undefined,
  60283. /**
  60284. * Defines the explicit list of files (undefined by default)
  60285. */
  60286. files?: string[] | undefined);
  60287. /**
  60288. * Execute the current task
  60289. * @param scene defines the scene where you want your assets to be loaded
  60290. * @param onSuccess is a callback called when the task is successfully executed
  60291. * @param onError is a callback called if an error occurs
  60292. */
  60293. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60294. }
  60295. /**
  60296. * Define a task used by AssetsManager to load HDR cube textures
  60297. */
  60298. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60299. /**
  60300. * Defines the name of the task
  60301. */
  60302. name: string;
  60303. /**
  60304. * Defines the location of the file to load
  60305. */
  60306. url: string;
  60307. /**
  60308. * Defines the desired size (the more it increases the longer the generation will be)
  60309. */
  60310. size: number;
  60311. /**
  60312. * Defines if mipmaps should not be generated (default is false)
  60313. */
  60314. noMipmap: boolean;
  60315. /**
  60316. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60317. */
  60318. generateHarmonics: boolean;
  60319. /**
  60320. * 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)
  60321. */
  60322. gammaSpace: boolean;
  60323. /**
  60324. * Internal Use Only
  60325. */
  60326. reserved: boolean;
  60327. /**
  60328. * Gets the loaded texture
  60329. */
  60330. texture: HDRCubeTexture;
  60331. /**
  60332. * Callback called when the task is successful
  60333. */
  60334. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60335. /**
  60336. * Callback called when the task is successful
  60337. */
  60338. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60339. /**
  60340. * Creates a new HDRCubeTextureAssetTask object
  60341. * @param name defines the name of the task
  60342. * @param url defines the location of the file to load
  60343. * @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.
  60344. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60345. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60346. * @param gammaSpace 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)
  60347. * @param reserved Internal use only
  60348. */
  60349. constructor(
  60350. /**
  60351. * Defines the name of the task
  60352. */
  60353. name: string,
  60354. /**
  60355. * Defines the location of the file to load
  60356. */
  60357. url: string,
  60358. /**
  60359. * Defines the desired size (the more it increases the longer the generation will be)
  60360. */
  60361. size: number,
  60362. /**
  60363. * Defines if mipmaps should not be generated (default is false)
  60364. */
  60365. noMipmap?: boolean,
  60366. /**
  60367. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60368. */
  60369. generateHarmonics?: boolean,
  60370. /**
  60371. * 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)
  60372. */
  60373. gammaSpace?: boolean,
  60374. /**
  60375. * Internal Use Only
  60376. */
  60377. reserved?: boolean);
  60378. /**
  60379. * Execute the current task
  60380. * @param scene defines the scene where you want your assets to be loaded
  60381. * @param onSuccess is a callback called when the task is successfully executed
  60382. * @param onError is a callback called if an error occurs
  60383. */
  60384. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60385. }
  60386. /**
  60387. * Define a task used by AssetsManager to load Equirectangular cube textures
  60388. */
  60389. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60390. /**
  60391. * Defines the name of the task
  60392. */
  60393. name: string;
  60394. /**
  60395. * Defines the location of the file to load
  60396. */
  60397. url: string;
  60398. /**
  60399. * Defines the desired size (the more it increases the longer the generation will be)
  60400. */
  60401. size: number;
  60402. /**
  60403. * Defines if mipmaps should not be generated (default is false)
  60404. */
  60405. noMipmap: boolean;
  60406. /**
  60407. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60408. * but the standard material would require them in Gamma space) (default is true)
  60409. */
  60410. gammaSpace: boolean;
  60411. /**
  60412. * Gets the loaded texture
  60413. */
  60414. texture: EquiRectangularCubeTexture;
  60415. /**
  60416. * Callback called when the task is successful
  60417. */
  60418. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60419. /**
  60420. * Callback called when the task is successful
  60421. */
  60422. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60423. /**
  60424. * Creates a new EquiRectangularCubeTextureAssetTask object
  60425. * @param name defines the name of the task
  60426. * @param url defines the location of the file to load
  60427. * @param size defines the desired size (the more it increases the longer the generation will be)
  60428. * If the size is omitted this implies you are using a preprocessed cubemap.
  60429. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60430. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60431. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60432. * (default is true)
  60433. */
  60434. constructor(
  60435. /**
  60436. * Defines the name of the task
  60437. */
  60438. name: string,
  60439. /**
  60440. * Defines the location of the file to load
  60441. */
  60442. url: string,
  60443. /**
  60444. * Defines the desired size (the more it increases the longer the generation will be)
  60445. */
  60446. size: number,
  60447. /**
  60448. * Defines if mipmaps should not be generated (default is false)
  60449. */
  60450. noMipmap?: boolean,
  60451. /**
  60452. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60453. * but the standard material would require them in Gamma space) (default is true)
  60454. */
  60455. gammaSpace?: boolean);
  60456. /**
  60457. * Execute the current task
  60458. * @param scene defines the scene where you want your assets to be loaded
  60459. * @param onSuccess is a callback called when the task is successfully executed
  60460. * @param onError is a callback called if an error occurs
  60461. */
  60462. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60463. }
  60464. /**
  60465. * This class can be used to easily import assets into a scene
  60466. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  60467. */
  60468. export class AssetsManager {
  60469. private _scene;
  60470. private _isLoading;
  60471. protected _tasks: AbstractAssetTask[];
  60472. protected _waitingTasksCount: number;
  60473. protected _totalTasksCount: number;
  60474. /**
  60475. * Callback called when all tasks are processed
  60476. */
  60477. onFinish: (tasks: AbstractAssetTask[]) => void;
  60478. /**
  60479. * Callback called when a task is successful
  60480. */
  60481. onTaskSuccess: (task: AbstractAssetTask) => void;
  60482. /**
  60483. * Callback called when a task had an error
  60484. */
  60485. onTaskError: (task: AbstractAssetTask) => void;
  60486. /**
  60487. * Callback called when a task is done (whatever the result is)
  60488. */
  60489. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  60490. /**
  60491. * Observable called when all tasks are processed
  60492. */
  60493. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  60494. /**
  60495. * Observable called when a task had an error
  60496. */
  60497. onTaskErrorObservable: Observable<AbstractAssetTask>;
  60498. /**
  60499. * Observable called when all tasks were executed
  60500. */
  60501. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  60502. /**
  60503. * Observable called when a task is done (whatever the result is)
  60504. */
  60505. onProgressObservable: Observable<IAssetsProgressEvent>;
  60506. /**
  60507. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  60508. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  60509. */
  60510. useDefaultLoadingScreen: boolean;
  60511. /**
  60512. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  60513. * when all assets have been downloaded.
  60514. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  60515. */
  60516. autoHideLoadingUI: boolean;
  60517. /**
  60518. * Creates a new AssetsManager
  60519. * @param scene defines the scene to work on
  60520. */
  60521. constructor(scene: Scene);
  60522. /**
  60523. * Add a MeshAssetTask to the list of active tasks
  60524. * @param taskName defines the name of the new task
  60525. * @param meshesNames defines the name of meshes to load
  60526. * @param rootUrl defines the root url to use to locate files
  60527. * @param sceneFilename defines the filename of the scene file
  60528. * @returns a new MeshAssetTask object
  60529. */
  60530. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  60531. /**
  60532. * Add a TextFileAssetTask to the list of active tasks
  60533. * @param taskName defines the name of the new task
  60534. * @param url defines the url of the file to load
  60535. * @returns a new TextFileAssetTask object
  60536. */
  60537. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  60538. /**
  60539. * Add a BinaryFileAssetTask to the list of active tasks
  60540. * @param taskName defines the name of the new task
  60541. * @param url defines the url of the file to load
  60542. * @returns a new BinaryFileAssetTask object
  60543. */
  60544. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  60545. /**
  60546. * Add a ImageAssetTask to the list of active tasks
  60547. * @param taskName defines the name of the new task
  60548. * @param url defines the url of the file to load
  60549. * @returns a new ImageAssetTask object
  60550. */
  60551. addImageTask(taskName: string, url: string): ImageAssetTask;
  60552. /**
  60553. * Add a TextureAssetTask to the list of active tasks
  60554. * @param taskName defines the name of the new task
  60555. * @param url defines the url of the file to load
  60556. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60557. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  60558. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60559. * @returns a new TextureAssetTask object
  60560. */
  60561. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  60562. /**
  60563. * Add a CubeTextureAssetTask to the list of active tasks
  60564. * @param taskName defines the name of the new task
  60565. * @param url defines the url of the file to load
  60566. * @param extensions defines the extension to use to load the cube map (can be null)
  60567. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60568. * @param files defines the list of files to load (can be null)
  60569. * @returns a new CubeTextureAssetTask object
  60570. */
  60571. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  60572. /**
  60573. *
  60574. * Add a HDRCubeTextureAssetTask to the list of active tasks
  60575. * @param taskName defines the name of the new task
  60576. * @param url defines the url of the file to load
  60577. * @param size defines the size you want for the cubemap (can be null)
  60578. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60579. * @param generateHarmonics defines if you want to automatically generate (true by default)
  60580. * @param gammaSpace 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)
  60581. * @param reserved Internal use only
  60582. * @returns a new HDRCubeTextureAssetTask object
  60583. */
  60584. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  60585. /**
  60586. *
  60587. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  60588. * @param taskName defines the name of the new task
  60589. * @param url defines the url of the file to load
  60590. * @param size defines the size you want for the cubemap (can be null)
  60591. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60592. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60593. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60594. * @returns a new EquiRectangularCubeTextureAssetTask object
  60595. */
  60596. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  60597. /**
  60598. * Remove a task from the assets manager.
  60599. * @param task the task to remove
  60600. */
  60601. removeTask(task: AbstractAssetTask): void;
  60602. private _decreaseWaitingTasksCount;
  60603. private _runTask;
  60604. /**
  60605. * Reset the AssetsManager and remove all tasks
  60606. * @return the current instance of the AssetsManager
  60607. */
  60608. reset(): AssetsManager;
  60609. /**
  60610. * Start the loading process
  60611. * @return the current instance of the AssetsManager
  60612. */
  60613. load(): AssetsManager;
  60614. /**
  60615. * Start the loading process as an async operation
  60616. * @return a promise returning the list of failed tasks
  60617. */
  60618. loadAsync(): Promise<void>;
  60619. }
  60620. }
  60621. declare module BABYLON {
  60622. /**
  60623. * Wrapper class for promise with external resolve and reject.
  60624. */
  60625. export class Deferred<T> {
  60626. /**
  60627. * The promise associated with this deferred object.
  60628. */
  60629. readonly promise: Promise<T>;
  60630. private _resolve;
  60631. private _reject;
  60632. /**
  60633. * The resolve method of the promise associated with this deferred object.
  60634. */
  60635. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  60636. /**
  60637. * The reject method of the promise associated with this deferred object.
  60638. */
  60639. readonly reject: (reason?: any) => void;
  60640. /**
  60641. * Constructor for this deferred object.
  60642. */
  60643. constructor();
  60644. }
  60645. }
  60646. declare module BABYLON {
  60647. /**
  60648. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  60649. */
  60650. export class MeshExploder {
  60651. private _centerMesh;
  60652. private _meshes;
  60653. private _meshesOrigins;
  60654. private _toCenterVectors;
  60655. private _scaledDirection;
  60656. private _newPosition;
  60657. private _centerPosition;
  60658. /**
  60659. * Explodes meshes from a center mesh.
  60660. * @param meshes The meshes to explode.
  60661. * @param centerMesh The mesh to be center of explosion.
  60662. */
  60663. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  60664. private _setCenterMesh;
  60665. /**
  60666. * Get class name
  60667. * @returns "MeshExploder"
  60668. */
  60669. getClassName(): string;
  60670. /**
  60671. * "Exploded meshes"
  60672. * @returns Array of meshes with the centerMesh at index 0.
  60673. */
  60674. getMeshes(): Array<Mesh>;
  60675. /**
  60676. * Explodes meshes giving a specific direction
  60677. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  60678. */
  60679. explode(direction?: number): void;
  60680. }
  60681. }
  60682. declare module BABYLON {
  60683. /**
  60684. * Class used to help managing file picking and drag'n'drop
  60685. */
  60686. export class FilesInput {
  60687. /**
  60688. * List of files ready to be loaded
  60689. */
  60690. static readonly FilesToLoad: {
  60691. [key: string]: File;
  60692. };
  60693. /**
  60694. * Callback called when a file is processed
  60695. */
  60696. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  60697. private _engine;
  60698. private _currentScene;
  60699. private _sceneLoadedCallback;
  60700. private _progressCallback;
  60701. private _additionalRenderLoopLogicCallback;
  60702. private _textureLoadingCallback;
  60703. private _startingProcessingFilesCallback;
  60704. private _onReloadCallback;
  60705. private _errorCallback;
  60706. private _elementToMonitor;
  60707. private _sceneFileToLoad;
  60708. private _filesToLoad;
  60709. /**
  60710. * Creates a new FilesInput
  60711. * @param engine defines the rendering engine
  60712. * @param scene defines the hosting scene
  60713. * @param sceneLoadedCallback callback called when scene is loaded
  60714. * @param progressCallback callback called to track progress
  60715. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  60716. * @param textureLoadingCallback callback called when a texture is loading
  60717. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  60718. * @param onReloadCallback callback called when a reload is requested
  60719. * @param errorCallback callback call if an error occurs
  60720. */
  60721. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  60722. private _dragEnterHandler;
  60723. private _dragOverHandler;
  60724. private _dropHandler;
  60725. /**
  60726. * Calls this function to listen to drag'n'drop events on a specific DOM element
  60727. * @param elementToMonitor defines the DOM element to track
  60728. */
  60729. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  60730. /**
  60731. * Release all associated resources
  60732. */
  60733. dispose(): void;
  60734. private renderFunction;
  60735. private drag;
  60736. private drop;
  60737. private _traverseFolder;
  60738. private _processFiles;
  60739. /**
  60740. * Load files from a drop event
  60741. * @param event defines the drop event to use as source
  60742. */
  60743. loadFiles(event: any): void;
  60744. private _processReload;
  60745. /**
  60746. * Reload the current scene from the loaded files
  60747. */
  60748. reload(): void;
  60749. }
  60750. }
  60751. declare module BABYLON {
  60752. /**
  60753. * Defines the root class used to create scene optimization to use with SceneOptimizer
  60754. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60755. */
  60756. export class SceneOptimization {
  60757. /**
  60758. * Defines the priority of this optimization (0 by default which means first in the list)
  60759. */
  60760. priority: number;
  60761. /**
  60762. * Gets a string describing the action executed by the current optimization
  60763. * @returns description string
  60764. */
  60765. getDescription(): string;
  60766. /**
  60767. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60768. * @param scene defines the current scene where to apply this optimization
  60769. * @param optimizer defines the current optimizer
  60770. * @returns true if everything that can be done was applied
  60771. */
  60772. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60773. /**
  60774. * Creates the SceneOptimization object
  60775. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60776. * @param desc defines the description associated with the optimization
  60777. */
  60778. constructor(
  60779. /**
  60780. * Defines the priority of this optimization (0 by default which means first in the list)
  60781. */
  60782. priority?: number);
  60783. }
  60784. /**
  60785. * Defines an optimization used to reduce the size of render target textures
  60786. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60787. */
  60788. export class TextureOptimization extends SceneOptimization {
  60789. /**
  60790. * Defines the priority of this optimization (0 by default which means first in the list)
  60791. */
  60792. priority: number;
  60793. /**
  60794. * 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
  60795. */
  60796. maximumSize: number;
  60797. /**
  60798. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60799. */
  60800. step: number;
  60801. /**
  60802. * Gets a string describing the action executed by the current optimization
  60803. * @returns description string
  60804. */
  60805. getDescription(): string;
  60806. /**
  60807. * Creates the TextureOptimization object
  60808. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60809. * @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
  60810. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60811. */
  60812. constructor(
  60813. /**
  60814. * Defines the priority of this optimization (0 by default which means first in the list)
  60815. */
  60816. priority?: number,
  60817. /**
  60818. * 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
  60819. */
  60820. maximumSize?: number,
  60821. /**
  60822. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60823. */
  60824. step?: number);
  60825. /**
  60826. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60827. * @param scene defines the current scene where to apply this optimization
  60828. * @param optimizer defines the current optimizer
  60829. * @returns true if everything that can be done was applied
  60830. */
  60831. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60832. }
  60833. /**
  60834. * Defines an optimization used to increase or decrease the rendering resolution
  60835. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60836. */
  60837. export class HardwareScalingOptimization extends SceneOptimization {
  60838. /**
  60839. * Defines the priority of this optimization (0 by default which means first in the list)
  60840. */
  60841. priority: number;
  60842. /**
  60843. * Defines the maximum scale to use (2 by default)
  60844. */
  60845. maximumScale: number;
  60846. /**
  60847. * Defines the step to use between two passes (0.5 by default)
  60848. */
  60849. step: number;
  60850. private _currentScale;
  60851. private _directionOffset;
  60852. /**
  60853. * Gets a string describing the action executed by the current optimization
  60854. * @return description string
  60855. */
  60856. getDescription(): string;
  60857. /**
  60858. * Creates the HardwareScalingOptimization object
  60859. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60860. * @param maximumScale defines the maximum scale to use (2 by default)
  60861. * @param step defines the step to use between two passes (0.5 by default)
  60862. */
  60863. constructor(
  60864. /**
  60865. * Defines the priority of this optimization (0 by default which means first in the list)
  60866. */
  60867. priority?: number,
  60868. /**
  60869. * Defines the maximum scale to use (2 by default)
  60870. */
  60871. maximumScale?: number,
  60872. /**
  60873. * Defines the step to use between two passes (0.5 by default)
  60874. */
  60875. step?: number);
  60876. /**
  60877. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60878. * @param scene defines the current scene where to apply this optimization
  60879. * @param optimizer defines the current optimizer
  60880. * @returns true if everything that can be done was applied
  60881. */
  60882. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60883. }
  60884. /**
  60885. * Defines an optimization used to remove shadows
  60886. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60887. */
  60888. export class ShadowsOptimization extends SceneOptimization {
  60889. /**
  60890. * Gets a string describing the action executed by the current optimization
  60891. * @return description string
  60892. */
  60893. getDescription(): string;
  60894. /**
  60895. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60896. * @param scene defines the current scene where to apply this optimization
  60897. * @param optimizer defines the current optimizer
  60898. * @returns true if everything that can be done was applied
  60899. */
  60900. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60901. }
  60902. /**
  60903. * Defines an optimization used to turn post-processes off
  60904. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60905. */
  60906. export class PostProcessesOptimization extends SceneOptimization {
  60907. /**
  60908. * Gets a string describing the action executed by the current optimization
  60909. * @return description string
  60910. */
  60911. getDescription(): string;
  60912. /**
  60913. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60914. * @param scene defines the current scene where to apply this optimization
  60915. * @param optimizer defines the current optimizer
  60916. * @returns true if everything that can be done was applied
  60917. */
  60918. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60919. }
  60920. /**
  60921. * Defines an optimization used to turn lens flares off
  60922. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60923. */
  60924. export class LensFlaresOptimization extends SceneOptimization {
  60925. /**
  60926. * Gets a string describing the action executed by the current optimization
  60927. * @return description string
  60928. */
  60929. getDescription(): string;
  60930. /**
  60931. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60932. * @param scene defines the current scene where to apply this optimization
  60933. * @param optimizer defines the current optimizer
  60934. * @returns true if everything that can be done was applied
  60935. */
  60936. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60937. }
  60938. /**
  60939. * Defines an optimization based on user defined callback.
  60940. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60941. */
  60942. export class CustomOptimization extends SceneOptimization {
  60943. /**
  60944. * Callback called to apply the custom optimization.
  60945. */
  60946. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  60947. /**
  60948. * Callback called to get custom description
  60949. */
  60950. onGetDescription: () => string;
  60951. /**
  60952. * Gets a string describing the action executed by the current optimization
  60953. * @returns description string
  60954. */
  60955. getDescription(): string;
  60956. /**
  60957. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60958. * @param scene defines the current scene where to apply this optimization
  60959. * @param optimizer defines the current optimizer
  60960. * @returns true if everything that can be done was applied
  60961. */
  60962. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60963. }
  60964. /**
  60965. * Defines an optimization used to turn particles off
  60966. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60967. */
  60968. export class ParticlesOptimization extends SceneOptimization {
  60969. /**
  60970. * Gets a string describing the action executed by the current optimization
  60971. * @return description string
  60972. */
  60973. getDescription(): string;
  60974. /**
  60975. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60976. * @param scene defines the current scene where to apply this optimization
  60977. * @param optimizer defines the current optimizer
  60978. * @returns true if everything that can be done was applied
  60979. */
  60980. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60981. }
  60982. /**
  60983. * Defines an optimization used to turn render targets off
  60984. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60985. */
  60986. export class RenderTargetsOptimization extends SceneOptimization {
  60987. /**
  60988. * Gets a string describing the action executed by the current optimization
  60989. * @return description string
  60990. */
  60991. getDescription(): string;
  60992. /**
  60993. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60994. * @param scene defines the current scene where to apply this optimization
  60995. * @param optimizer defines the current optimizer
  60996. * @returns true if everything that can be done was applied
  60997. */
  60998. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60999. }
  61000. /**
  61001. * Defines an optimization used to merge meshes with compatible materials
  61002. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61003. */
  61004. export class MergeMeshesOptimization extends SceneOptimization {
  61005. private static _UpdateSelectionTree;
  61006. /**
  61007. * Gets or sets a boolean which defines if optimization octree has to be updated
  61008. */
  61009. /**
  61010. * Gets or sets a boolean which defines if optimization octree has to be updated
  61011. */
  61012. static UpdateSelectionTree: boolean;
  61013. /**
  61014. * Gets a string describing the action executed by the current optimization
  61015. * @return description string
  61016. */
  61017. getDescription(): string;
  61018. private _canBeMerged;
  61019. /**
  61020. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61021. * @param scene defines the current scene where to apply this optimization
  61022. * @param optimizer defines the current optimizer
  61023. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61024. * @returns true if everything that can be done was applied
  61025. */
  61026. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61027. }
  61028. /**
  61029. * Defines a list of options used by SceneOptimizer
  61030. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61031. */
  61032. export class SceneOptimizerOptions {
  61033. /**
  61034. * Defines the target frame rate to reach (60 by default)
  61035. */
  61036. targetFrameRate: number;
  61037. /**
  61038. * Defines the interval between two checkes (2000ms by default)
  61039. */
  61040. trackerDuration: number;
  61041. /**
  61042. * Gets the list of optimizations to apply
  61043. */
  61044. optimizations: SceneOptimization[];
  61045. /**
  61046. * Creates a new list of options used by SceneOptimizer
  61047. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61048. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61049. */
  61050. constructor(
  61051. /**
  61052. * Defines the target frame rate to reach (60 by default)
  61053. */
  61054. targetFrameRate?: number,
  61055. /**
  61056. * Defines the interval between two checkes (2000ms by default)
  61057. */
  61058. trackerDuration?: number);
  61059. /**
  61060. * Add a new optimization
  61061. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61062. * @returns the current SceneOptimizerOptions
  61063. */
  61064. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61065. /**
  61066. * Add a new custom optimization
  61067. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61068. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61069. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61070. * @returns the current SceneOptimizerOptions
  61071. */
  61072. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61073. /**
  61074. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61075. * @param targetFrameRate defines the target frame rate (60 by default)
  61076. * @returns a SceneOptimizerOptions object
  61077. */
  61078. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61079. /**
  61080. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61081. * @param targetFrameRate defines the target frame rate (60 by default)
  61082. * @returns a SceneOptimizerOptions object
  61083. */
  61084. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61085. /**
  61086. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61087. * @param targetFrameRate defines the target frame rate (60 by default)
  61088. * @returns a SceneOptimizerOptions object
  61089. */
  61090. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61091. }
  61092. /**
  61093. * Class used to run optimizations in order to reach a target frame rate
  61094. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61095. */
  61096. export class SceneOptimizer implements IDisposable {
  61097. private _isRunning;
  61098. private _options;
  61099. private _scene;
  61100. private _currentPriorityLevel;
  61101. private _targetFrameRate;
  61102. private _trackerDuration;
  61103. private _currentFrameRate;
  61104. private _sceneDisposeObserver;
  61105. private _improvementMode;
  61106. /**
  61107. * Defines an observable called when the optimizer reaches the target frame rate
  61108. */
  61109. onSuccessObservable: Observable<SceneOptimizer>;
  61110. /**
  61111. * Defines an observable called when the optimizer enables an optimization
  61112. */
  61113. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61114. /**
  61115. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61116. */
  61117. onFailureObservable: Observable<SceneOptimizer>;
  61118. /**
  61119. * Gets a boolean indicating if the optimizer is in improvement mode
  61120. */
  61121. readonly isInImprovementMode: boolean;
  61122. /**
  61123. * Gets the current priority level (0 at start)
  61124. */
  61125. readonly currentPriorityLevel: number;
  61126. /**
  61127. * Gets the current frame rate checked by the SceneOptimizer
  61128. */
  61129. readonly currentFrameRate: number;
  61130. /**
  61131. * Gets or sets the current target frame rate (60 by default)
  61132. */
  61133. /**
  61134. * Gets or sets the current target frame rate (60 by default)
  61135. */
  61136. targetFrameRate: number;
  61137. /**
  61138. * Gets or sets the current interval between two checks (every 2000ms by default)
  61139. */
  61140. /**
  61141. * Gets or sets the current interval between two checks (every 2000ms by default)
  61142. */
  61143. trackerDuration: number;
  61144. /**
  61145. * Gets the list of active optimizations
  61146. */
  61147. readonly optimizations: SceneOptimization[];
  61148. /**
  61149. * Creates a new SceneOptimizer
  61150. * @param scene defines the scene to work on
  61151. * @param options defines the options to use with the SceneOptimizer
  61152. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61153. * @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)
  61154. */
  61155. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61156. /**
  61157. * Stops the current optimizer
  61158. */
  61159. stop(): void;
  61160. /**
  61161. * Reset the optimizer to initial step (current priority level = 0)
  61162. */
  61163. reset(): void;
  61164. /**
  61165. * Start the optimizer. By default it will try to reach a specific framerate
  61166. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61167. */
  61168. start(): void;
  61169. private _checkCurrentState;
  61170. /**
  61171. * Release all resources
  61172. */
  61173. dispose(): void;
  61174. /**
  61175. * Helper function to create a SceneOptimizer with one single line of code
  61176. * @param scene defines the scene to work on
  61177. * @param options defines the options to use with the SceneOptimizer
  61178. * @param onSuccess defines a callback to call on success
  61179. * @param onFailure defines a callback to call on failure
  61180. * @returns the new SceneOptimizer object
  61181. */
  61182. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61183. }
  61184. }
  61185. declare module BABYLON {
  61186. /**
  61187. * Class used to serialize a scene into a string
  61188. */
  61189. export class SceneSerializer {
  61190. /**
  61191. * Clear cache used by a previous serialization
  61192. */
  61193. static ClearCache(): void;
  61194. /**
  61195. * Serialize a scene into a JSON compatible object
  61196. * @param scene defines the scene to serialize
  61197. * @returns a JSON compatible object
  61198. */
  61199. static Serialize(scene: Scene): any;
  61200. /**
  61201. * Serialize a mesh into a JSON compatible object
  61202. * @param toSerialize defines the mesh to serialize
  61203. * @param withParents defines if parents must be serialized as well
  61204. * @param withChildren defines if children must be serialized as well
  61205. * @returns a JSON compatible object
  61206. */
  61207. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61208. }
  61209. }
  61210. declare module BABYLON {
  61211. /**
  61212. * Class used to host texture specific utilities
  61213. */
  61214. export class TextureTools {
  61215. /**
  61216. * Uses the GPU to create a copy texture rescaled at a given size
  61217. * @param texture Texture to copy from
  61218. * @param width defines the desired width
  61219. * @param height defines the desired height
  61220. * @param useBilinearMode defines if bilinear mode has to be used
  61221. * @return the generated texture
  61222. */
  61223. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61224. }
  61225. }
  61226. declare module BABYLON {
  61227. /**
  61228. * This represents the different options available for the video capture.
  61229. */
  61230. export interface VideoRecorderOptions {
  61231. /** Defines the mime type of the video. */
  61232. mimeType: string;
  61233. /** Defines the FPS the video should be recorded at. */
  61234. fps: number;
  61235. /** Defines the chunk size for the recording data. */
  61236. recordChunckSize: number;
  61237. /** The audio tracks to attach to the recording. */
  61238. audioTracks?: MediaStreamTrack[];
  61239. }
  61240. /**
  61241. * This can help with recording videos from BabylonJS.
  61242. * This is based on the available WebRTC functionalities of the browser.
  61243. *
  61244. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61245. */
  61246. export class VideoRecorder {
  61247. private static readonly _defaultOptions;
  61248. /**
  61249. * Returns whether or not the VideoRecorder is available in your browser.
  61250. * @param engine Defines the Babylon Engine.
  61251. * @returns true if supported otherwise false.
  61252. */
  61253. static IsSupported(engine: Engine): boolean;
  61254. private readonly _options;
  61255. private _canvas;
  61256. private _mediaRecorder;
  61257. private _recordedChunks;
  61258. private _fileName;
  61259. private _resolve;
  61260. private _reject;
  61261. /**
  61262. * True when a recording is already in progress.
  61263. */
  61264. readonly isRecording: boolean;
  61265. /**
  61266. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  61267. * @param engine Defines the BabylonJS Engine you wish to record.
  61268. * @param options Defines options that can be used to customize the capture.
  61269. */
  61270. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61271. /**
  61272. * Stops the current recording before the default capture timeout passed in the startRecording function.
  61273. */
  61274. stopRecording(): void;
  61275. /**
  61276. * Starts recording the canvas for a max duration specified in parameters.
  61277. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  61278. * If null no automatic download will start and you can rely on the promise to get the data back.
  61279. * @param maxDuration Defines the maximum recording time in seconds.
  61280. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61281. * @return A promise callback at the end of the recording with the video data in Blob.
  61282. */
  61283. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61284. /**
  61285. * Releases internal resources used during the recording.
  61286. */
  61287. dispose(): void;
  61288. private _handleDataAvailable;
  61289. private _handleError;
  61290. private _handleStop;
  61291. }
  61292. }
  61293. declare module BABYLON {
  61294. /**
  61295. * Class containing a set of static utilities functions for screenshots
  61296. */
  61297. export class ScreenshotTools {
  61298. /**
  61299. * Captures a screenshot of the current rendering
  61300. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61301. * @param engine defines the rendering engine
  61302. * @param camera defines the source camera
  61303. * @param size This parameter can be set to a single number or to an object with the
  61304. * following (optional) properties: precision, width, height. If a single number is passed,
  61305. * it will be used for both width and height. If an object is passed, the screenshot size
  61306. * will be derived from the parameters. The precision property is a multiplier allowing
  61307. * rendering at a higher or lower resolution
  61308. * @param successCallback defines the callback receives a single parameter which contains the
  61309. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61310. * src parameter of an <img> to display it
  61311. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61312. * Check your browser for supported MIME types
  61313. */
  61314. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  61315. /**
  61316. * Captures a screenshot of the current rendering
  61317. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61318. * @param engine defines the rendering engine
  61319. * @param camera defines the source camera
  61320. * @param size This parameter can be set to a single number or to an object with the
  61321. * following (optional) properties: precision, width, height. If a single number is passed,
  61322. * it will be used for both width and height. If an object is passed, the screenshot size
  61323. * will be derived from the parameters. The precision property is a multiplier allowing
  61324. * rendering at a higher or lower resolution
  61325. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61326. * Check your browser for supported MIME types
  61327. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61328. * to the src parameter of an <img> to display it
  61329. */
  61330. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  61331. /**
  61332. * Generates an image screenshot from the specified camera.
  61333. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61334. * @param engine The engine to use for rendering
  61335. * @param camera The camera to use for rendering
  61336. * @param size This parameter can be set to a single number or to an object with the
  61337. * following (optional) properties: precision, width, height. If a single number is passed,
  61338. * it will be used for both width and height. If an object is passed, the screenshot size
  61339. * will be derived from the parameters. The precision property is a multiplier allowing
  61340. * rendering at a higher or lower resolution
  61341. * @param successCallback The callback receives a single parameter which contains the
  61342. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61343. * src parameter of an <img> to display it
  61344. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61345. * Check your browser for supported MIME types
  61346. * @param samples Texture samples (default: 1)
  61347. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61348. * @param fileName A name for for the downloaded file.
  61349. */
  61350. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61351. /**
  61352. * Generates an image screenshot from the specified camera.
  61353. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61354. * @param engine The engine to use for rendering
  61355. * @param camera The camera to use for rendering
  61356. * @param size This parameter can be set to a single number or to an object with the
  61357. * following (optional) properties: precision, width, height. If a single number is passed,
  61358. * it will be used for both width and height. If an object is passed, the screenshot size
  61359. * will be derived from the parameters. The precision property is a multiplier allowing
  61360. * rendering at a higher or lower resolution
  61361. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61362. * Check your browser for supported MIME types
  61363. * @param samples Texture samples (default: 1)
  61364. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61365. * @param fileName A name for for the downloaded file.
  61366. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61367. * to the src parameter of an <img> to display it
  61368. */
  61369. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  61370. /**
  61371. * Gets height and width for screenshot size
  61372. * @private
  61373. */
  61374. private static _getScreenshotSize;
  61375. }
  61376. }
  61377. declare module BABYLON {
  61378. /**
  61379. * A cursor which tracks a point on a path
  61380. */
  61381. export class PathCursor {
  61382. private path;
  61383. /**
  61384. * Stores path cursor callbacks for when an onchange event is triggered
  61385. */
  61386. private _onchange;
  61387. /**
  61388. * The value of the path cursor
  61389. */
  61390. value: number;
  61391. /**
  61392. * The animation array of the path cursor
  61393. */
  61394. animations: Animation[];
  61395. /**
  61396. * Initializes the path cursor
  61397. * @param path The path to track
  61398. */
  61399. constructor(path: Path2);
  61400. /**
  61401. * Gets the cursor point on the path
  61402. * @returns A point on the path cursor at the cursor location
  61403. */
  61404. getPoint(): Vector3;
  61405. /**
  61406. * Moves the cursor ahead by the step amount
  61407. * @param step The amount to move the cursor forward
  61408. * @returns This path cursor
  61409. */
  61410. moveAhead(step?: number): PathCursor;
  61411. /**
  61412. * Moves the cursor behind by the step amount
  61413. * @param step The amount to move the cursor back
  61414. * @returns This path cursor
  61415. */
  61416. moveBack(step?: number): PathCursor;
  61417. /**
  61418. * Moves the cursor by the step amount
  61419. * If the step amount is greater than one, an exception is thrown
  61420. * @param step The amount to move the cursor
  61421. * @returns This path cursor
  61422. */
  61423. move(step: number): PathCursor;
  61424. /**
  61425. * Ensures that the value is limited between zero and one
  61426. * @returns This path cursor
  61427. */
  61428. private ensureLimits;
  61429. /**
  61430. * Runs onchange callbacks on change (used by the animation engine)
  61431. * @returns This path cursor
  61432. */
  61433. private raiseOnChange;
  61434. /**
  61435. * Executes a function on change
  61436. * @param f A path cursor onchange callback
  61437. * @returns This path cursor
  61438. */
  61439. onchange(f: (cursor: PathCursor) => void): PathCursor;
  61440. }
  61441. }
  61442. declare module BABYLON {
  61443. /** @hidden */
  61444. export var blurPixelShader: {
  61445. name: string;
  61446. shader: string;
  61447. };
  61448. }
  61449. declare module BABYLON {
  61450. /** @hidden */
  61451. export var pointCloudVertexDeclaration: {
  61452. name: string;
  61453. shader: string;
  61454. };
  61455. }
  61456. // Mixins
  61457. interface Window {
  61458. mozIndexedDB: IDBFactory;
  61459. webkitIndexedDB: IDBFactory;
  61460. msIndexedDB: IDBFactory;
  61461. webkitURL: typeof URL;
  61462. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  61463. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  61464. WebGLRenderingContext: WebGLRenderingContext;
  61465. MSGesture: MSGesture;
  61466. CANNON: any;
  61467. AudioContext: AudioContext;
  61468. webkitAudioContext: AudioContext;
  61469. PointerEvent: any;
  61470. Math: Math;
  61471. Uint8Array: Uint8ArrayConstructor;
  61472. Float32Array: Float32ArrayConstructor;
  61473. mozURL: typeof URL;
  61474. msURL: typeof URL;
  61475. VRFrameData: any; // WebVR, from specs 1.1
  61476. DracoDecoderModule: any;
  61477. setImmediate(handler: (...args: any[]) => void): number;
  61478. }
  61479. interface HTMLCanvasElement {
  61480. requestPointerLock(): void;
  61481. msRequestPointerLock?(): void;
  61482. mozRequestPointerLock?(): void;
  61483. webkitRequestPointerLock?(): void;
  61484. /** Track wether a record is in progress */
  61485. isRecording: boolean;
  61486. /** Capture Stream method defined by some browsers */
  61487. captureStream(fps?: number): MediaStream;
  61488. }
  61489. interface CanvasRenderingContext2D {
  61490. msImageSmoothingEnabled: boolean;
  61491. }
  61492. interface MouseEvent {
  61493. mozMovementX: number;
  61494. mozMovementY: number;
  61495. webkitMovementX: number;
  61496. webkitMovementY: number;
  61497. msMovementX: number;
  61498. msMovementY: number;
  61499. }
  61500. interface Navigator {
  61501. mozGetVRDevices: (any: any) => any;
  61502. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61503. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61504. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61505. webkitGetGamepads(): Gamepad[];
  61506. msGetGamepads(): Gamepad[];
  61507. webkitGamepads(): Gamepad[];
  61508. }
  61509. interface HTMLVideoElement {
  61510. mozSrcObject: any;
  61511. }
  61512. interface Math {
  61513. fround(x: number): number;
  61514. imul(a: number, b: number): number;
  61515. }
  61516. interface WebGLRenderingContext {
  61517. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  61518. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  61519. vertexAttribDivisor(index: number, divisor: number): void;
  61520. createVertexArray(): any;
  61521. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  61522. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  61523. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  61524. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  61525. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  61526. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  61527. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  61528. // Queries
  61529. createQuery(): WebGLQuery;
  61530. deleteQuery(query: WebGLQuery): void;
  61531. beginQuery(target: number, query: WebGLQuery): void;
  61532. endQuery(target: number): void;
  61533. getQueryParameter(query: WebGLQuery, pname: number): any;
  61534. getQuery(target: number, pname: number): any;
  61535. MAX_SAMPLES: number;
  61536. RGBA8: number;
  61537. READ_FRAMEBUFFER: number;
  61538. DRAW_FRAMEBUFFER: number;
  61539. UNIFORM_BUFFER: number;
  61540. HALF_FLOAT_OES: number;
  61541. RGBA16F: number;
  61542. RGBA32F: number;
  61543. R32F: number;
  61544. RG32F: number;
  61545. RGB32F: number;
  61546. R16F: number;
  61547. RG16F: number;
  61548. RGB16F: number;
  61549. RED: number;
  61550. RG: number;
  61551. R8: number;
  61552. RG8: number;
  61553. UNSIGNED_INT_24_8: number;
  61554. DEPTH24_STENCIL8: number;
  61555. /* Multiple Render Targets */
  61556. drawBuffers(buffers: number[]): void;
  61557. readBuffer(src: number): void;
  61558. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  61559. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  61560. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  61561. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  61562. // Occlusion Query
  61563. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  61564. ANY_SAMPLES_PASSED: number;
  61565. QUERY_RESULT_AVAILABLE: number;
  61566. QUERY_RESULT: number;
  61567. }
  61568. interface WebGLProgram {
  61569. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  61570. }
  61571. interface EXT_disjoint_timer_query {
  61572. QUERY_COUNTER_BITS_EXT: number;
  61573. TIME_ELAPSED_EXT: number;
  61574. TIMESTAMP_EXT: number;
  61575. GPU_DISJOINT_EXT: number;
  61576. QUERY_RESULT_EXT: number;
  61577. QUERY_RESULT_AVAILABLE_EXT: number;
  61578. queryCounterEXT(query: WebGLQuery, target: number): void;
  61579. createQueryEXT(): WebGLQuery;
  61580. beginQueryEXT(target: number, query: WebGLQuery): void;
  61581. endQueryEXT(target: number): void;
  61582. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  61583. deleteQueryEXT(query: WebGLQuery): void;
  61584. }
  61585. interface WebGLUniformLocation {
  61586. _currentState: any;
  61587. }
  61588. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  61589. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  61590. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  61591. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61592. interface WebGLRenderingContext {
  61593. readonly RASTERIZER_DISCARD: number;
  61594. readonly DEPTH_COMPONENT24: number;
  61595. readonly TEXTURE_3D: number;
  61596. readonly TEXTURE_2D_ARRAY: number;
  61597. readonly TEXTURE_COMPARE_FUNC: number;
  61598. readonly TEXTURE_COMPARE_MODE: number;
  61599. readonly COMPARE_REF_TO_TEXTURE: number;
  61600. readonly TEXTURE_WRAP_R: number;
  61601. readonly HALF_FLOAT: number;
  61602. readonly RGB8: number;
  61603. readonly RED_INTEGER: number;
  61604. readonly RG_INTEGER: number;
  61605. readonly RGB_INTEGER: number;
  61606. readonly RGBA_INTEGER: number;
  61607. readonly R8_SNORM: number;
  61608. readonly RG8_SNORM: number;
  61609. readonly RGB8_SNORM: number;
  61610. readonly RGBA8_SNORM: number;
  61611. readonly R8I: number;
  61612. readonly RG8I: number;
  61613. readonly RGB8I: number;
  61614. readonly RGBA8I: number;
  61615. readonly R8UI: number;
  61616. readonly RG8UI: number;
  61617. readonly RGB8UI: number;
  61618. readonly RGBA8UI: number;
  61619. readonly R16I: number;
  61620. readonly RG16I: number;
  61621. readonly RGB16I: number;
  61622. readonly RGBA16I: number;
  61623. readonly R16UI: number;
  61624. readonly RG16UI: number;
  61625. readonly RGB16UI: number;
  61626. readonly RGBA16UI: number;
  61627. readonly R32I: number;
  61628. readonly RG32I: number;
  61629. readonly RGB32I: number;
  61630. readonly RGBA32I: number;
  61631. readonly R32UI: number;
  61632. readonly RG32UI: number;
  61633. readonly RGB32UI: number;
  61634. readonly RGBA32UI: number;
  61635. readonly RGB10_A2UI: number;
  61636. readonly R11F_G11F_B10F: number;
  61637. readonly RGB9_E5: number;
  61638. readonly RGB10_A2: number;
  61639. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  61640. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  61641. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  61642. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61643. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  61644. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  61645. 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;
  61646. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  61647. readonly TRANSFORM_FEEDBACK: number;
  61648. readonly INTERLEAVED_ATTRIBS: number;
  61649. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  61650. createTransformFeedback(): WebGLTransformFeedback;
  61651. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  61652. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  61653. beginTransformFeedback(primitiveMode: number): void;
  61654. endTransformFeedback(): void;
  61655. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  61656. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61657. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61658. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61659. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  61660. }
  61661. interface ImageBitmap {
  61662. readonly width: number;
  61663. readonly height: number;
  61664. close(): void;
  61665. }
  61666. interface WebGLQuery extends WebGLObject {
  61667. }
  61668. declare var WebGLQuery: {
  61669. prototype: WebGLQuery;
  61670. new(): WebGLQuery;
  61671. };
  61672. interface WebGLSampler extends WebGLObject {
  61673. }
  61674. declare var WebGLSampler: {
  61675. prototype: WebGLSampler;
  61676. new(): WebGLSampler;
  61677. };
  61678. interface WebGLSync extends WebGLObject {
  61679. }
  61680. declare var WebGLSync: {
  61681. prototype: WebGLSync;
  61682. new(): WebGLSync;
  61683. };
  61684. interface WebGLTransformFeedback extends WebGLObject {
  61685. }
  61686. declare var WebGLTransformFeedback: {
  61687. prototype: WebGLTransformFeedback;
  61688. new(): WebGLTransformFeedback;
  61689. };
  61690. interface WebGLVertexArrayObject extends WebGLObject {
  61691. }
  61692. declare var WebGLVertexArrayObject: {
  61693. prototype: WebGLVertexArrayObject;
  61694. new(): WebGLVertexArrayObject;
  61695. };
  61696. // Type definitions for WebVR API
  61697. // Project: https://w3c.github.io/webvr/
  61698. // Definitions by: six a <https://github.com/lostfictions>
  61699. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61700. interface VRDisplay extends EventTarget {
  61701. /**
  61702. * Dictionary of capabilities describing the VRDisplay.
  61703. */
  61704. readonly capabilities: VRDisplayCapabilities;
  61705. /**
  61706. * z-depth defining the far plane of the eye view frustum
  61707. * enables mapping of values in the render target depth
  61708. * attachment to scene coordinates. Initially set to 10000.0.
  61709. */
  61710. depthFar: number;
  61711. /**
  61712. * z-depth defining the near plane of the eye view frustum
  61713. * enables mapping of values in the render target depth
  61714. * attachment to scene coordinates. Initially set to 0.01.
  61715. */
  61716. depthNear: number;
  61717. /**
  61718. * An identifier for this distinct VRDisplay. Used as an
  61719. * association point in the Gamepad API.
  61720. */
  61721. readonly displayId: number;
  61722. /**
  61723. * A display name, a user-readable name identifying it.
  61724. */
  61725. readonly displayName: string;
  61726. readonly isConnected: boolean;
  61727. readonly isPresenting: boolean;
  61728. /**
  61729. * If this VRDisplay supports room-scale experiences, the optional
  61730. * stage attribute contains details on the room-scale parameters.
  61731. */
  61732. readonly stageParameters: VRStageParameters | null;
  61733. /**
  61734. * Passing the value returned by `requestAnimationFrame` to
  61735. * `cancelAnimationFrame` will unregister the callback.
  61736. * @param handle Define the hanle of the request to cancel
  61737. */
  61738. cancelAnimationFrame(handle: number): void;
  61739. /**
  61740. * Stops presenting to the VRDisplay.
  61741. * @returns a promise to know when it stopped
  61742. */
  61743. exitPresent(): Promise<void>;
  61744. /**
  61745. * Return the current VREyeParameters for the given eye.
  61746. * @param whichEye Define the eye we want the parameter for
  61747. * @returns the eye parameters
  61748. */
  61749. getEyeParameters(whichEye: string): VREyeParameters;
  61750. /**
  61751. * Populates the passed VRFrameData with the information required to render
  61752. * the current frame.
  61753. * @param frameData Define the data structure to populate
  61754. * @returns true if ok otherwise false
  61755. */
  61756. getFrameData(frameData: VRFrameData): boolean;
  61757. /**
  61758. * Get the layers currently being presented.
  61759. * @returns the list of VR layers
  61760. */
  61761. getLayers(): VRLayer[];
  61762. /**
  61763. * Return a VRPose containing the future predicted pose of the VRDisplay
  61764. * when the current frame will be presented. The value returned will not
  61765. * change until JavaScript has returned control to the browser.
  61766. *
  61767. * The VRPose will contain the position, orientation, velocity,
  61768. * and acceleration of each of these properties.
  61769. * @returns the pose object
  61770. */
  61771. getPose(): VRPose;
  61772. /**
  61773. * Return the current instantaneous pose of the VRDisplay, with no
  61774. * prediction applied.
  61775. * @returns the current instantaneous pose
  61776. */
  61777. getImmediatePose(): VRPose;
  61778. /**
  61779. * The callback passed to `requestAnimationFrame` will be called
  61780. * any time a new frame should be rendered. When the VRDisplay is
  61781. * presenting the callback will be called at the native refresh
  61782. * rate of the HMD. When not presenting this function acts
  61783. * identically to how window.requestAnimationFrame acts. Content should
  61784. * make no assumptions of frame rate or vsync behavior as the HMD runs
  61785. * asynchronously from other displays and at differing refresh rates.
  61786. * @param callback Define the eaction to run next frame
  61787. * @returns the request handle it
  61788. */
  61789. requestAnimationFrame(callback: FrameRequestCallback): number;
  61790. /**
  61791. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  61792. * Repeat calls while already presenting will update the VRLayers being displayed.
  61793. * @param layers Define the list of layer to present
  61794. * @returns a promise to know when the request has been fulfilled
  61795. */
  61796. requestPresent(layers: VRLayer[]): Promise<void>;
  61797. /**
  61798. * Reset the pose for this display, treating its current position and
  61799. * orientation as the "origin/zero" values. VRPose.position,
  61800. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  61801. * updated when calling resetPose(). This should be called in only
  61802. * sitting-space experiences.
  61803. */
  61804. resetPose(): void;
  61805. /**
  61806. * The VRLayer provided to the VRDisplay will be captured and presented
  61807. * in the HMD. Calling this function has the same effect on the source
  61808. * canvas as any other operation that uses its source image, and canvases
  61809. * created without preserveDrawingBuffer set to true will be cleared.
  61810. * @param pose Define the pose to submit
  61811. */
  61812. submitFrame(pose?: VRPose): void;
  61813. }
  61814. declare var VRDisplay: {
  61815. prototype: VRDisplay;
  61816. new(): VRDisplay;
  61817. };
  61818. interface VRLayer {
  61819. leftBounds?: number[] | Float32Array | null;
  61820. rightBounds?: number[] | Float32Array | null;
  61821. source?: HTMLCanvasElement | null;
  61822. }
  61823. interface VRDisplayCapabilities {
  61824. readonly canPresent: boolean;
  61825. readonly hasExternalDisplay: boolean;
  61826. readonly hasOrientation: boolean;
  61827. readonly hasPosition: boolean;
  61828. readonly maxLayers: number;
  61829. }
  61830. interface VREyeParameters {
  61831. /** @deprecated */
  61832. readonly fieldOfView: VRFieldOfView;
  61833. readonly offset: Float32Array;
  61834. readonly renderHeight: number;
  61835. readonly renderWidth: number;
  61836. }
  61837. interface VRFieldOfView {
  61838. readonly downDegrees: number;
  61839. readonly leftDegrees: number;
  61840. readonly rightDegrees: number;
  61841. readonly upDegrees: number;
  61842. }
  61843. interface VRFrameData {
  61844. readonly leftProjectionMatrix: Float32Array;
  61845. readonly leftViewMatrix: Float32Array;
  61846. readonly pose: VRPose;
  61847. readonly rightProjectionMatrix: Float32Array;
  61848. readonly rightViewMatrix: Float32Array;
  61849. readonly timestamp: number;
  61850. }
  61851. interface VRPose {
  61852. readonly angularAcceleration: Float32Array | null;
  61853. readonly angularVelocity: Float32Array | null;
  61854. readonly linearAcceleration: Float32Array | null;
  61855. readonly linearVelocity: Float32Array | null;
  61856. readonly orientation: Float32Array | null;
  61857. readonly position: Float32Array | null;
  61858. readonly timestamp: number;
  61859. }
  61860. interface VRStageParameters {
  61861. sittingToStandingTransform?: Float32Array;
  61862. sizeX?: number;
  61863. sizeY?: number;
  61864. }
  61865. interface Navigator {
  61866. getVRDisplays(): Promise<VRDisplay[]>;
  61867. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  61868. }
  61869. interface Window {
  61870. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  61871. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  61872. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  61873. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61874. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61875. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  61876. }
  61877. interface Gamepad {
  61878. readonly displayId: number;
  61879. }
  61880. type XRSessionMode =
  61881. | "inline"
  61882. | "immersive-vr"
  61883. | "immersive-ar";
  61884. type XRReferenceSpaceType =
  61885. | "viewer"
  61886. | "local"
  61887. | "local-floor"
  61888. | "bounded-floor"
  61889. | "unbounded";
  61890. type XREnvironmentBlendMode =
  61891. | "opaque"
  61892. | "additive"
  61893. | "alpha-blend";
  61894. type XRVisibilityState =
  61895. | "visible"
  61896. | "visible-blurred"
  61897. | "hidden";
  61898. type XRHandedness =
  61899. | "none"
  61900. | "left"
  61901. | "right";
  61902. type XRTargetRayMode =
  61903. | "gaze"
  61904. | "tracked-pointer"
  61905. | "screen";
  61906. type XREye =
  61907. | "none"
  61908. | "left"
  61909. | "right";
  61910. interface XRSpace extends EventTarget {
  61911. }
  61912. interface XRRenderState {
  61913. depthNear?: number;
  61914. depthFar?: number;
  61915. inlineVerticalFieldOfView?: number;
  61916. baseLayer?: XRWebGLLayer;
  61917. }
  61918. interface XRInputSource {
  61919. handedness: XRHandedness;
  61920. targetRayMode: XRTargetRayMode;
  61921. targetRaySpace: XRSpace;
  61922. gripSpace: XRSpace | undefined;
  61923. gamepad: Gamepad | undefined;
  61924. profiles: Array<string>;
  61925. }
  61926. interface XRSession {
  61927. addEventListener: Function;
  61928. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  61929. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  61930. requestAnimationFrame: Function;
  61931. end(): Promise<void>;
  61932. renderState: XRRenderState;
  61933. inputSources: Array<XRInputSource>;
  61934. }
  61935. interface XRReferenceSpace extends XRSpace {
  61936. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  61937. onreset: any;
  61938. }
  61939. interface XRFrame {
  61940. session: XRSession;
  61941. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  61942. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  61943. }
  61944. interface XRViewerPose extends XRPose {
  61945. views: Array<XRView>;
  61946. }
  61947. interface XRPose {
  61948. transform: XRRigidTransform;
  61949. emulatedPosition: boolean;
  61950. }
  61951. declare var XRWebGLLayer: {
  61952. prototype: XRWebGLLayer;
  61953. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  61954. };
  61955. interface XRWebGLLayer {
  61956. framebuffer: WebGLFramebuffer;
  61957. framebufferWidth: number;
  61958. framebufferHeight: number;
  61959. getViewport: Function;
  61960. }
  61961. interface XRRigidTransform {
  61962. position: DOMPointReadOnly;
  61963. orientation: DOMPointReadOnly;
  61964. matrix: Float32Array;
  61965. inverse: XRRigidTransform;
  61966. }
  61967. interface XRView {
  61968. eye: XREye;
  61969. projectionMatrix: Float32Array;
  61970. transform: XRRigidTransform;
  61971. }
  61972. interface XRInputSourceChangeEvent {
  61973. session: XRSession;
  61974. removed: Array<XRInputSource>;
  61975. added: Array<XRInputSource>;
  61976. }
  61977. declare module BABYLON.GUI {
  61978. /**
  61979. * Class used to specific a value and its associated unit
  61980. */
  61981. export class ValueAndUnit {
  61982. /** defines the unit to store */
  61983. unit: number;
  61984. /** defines a boolean indicating if the value can be negative */
  61985. negativeValueAllowed: boolean;
  61986. private _value;
  61987. private _originalUnit;
  61988. /**
  61989. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  61990. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61991. */
  61992. ignoreAdaptiveScaling: boolean;
  61993. /**
  61994. * Creates a new ValueAndUnit
  61995. * @param value defines the value to store
  61996. * @param unit defines the unit to store
  61997. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  61998. */
  61999. constructor(value: number,
  62000. /** defines the unit to store */
  62001. unit?: number,
  62002. /** defines a boolean indicating if the value can be negative */
  62003. negativeValueAllowed?: boolean);
  62004. /** Gets a boolean indicating if the value is a percentage */
  62005. readonly isPercentage: boolean;
  62006. /** Gets a boolean indicating if the value is store as pixel */
  62007. readonly isPixel: boolean;
  62008. /** Gets direct internal value */
  62009. readonly internalValue: number;
  62010. /**
  62011. * Gets value as pixel
  62012. * @param host defines the root host
  62013. * @param refValue defines the reference value for percentages
  62014. * @returns the value as pixel
  62015. */
  62016. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  62017. /**
  62018. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  62019. * @param value defines the value to store
  62020. * @param unit defines the unit to store
  62021. * @returns the current ValueAndUnit
  62022. */
  62023. updateInPlace(value: number, unit?: number): ValueAndUnit;
  62024. /**
  62025. * Gets the value accordingly to its unit
  62026. * @param host defines the root host
  62027. * @returns the value
  62028. */
  62029. getValue(host: AdvancedDynamicTexture): number;
  62030. /**
  62031. * Gets a string representation of the value
  62032. * @param host defines the root host
  62033. * @param decimals defines an optional number of decimals to display
  62034. * @returns a string
  62035. */
  62036. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  62037. /**
  62038. * Store a value parsed from a string
  62039. * @param source defines the source string
  62040. * @returns true if the value was successfully parsed
  62041. */
  62042. fromString(source: string | number): boolean;
  62043. private static _Regex;
  62044. private static _UNITMODE_PERCENTAGE;
  62045. private static _UNITMODE_PIXEL;
  62046. /** UNITMODE_PERCENTAGE */
  62047. static readonly UNITMODE_PERCENTAGE: number;
  62048. /** UNITMODE_PIXEL */
  62049. static readonly UNITMODE_PIXEL: number;
  62050. }
  62051. }
  62052. declare module BABYLON.GUI {
  62053. /**
  62054. * Define a style used by control to automatically setup properties based on a template.
  62055. * Only support font related properties so far
  62056. */
  62057. export class Style implements BABYLON.IDisposable {
  62058. private _fontFamily;
  62059. private _fontStyle;
  62060. private _fontWeight;
  62061. /** @hidden */
  62062. _host: AdvancedDynamicTexture;
  62063. /** @hidden */
  62064. _fontSize: ValueAndUnit;
  62065. /**
  62066. * BABYLON.Observable raised when the style values are changed
  62067. */
  62068. onChangedObservable: BABYLON.Observable<Style>;
  62069. /**
  62070. * Creates a new style object
  62071. * @param host defines the AdvancedDynamicTexture which hosts this style
  62072. */
  62073. constructor(host: AdvancedDynamicTexture);
  62074. /**
  62075. * Gets or sets the font size
  62076. */
  62077. fontSize: string | number;
  62078. /**
  62079. * Gets or sets the font family
  62080. */
  62081. fontFamily: string;
  62082. /**
  62083. * Gets or sets the font style
  62084. */
  62085. fontStyle: string;
  62086. /** Gets or sets font weight */
  62087. fontWeight: string;
  62088. /** Dispose all associated resources */
  62089. dispose(): void;
  62090. }
  62091. }
  62092. declare module BABYLON.GUI {
  62093. /**
  62094. * Class used to transport BABYLON.Vector2 information for pointer events
  62095. */
  62096. export class Vector2WithInfo extends BABYLON.Vector2 {
  62097. /** defines the current mouse button index */
  62098. buttonIndex: number;
  62099. /**
  62100. * Creates a new Vector2WithInfo
  62101. * @param source defines the vector2 data to transport
  62102. * @param buttonIndex defines the current mouse button index
  62103. */
  62104. constructor(source: BABYLON.Vector2,
  62105. /** defines the current mouse button index */
  62106. buttonIndex?: number);
  62107. }
  62108. /** Class used to provide 2D matrix features */
  62109. export class Matrix2D {
  62110. /** Gets the internal array of 6 floats used to store matrix data */
  62111. m: Float32Array;
  62112. /**
  62113. * Creates a new matrix
  62114. * @param m00 defines value for (0, 0)
  62115. * @param m01 defines value for (0, 1)
  62116. * @param m10 defines value for (1, 0)
  62117. * @param m11 defines value for (1, 1)
  62118. * @param m20 defines value for (2, 0)
  62119. * @param m21 defines value for (2, 1)
  62120. */
  62121. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  62122. /**
  62123. * Fills the matrix from direct values
  62124. * @param m00 defines value for (0, 0)
  62125. * @param m01 defines value for (0, 1)
  62126. * @param m10 defines value for (1, 0)
  62127. * @param m11 defines value for (1, 1)
  62128. * @param m20 defines value for (2, 0)
  62129. * @param m21 defines value for (2, 1)
  62130. * @returns the current modified matrix
  62131. */
  62132. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  62133. /**
  62134. * Gets matrix determinant
  62135. * @returns the determinant
  62136. */
  62137. determinant(): number;
  62138. /**
  62139. * Inverses the matrix and stores it in a target matrix
  62140. * @param result defines the target matrix
  62141. * @returns the current matrix
  62142. */
  62143. invertToRef(result: Matrix2D): Matrix2D;
  62144. /**
  62145. * Multiplies the current matrix with another one
  62146. * @param other defines the second operand
  62147. * @param result defines the target matrix
  62148. * @returns the current matrix
  62149. */
  62150. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  62151. /**
  62152. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  62153. * @param x defines the x coordinate to transform
  62154. * @param y defines the x coordinate to transform
  62155. * @param result defines the target vector2
  62156. * @returns the current matrix
  62157. */
  62158. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  62159. /**
  62160. * Creates an identity matrix
  62161. * @returns a new matrix
  62162. */
  62163. static Identity(): Matrix2D;
  62164. /**
  62165. * Creates a translation matrix and stores it in a target matrix
  62166. * @param x defines the x coordinate of the translation
  62167. * @param y defines the y coordinate of the translation
  62168. * @param result defines the target matrix
  62169. */
  62170. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  62171. /**
  62172. * Creates a scaling matrix and stores it in a target matrix
  62173. * @param x defines the x coordinate of the scaling
  62174. * @param y defines the y coordinate of the scaling
  62175. * @param result defines the target matrix
  62176. */
  62177. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  62178. /**
  62179. * Creates a rotation matrix and stores it in a target matrix
  62180. * @param angle defines the rotation angle
  62181. * @param result defines the target matrix
  62182. */
  62183. static RotationToRef(angle: number, result: Matrix2D): void;
  62184. private static _TempPreTranslationMatrix;
  62185. private static _TempPostTranslationMatrix;
  62186. private static _TempRotationMatrix;
  62187. private static _TempScalingMatrix;
  62188. private static _TempCompose0;
  62189. private static _TempCompose1;
  62190. private static _TempCompose2;
  62191. /**
  62192. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  62193. * @param tx defines the x coordinate of the translation
  62194. * @param ty defines the y coordinate of the translation
  62195. * @param angle defines the rotation angle
  62196. * @param scaleX defines the x coordinate of the scaling
  62197. * @param scaleY defines the y coordinate of the scaling
  62198. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  62199. * @param result defines the target matrix
  62200. */
  62201. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  62202. }
  62203. }
  62204. declare module BABYLON.GUI {
  62205. /**
  62206. * Class used to store 2D control sizes
  62207. */
  62208. export class Measure {
  62209. /** defines left coordinate */
  62210. left: number;
  62211. /** defines top coordinate */
  62212. top: number;
  62213. /** defines width dimension */
  62214. width: number;
  62215. /** defines height dimension */
  62216. height: number;
  62217. /**
  62218. * Creates a new measure
  62219. * @param left defines left coordinate
  62220. * @param top defines top coordinate
  62221. * @param width defines width dimension
  62222. * @param height defines height dimension
  62223. */
  62224. constructor(
  62225. /** defines left coordinate */
  62226. left: number,
  62227. /** defines top coordinate */
  62228. top: number,
  62229. /** defines width dimension */
  62230. width: number,
  62231. /** defines height dimension */
  62232. height: number);
  62233. /**
  62234. * Copy from another measure
  62235. * @param other defines the other measure to copy from
  62236. */
  62237. copyFrom(other: Measure): void;
  62238. /**
  62239. * Copy from a group of 4 floats
  62240. * @param left defines left coordinate
  62241. * @param top defines top coordinate
  62242. * @param width defines width dimension
  62243. * @param height defines height dimension
  62244. */
  62245. copyFromFloats(left: number, top: number, width: number, height: number): void;
  62246. /**
  62247. * Computes the axis aligned bounding box measure for two given measures
  62248. * @param a Input measure
  62249. * @param b Input measure
  62250. * @param result the resulting bounding measure
  62251. */
  62252. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  62253. /**
  62254. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  62255. * @param transform the matrix to transform the measure before computing the AABB
  62256. * @param result the resulting AABB
  62257. */
  62258. transformToRef(transform: Matrix2D, result: Measure): void;
  62259. /**
  62260. * Check equality between this measure and another one
  62261. * @param other defines the other measures
  62262. * @returns true if both measures are equals
  62263. */
  62264. isEqualsTo(other: Measure): boolean;
  62265. /**
  62266. * Creates an empty measure
  62267. * @returns a new measure
  62268. */
  62269. static Empty(): Measure;
  62270. }
  62271. }
  62272. declare module BABYLON.GUI {
  62273. /**
  62274. * Interface used to define a control that can receive focus
  62275. */
  62276. export interface IFocusableControl {
  62277. /**
  62278. * Function called when the control receives the focus
  62279. */
  62280. onFocus(): void;
  62281. /**
  62282. * Function called when the control loses the focus
  62283. */
  62284. onBlur(): void;
  62285. /**
  62286. * Function called to let the control handle keyboard events
  62287. * @param evt defines the current keyboard event
  62288. */
  62289. processKeyboard(evt: KeyboardEvent): void;
  62290. /**
  62291. * Function called to get the list of controls that should not steal the focus from this control
  62292. * @returns an array of controls
  62293. */
  62294. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62295. }
  62296. /**
  62297. * Class used to create texture to support 2D GUI elements
  62298. * @see http://doc.babylonjs.com/how_to/gui
  62299. */
  62300. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  62301. private _isDirty;
  62302. private _renderObserver;
  62303. private _resizeObserver;
  62304. private _preKeyboardObserver;
  62305. private _pointerMoveObserver;
  62306. private _pointerObserver;
  62307. private _canvasPointerOutObserver;
  62308. private _background;
  62309. /** @hidden */
  62310. _rootContainer: Container;
  62311. /** @hidden */
  62312. _lastPickedControl: Control;
  62313. /** @hidden */
  62314. _lastControlOver: {
  62315. [pointerId: number]: Control;
  62316. };
  62317. /** @hidden */
  62318. _lastControlDown: {
  62319. [pointerId: number]: Control;
  62320. };
  62321. /** @hidden */
  62322. _capturingControl: {
  62323. [pointerId: number]: Control;
  62324. };
  62325. /** @hidden */
  62326. _shouldBlockPointer: boolean;
  62327. /** @hidden */
  62328. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  62329. /** @hidden */
  62330. _linkedControls: Control[];
  62331. private _isFullscreen;
  62332. private _fullscreenViewport;
  62333. private _idealWidth;
  62334. private _idealHeight;
  62335. private _useSmallestIdeal;
  62336. private _renderAtIdealSize;
  62337. private _focusedControl;
  62338. private _blockNextFocusCheck;
  62339. private _renderScale;
  62340. private _rootCanvas;
  62341. private _cursorChanged;
  62342. /**
  62343. * Define type to string to ensure compatibility across browsers
  62344. * Safari doesn't support DataTransfer constructor
  62345. */
  62346. private _clipboardData;
  62347. /**
  62348. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  62349. */
  62350. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  62351. /**
  62352. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  62353. */
  62354. onControlPickedObservable: BABYLON.Observable<Control>;
  62355. /**
  62356. * BABYLON.Observable event triggered before layout is evaluated
  62357. */
  62358. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62359. /**
  62360. * BABYLON.Observable event triggered after the layout was evaluated
  62361. */
  62362. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62363. /**
  62364. * BABYLON.Observable event triggered before the texture is rendered
  62365. */
  62366. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62367. /**
  62368. * BABYLON.Observable event triggered after the texture was rendered
  62369. */
  62370. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62371. /**
  62372. * Gets or sets a boolean defining if alpha is stored as premultiplied
  62373. */
  62374. premulAlpha: boolean;
  62375. /**
  62376. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  62377. * Useful when you want more antialiasing
  62378. */
  62379. renderScale: number;
  62380. /** Gets or sets the background color */
  62381. background: string;
  62382. /**
  62383. * Gets or sets the ideal width used to design controls.
  62384. * The GUI will then rescale everything accordingly
  62385. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62386. */
  62387. idealWidth: number;
  62388. /**
  62389. * Gets or sets the ideal height used to design controls.
  62390. * The GUI will then rescale everything accordingly
  62391. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62392. */
  62393. idealHeight: number;
  62394. /**
  62395. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  62396. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62397. */
  62398. useSmallestIdeal: boolean;
  62399. /**
  62400. * Gets or sets a boolean indicating if adaptive scaling must be used
  62401. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62402. */
  62403. renderAtIdealSize: boolean;
  62404. /**
  62405. * Gets the underlying layer used to render the texture when in fullscreen mode
  62406. */
  62407. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  62408. /**
  62409. * Gets the root container control
  62410. */
  62411. readonly rootContainer: Container;
  62412. /**
  62413. * Returns an array containing the root container.
  62414. * This is mostly used to let the Inspector introspects the ADT
  62415. * @returns an array containing the rootContainer
  62416. */
  62417. getChildren(): Array<Container>;
  62418. /**
  62419. * Will return all controls that are inside this texture
  62420. * @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
  62421. * @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
  62422. * @return all child controls
  62423. */
  62424. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62425. /**
  62426. * Gets or sets the current focused control
  62427. */
  62428. focusedControl: BABYLON.Nullable<IFocusableControl>;
  62429. /**
  62430. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  62431. */
  62432. isForeground: boolean;
  62433. /**
  62434. * Gets or set information about clipboardData
  62435. */
  62436. clipboardData: string;
  62437. /**
  62438. * Creates a new AdvancedDynamicTexture
  62439. * @param name defines the name of the texture
  62440. * @param width defines the width of the texture
  62441. * @param height defines the height of the texture
  62442. * @param scene defines the hosting scene
  62443. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  62444. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  62445. */
  62446. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  62447. /**
  62448. * Get the current class name of the texture useful for serialization or dynamic coding.
  62449. * @returns "AdvancedDynamicTexture"
  62450. */
  62451. getClassName(): string;
  62452. /**
  62453. * Function used to execute a function on all controls
  62454. * @param func defines the function to execute
  62455. * @param container defines the container where controls belong. If null the root container will be used
  62456. */
  62457. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  62458. private _useInvalidateRectOptimization;
  62459. /**
  62460. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  62461. */
  62462. useInvalidateRectOptimization: boolean;
  62463. private _invalidatedRectangle;
  62464. /**
  62465. * Invalidates a rectangle area on the gui texture
  62466. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  62467. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  62468. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  62469. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  62470. */
  62471. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  62472. /**
  62473. * Marks the texture as dirty forcing a complete update
  62474. */
  62475. markAsDirty(): void;
  62476. /**
  62477. * Helper function used to create a new style
  62478. * @returns a new style
  62479. * @see http://doc.babylonjs.com/how_to/gui#styles
  62480. */
  62481. createStyle(): Style;
  62482. /**
  62483. * Adds a new control to the root container
  62484. * @param control defines the control to add
  62485. * @returns the current texture
  62486. */
  62487. addControl(control: Control): AdvancedDynamicTexture;
  62488. /**
  62489. * Removes a control from the root container
  62490. * @param control defines the control to remove
  62491. * @returns the current texture
  62492. */
  62493. removeControl(control: Control): AdvancedDynamicTexture;
  62494. /**
  62495. * Release all resources
  62496. */
  62497. dispose(): void;
  62498. private _onResize;
  62499. /** @hidden */
  62500. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  62501. /**
  62502. * Get screen coordinates for a vector3
  62503. * @param position defines the position to project
  62504. * @param worldMatrix defines the world matrix to use
  62505. * @returns the projected position
  62506. */
  62507. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  62508. private _checkUpdate;
  62509. private _clearMeasure;
  62510. private _render;
  62511. /** @hidden */
  62512. _changeCursor(cursor: string): void;
  62513. /** @hidden */
  62514. _registerLastControlDown(control: Control, pointerId: number): void;
  62515. private _doPicking;
  62516. /** @hidden */
  62517. _cleanControlAfterRemovalFromList(list: {
  62518. [pointerId: number]: Control;
  62519. }, control: Control): void;
  62520. /** @hidden */
  62521. _cleanControlAfterRemoval(control: Control): void;
  62522. /** Attach to all scene events required to support pointer events */
  62523. attach(): void;
  62524. /** @hidden */
  62525. private onClipboardCopy;
  62526. /** @hidden */
  62527. private onClipboardCut;
  62528. /** @hidden */
  62529. private onClipboardPaste;
  62530. /**
  62531. * Register the clipboard Events onto the canvas
  62532. */
  62533. registerClipboardEvents(): void;
  62534. /**
  62535. * Unregister the clipboard Events from the canvas
  62536. */
  62537. unRegisterClipboardEvents(): void;
  62538. /**
  62539. * Connect the texture to a hosting mesh to enable interactions
  62540. * @param mesh defines the mesh to attach to
  62541. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  62542. */
  62543. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  62544. /**
  62545. * Move the focus to a specific control
  62546. * @param control defines the control which will receive the focus
  62547. */
  62548. moveFocusToControl(control: IFocusableControl): void;
  62549. private _manageFocus;
  62550. private _attachToOnPointerOut;
  62551. /**
  62552. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  62553. * @param mesh defines the mesh which will receive the texture
  62554. * @param width defines the texture width (1024 by default)
  62555. * @param height defines the texture height (1024 by default)
  62556. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  62557. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  62558. * @returns a new AdvancedDynamicTexture
  62559. */
  62560. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  62561. /**
  62562. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  62563. * In this mode the texture will rely on a layer for its rendering.
  62564. * This allows it to be treated like any other layer.
  62565. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  62566. * LayerMask is set through advancedTexture.layer.layerMask
  62567. * @param name defines name for the texture
  62568. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  62569. * @param scene defines the hsoting scene
  62570. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  62571. * @returns a new AdvancedDynamicTexture
  62572. */
  62573. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  62574. }
  62575. }
  62576. declare module BABYLON.GUI {
  62577. /**
  62578. * Root class used for all 2D controls
  62579. * @see http://doc.babylonjs.com/how_to/gui#controls
  62580. */
  62581. export class Control {
  62582. /** defines the name of the control */
  62583. name?: string | undefined;
  62584. /**
  62585. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  62586. */
  62587. static AllowAlphaInheritance: boolean;
  62588. private _alpha;
  62589. private _alphaSet;
  62590. private _zIndex;
  62591. /** @hidden */
  62592. _host: AdvancedDynamicTexture;
  62593. /** Gets or sets the control parent */
  62594. parent: BABYLON.Nullable<Container>;
  62595. /** @hidden */
  62596. _currentMeasure: Measure;
  62597. private _fontFamily;
  62598. private _fontStyle;
  62599. private _fontWeight;
  62600. private _fontSize;
  62601. private _font;
  62602. /** @hidden */
  62603. _width: ValueAndUnit;
  62604. /** @hidden */
  62605. _height: ValueAndUnit;
  62606. /** @hidden */
  62607. protected _fontOffset: {
  62608. ascent: number;
  62609. height: number;
  62610. descent: number;
  62611. };
  62612. private _color;
  62613. private _style;
  62614. private _styleObserver;
  62615. /** @hidden */
  62616. protected _horizontalAlignment: number;
  62617. /** @hidden */
  62618. protected _verticalAlignment: number;
  62619. /** @hidden */
  62620. protected _isDirty: boolean;
  62621. /** @hidden */
  62622. protected _wasDirty: boolean;
  62623. /** @hidden */
  62624. _tempParentMeasure: Measure;
  62625. /** @hidden */
  62626. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  62627. /** @hidden */
  62628. protected _cachedParentMeasure: Measure;
  62629. private _paddingLeft;
  62630. private _paddingRight;
  62631. private _paddingTop;
  62632. private _paddingBottom;
  62633. /** @hidden */
  62634. _left: ValueAndUnit;
  62635. /** @hidden */
  62636. _top: ValueAndUnit;
  62637. private _scaleX;
  62638. private _scaleY;
  62639. private _rotation;
  62640. private _transformCenterX;
  62641. private _transformCenterY;
  62642. /** @hidden */
  62643. _transformMatrix: Matrix2D;
  62644. /** @hidden */
  62645. protected _invertTransformMatrix: Matrix2D;
  62646. /** @hidden */
  62647. protected _transformedPosition: BABYLON.Vector2;
  62648. private _isMatrixDirty;
  62649. private _cachedOffsetX;
  62650. private _cachedOffsetY;
  62651. private _isVisible;
  62652. private _isHighlighted;
  62653. /** @hidden */
  62654. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62655. private _fontSet;
  62656. private _dummyVector2;
  62657. private _downCount;
  62658. private _enterCount;
  62659. private _doNotRender;
  62660. private _downPointerIds;
  62661. protected _isEnabled: boolean;
  62662. protected _disabledColor: string;
  62663. /** @hidden */
  62664. protected _rebuildLayout: boolean;
  62665. /** @hidden */
  62666. _isClipped: boolean;
  62667. /** @hidden */
  62668. _tag: any;
  62669. /**
  62670. * Gets or sets the unique id of the node. Please note that this number will be updated when the control is added to a container
  62671. */
  62672. uniqueId: number;
  62673. /**
  62674. * Gets or sets an object used to store user defined information for the node
  62675. */
  62676. metadata: any;
  62677. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  62678. isHitTestVisible: boolean;
  62679. /** Gets or sets a boolean indicating if the control can block pointer events */
  62680. isPointerBlocker: boolean;
  62681. /** Gets or sets a boolean indicating if the control can be focusable */
  62682. isFocusInvisible: boolean;
  62683. /**
  62684. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  62685. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  62686. */
  62687. clipChildren: boolean;
  62688. /**
  62689. * Gets or sets a boolean indicating that control content must be clipped
  62690. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  62691. */
  62692. clipContent: boolean;
  62693. /**
  62694. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  62695. */
  62696. useBitmapCache: boolean;
  62697. private _cacheData;
  62698. private _shadowOffsetX;
  62699. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  62700. shadowOffsetX: number;
  62701. private _shadowOffsetY;
  62702. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  62703. shadowOffsetY: number;
  62704. private _shadowBlur;
  62705. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  62706. shadowBlur: number;
  62707. private _shadowColor;
  62708. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  62709. shadowColor: string;
  62710. /** Gets or sets the cursor to use when the control is hovered */
  62711. hoverCursor: string;
  62712. /** @hidden */
  62713. protected _linkOffsetX: ValueAndUnit;
  62714. /** @hidden */
  62715. protected _linkOffsetY: ValueAndUnit;
  62716. /** Gets the control type name */
  62717. readonly typeName: string;
  62718. /**
  62719. * Get the current class name of the control.
  62720. * @returns current class name
  62721. */
  62722. getClassName(): string;
  62723. /**
  62724. * An event triggered when the pointer move over the control.
  62725. */
  62726. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  62727. /**
  62728. * An event triggered when the pointer move out of the control.
  62729. */
  62730. onPointerOutObservable: BABYLON.Observable<Control>;
  62731. /**
  62732. * An event triggered when the pointer taps the control
  62733. */
  62734. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  62735. /**
  62736. * An event triggered when pointer up
  62737. */
  62738. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  62739. /**
  62740. * An event triggered when a control is clicked on
  62741. */
  62742. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  62743. /**
  62744. * An event triggered when pointer enters the control
  62745. */
  62746. onPointerEnterObservable: BABYLON.Observable<Control>;
  62747. /**
  62748. * An event triggered when the control is marked as dirty
  62749. */
  62750. onDirtyObservable: BABYLON.Observable<Control>;
  62751. /**
  62752. * An event triggered before drawing the control
  62753. */
  62754. onBeforeDrawObservable: BABYLON.Observable<Control>;
  62755. /**
  62756. * An event triggered after the control was drawn
  62757. */
  62758. onAfterDrawObservable: BABYLON.Observable<Control>;
  62759. /**
  62760. * Get the hosting AdvancedDynamicTexture
  62761. */
  62762. readonly host: AdvancedDynamicTexture;
  62763. /** Gets or set information about font offsets (used to render and align text) */
  62764. fontOffset: {
  62765. ascent: number;
  62766. height: number;
  62767. descent: number;
  62768. };
  62769. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  62770. alpha: number;
  62771. /**
  62772. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  62773. */
  62774. isHighlighted: boolean;
  62775. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  62776. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62777. */
  62778. scaleX: number;
  62779. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  62780. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62781. */
  62782. scaleY: number;
  62783. /** Gets or sets the rotation angle (0 by default)
  62784. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62785. */
  62786. rotation: number;
  62787. /** Gets or sets the transformation center on Y axis (0 by default)
  62788. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62789. */
  62790. transformCenterY: number;
  62791. /** Gets or sets the transformation center on X axis (0 by default)
  62792. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62793. */
  62794. transformCenterX: number;
  62795. /**
  62796. * Gets or sets the horizontal alignment
  62797. * @see http://doc.babylonjs.com/how_to/gui#alignments
  62798. */
  62799. horizontalAlignment: number;
  62800. /**
  62801. * Gets or sets the vertical alignment
  62802. * @see http://doc.babylonjs.com/how_to/gui#alignments
  62803. */
  62804. verticalAlignment: number;
  62805. /**
  62806. * Gets or sets control width
  62807. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62808. */
  62809. width: string | number;
  62810. /**
  62811. * Gets or sets the control width in pixel
  62812. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62813. */
  62814. widthInPixels: number;
  62815. /**
  62816. * Gets or sets control height
  62817. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62818. */
  62819. height: string | number;
  62820. /**
  62821. * Gets or sets control height in pixel
  62822. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62823. */
  62824. heightInPixels: number;
  62825. /** Gets or set font family */
  62826. fontFamily: string;
  62827. /** Gets or sets font style */
  62828. fontStyle: string;
  62829. /** Gets or sets font weight */
  62830. fontWeight: string;
  62831. /**
  62832. * Gets or sets style
  62833. * @see http://doc.babylonjs.com/how_to/gui#styles
  62834. */
  62835. style: BABYLON.Nullable<Style>;
  62836. /** @hidden */
  62837. readonly _isFontSizeInPercentage: boolean;
  62838. /** Gets or sets font size in pixels */
  62839. fontSizeInPixels: number;
  62840. /** Gets or sets font size */
  62841. fontSize: string | number;
  62842. /** Gets or sets foreground color */
  62843. color: string;
  62844. /** Gets or sets z index which is used to reorder controls on the z axis */
  62845. zIndex: number;
  62846. /** Gets or sets a boolean indicating if the control can be rendered */
  62847. notRenderable: boolean;
  62848. /** Gets or sets a boolean indicating if the control is visible */
  62849. isVisible: boolean;
  62850. /** Gets a boolean indicating that the control needs to update its rendering */
  62851. readonly isDirty: boolean;
  62852. /**
  62853. * Gets the current linked mesh (or null if none)
  62854. */
  62855. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62856. /**
  62857. * Gets or sets a value indicating the padding to use on the left of the control
  62858. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62859. */
  62860. paddingLeft: string | number;
  62861. /**
  62862. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  62863. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62864. */
  62865. paddingLeftInPixels: number;
  62866. /**
  62867. * Gets or sets a value indicating the padding to use on the right of the control
  62868. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62869. */
  62870. paddingRight: string | number;
  62871. /**
  62872. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  62873. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62874. */
  62875. paddingRightInPixels: number;
  62876. /**
  62877. * Gets or sets a value indicating the padding to use on the top of the control
  62878. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62879. */
  62880. paddingTop: string | number;
  62881. /**
  62882. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  62883. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62884. */
  62885. paddingTopInPixels: number;
  62886. /**
  62887. * Gets or sets a value indicating the padding to use on the bottom of the control
  62888. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62889. */
  62890. paddingBottom: string | number;
  62891. /**
  62892. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  62893. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62894. */
  62895. paddingBottomInPixels: number;
  62896. /**
  62897. * Gets or sets a value indicating the left coordinate of the control
  62898. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62899. */
  62900. left: string | number;
  62901. /**
  62902. * Gets or sets a value indicating the left coordinate in pixels of the control
  62903. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62904. */
  62905. leftInPixels: number;
  62906. /**
  62907. * Gets or sets a value indicating the top coordinate of the control
  62908. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62909. */
  62910. top: string | number;
  62911. /**
  62912. * Gets or sets a value indicating the top coordinate in pixels of the control
  62913. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62914. */
  62915. topInPixels: number;
  62916. /**
  62917. * Gets or sets a value indicating the offset on X axis to the linked mesh
  62918. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62919. */
  62920. linkOffsetX: string | number;
  62921. /**
  62922. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  62923. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62924. */
  62925. linkOffsetXInPixels: number;
  62926. /**
  62927. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  62928. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62929. */
  62930. linkOffsetY: string | number;
  62931. /**
  62932. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  62933. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62934. */
  62935. linkOffsetYInPixels: number;
  62936. /** Gets the center coordinate on X axis */
  62937. readonly centerX: number;
  62938. /** Gets the center coordinate on Y axis */
  62939. readonly centerY: number;
  62940. /** Gets or sets if control is Enabled*/
  62941. isEnabled: boolean;
  62942. /** Gets or sets background color of control if it's disabled*/
  62943. disabledColor: string;
  62944. /**
  62945. * Creates a new control
  62946. * @param name defines the name of the control
  62947. */
  62948. constructor(
  62949. /** defines the name of the control */
  62950. name?: string | undefined);
  62951. /** @hidden */
  62952. protected _getTypeName(): string;
  62953. /**
  62954. * Gets the first ascendant in the hierarchy of the given type
  62955. * @param className defines the required type
  62956. * @returns the ascendant or null if not found
  62957. */
  62958. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  62959. /** @hidden */
  62960. _resetFontCache(): void;
  62961. /**
  62962. * Determines if a container is an ascendant of the current control
  62963. * @param container defines the container to look for
  62964. * @returns true if the container is one of the ascendant of the control
  62965. */
  62966. isAscendant(container: Control): boolean;
  62967. /**
  62968. * Gets coordinates in local control space
  62969. * @param globalCoordinates defines the coordinates to transform
  62970. * @returns the new coordinates in local space
  62971. */
  62972. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62973. /**
  62974. * Gets coordinates in local control space
  62975. * @param globalCoordinates defines the coordinates to transform
  62976. * @param result defines the target vector2 where to store the result
  62977. * @returns the current control
  62978. */
  62979. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  62980. /**
  62981. * Gets coordinates in parent local control space
  62982. * @param globalCoordinates defines the coordinates to transform
  62983. * @returns the new coordinates in parent local space
  62984. */
  62985. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62986. /**
  62987. * Move the current control to a vector3 position projected onto the screen.
  62988. * @param position defines the target position
  62989. * @param scene defines the hosting scene
  62990. */
  62991. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  62992. /** @hidden */
  62993. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62994. /**
  62995. * Will return all controls that have this control as ascendant
  62996. * @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
  62997. * @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
  62998. * @return all child controls
  62999. */
  63000. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63001. /**
  63002. * Link current control with a target mesh
  63003. * @param mesh defines the mesh to link with
  63004. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63005. */
  63006. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  63007. /** @hidden */
  63008. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  63009. /** @hidden */
  63010. _offsetLeft(offset: number): void;
  63011. /** @hidden */
  63012. _offsetTop(offset: number): void;
  63013. /** @hidden */
  63014. _markMatrixAsDirty(): void;
  63015. /** @hidden */
  63016. _flagDescendantsAsMatrixDirty(): void;
  63017. /** @hidden */
  63018. _intersectsRect(rect: Measure): boolean;
  63019. /** @hidden */
  63020. protected invalidateRect(): void;
  63021. /** @hidden */
  63022. _markAsDirty(force?: boolean): void;
  63023. /** @hidden */
  63024. _markAllAsDirty(): void;
  63025. /** @hidden */
  63026. _link(host: AdvancedDynamicTexture): void;
  63027. /** @hidden */
  63028. protected _transform(context?: CanvasRenderingContext2D): void;
  63029. /** @hidden */
  63030. _renderHighlight(context: CanvasRenderingContext2D): void;
  63031. /** @hidden */
  63032. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63033. /** @hidden */
  63034. protected _applyStates(context: CanvasRenderingContext2D): void;
  63035. /** @hidden */
  63036. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63037. /** @hidden */
  63038. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63039. protected _evaluateClippingState(parentMeasure: Measure): void;
  63040. /** @hidden */
  63041. _measure(): void;
  63042. /** @hidden */
  63043. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63044. /** @hidden */
  63045. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63046. /** @hidden */
  63047. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63048. /** @hidden */
  63049. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63050. private static _ClipMeasure;
  63051. private _tmpMeasureA;
  63052. private _clip;
  63053. /** @hidden */
  63054. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  63055. /** @hidden */
  63056. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  63057. /**
  63058. * Tests if a given coordinates belong to the current control
  63059. * @param x defines x coordinate to test
  63060. * @param y defines y coordinate to test
  63061. * @returns true if the coordinates are inside the control
  63062. */
  63063. contains(x: number, y: number): boolean;
  63064. /** @hidden */
  63065. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63066. /** @hidden */
  63067. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63068. /** @hidden */
  63069. _onPointerEnter(target: Control): boolean;
  63070. /** @hidden */
  63071. _onPointerOut(target: Control, force?: boolean): void;
  63072. /** @hidden */
  63073. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63074. /** @hidden */
  63075. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63076. /** @hidden */
  63077. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63078. /** @hidden */
  63079. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  63080. private _prepareFont;
  63081. /** Releases associated resources */
  63082. dispose(): void;
  63083. private static _HORIZONTAL_ALIGNMENT_LEFT;
  63084. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  63085. private static _HORIZONTAL_ALIGNMENT_CENTER;
  63086. private static _VERTICAL_ALIGNMENT_TOP;
  63087. private static _VERTICAL_ALIGNMENT_BOTTOM;
  63088. private static _VERTICAL_ALIGNMENT_CENTER;
  63089. /** HORIZONTAL_ALIGNMENT_LEFT */
  63090. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  63091. /** HORIZONTAL_ALIGNMENT_RIGHT */
  63092. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  63093. /** HORIZONTAL_ALIGNMENT_CENTER */
  63094. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  63095. /** VERTICAL_ALIGNMENT_TOP */
  63096. static readonly VERTICAL_ALIGNMENT_TOP: number;
  63097. /** VERTICAL_ALIGNMENT_BOTTOM */
  63098. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  63099. /** VERTICAL_ALIGNMENT_CENTER */
  63100. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  63101. private static _FontHeightSizes;
  63102. /** @hidden */
  63103. static _GetFontOffset(font: string): {
  63104. ascent: number;
  63105. height: number;
  63106. descent: number;
  63107. };
  63108. /**
  63109. * Creates a stack panel that can be used to render headers
  63110. * @param control defines the control to associate with the header
  63111. * @param text defines the text of the header
  63112. * @param size defines the size of the header
  63113. * @param options defines options used to configure the header
  63114. * @returns a new StackPanel
  63115. * @ignore
  63116. * @hidden
  63117. */
  63118. static AddHeader: (control: Control, text: string, size: string | number, options: {
  63119. isHorizontal: boolean;
  63120. controlFirst: boolean;
  63121. }) => any;
  63122. /** @hidden */
  63123. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  63124. }
  63125. }
  63126. declare module BABYLON.GUI {
  63127. /**
  63128. * Root class for 2D containers
  63129. * @see http://doc.babylonjs.com/how_to/gui#containers
  63130. */
  63131. export class Container extends Control {
  63132. name?: string | undefined;
  63133. /** @hidden */
  63134. protected _children: Control[];
  63135. /** @hidden */
  63136. protected _measureForChildren: Measure;
  63137. /** @hidden */
  63138. protected _background: string;
  63139. /** @hidden */
  63140. protected _adaptWidthToChildren: boolean;
  63141. /** @hidden */
  63142. protected _adaptHeightToChildren: boolean;
  63143. /**
  63144. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  63145. */
  63146. logLayoutCycleErrors: boolean;
  63147. /**
  63148. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  63149. */
  63150. maxLayoutCycle: number;
  63151. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  63152. adaptHeightToChildren: boolean;
  63153. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  63154. adaptWidthToChildren: boolean;
  63155. /** Gets or sets background color */
  63156. background: string;
  63157. /** Gets the list of children */
  63158. readonly children: Control[];
  63159. /**
  63160. * Creates a new Container
  63161. * @param name defines the name of the container
  63162. */
  63163. constructor(name?: string | undefined);
  63164. protected _getTypeName(): string;
  63165. _flagDescendantsAsMatrixDirty(): void;
  63166. /**
  63167. * Gets a child using its name
  63168. * @param name defines the child name to look for
  63169. * @returns the child control if found
  63170. */
  63171. getChildByName(name: string): BABYLON.Nullable<Control>;
  63172. /**
  63173. * Gets a child using its type and its name
  63174. * @param name defines the child name to look for
  63175. * @param type defines the child type to look for
  63176. * @returns the child control if found
  63177. */
  63178. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  63179. /**
  63180. * Search for a specific control in children
  63181. * @param control defines the control to look for
  63182. * @returns true if the control is in child list
  63183. */
  63184. containsControl(control: Control): boolean;
  63185. /**
  63186. * Adds a new control to the current container
  63187. * @param control defines the control to add
  63188. * @returns the current container
  63189. */
  63190. addControl(control: BABYLON.Nullable<Control>): Container;
  63191. /**
  63192. * Removes all controls from the current container
  63193. * @returns the current container
  63194. */
  63195. clearControls(): Container;
  63196. /**
  63197. * Removes a control from the current container
  63198. * @param control defines the control to remove
  63199. * @returns the current container
  63200. */
  63201. removeControl(control: Control): Container;
  63202. /** @hidden */
  63203. _reOrderControl(control: Control): void;
  63204. /** @hidden */
  63205. _offsetLeft(offset: number): void;
  63206. /** @hidden */
  63207. _offsetTop(offset: number): void;
  63208. /** @hidden */
  63209. _markAllAsDirty(): void;
  63210. /** @hidden */
  63211. protected _localDraw(context: CanvasRenderingContext2D): void;
  63212. /** @hidden */
  63213. _link(host: AdvancedDynamicTexture): void;
  63214. /** @hidden */
  63215. protected _beforeLayout(): void;
  63216. /** @hidden */
  63217. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63218. /** @hidden */
  63219. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63220. protected _postMeasure(): void;
  63221. /** @hidden */
  63222. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  63223. /** @hidden */
  63224. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63225. /** @hidden */
  63226. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63227. /** @hidden */
  63228. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63229. /** Releases associated resources */
  63230. dispose(): void;
  63231. }
  63232. }
  63233. declare module BABYLON.GUI {
  63234. /** Class used to create rectangle container */
  63235. export class Rectangle extends Container {
  63236. name?: string | undefined;
  63237. private _thickness;
  63238. private _cornerRadius;
  63239. /** Gets or sets border thickness */
  63240. thickness: number;
  63241. /** Gets or sets the corner radius angle */
  63242. cornerRadius: number;
  63243. /**
  63244. * Creates a new Rectangle
  63245. * @param name defines the control name
  63246. */
  63247. constructor(name?: string | undefined);
  63248. protected _getTypeName(): string;
  63249. protected _localDraw(context: CanvasRenderingContext2D): void;
  63250. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63251. private _drawRoundedRect;
  63252. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63253. }
  63254. }
  63255. declare module BABYLON.GUI {
  63256. /**
  63257. * Enum that determines the text-wrapping mode to use.
  63258. */
  63259. export enum TextWrapping {
  63260. /**
  63261. * Clip the text when it's larger than Control.width; this is the default mode.
  63262. */
  63263. Clip = 0,
  63264. /**
  63265. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  63266. */
  63267. WordWrap = 1,
  63268. /**
  63269. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  63270. */
  63271. Ellipsis = 2
  63272. }
  63273. /**
  63274. * Class used to create text block control
  63275. */
  63276. export class TextBlock extends Control {
  63277. /**
  63278. * Defines the name of the control
  63279. */
  63280. name?: string | undefined;
  63281. private _text;
  63282. private _textWrapping;
  63283. private _textHorizontalAlignment;
  63284. private _textVerticalAlignment;
  63285. private _lines;
  63286. private _resizeToFit;
  63287. private _lineSpacing;
  63288. private _outlineWidth;
  63289. private _outlineColor;
  63290. /**
  63291. * An event triggered after the text is changed
  63292. */
  63293. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  63294. /**
  63295. * An event triggered after the text was broken up into lines
  63296. */
  63297. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  63298. /**
  63299. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  63300. */
  63301. readonly lines: any[];
  63302. /**
  63303. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63304. */
  63305. /**
  63306. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63307. */
  63308. resizeToFit: boolean;
  63309. /**
  63310. * Gets or sets a boolean indicating if text must be wrapped
  63311. */
  63312. /**
  63313. * Gets or sets a boolean indicating if text must be wrapped
  63314. */
  63315. textWrapping: TextWrapping | boolean;
  63316. /**
  63317. * Gets or sets text to display
  63318. */
  63319. /**
  63320. * Gets or sets text to display
  63321. */
  63322. text: string;
  63323. /**
  63324. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63325. */
  63326. /**
  63327. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63328. */
  63329. textHorizontalAlignment: number;
  63330. /**
  63331. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63332. */
  63333. /**
  63334. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63335. */
  63336. textVerticalAlignment: number;
  63337. /**
  63338. * Gets or sets line spacing value
  63339. */
  63340. /**
  63341. * Gets or sets line spacing value
  63342. */
  63343. lineSpacing: string | number;
  63344. /**
  63345. * Gets or sets outlineWidth of the text to display
  63346. */
  63347. /**
  63348. * Gets or sets outlineWidth of the text to display
  63349. */
  63350. outlineWidth: number;
  63351. /**
  63352. * Gets or sets outlineColor of the text to display
  63353. */
  63354. /**
  63355. * Gets or sets outlineColor of the text to display
  63356. */
  63357. outlineColor: string;
  63358. /**
  63359. * Creates a new TextBlock object
  63360. * @param name defines the name of the control
  63361. * @param text defines the text to display (emptry string by default)
  63362. */
  63363. constructor(
  63364. /**
  63365. * Defines the name of the control
  63366. */
  63367. name?: string | undefined, text?: string);
  63368. protected _getTypeName(): string;
  63369. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63370. private _drawText;
  63371. /** @hidden */
  63372. _draw(context: CanvasRenderingContext2D): void;
  63373. protected _applyStates(context: CanvasRenderingContext2D): void;
  63374. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  63375. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  63376. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  63377. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  63378. protected _renderLines(context: CanvasRenderingContext2D): void;
  63379. /**
  63380. * Given a width constraint applied on the text block, find the expected height
  63381. * @returns expected height
  63382. */
  63383. computeExpectedHeight(): number;
  63384. dispose(): void;
  63385. }
  63386. }
  63387. declare module BABYLON.GUI {
  63388. /**
  63389. * Class used to create 2D images
  63390. */
  63391. export class Image extends Control {
  63392. name?: string | undefined;
  63393. private static _WorkingCanvas;
  63394. private _domImage;
  63395. private _imageWidth;
  63396. private _imageHeight;
  63397. private _loaded;
  63398. private _stretch;
  63399. private _source;
  63400. private _autoScale;
  63401. private _sourceLeft;
  63402. private _sourceTop;
  63403. private _sourceWidth;
  63404. private _sourceHeight;
  63405. private _cellWidth;
  63406. private _cellHeight;
  63407. private _cellId;
  63408. private _populateNinePatchSlicesFromImage;
  63409. private _sliceLeft;
  63410. private _sliceRight;
  63411. private _sliceTop;
  63412. private _sliceBottom;
  63413. private _detectPointerOnOpaqueOnly;
  63414. /**
  63415. * BABYLON.Observable notified when the content is loaded
  63416. */
  63417. onImageLoadedObservable: BABYLON.Observable<Image>;
  63418. /**
  63419. * Gets a boolean indicating that the content is loaded
  63420. */
  63421. readonly isLoaded: boolean;
  63422. /**
  63423. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  63424. */
  63425. populateNinePatchSlicesFromImage: boolean;
  63426. /**
  63427. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  63428. * Beware using this as this will comsume more memory as the image has to be stored twice
  63429. */
  63430. detectPointerOnOpaqueOnly: boolean;
  63431. /**
  63432. * Gets or sets the left value for slicing (9-patch)
  63433. */
  63434. sliceLeft: number;
  63435. /**
  63436. * Gets or sets the right value for slicing (9-patch)
  63437. */
  63438. sliceRight: number;
  63439. /**
  63440. * Gets or sets the top value for slicing (9-patch)
  63441. */
  63442. sliceTop: number;
  63443. /**
  63444. * Gets or sets the bottom value for slicing (9-patch)
  63445. */
  63446. sliceBottom: number;
  63447. /**
  63448. * Gets or sets the left coordinate in the source image
  63449. */
  63450. sourceLeft: number;
  63451. /**
  63452. * Gets or sets the top coordinate in the source image
  63453. */
  63454. sourceTop: number;
  63455. /**
  63456. * Gets or sets the width to capture in the source image
  63457. */
  63458. sourceWidth: number;
  63459. /**
  63460. * Gets or sets the height to capture in the source image
  63461. */
  63462. sourceHeight: number;
  63463. /**
  63464. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  63465. * @see http://doc.babylonjs.com/how_to/gui#image
  63466. */
  63467. autoScale: boolean;
  63468. /** Gets or sets the streching mode used by the image */
  63469. stretch: number;
  63470. /**
  63471. * Gets or sets the internal DOM image used to render the control
  63472. */
  63473. domImage: HTMLImageElement;
  63474. private _onImageLoaded;
  63475. private _extractNinePatchSliceDataFromImage;
  63476. /**
  63477. * Gets or sets image source url
  63478. */
  63479. source: BABYLON.Nullable<string>;
  63480. /**
  63481. * Gets or sets the cell width to use when animation sheet is enabled
  63482. * @see http://doc.babylonjs.com/how_to/gui#image
  63483. */
  63484. cellWidth: number;
  63485. /**
  63486. * Gets or sets the cell height to use when animation sheet is enabled
  63487. * @see http://doc.babylonjs.com/how_to/gui#image
  63488. */
  63489. cellHeight: number;
  63490. /**
  63491. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  63492. * @see http://doc.babylonjs.com/how_to/gui#image
  63493. */
  63494. cellId: number;
  63495. /**
  63496. * Creates a new Image
  63497. * @param name defines the control name
  63498. * @param url defines the image url
  63499. */
  63500. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  63501. /**
  63502. * Tests if a given coordinates belong to the current control
  63503. * @param x defines x coordinate to test
  63504. * @param y defines y coordinate to test
  63505. * @returns true if the coordinates are inside the control
  63506. */
  63507. contains(x: number, y: number): boolean;
  63508. protected _getTypeName(): string;
  63509. /** Force the control to synchronize with its content */
  63510. synchronizeSizeWithContent(): void;
  63511. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63512. private _prepareWorkingCanvasForOpaqueDetection;
  63513. private _drawImage;
  63514. _draw(context: CanvasRenderingContext2D): void;
  63515. private _renderCornerPatch;
  63516. private _renderNinePatch;
  63517. dispose(): void;
  63518. /** STRETCH_NONE */
  63519. static readonly STRETCH_NONE: number;
  63520. /** STRETCH_FILL */
  63521. static readonly STRETCH_FILL: number;
  63522. /** STRETCH_UNIFORM */
  63523. static readonly STRETCH_UNIFORM: number;
  63524. /** STRETCH_EXTEND */
  63525. static readonly STRETCH_EXTEND: number;
  63526. /** NINE_PATCH */
  63527. static readonly STRETCH_NINE_PATCH: number;
  63528. }
  63529. }
  63530. declare module BABYLON.GUI {
  63531. /**
  63532. * Class used to create 2D buttons
  63533. */
  63534. export class Button extends Rectangle {
  63535. name?: string | undefined;
  63536. /**
  63537. * Function called to generate a pointer enter animation
  63538. */
  63539. pointerEnterAnimation: () => void;
  63540. /**
  63541. * Function called to generate a pointer out animation
  63542. */
  63543. pointerOutAnimation: () => void;
  63544. /**
  63545. * Function called to generate a pointer down animation
  63546. */
  63547. pointerDownAnimation: () => void;
  63548. /**
  63549. * Function called to generate a pointer up animation
  63550. */
  63551. pointerUpAnimation: () => void;
  63552. /**
  63553. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  63554. */
  63555. delegatePickingToChildren: boolean;
  63556. private _image;
  63557. /**
  63558. * Returns the image part of the button (if any)
  63559. */
  63560. readonly image: BABYLON.Nullable<Image>;
  63561. private _textBlock;
  63562. /**
  63563. * Returns the image part of the button (if any)
  63564. */
  63565. readonly textBlock: BABYLON.Nullable<TextBlock>;
  63566. /**
  63567. * Creates a new Button
  63568. * @param name defines the name of the button
  63569. */
  63570. constructor(name?: string | undefined);
  63571. protected _getTypeName(): string;
  63572. /** @hidden */
  63573. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63574. /** @hidden */
  63575. _onPointerEnter(target: Control): boolean;
  63576. /** @hidden */
  63577. _onPointerOut(target: Control, force?: boolean): void;
  63578. /** @hidden */
  63579. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63580. /** @hidden */
  63581. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63582. /**
  63583. * Creates a new button made with an image and a text
  63584. * @param name defines the name of the button
  63585. * @param text defines the text of the button
  63586. * @param imageUrl defines the url of the image
  63587. * @returns a new Button
  63588. */
  63589. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  63590. /**
  63591. * Creates a new button made with an image
  63592. * @param name defines the name of the button
  63593. * @param imageUrl defines the url of the image
  63594. * @returns a new Button
  63595. */
  63596. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  63597. /**
  63598. * Creates a new button made with a text
  63599. * @param name defines the name of the button
  63600. * @param text defines the text of the button
  63601. * @returns a new Button
  63602. */
  63603. static CreateSimpleButton(name: string, text: string): Button;
  63604. /**
  63605. * Creates a new button made with an image and a centered text
  63606. * @param name defines the name of the button
  63607. * @param text defines the text of the button
  63608. * @param imageUrl defines the url of the image
  63609. * @returns a new Button
  63610. */
  63611. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  63612. }
  63613. }
  63614. declare module BABYLON.GUI {
  63615. /**
  63616. * Class used to create a 2D stack panel container
  63617. */
  63618. export class StackPanel extends Container {
  63619. name?: string | undefined;
  63620. private _isVertical;
  63621. private _manualWidth;
  63622. private _manualHeight;
  63623. private _doNotTrackManualChanges;
  63624. /**
  63625. * Gets or sets a boolean indicating that layou warnings should be ignored
  63626. */
  63627. ignoreLayoutWarnings: boolean;
  63628. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  63629. isVertical: boolean;
  63630. /**
  63631. * Gets or sets panel width.
  63632. * This value should not be set when in horizontal mode as it will be computed automatically
  63633. */
  63634. width: string | number;
  63635. /**
  63636. * Gets or sets panel height.
  63637. * This value should not be set when in vertical mode as it will be computed automatically
  63638. */
  63639. height: string | number;
  63640. /**
  63641. * Creates a new StackPanel
  63642. * @param name defines control name
  63643. */
  63644. constructor(name?: string | undefined);
  63645. protected _getTypeName(): string;
  63646. /** @hidden */
  63647. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63648. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63649. protected _postMeasure(): void;
  63650. }
  63651. }
  63652. declare module BABYLON.GUI {
  63653. /**
  63654. * Class used to represent a 2D checkbox
  63655. */
  63656. export class Checkbox extends Control {
  63657. name?: string | undefined;
  63658. private _isChecked;
  63659. private _background;
  63660. private _checkSizeRatio;
  63661. private _thickness;
  63662. /** Gets or sets border thickness */
  63663. thickness: number;
  63664. /**
  63665. * BABYLON.Observable raised when isChecked property changes
  63666. */
  63667. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63668. /** Gets or sets a value indicating the ratio between overall size and check size */
  63669. checkSizeRatio: number;
  63670. /** Gets or sets background color */
  63671. background: string;
  63672. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63673. isChecked: boolean;
  63674. /**
  63675. * Creates a new CheckBox
  63676. * @param name defines the control name
  63677. */
  63678. constructor(name?: string | undefined);
  63679. protected _getTypeName(): string;
  63680. /** @hidden */
  63681. _draw(context: CanvasRenderingContext2D): void;
  63682. /** @hidden */
  63683. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63684. /**
  63685. * Utility function to easily create a checkbox with a header
  63686. * @param title defines the label to use for the header
  63687. * @param onValueChanged defines the callback to call when value changes
  63688. * @returns a StackPanel containing the checkbox and a textBlock
  63689. */
  63690. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  63691. }
  63692. }
  63693. declare module BABYLON.GUI {
  63694. /**
  63695. * Class used to store key control properties
  63696. */
  63697. export class KeyPropertySet {
  63698. /** Width */
  63699. width?: string;
  63700. /** Height */
  63701. height?: string;
  63702. /** Left padding */
  63703. paddingLeft?: string;
  63704. /** Right padding */
  63705. paddingRight?: string;
  63706. /** Top padding */
  63707. paddingTop?: string;
  63708. /** Bottom padding */
  63709. paddingBottom?: string;
  63710. /** Foreground color */
  63711. color?: string;
  63712. /** Background color */
  63713. background?: string;
  63714. }
  63715. /**
  63716. * Class used to create virtual keyboard
  63717. */
  63718. export class VirtualKeyboard extends StackPanel {
  63719. /** BABYLON.Observable raised when a key is pressed */
  63720. onKeyPressObservable: BABYLON.Observable<string>;
  63721. /** Gets or sets default key button width */
  63722. defaultButtonWidth: string;
  63723. /** Gets or sets default key button height */
  63724. defaultButtonHeight: string;
  63725. /** Gets or sets default key button left padding */
  63726. defaultButtonPaddingLeft: string;
  63727. /** Gets or sets default key button right padding */
  63728. defaultButtonPaddingRight: string;
  63729. /** Gets or sets default key button top padding */
  63730. defaultButtonPaddingTop: string;
  63731. /** Gets or sets default key button bottom padding */
  63732. defaultButtonPaddingBottom: string;
  63733. /** Gets or sets default key button foreground color */
  63734. defaultButtonColor: string;
  63735. /** Gets or sets default key button background color */
  63736. defaultButtonBackground: string;
  63737. /** Gets or sets shift button foreground color */
  63738. shiftButtonColor: string;
  63739. /** Gets or sets shift button thickness*/
  63740. selectedShiftThickness: number;
  63741. /** Gets shift key state */
  63742. shiftState: number;
  63743. protected _getTypeName(): string;
  63744. private _createKey;
  63745. /**
  63746. * Adds a new row of keys
  63747. * @param keys defines the list of keys to add
  63748. * @param propertySets defines the associated property sets
  63749. */
  63750. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  63751. /**
  63752. * Set the shift key to a specific state
  63753. * @param shiftState defines the new shift state
  63754. */
  63755. applyShiftState(shiftState: number): void;
  63756. private _currentlyConnectedInputText;
  63757. private _connectedInputTexts;
  63758. private _onKeyPressObserver;
  63759. /** Gets the input text control currently attached to the keyboard */
  63760. readonly connectedInputText: BABYLON.Nullable<InputText>;
  63761. /**
  63762. * Connects the keyboard with an input text control
  63763. *
  63764. * @param input defines the target control
  63765. */
  63766. connect(input: InputText): void;
  63767. /**
  63768. * Disconnects the keyboard from connected InputText controls
  63769. *
  63770. * @param input optionally defines a target control, otherwise all are disconnected
  63771. */
  63772. disconnect(input?: InputText): void;
  63773. private _removeConnectedInputObservables;
  63774. /**
  63775. * Release all resources
  63776. */
  63777. dispose(): void;
  63778. /**
  63779. * Creates a new keyboard using a default layout
  63780. *
  63781. * @param name defines control name
  63782. * @returns a new VirtualKeyboard
  63783. */
  63784. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  63785. }
  63786. }
  63787. declare module BABYLON.GUI {
  63788. /**
  63789. * Class used to create input text control
  63790. */
  63791. export class InputText extends Control implements IFocusableControl {
  63792. name?: string | undefined;
  63793. private _text;
  63794. private _placeholderText;
  63795. private _background;
  63796. private _focusedBackground;
  63797. private _focusedColor;
  63798. private _placeholderColor;
  63799. private _thickness;
  63800. private _margin;
  63801. private _autoStretchWidth;
  63802. private _maxWidth;
  63803. private _isFocused;
  63804. private _blinkTimeout;
  63805. private _blinkIsEven;
  63806. private _cursorOffset;
  63807. private _scrollLeft;
  63808. private _textWidth;
  63809. private _clickedCoordinate;
  63810. private _deadKey;
  63811. private _addKey;
  63812. private _currentKey;
  63813. private _isTextHighlightOn;
  63814. private _textHighlightColor;
  63815. private _highligherOpacity;
  63816. private _highlightedText;
  63817. private _startHighlightIndex;
  63818. private _endHighlightIndex;
  63819. private _cursorIndex;
  63820. private _onFocusSelectAll;
  63821. private _isPointerDown;
  63822. private _onClipboardObserver;
  63823. private _onPointerDblTapObserver;
  63824. /** @hidden */
  63825. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  63826. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  63827. promptMessage: string;
  63828. /** Force disable prompt on mobile device */
  63829. disableMobilePrompt: boolean;
  63830. /** BABYLON.Observable raised when the text changes */
  63831. onTextChangedObservable: BABYLON.Observable<InputText>;
  63832. /** BABYLON.Observable raised just before an entered character is to be added */
  63833. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  63834. /** BABYLON.Observable raised when the control gets the focus */
  63835. onFocusObservable: BABYLON.Observable<InputText>;
  63836. /** BABYLON.Observable raised when the control loses the focus */
  63837. onBlurObservable: BABYLON.Observable<InputText>;
  63838. /**Observable raised when the text is highlighted */
  63839. onTextHighlightObservable: BABYLON.Observable<InputText>;
  63840. /**Observable raised when copy event is triggered */
  63841. onTextCopyObservable: BABYLON.Observable<InputText>;
  63842. /** BABYLON.Observable raised when cut event is triggered */
  63843. onTextCutObservable: BABYLON.Observable<InputText>;
  63844. /** BABYLON.Observable raised when paste event is triggered */
  63845. onTextPasteObservable: BABYLON.Observable<InputText>;
  63846. /** BABYLON.Observable raised when a key event was processed */
  63847. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  63848. /** Gets or sets the maximum width allowed by the control */
  63849. maxWidth: string | number;
  63850. /** Gets the maximum width allowed by the control in pixels */
  63851. readonly maxWidthInPixels: number;
  63852. /** Gets or sets the text highlighter transparency; default: 0.4 */
  63853. highligherOpacity: number;
  63854. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  63855. onFocusSelectAll: boolean;
  63856. /** Gets or sets the text hightlight color */
  63857. textHighlightColor: string;
  63858. /** Gets or sets control margin */
  63859. margin: string;
  63860. /** Gets control margin in pixels */
  63861. readonly marginInPixels: number;
  63862. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  63863. autoStretchWidth: boolean;
  63864. /** Gets or sets border thickness */
  63865. thickness: number;
  63866. /** Gets or sets the background color when focused */
  63867. focusedBackground: string;
  63868. /** Gets or sets the background color when focused */
  63869. focusedColor: string;
  63870. /** Gets or sets the background color */
  63871. background: string;
  63872. /** Gets or sets the placeholder color */
  63873. placeholderColor: string;
  63874. /** Gets or sets the text displayed when the control is empty */
  63875. placeholderText: string;
  63876. /** Gets or sets the dead key flag */
  63877. deadKey: boolean;
  63878. /** Gets or sets the highlight text */
  63879. highlightedText: string;
  63880. /** Gets or sets if the current key should be added */
  63881. addKey: boolean;
  63882. /** Gets or sets the value of the current key being entered */
  63883. currentKey: string;
  63884. /** Gets or sets the text displayed in the control */
  63885. text: string;
  63886. /** Gets or sets control width */
  63887. width: string | number;
  63888. /**
  63889. * Creates a new InputText
  63890. * @param name defines the control name
  63891. * @param text defines the text of the control
  63892. */
  63893. constructor(name?: string | undefined, text?: string);
  63894. /** @hidden */
  63895. onBlur(): void;
  63896. /** @hidden */
  63897. onFocus(): void;
  63898. protected _getTypeName(): string;
  63899. /**
  63900. * Function called to get the list of controls that should not steal the focus from this control
  63901. * @returns an array of controls
  63902. */
  63903. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63904. /** @hidden */
  63905. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  63906. /** @hidden */
  63907. private _updateValueFromCursorIndex;
  63908. /** @hidden */
  63909. private _processDblClick;
  63910. /** @hidden */
  63911. private _selectAllText;
  63912. /**
  63913. * Handles the keyboard event
  63914. * @param evt Defines the KeyboardEvent
  63915. */
  63916. processKeyboard(evt: KeyboardEvent): void;
  63917. /** @hidden */
  63918. private _onCopyText;
  63919. /** @hidden */
  63920. private _onCutText;
  63921. /** @hidden */
  63922. private _onPasteText;
  63923. _draw(context: CanvasRenderingContext2D): void;
  63924. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63925. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63926. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63927. protected _beforeRenderText(text: string): string;
  63928. dispose(): void;
  63929. }
  63930. }
  63931. declare module BABYLON.GUI {
  63932. /**
  63933. * Class used to create a 2D grid container
  63934. */
  63935. export class Grid extends Container {
  63936. name?: string | undefined;
  63937. private _rowDefinitions;
  63938. private _columnDefinitions;
  63939. private _cells;
  63940. private _childControls;
  63941. /**
  63942. * Gets the number of columns
  63943. */
  63944. readonly columnCount: number;
  63945. /**
  63946. * Gets the number of rows
  63947. */
  63948. readonly rowCount: number;
  63949. /** Gets the list of children */
  63950. readonly children: Control[];
  63951. /** Gets the list of cells (e.g. the containers) */
  63952. readonly cells: {
  63953. [key: string]: Container;
  63954. };
  63955. /**
  63956. * Gets the definition of a specific row
  63957. * @param index defines the index of the row
  63958. * @returns the row definition
  63959. */
  63960. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  63961. /**
  63962. * Gets the definition of a specific column
  63963. * @param index defines the index of the column
  63964. * @returns the column definition
  63965. */
  63966. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  63967. /**
  63968. * Adds a new row to the grid
  63969. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  63970. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  63971. * @returns the current grid
  63972. */
  63973. addRowDefinition(height: number, isPixel?: boolean): Grid;
  63974. /**
  63975. * Adds a new column to the grid
  63976. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63977. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63978. * @returns the current grid
  63979. */
  63980. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  63981. /**
  63982. * Update a row definition
  63983. * @param index defines the index of the row to update
  63984. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  63985. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  63986. * @returns the current grid
  63987. */
  63988. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  63989. /**
  63990. * Update a column definition
  63991. * @param index defines the index of the column to update
  63992. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63993. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63994. * @returns the current grid
  63995. */
  63996. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  63997. /**
  63998. * Gets the list of children stored in a specific cell
  63999. * @param row defines the row to check
  64000. * @param column defines the column to check
  64001. * @returns the list of controls
  64002. */
  64003. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  64004. /**
  64005. * Gets a string representing the child cell info (row x column)
  64006. * @param child defines the control to get info from
  64007. * @returns a string containing the child cell info (row x column)
  64008. */
  64009. getChildCellInfo(child: Control): string;
  64010. private _removeCell;
  64011. private _offsetCell;
  64012. /**
  64013. * Remove a column definition at specified index
  64014. * @param index defines the index of the column to remove
  64015. * @returns the current grid
  64016. */
  64017. removeColumnDefinition(index: number): Grid;
  64018. /**
  64019. * Remove a row definition at specified index
  64020. * @param index defines the index of the row to remove
  64021. * @returns the current grid
  64022. */
  64023. removeRowDefinition(index: number): Grid;
  64024. /**
  64025. * Adds a new control to the current grid
  64026. * @param control defines the control to add
  64027. * @param row defines the row where to add the control (0 by default)
  64028. * @param column defines the column where to add the control (0 by default)
  64029. * @returns the current grid
  64030. */
  64031. addControl(control: Control, row?: number, column?: number): Grid;
  64032. /**
  64033. * Removes a control from the current container
  64034. * @param control defines the control to remove
  64035. * @returns the current container
  64036. */
  64037. removeControl(control: Control): Container;
  64038. /**
  64039. * Creates a new Grid
  64040. * @param name defines control name
  64041. */
  64042. constructor(name?: string | undefined);
  64043. protected _getTypeName(): string;
  64044. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  64045. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64046. _flagDescendantsAsMatrixDirty(): void;
  64047. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64048. /** Releases associated resources */
  64049. dispose(): void;
  64050. }
  64051. }
  64052. declare module BABYLON.GUI {
  64053. /** Class used to create color pickers */
  64054. export class ColorPicker extends Control {
  64055. name?: string | undefined;
  64056. private static _Epsilon;
  64057. private _colorWheelCanvas;
  64058. private _value;
  64059. private _tmpColor;
  64060. private _pointerStartedOnSquare;
  64061. private _pointerStartedOnWheel;
  64062. private _squareLeft;
  64063. private _squareTop;
  64064. private _squareSize;
  64065. private _h;
  64066. private _s;
  64067. private _v;
  64068. private _lastPointerDownID;
  64069. /**
  64070. * BABYLON.Observable raised when the value changes
  64071. */
  64072. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  64073. /** Gets or sets the color of the color picker */
  64074. value: BABYLON.Color3;
  64075. /**
  64076. * Gets or sets control width
  64077. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64078. */
  64079. width: string | number;
  64080. /**
  64081. * Gets or sets control height
  64082. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64083. */
  64084. /** Gets or sets control height */
  64085. height: string | number;
  64086. /** Gets or sets control size */
  64087. size: string | number;
  64088. /**
  64089. * Creates a new ColorPicker
  64090. * @param name defines the control name
  64091. */
  64092. constructor(name?: string | undefined);
  64093. protected _getTypeName(): string;
  64094. /** @hidden */
  64095. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64096. private _updateSquareProps;
  64097. private _drawGradientSquare;
  64098. private _drawCircle;
  64099. private _createColorWheelCanvas;
  64100. /** @hidden */
  64101. _draw(context: CanvasRenderingContext2D): void;
  64102. private _pointerIsDown;
  64103. private _updateValueFromPointer;
  64104. private _isPointOnSquare;
  64105. private _isPointOnWheel;
  64106. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64107. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64108. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64109. /**
  64110. * This function expands the color picker by creating a color picker dialog with manual
  64111. * color value input and the ability to save colors into an array to be used later in
  64112. * subsequent launches of the dialogue.
  64113. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  64114. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  64115. * @returns picked color as a hex string and the saved colors array as hex strings.
  64116. */
  64117. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  64118. pickerWidth?: string;
  64119. pickerHeight?: string;
  64120. headerHeight?: string;
  64121. lastColor?: string;
  64122. swatchLimit?: number;
  64123. numSwatchesPerLine?: number;
  64124. savedColors?: Array<string>;
  64125. }): Promise<{
  64126. savedColors?: string[];
  64127. pickedColor: string;
  64128. }>;
  64129. }
  64130. }
  64131. declare module BABYLON.GUI {
  64132. /** Class used to create 2D ellipse containers */
  64133. export class Ellipse extends Container {
  64134. name?: string | undefined;
  64135. private _thickness;
  64136. /** Gets or sets border thickness */
  64137. thickness: number;
  64138. /**
  64139. * Creates a new Ellipse
  64140. * @param name defines the control name
  64141. */
  64142. constructor(name?: string | undefined);
  64143. protected _getTypeName(): string;
  64144. protected _localDraw(context: CanvasRenderingContext2D): void;
  64145. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64146. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64147. }
  64148. }
  64149. declare module BABYLON.GUI {
  64150. /**
  64151. * Class used to create a password control
  64152. */
  64153. export class InputPassword extends InputText {
  64154. protected _beforeRenderText(text: string): string;
  64155. }
  64156. }
  64157. declare module BABYLON.GUI {
  64158. /** Class used to render 2D lines */
  64159. export class Line extends Control {
  64160. name?: string | undefined;
  64161. private _lineWidth;
  64162. private _x1;
  64163. private _y1;
  64164. private _x2;
  64165. private _y2;
  64166. private _dash;
  64167. private _connectedControl;
  64168. private _connectedControlDirtyObserver;
  64169. /** Gets or sets the dash pattern */
  64170. dash: Array<number>;
  64171. /** Gets or sets the control connected with the line end */
  64172. connectedControl: Control;
  64173. /** Gets or sets start coordinates on X axis */
  64174. x1: string | number;
  64175. /** Gets or sets start coordinates on Y axis */
  64176. y1: string | number;
  64177. /** Gets or sets end coordinates on X axis */
  64178. x2: string | number;
  64179. /** Gets or sets end coordinates on Y axis */
  64180. y2: string | number;
  64181. /** Gets or sets line width */
  64182. lineWidth: number;
  64183. /** Gets or sets horizontal alignment */
  64184. horizontalAlignment: number;
  64185. /** Gets or sets vertical alignment */
  64186. verticalAlignment: number;
  64187. private readonly _effectiveX2;
  64188. private readonly _effectiveY2;
  64189. /**
  64190. * Creates a new Line
  64191. * @param name defines the control name
  64192. */
  64193. constructor(name?: string | undefined);
  64194. protected _getTypeName(): string;
  64195. _draw(context: CanvasRenderingContext2D): void;
  64196. _measure(): void;
  64197. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64198. /**
  64199. * Move one end of the line given 3D cartesian coordinates.
  64200. * @param position Targeted world position
  64201. * @param scene BABYLON.Scene
  64202. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64203. */
  64204. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  64205. /**
  64206. * Move one end of the line to a position in screen absolute space.
  64207. * @param projectedPosition Position in screen absolute space (X, Y)
  64208. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64209. */
  64210. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  64211. }
  64212. }
  64213. declare module BABYLON.GUI {
  64214. /**
  64215. * Class used to store a point for a MultiLine object.
  64216. * The point can be pure 2D coordinates, a mesh or a control
  64217. */
  64218. export class MultiLinePoint {
  64219. private _multiLine;
  64220. private _x;
  64221. private _y;
  64222. private _control;
  64223. private _mesh;
  64224. private _controlObserver;
  64225. private _meshObserver;
  64226. /** @hidden */
  64227. _point: BABYLON.Vector2;
  64228. /**
  64229. * Creates a new MultiLinePoint
  64230. * @param multiLine defines the source MultiLine object
  64231. */
  64232. constructor(multiLine: MultiLine);
  64233. /** Gets or sets x coordinate */
  64234. x: string | number;
  64235. /** Gets or sets y coordinate */
  64236. y: string | number;
  64237. /** Gets or sets the control associated with this point */
  64238. control: BABYLON.Nullable<Control>;
  64239. /** Gets or sets the mesh associated with this point */
  64240. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64241. /** Resets links */
  64242. resetLinks(): void;
  64243. /**
  64244. * Gets a translation vector
  64245. * @returns the translation vector
  64246. */
  64247. translate(): BABYLON.Vector2;
  64248. private _translatePoint;
  64249. /** Release associated resources */
  64250. dispose(): void;
  64251. }
  64252. }
  64253. declare module BABYLON.GUI {
  64254. /**
  64255. * Class used to create multi line control
  64256. */
  64257. export class MultiLine extends Control {
  64258. name?: string | undefined;
  64259. private _lineWidth;
  64260. private _dash;
  64261. private _points;
  64262. private _minX;
  64263. private _minY;
  64264. private _maxX;
  64265. private _maxY;
  64266. /**
  64267. * Creates a new MultiLine
  64268. * @param name defines the control name
  64269. */
  64270. constructor(name?: string | undefined);
  64271. /** Gets or sets dash pattern */
  64272. dash: Array<number>;
  64273. /**
  64274. * Gets point stored at specified index
  64275. * @param index defines the index to look for
  64276. * @returns the requested point if found
  64277. */
  64278. getAt(index: number): MultiLinePoint;
  64279. /** Function called when a point is updated */
  64280. onPointUpdate: () => void;
  64281. /**
  64282. * Adds new points to the point collection
  64283. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  64284. * @returns the list of created MultiLinePoint
  64285. */
  64286. add(...items: (AbstractMesh | Control | {
  64287. x: string | number;
  64288. y: string | number;
  64289. })[]): MultiLinePoint[];
  64290. /**
  64291. * Adds a new point to the point collection
  64292. * @param item defines the item (mesh, control or 2d coordiantes) to add
  64293. * @returns the created MultiLinePoint
  64294. */
  64295. push(item?: (AbstractMesh | Control | {
  64296. x: string | number;
  64297. y: string | number;
  64298. })): MultiLinePoint;
  64299. /**
  64300. * Remove a specific value or point from the active point collection
  64301. * @param value defines the value or point to remove
  64302. */
  64303. remove(value: number | MultiLinePoint): void;
  64304. /**
  64305. * Resets this object to initial state (no point)
  64306. */
  64307. reset(): void;
  64308. /**
  64309. * Resets all links
  64310. */
  64311. resetLinks(): void;
  64312. /** Gets or sets line width */
  64313. lineWidth: number;
  64314. horizontalAlignment: number;
  64315. verticalAlignment: number;
  64316. protected _getTypeName(): string;
  64317. _draw(context: CanvasRenderingContext2D): void;
  64318. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64319. _measure(): void;
  64320. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64321. dispose(): void;
  64322. }
  64323. }
  64324. declare module BABYLON.GUI {
  64325. /**
  64326. * Class used to create radio button controls
  64327. */
  64328. export class RadioButton extends Control {
  64329. name?: string | undefined;
  64330. private _isChecked;
  64331. private _background;
  64332. private _checkSizeRatio;
  64333. private _thickness;
  64334. /** Gets or sets border thickness */
  64335. thickness: number;
  64336. /** Gets or sets group name */
  64337. group: string;
  64338. /** BABYLON.Observable raised when isChecked is changed */
  64339. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64340. /** Gets or sets a value indicating the ratio between overall size and check size */
  64341. checkSizeRatio: number;
  64342. /** Gets or sets background color */
  64343. background: string;
  64344. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64345. isChecked: boolean;
  64346. /**
  64347. * Creates a new RadioButton
  64348. * @param name defines the control name
  64349. */
  64350. constructor(name?: string | undefined);
  64351. protected _getTypeName(): string;
  64352. _draw(context: CanvasRenderingContext2D): void;
  64353. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64354. /**
  64355. * Utility function to easily create a radio button with a header
  64356. * @param title defines the label to use for the header
  64357. * @param group defines the group to use for the radio button
  64358. * @param isChecked defines the initial state of the radio button
  64359. * @param onValueChanged defines the callback to call when value changes
  64360. * @returns a StackPanel containing the radio button and a textBlock
  64361. */
  64362. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  64363. }
  64364. }
  64365. declare module BABYLON.GUI {
  64366. /**
  64367. * Class used to create slider controls
  64368. */
  64369. export class BaseSlider extends Control {
  64370. name?: string | undefined;
  64371. protected _thumbWidth: ValueAndUnit;
  64372. private _minimum;
  64373. private _maximum;
  64374. private _value;
  64375. private _isVertical;
  64376. protected _barOffset: ValueAndUnit;
  64377. private _isThumbClamped;
  64378. protected _displayThumb: boolean;
  64379. private _step;
  64380. private _lastPointerDownID;
  64381. protected _effectiveBarOffset: number;
  64382. protected _renderLeft: number;
  64383. protected _renderTop: number;
  64384. protected _renderWidth: number;
  64385. protected _renderHeight: number;
  64386. protected _backgroundBoxLength: number;
  64387. protected _backgroundBoxThickness: number;
  64388. protected _effectiveThumbThickness: number;
  64389. /** BABYLON.Observable raised when the sldier value changes */
  64390. onValueChangedObservable: BABYLON.Observable<number>;
  64391. /** Gets or sets a boolean indicating if the thumb must be rendered */
  64392. displayThumb: boolean;
  64393. /** Gets or sets a step to apply to values (0 by default) */
  64394. step: number;
  64395. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  64396. barOffset: string | number;
  64397. /** Gets main bar offset in pixels*/
  64398. readonly barOffsetInPixels: number;
  64399. /** Gets or sets thumb width */
  64400. thumbWidth: string | number;
  64401. /** Gets thumb width in pixels */
  64402. readonly thumbWidthInPixels: number;
  64403. /** Gets or sets minimum value */
  64404. minimum: number;
  64405. /** Gets or sets maximum value */
  64406. maximum: number;
  64407. /** Gets or sets current value */
  64408. value: number;
  64409. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  64410. isVertical: boolean;
  64411. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  64412. isThumbClamped: boolean;
  64413. /**
  64414. * Creates a new BaseSlider
  64415. * @param name defines the control name
  64416. */
  64417. constructor(name?: string | undefined);
  64418. protected _getTypeName(): string;
  64419. protected _getThumbPosition(): number;
  64420. protected _getThumbThickness(type: string): number;
  64421. protected _prepareRenderingData(type: string): void;
  64422. private _pointerIsDown;
  64423. /** @hidden */
  64424. protected _updateValueFromPointer(x: number, y: number): void;
  64425. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64426. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64427. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64428. }
  64429. }
  64430. declare module BABYLON.GUI {
  64431. /**
  64432. * Class used to create slider controls
  64433. */
  64434. export class Slider extends BaseSlider {
  64435. name?: string | undefined;
  64436. private _background;
  64437. private _borderColor;
  64438. private _isThumbCircle;
  64439. protected _displayValueBar: boolean;
  64440. /** Gets or sets a boolean indicating if the value bar must be rendered */
  64441. displayValueBar: boolean;
  64442. /** Gets or sets border color */
  64443. borderColor: string;
  64444. /** Gets or sets background color */
  64445. background: string;
  64446. /** Gets or sets a boolean indicating if the thumb should be round or square */
  64447. isThumbCircle: boolean;
  64448. /**
  64449. * Creates a new Slider
  64450. * @param name defines the control name
  64451. */
  64452. constructor(name?: string | undefined);
  64453. protected _getTypeName(): string;
  64454. _draw(context: CanvasRenderingContext2D): void;
  64455. }
  64456. }
  64457. declare module BABYLON.GUI {
  64458. /** Class used to create a RadioGroup
  64459. * which contains groups of radio buttons
  64460. */
  64461. export class SelectorGroup {
  64462. /** name of SelectorGroup */
  64463. name: string;
  64464. private _groupPanel;
  64465. private _selectors;
  64466. private _groupHeader;
  64467. /**
  64468. * Creates a new SelectorGroup
  64469. * @param name of group, used as a group heading
  64470. */
  64471. constructor(
  64472. /** name of SelectorGroup */
  64473. name: string);
  64474. /** Gets the groupPanel of the SelectorGroup */
  64475. readonly groupPanel: StackPanel;
  64476. /** Gets the selectors array */
  64477. readonly selectors: StackPanel[];
  64478. /** Gets and sets the group header */
  64479. header: string;
  64480. /** @hidden */
  64481. private _addGroupHeader;
  64482. /** @hidden*/
  64483. _getSelector(selectorNb: number): StackPanel | undefined;
  64484. /** Removes the selector at the given position
  64485. * @param selectorNb the position of the selector within the group
  64486. */
  64487. removeSelector(selectorNb: number): void;
  64488. }
  64489. /** Class used to create a CheckboxGroup
  64490. * which contains groups of checkbox buttons
  64491. */
  64492. export class CheckboxGroup extends SelectorGroup {
  64493. /** Adds a checkbox as a control
  64494. * @param text is the label for the selector
  64495. * @param func is the function called when the Selector is checked
  64496. * @param checked is true when Selector is checked
  64497. */
  64498. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  64499. /** @hidden */
  64500. _setSelectorLabel(selectorNb: number, label: string): void;
  64501. /** @hidden */
  64502. _setSelectorLabelColor(selectorNb: number, color: string): void;
  64503. /** @hidden */
  64504. _setSelectorButtonColor(selectorNb: number, color: string): void;
  64505. /** @hidden */
  64506. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64507. }
  64508. /** Class used to create a RadioGroup
  64509. * which contains groups of radio buttons
  64510. */
  64511. export class RadioGroup extends SelectorGroup {
  64512. private _selectNb;
  64513. /** Adds a radio button as a control
  64514. * @param label is the label for the selector
  64515. * @param func is the function called when the Selector is checked
  64516. * @param checked is true when Selector is checked
  64517. */
  64518. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  64519. /** @hidden */
  64520. _setSelectorLabel(selectorNb: number, label: string): void;
  64521. /** @hidden */
  64522. _setSelectorLabelColor(selectorNb: number, color: string): void;
  64523. /** @hidden */
  64524. _setSelectorButtonColor(selectorNb: number, color: string): void;
  64525. /** @hidden */
  64526. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64527. }
  64528. /** Class used to create a SliderGroup
  64529. * which contains groups of slider buttons
  64530. */
  64531. export class SliderGroup extends SelectorGroup {
  64532. /**
  64533. * Adds a slider to the SelectorGroup
  64534. * @param label is the label for the SliderBar
  64535. * @param func is the function called when the Slider moves
  64536. * @param unit is a string describing the units used, eg degrees or metres
  64537. * @param min is the minimum value for the Slider
  64538. * @param max is the maximum value for the Slider
  64539. * @param value is the start value for the Slider between min and max
  64540. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  64541. */
  64542. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  64543. /** @hidden */
  64544. _setSelectorLabel(selectorNb: number, label: string): void;
  64545. /** @hidden */
  64546. _setSelectorLabelColor(selectorNb: number, color: string): void;
  64547. /** @hidden */
  64548. _setSelectorButtonColor(selectorNb: number, color: string): void;
  64549. /** @hidden */
  64550. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64551. }
  64552. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  64553. * @see http://doc.babylonjs.com/how_to/selector
  64554. */
  64555. export class SelectionPanel extends Rectangle {
  64556. /** name of SelectionPanel */
  64557. name: string;
  64558. /** an array of SelectionGroups */
  64559. groups: SelectorGroup[];
  64560. private _panel;
  64561. private _buttonColor;
  64562. private _buttonBackground;
  64563. private _headerColor;
  64564. private _barColor;
  64565. private _barHeight;
  64566. private _spacerHeight;
  64567. private _labelColor;
  64568. private _groups;
  64569. private _bars;
  64570. /**
  64571. * Creates a new SelectionPanel
  64572. * @param name of SelectionPanel
  64573. * @param groups is an array of SelectionGroups
  64574. */
  64575. constructor(
  64576. /** name of SelectionPanel */
  64577. name: string,
  64578. /** an array of SelectionGroups */
  64579. groups?: SelectorGroup[]);
  64580. protected _getTypeName(): string;
  64581. /** Gets or sets the headerColor */
  64582. headerColor: string;
  64583. private _setHeaderColor;
  64584. /** Gets or sets the button color */
  64585. buttonColor: string;
  64586. private _setbuttonColor;
  64587. /** Gets or sets the label color */
  64588. labelColor: string;
  64589. private _setLabelColor;
  64590. /** Gets or sets the button background */
  64591. buttonBackground: string;
  64592. private _setButtonBackground;
  64593. /** Gets or sets the color of separator bar */
  64594. barColor: string;
  64595. private _setBarColor;
  64596. /** Gets or sets the height of separator bar */
  64597. barHeight: string;
  64598. private _setBarHeight;
  64599. /** Gets or sets the height of spacers*/
  64600. spacerHeight: string;
  64601. private _setSpacerHeight;
  64602. /** Adds a bar between groups */
  64603. private _addSpacer;
  64604. /** Add a group to the selection panel
  64605. * @param group is the selector group to add
  64606. */
  64607. addGroup(group: SelectorGroup): void;
  64608. /** Remove the group from the given position
  64609. * @param groupNb is the position of the group in the list
  64610. */
  64611. removeGroup(groupNb: number): void;
  64612. /** Change a group header label
  64613. * @param label is the new group header label
  64614. * @param groupNb is the number of the group to relabel
  64615. * */
  64616. setHeaderName(label: string, groupNb: number): void;
  64617. /** Change selector label to the one given
  64618. * @param label is the new selector label
  64619. * @param groupNb is the number of the groupcontaining the selector
  64620. * @param selectorNb is the number of the selector within a group to relabel
  64621. * */
  64622. relabel(label: string, groupNb: number, selectorNb: number): void;
  64623. /** For a given group position remove the selector at the given position
  64624. * @param groupNb is the number of the group to remove the selector from
  64625. * @param selectorNb is the number of the selector within the group
  64626. */
  64627. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  64628. /** For a given group position of correct type add a checkbox button
  64629. * @param groupNb is the number of the group to remove the selector from
  64630. * @param label is the label for the selector
  64631. * @param func is the function called when the Selector is checked
  64632. * @param checked is true when Selector is checked
  64633. */
  64634. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64635. /** For a given group position of correct type add a radio button
  64636. * @param groupNb is the number of the group to remove the selector from
  64637. * @param label is the label for the selector
  64638. * @param func is the function called when the Selector is checked
  64639. * @param checked is true when Selector is checked
  64640. */
  64641. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64642. /**
  64643. * For a given slider group add a slider
  64644. * @param groupNb is the number of the group to add the slider to
  64645. * @param label is the label for the Slider
  64646. * @param func is the function called when the Slider moves
  64647. * @param unit is a string describing the units used, eg degrees or metres
  64648. * @param min is the minimum value for the Slider
  64649. * @param max is the maximum value for the Slider
  64650. * @param value is the start value for the Slider between min and max
  64651. * @param onVal is the function used to format the value displayed, eg radians to degrees
  64652. */
  64653. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  64654. }
  64655. }
  64656. declare module BABYLON.GUI {
  64657. /**
  64658. * Class used to hold a the container for ScrollViewer
  64659. * @hidden
  64660. */
  64661. export class _ScrollViewerWindow extends Container {
  64662. parentClientWidth: number;
  64663. parentClientHeight: number;
  64664. /**
  64665. * Creates a new ScrollViewerWindow
  64666. * @param name of ScrollViewerWindow
  64667. */
  64668. constructor(name?: string);
  64669. protected _getTypeName(): string;
  64670. /** @hidden */
  64671. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64672. protected _postMeasure(): void;
  64673. }
  64674. }
  64675. declare module BABYLON.GUI {
  64676. /**
  64677. * Class used to create slider controls
  64678. */
  64679. export class ScrollBar extends BaseSlider {
  64680. name?: string | undefined;
  64681. private _background;
  64682. private _borderColor;
  64683. private _thumbMeasure;
  64684. /** Gets or sets border color */
  64685. borderColor: string;
  64686. /** Gets or sets background color */
  64687. background: string;
  64688. /**
  64689. * Creates a new Slider
  64690. * @param name defines the control name
  64691. */
  64692. constructor(name?: string | undefined);
  64693. protected _getTypeName(): string;
  64694. protected _getThumbThickness(): number;
  64695. _draw(context: CanvasRenderingContext2D): void;
  64696. private _first;
  64697. private _originX;
  64698. private _originY;
  64699. /** @hidden */
  64700. protected _updateValueFromPointer(x: number, y: number): void;
  64701. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64702. }
  64703. }
  64704. declare module BABYLON.GUI {
  64705. /**
  64706. * Class used to hold a viewer window and sliders in a grid
  64707. */
  64708. export class ScrollViewer extends Rectangle {
  64709. private _grid;
  64710. private _horizontalBarSpace;
  64711. private _verticalBarSpace;
  64712. private _dragSpace;
  64713. private _horizontalBar;
  64714. private _verticalBar;
  64715. private _barColor;
  64716. private _barBackground;
  64717. private _barSize;
  64718. private _endLeft;
  64719. private _endTop;
  64720. private _window;
  64721. private _pointerIsOver;
  64722. private _wheelPrecision;
  64723. private _onPointerObserver;
  64724. private _clientWidth;
  64725. private _clientHeight;
  64726. /**
  64727. * Gets the horizontal scrollbar
  64728. */
  64729. readonly horizontalBar: ScrollBar;
  64730. /**
  64731. * Gets the vertical scrollbar
  64732. */
  64733. readonly verticalBar: ScrollBar;
  64734. /**
  64735. * Adds a new control to the current container
  64736. * @param control defines the control to add
  64737. * @returns the current container
  64738. */
  64739. addControl(control: BABYLON.Nullable<Control>): Container;
  64740. /**
  64741. * Removes a control from the current container
  64742. * @param control defines the control to remove
  64743. * @returns the current container
  64744. */
  64745. removeControl(control: Control): Container;
  64746. /** Gets the list of children */
  64747. readonly children: Control[];
  64748. _flagDescendantsAsMatrixDirty(): void;
  64749. /**
  64750. * Creates a new ScrollViewer
  64751. * @param name of ScrollViewer
  64752. */
  64753. constructor(name?: string);
  64754. /** Reset the scroll viewer window to initial size */
  64755. resetWindow(): void;
  64756. protected _getTypeName(): string;
  64757. private _buildClientSizes;
  64758. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64759. protected _postMeasure(): void;
  64760. /**
  64761. * Gets or sets the mouse wheel precision
  64762. * from 0 to 1 with a default value of 0.05
  64763. * */
  64764. wheelPrecision: number;
  64765. /** Gets or sets the bar color */
  64766. barColor: string;
  64767. /** Gets or sets the size of the bar */
  64768. barSize: number;
  64769. /** Gets or sets the bar background */
  64770. barBackground: string;
  64771. /** @hidden */
  64772. private _updateScroller;
  64773. _link(host: AdvancedDynamicTexture): void;
  64774. /** @hidden */
  64775. private _attachWheel;
  64776. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64777. /** Releases associated resources */
  64778. dispose(): void;
  64779. }
  64780. }
  64781. declare module BABYLON.GUI {
  64782. /** Class used to render a grid */
  64783. export class DisplayGrid extends Control {
  64784. name?: string | undefined;
  64785. private _cellWidth;
  64786. private _cellHeight;
  64787. private _minorLineTickness;
  64788. private _minorLineColor;
  64789. private _majorLineTickness;
  64790. private _majorLineColor;
  64791. private _majorLineFrequency;
  64792. private _background;
  64793. private _displayMajorLines;
  64794. private _displayMinorLines;
  64795. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  64796. displayMinorLines: boolean;
  64797. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  64798. displayMajorLines: boolean;
  64799. /** Gets or sets background color (Black by default) */
  64800. background: string;
  64801. /** Gets or sets the width of each cell (20 by default) */
  64802. cellWidth: number;
  64803. /** Gets or sets the height of each cell (20 by default) */
  64804. cellHeight: number;
  64805. /** Gets or sets the tickness of minor lines (1 by default) */
  64806. minorLineTickness: number;
  64807. /** Gets or sets the color of minor lines (DarkGray by default) */
  64808. minorLineColor: string;
  64809. /** Gets or sets the tickness of major lines (2 by default) */
  64810. majorLineTickness: number;
  64811. /** Gets or sets the color of major lines (White by default) */
  64812. majorLineColor: string;
  64813. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  64814. majorLineFrequency: number;
  64815. /**
  64816. * Creates a new GridDisplayRectangle
  64817. * @param name defines the control name
  64818. */
  64819. constructor(name?: string | undefined);
  64820. _draw(context: CanvasRenderingContext2D): void;
  64821. protected _getTypeName(): string;
  64822. }
  64823. }
  64824. declare module BABYLON.GUI {
  64825. /**
  64826. * Class used to create slider controls based on images
  64827. */
  64828. export class ImageBasedSlider extends BaseSlider {
  64829. name?: string | undefined;
  64830. private _backgroundImage;
  64831. private _thumbImage;
  64832. private _valueBarImage;
  64833. private _tempMeasure;
  64834. displayThumb: boolean;
  64835. /**
  64836. * Gets or sets the image used to render the background
  64837. */
  64838. backgroundImage: Image;
  64839. /**
  64840. * Gets or sets the image used to render the value bar
  64841. */
  64842. valueBarImage: Image;
  64843. /**
  64844. * Gets or sets the image used to render the thumb
  64845. */
  64846. thumbImage: Image;
  64847. /**
  64848. * Creates a new ImageBasedSlider
  64849. * @param name defines the control name
  64850. */
  64851. constructor(name?: string | undefined);
  64852. protected _getTypeName(): string;
  64853. _draw(context: CanvasRenderingContext2D): void;
  64854. }
  64855. }
  64856. declare module BABYLON.GUI {
  64857. /**
  64858. * Forcing an export so that this code will execute
  64859. * @hidden
  64860. */
  64861. const name = "Statics";
  64862. }
  64863. declare module BABYLON.GUI {
  64864. /**
  64865. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  64866. */
  64867. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  64868. /**
  64869. * Define the instrumented AdvancedDynamicTexture.
  64870. */
  64871. texture: AdvancedDynamicTexture;
  64872. private _captureRenderTime;
  64873. private _renderTime;
  64874. private _captureLayoutTime;
  64875. private _layoutTime;
  64876. private _onBeginRenderObserver;
  64877. private _onEndRenderObserver;
  64878. private _onBeginLayoutObserver;
  64879. private _onEndLayoutObserver;
  64880. /**
  64881. * Gets the perf counter used to capture render time
  64882. */
  64883. readonly renderTimeCounter: BABYLON.PerfCounter;
  64884. /**
  64885. * Gets the perf counter used to capture layout time
  64886. */
  64887. readonly layoutTimeCounter: BABYLON.PerfCounter;
  64888. /**
  64889. * Enable or disable the render time capture
  64890. */
  64891. captureRenderTime: boolean;
  64892. /**
  64893. * Enable or disable the layout time capture
  64894. */
  64895. captureLayoutTime: boolean;
  64896. /**
  64897. * Instantiates a new advanced dynamic texture instrumentation.
  64898. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  64899. * @param texture Defines the AdvancedDynamicTexture to instrument
  64900. */
  64901. constructor(
  64902. /**
  64903. * Define the instrumented AdvancedDynamicTexture.
  64904. */
  64905. texture: AdvancedDynamicTexture);
  64906. /**
  64907. * Dispose and release associated resources.
  64908. */
  64909. dispose(): void;
  64910. }
  64911. }
  64912. declare module BABYLON.GUI {
  64913. /**
  64914. * Class used to create containers for controls
  64915. */
  64916. export class Container3D extends Control3D {
  64917. private _blockLayout;
  64918. /**
  64919. * Gets the list of child controls
  64920. */
  64921. protected _children: Control3D[];
  64922. /**
  64923. * Gets the list of child controls
  64924. */
  64925. readonly children: Array<Control3D>;
  64926. /**
  64927. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  64928. * This is helpful to optimize layout operation when adding multiple children in a row
  64929. */
  64930. blockLayout: boolean;
  64931. /**
  64932. * Creates a new container
  64933. * @param name defines the container name
  64934. */
  64935. constructor(name?: string);
  64936. /**
  64937. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  64938. * @returns the current container
  64939. */
  64940. updateLayout(): Container3D;
  64941. /**
  64942. * Gets a boolean indicating if the given control is in the children of this control
  64943. * @param control defines the control to check
  64944. * @returns true if the control is in the child list
  64945. */
  64946. containsControl(control: Control3D): boolean;
  64947. /**
  64948. * Adds a control to the children of this control
  64949. * @param control defines the control to add
  64950. * @returns the current container
  64951. */
  64952. addControl(control: Control3D): Container3D;
  64953. /**
  64954. * This function will be called everytime a new control is added
  64955. */
  64956. protected _arrangeChildren(): void;
  64957. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  64958. /**
  64959. * Removes a control from the children of this control
  64960. * @param control defines the control to remove
  64961. * @returns the current container
  64962. */
  64963. removeControl(control: Control3D): Container3D;
  64964. protected _getTypeName(): string;
  64965. /**
  64966. * Releases all associated resources
  64967. */
  64968. dispose(): void;
  64969. /** Control rotation will remain unchanged */
  64970. static readonly UNSET_ORIENTATION: number;
  64971. /** Control will rotate to make it look at sphere central axis */
  64972. static readonly FACEORIGIN_ORIENTATION: number;
  64973. /** Control will rotate to make it look back at sphere central axis */
  64974. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  64975. /** Control will rotate to look at z axis (0, 0, 1) */
  64976. static readonly FACEFORWARD_ORIENTATION: number;
  64977. /** Control will rotate to look at negative z axis (0, 0, -1) */
  64978. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  64979. }
  64980. }
  64981. declare module BABYLON.GUI {
  64982. /**
  64983. * Class used to manage 3D user interface
  64984. * @see http://doc.babylonjs.com/how_to/gui3d
  64985. */
  64986. export class GUI3DManager implements BABYLON.IDisposable {
  64987. private _scene;
  64988. private _sceneDisposeObserver;
  64989. private _utilityLayer;
  64990. private _rootContainer;
  64991. private _pointerObserver;
  64992. private _pointerOutObserver;
  64993. /** @hidden */
  64994. _lastPickedControl: Control3D;
  64995. /** @hidden */
  64996. _lastControlOver: {
  64997. [pointerId: number]: Control3D;
  64998. };
  64999. /** @hidden */
  65000. _lastControlDown: {
  65001. [pointerId: number]: Control3D;
  65002. };
  65003. /**
  65004. * BABYLON.Observable raised when the point picked by the pointer events changed
  65005. */
  65006. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  65007. /** @hidden */
  65008. _sharedMaterials: {
  65009. [key: string]: BABYLON.Material;
  65010. };
  65011. /** Gets the hosting scene */
  65012. readonly scene: BABYLON.Scene;
  65013. /** Gets associated utility layer */
  65014. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  65015. /**
  65016. * Creates a new GUI3DManager
  65017. * @param scene
  65018. */
  65019. constructor(scene?: BABYLON.Scene);
  65020. private _handlePointerOut;
  65021. private _doPicking;
  65022. /**
  65023. * Gets the root container
  65024. */
  65025. readonly rootContainer: Container3D;
  65026. /**
  65027. * Gets a boolean indicating if the given control is in the root child list
  65028. * @param control defines the control to check
  65029. * @returns true if the control is in the root child list
  65030. */
  65031. containsControl(control: Control3D): boolean;
  65032. /**
  65033. * Adds a control to the root child list
  65034. * @param control defines the control to add
  65035. * @returns the current manager
  65036. */
  65037. addControl(control: Control3D): GUI3DManager;
  65038. /**
  65039. * Removes a control from the root child list
  65040. * @param control defines the control to remove
  65041. * @returns the current container
  65042. */
  65043. removeControl(control: Control3D): GUI3DManager;
  65044. /**
  65045. * Releases all associated resources
  65046. */
  65047. dispose(): void;
  65048. }
  65049. }
  65050. declare module BABYLON.GUI {
  65051. /**
  65052. * Class used to transport BABYLON.Vector3 information for pointer events
  65053. */
  65054. export class Vector3WithInfo extends BABYLON.Vector3 {
  65055. /** defines the current mouse button index */
  65056. buttonIndex: number;
  65057. /**
  65058. * Creates a new Vector3WithInfo
  65059. * @param source defines the vector3 data to transport
  65060. * @param buttonIndex defines the current mouse button index
  65061. */
  65062. constructor(source: BABYLON.Vector3,
  65063. /** defines the current mouse button index */
  65064. buttonIndex?: number);
  65065. }
  65066. }
  65067. declare module BABYLON.GUI {
  65068. /**
  65069. * Class used as base class for controls
  65070. */
  65071. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  65072. /** Defines the control name */
  65073. name?: string | undefined;
  65074. /** @hidden */
  65075. _host: GUI3DManager;
  65076. private _node;
  65077. private _downCount;
  65078. private _enterCount;
  65079. private _downPointerIds;
  65080. private _isVisible;
  65081. /** Gets or sets the control position in world space */
  65082. position: BABYLON.Vector3;
  65083. /** Gets or sets the control scaling in world space */
  65084. scaling: BABYLON.Vector3;
  65085. /** Callback used to start pointer enter animation */
  65086. pointerEnterAnimation: () => void;
  65087. /** Callback used to start pointer out animation */
  65088. pointerOutAnimation: () => void;
  65089. /** Callback used to start pointer down animation */
  65090. pointerDownAnimation: () => void;
  65091. /** Callback used to start pointer up animation */
  65092. pointerUpAnimation: () => void;
  65093. /**
  65094. * An event triggered when the pointer move over the control
  65095. */
  65096. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  65097. /**
  65098. * An event triggered when the pointer move out of the control
  65099. */
  65100. onPointerOutObservable: BABYLON.Observable<Control3D>;
  65101. /**
  65102. * An event triggered when the pointer taps the control
  65103. */
  65104. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  65105. /**
  65106. * An event triggered when pointer is up
  65107. */
  65108. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  65109. /**
  65110. * An event triggered when a control is clicked on (with a mouse)
  65111. */
  65112. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  65113. /**
  65114. * An event triggered when pointer enters the control
  65115. */
  65116. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  65117. /**
  65118. * Gets or sets the parent container
  65119. */
  65120. parent: BABYLON.Nullable<Container3D>;
  65121. private _behaviors;
  65122. /**
  65123. * Gets the list of attached behaviors
  65124. * @see http://doc.babylonjs.com/features/behaviour
  65125. */
  65126. readonly behaviors: BABYLON.Behavior<Control3D>[];
  65127. /**
  65128. * Attach a behavior to the control
  65129. * @see http://doc.babylonjs.com/features/behaviour
  65130. * @param behavior defines the behavior to attach
  65131. * @returns the current control
  65132. */
  65133. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65134. /**
  65135. * Remove an attached behavior
  65136. * @see http://doc.babylonjs.com/features/behaviour
  65137. * @param behavior defines the behavior to attach
  65138. * @returns the current control
  65139. */
  65140. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65141. /**
  65142. * Gets an attached behavior by name
  65143. * @param name defines the name of the behavior to look for
  65144. * @see http://doc.babylonjs.com/features/behaviour
  65145. * @returns null if behavior was not found else the requested behavior
  65146. */
  65147. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  65148. /** Gets or sets a boolean indicating if the control is visible */
  65149. isVisible: boolean;
  65150. /**
  65151. * Creates a new control
  65152. * @param name defines the control name
  65153. */
  65154. constructor(
  65155. /** Defines the control name */
  65156. name?: string | undefined);
  65157. /**
  65158. * Gets a string representing the class name
  65159. */
  65160. readonly typeName: string;
  65161. /**
  65162. * Get the current class name of the control.
  65163. * @returns current class name
  65164. */
  65165. getClassName(): string;
  65166. protected _getTypeName(): string;
  65167. /**
  65168. * Gets the transform node used by this control
  65169. */
  65170. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  65171. /**
  65172. * Gets the mesh used to render this control
  65173. */
  65174. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65175. /**
  65176. * Link the control as child of the given node
  65177. * @param node defines the node to link to. Use null to unlink the control
  65178. * @returns the current control
  65179. */
  65180. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  65181. /** @hidden **/
  65182. _prepareNode(scene: BABYLON.Scene): void;
  65183. /**
  65184. * Node creation.
  65185. * Can be overriden by children
  65186. * @param scene defines the scene where the node must be attached
  65187. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  65188. */
  65189. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65190. /**
  65191. * Affect a material to the given mesh
  65192. * @param mesh defines the mesh which will represent the control
  65193. */
  65194. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65195. /** @hidden */
  65196. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  65197. /** @hidden */
  65198. _onPointerEnter(target: Control3D): boolean;
  65199. /** @hidden */
  65200. _onPointerOut(target: Control3D): void;
  65201. /** @hidden */
  65202. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65203. /** @hidden */
  65204. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65205. /** @hidden */
  65206. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65207. /** @hidden */
  65208. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65209. /** @hidden */
  65210. _disposeNode(): void;
  65211. /**
  65212. * Releases all associated resources
  65213. */
  65214. dispose(): void;
  65215. }
  65216. }
  65217. declare module BABYLON.GUI {
  65218. /**
  65219. * Class used as a root to all buttons
  65220. */
  65221. export class AbstractButton3D extends Control3D {
  65222. /**
  65223. * Creates a new button
  65224. * @param name defines the control name
  65225. */
  65226. constructor(name?: string);
  65227. protected _getTypeName(): string;
  65228. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65229. }
  65230. }
  65231. declare module BABYLON.GUI {
  65232. /**
  65233. * Class used to create a button in 3D
  65234. */
  65235. export class Button3D extends AbstractButton3D {
  65236. /** @hidden */
  65237. protected _currentMaterial: BABYLON.Material;
  65238. private _facadeTexture;
  65239. private _content;
  65240. private _contentResolution;
  65241. private _contentScaleRatio;
  65242. /**
  65243. * Gets or sets the texture resolution used to render content (512 by default)
  65244. */
  65245. contentResolution: BABYLON.int;
  65246. /**
  65247. * Gets or sets the texture scale ratio used to render content (2 by default)
  65248. */
  65249. contentScaleRatio: number;
  65250. protected _disposeFacadeTexture(): void;
  65251. protected _resetContent(): void;
  65252. /**
  65253. * Creates a new button
  65254. * @param name defines the control name
  65255. */
  65256. constructor(name?: string);
  65257. /**
  65258. * Gets or sets the GUI 2D content used to display the button's facade
  65259. */
  65260. content: Control;
  65261. /**
  65262. * Apply the facade texture (created from the content property).
  65263. * This function can be overloaded by child classes
  65264. * @param facadeTexture defines the AdvancedDynamicTexture to use
  65265. */
  65266. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65267. protected _getTypeName(): string;
  65268. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65269. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65270. /**
  65271. * Releases all associated resources
  65272. */
  65273. dispose(): void;
  65274. }
  65275. }
  65276. declare module BABYLON.GUI {
  65277. /**
  65278. * Abstract class used to create a container panel deployed on the surface of a volume
  65279. */
  65280. export abstract class VolumeBasedPanel extends Container3D {
  65281. private _columns;
  65282. private _rows;
  65283. private _rowThenColum;
  65284. private _orientation;
  65285. protected _cellWidth: number;
  65286. protected _cellHeight: number;
  65287. /**
  65288. * Gets or sets the distance between elements
  65289. */
  65290. margin: number;
  65291. /**
  65292. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  65293. * | Value | Type | Description |
  65294. * | ----- | ----------------------------------- | ----------- |
  65295. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  65296. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  65297. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  65298. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  65299. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  65300. */
  65301. orientation: number;
  65302. /**
  65303. * Gets or sets the number of columns requested (10 by default).
  65304. * The panel will automatically compute the number of rows based on number of child controls.
  65305. */
  65306. columns: BABYLON.int;
  65307. /**
  65308. * Gets or sets a the number of rows requested.
  65309. * The panel will automatically compute the number of columns based on number of child controls.
  65310. */
  65311. rows: BABYLON.int;
  65312. /**
  65313. * Creates new VolumeBasedPanel
  65314. */
  65315. constructor();
  65316. protected _arrangeChildren(): void;
  65317. /** Child classes must implement this function to provide correct control positioning */
  65318. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65319. /** Child classes can implement this function to provide additional processing */
  65320. protected _finalProcessing(): void;
  65321. }
  65322. }
  65323. declare module BABYLON.GUI {
  65324. /**
  65325. * Class used to create a container panel deployed on the surface of a cylinder
  65326. */
  65327. export class CylinderPanel extends VolumeBasedPanel {
  65328. private _radius;
  65329. /**
  65330. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  65331. */
  65332. radius: BABYLON.float;
  65333. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65334. private _cylindricalMapping;
  65335. }
  65336. }
  65337. declare module BABYLON.GUI {
  65338. /** @hidden */
  65339. export var fluentVertexShader: {
  65340. name: string;
  65341. shader: string;
  65342. };
  65343. }
  65344. declare module BABYLON.GUI {
  65345. /** @hidden */
  65346. export var fluentPixelShader: {
  65347. name: string;
  65348. shader: string;
  65349. };
  65350. }
  65351. declare module BABYLON.GUI {
  65352. /** @hidden */
  65353. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  65354. INNERGLOW: boolean;
  65355. BORDER: boolean;
  65356. HOVERLIGHT: boolean;
  65357. TEXTURE: boolean;
  65358. constructor();
  65359. }
  65360. /**
  65361. * Class used to render controls with fluent desgin
  65362. */
  65363. export class FluentMaterial extends BABYLON.PushMaterial {
  65364. /**
  65365. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  65366. */
  65367. innerGlowColorIntensity: number;
  65368. /**
  65369. * Gets or sets the inner glow color (white by default)
  65370. */
  65371. innerGlowColor: BABYLON.Color3;
  65372. /**
  65373. * Gets or sets alpha value (default is 1.0)
  65374. */
  65375. alpha: number;
  65376. /**
  65377. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  65378. */
  65379. albedoColor: BABYLON.Color3;
  65380. /**
  65381. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  65382. */
  65383. renderBorders: boolean;
  65384. /**
  65385. * Gets or sets border width (default is 0.5)
  65386. */
  65387. borderWidth: number;
  65388. /**
  65389. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  65390. */
  65391. edgeSmoothingValue: number;
  65392. /**
  65393. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  65394. */
  65395. borderMinValue: number;
  65396. /**
  65397. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  65398. */
  65399. renderHoverLight: boolean;
  65400. /**
  65401. * Gets or sets the radius used to render the hover light (default is 1.0)
  65402. */
  65403. hoverRadius: number;
  65404. /**
  65405. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  65406. */
  65407. hoverColor: BABYLON.Color4;
  65408. /**
  65409. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  65410. */
  65411. hoverPosition: BABYLON.Vector3;
  65412. private _albedoTexture;
  65413. /** Gets or sets the texture to use for albedo color */
  65414. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  65415. /**
  65416. * Creates a new Fluent material
  65417. * @param name defines the name of the material
  65418. * @param scene defines the hosting scene
  65419. */
  65420. constructor(name: string, scene: BABYLON.Scene);
  65421. needAlphaBlending(): boolean;
  65422. needAlphaTesting(): boolean;
  65423. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65424. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65425. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65426. getActiveTextures(): BABYLON.BaseTexture[];
  65427. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65428. dispose(forceDisposeEffect?: boolean): void;
  65429. clone(name: string): FluentMaterial;
  65430. serialize(): any;
  65431. getClassName(): string;
  65432. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  65433. }
  65434. }
  65435. declare module BABYLON.GUI {
  65436. /**
  65437. * Class used to create a holographic button in 3D
  65438. */
  65439. export class HolographicButton extends Button3D {
  65440. private _backPlate;
  65441. private _textPlate;
  65442. private _frontPlate;
  65443. private _text;
  65444. private _imageUrl;
  65445. private _shareMaterials;
  65446. private _frontMaterial;
  65447. private _backMaterial;
  65448. private _plateMaterial;
  65449. private _pickedPointObserver;
  65450. private _tooltipFade;
  65451. private _tooltipTextBlock;
  65452. private _tooltipTexture;
  65453. private _tooltipMesh;
  65454. private _tooltipHoverObserver;
  65455. private _tooltipOutObserver;
  65456. private _disposeTooltip;
  65457. /**
  65458. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  65459. */
  65460. tooltipText: BABYLON.Nullable<string>;
  65461. /**
  65462. * Gets or sets text for the button
  65463. */
  65464. text: string;
  65465. /**
  65466. * Gets or sets the image url for the button
  65467. */
  65468. imageUrl: string;
  65469. /**
  65470. * Gets the back material used by this button
  65471. */
  65472. readonly backMaterial: FluentMaterial;
  65473. /**
  65474. * Gets the front material used by this button
  65475. */
  65476. readonly frontMaterial: FluentMaterial;
  65477. /**
  65478. * Gets the plate material used by this button
  65479. */
  65480. readonly plateMaterial: BABYLON.StandardMaterial;
  65481. /**
  65482. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  65483. */
  65484. readonly shareMaterials: boolean;
  65485. /**
  65486. * Creates a new button
  65487. * @param name defines the control name
  65488. */
  65489. constructor(name?: string, shareMaterials?: boolean);
  65490. protected _getTypeName(): string;
  65491. private _rebuildContent;
  65492. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65493. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65494. private _createBackMaterial;
  65495. private _createFrontMaterial;
  65496. private _createPlateMaterial;
  65497. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  65498. /**
  65499. * Releases all associated resources
  65500. */
  65501. dispose(): void;
  65502. }
  65503. }
  65504. declare module BABYLON.GUI {
  65505. /**
  65506. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  65507. */
  65508. export class MeshButton3D extends Button3D {
  65509. /** @hidden */
  65510. protected _currentMesh: BABYLON.Mesh;
  65511. /**
  65512. * Creates a new 3D button based on a mesh
  65513. * @param mesh mesh to become a 3D button
  65514. * @param name defines the control name
  65515. */
  65516. constructor(mesh: BABYLON.Mesh, name?: string);
  65517. protected _getTypeName(): string;
  65518. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65519. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65520. }
  65521. }
  65522. declare module BABYLON.GUI {
  65523. /**
  65524. * Class used to create a container panel deployed on the surface of a plane
  65525. */
  65526. export class PlanePanel extends VolumeBasedPanel {
  65527. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65528. }
  65529. }
  65530. declare module BABYLON.GUI {
  65531. /**
  65532. * Class used to create a container panel where items get randomized planar mapping
  65533. */
  65534. export class ScatterPanel extends VolumeBasedPanel {
  65535. private _iteration;
  65536. /**
  65537. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  65538. */
  65539. iteration: BABYLON.float;
  65540. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65541. private _scatterMapping;
  65542. protected _finalProcessing(): void;
  65543. }
  65544. }
  65545. declare module BABYLON.GUI {
  65546. /**
  65547. * Class used to create a container panel deployed on the surface of a sphere
  65548. */
  65549. export class SpherePanel extends VolumeBasedPanel {
  65550. private _radius;
  65551. /**
  65552. * Gets or sets the radius of the sphere where to project controls (5 by default)
  65553. */
  65554. radius: BABYLON.float;
  65555. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65556. private _sphericalMapping;
  65557. }
  65558. }
  65559. declare module BABYLON.GUI {
  65560. /**
  65561. * Class used to create a stack panel in 3D on XY plane
  65562. */
  65563. export class StackPanel3D extends Container3D {
  65564. private _isVertical;
  65565. /**
  65566. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  65567. */
  65568. isVertical: boolean;
  65569. /**
  65570. * Gets or sets the distance between elements
  65571. */
  65572. margin: number;
  65573. /**
  65574. * Creates new StackPanel
  65575. * @param isVertical
  65576. */
  65577. constructor(isVertical?: boolean);
  65578. protected _arrangeChildren(): void;
  65579. }
  65580. }
  65581. declare module BABYLON {
  65582. /**
  65583. * Mode that determines the coordinate system to use.
  65584. */
  65585. export enum GLTFLoaderCoordinateSystemMode {
  65586. /**
  65587. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  65588. */
  65589. AUTO = 0,
  65590. /**
  65591. * Sets the useRightHandedSystem flag on the scene.
  65592. */
  65593. FORCE_RIGHT_HANDED = 1
  65594. }
  65595. /**
  65596. * Mode that determines what animations will start.
  65597. */
  65598. export enum GLTFLoaderAnimationStartMode {
  65599. /**
  65600. * No animation will start.
  65601. */
  65602. NONE = 0,
  65603. /**
  65604. * The first animation will start.
  65605. */
  65606. FIRST = 1,
  65607. /**
  65608. * All animations will start.
  65609. */
  65610. ALL = 2
  65611. }
  65612. /**
  65613. * Interface that contains the data for the glTF asset.
  65614. */
  65615. export interface IGLTFLoaderData {
  65616. /**
  65617. * Object that represents the glTF JSON.
  65618. */
  65619. json: Object;
  65620. /**
  65621. * The BIN chunk of a binary glTF.
  65622. */
  65623. bin: Nullable<ArrayBufferView>;
  65624. }
  65625. /**
  65626. * Interface for extending the loader.
  65627. */
  65628. export interface IGLTFLoaderExtension {
  65629. /**
  65630. * The name of this extension.
  65631. */
  65632. readonly name: string;
  65633. /**
  65634. * Defines whether this extension is enabled.
  65635. */
  65636. enabled: boolean;
  65637. }
  65638. /**
  65639. * Loader state.
  65640. */
  65641. export enum GLTFLoaderState {
  65642. /**
  65643. * The asset is loading.
  65644. */
  65645. LOADING = 0,
  65646. /**
  65647. * The asset is ready for rendering.
  65648. */
  65649. READY = 1,
  65650. /**
  65651. * The asset is completely loaded.
  65652. */
  65653. COMPLETE = 2
  65654. }
  65655. /** @hidden */
  65656. export interface IGLTFLoader extends IDisposable {
  65657. readonly state: Nullable<GLTFLoaderState>;
  65658. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  65659. meshes: AbstractMesh[];
  65660. particleSystems: IParticleSystem[];
  65661. skeletons: Skeleton[];
  65662. animationGroups: AnimationGroup[];
  65663. }>;
  65664. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  65665. }
  65666. /**
  65667. * File loader for loading glTF files into a scene.
  65668. */
  65669. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65670. /** @hidden */
  65671. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65672. /** @hidden */
  65673. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65674. /**
  65675. * Raised when the asset has been parsed
  65676. */
  65677. onParsedObservable: Observable<IGLTFLoaderData>;
  65678. private _onParsedObserver;
  65679. /**
  65680. * Raised when the asset has been parsed
  65681. */
  65682. onParsed: (loaderData: IGLTFLoaderData) => void;
  65683. /**
  65684. * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.
  65685. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  65686. * Defaults to true.
  65687. * @hidden
  65688. */
  65689. static IncrementalLoading: boolean;
  65690. /**
  65691. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  65692. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  65693. * @hidden
  65694. */
  65695. static HomogeneousCoordinates: boolean;
  65696. /**
  65697. * The coordinate system mode. Defaults to AUTO.
  65698. */
  65699. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  65700. /**
  65701. * The animation start mode. Defaults to FIRST.
  65702. */
  65703. animationStartMode: GLTFLoaderAnimationStartMode;
  65704. /**
  65705. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  65706. */
  65707. compileMaterials: boolean;
  65708. /**
  65709. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  65710. */
  65711. useClipPlane: boolean;
  65712. /**
  65713. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  65714. */
  65715. compileShadowGenerators: boolean;
  65716. /**
  65717. * Defines if the Alpha blended materials are only applied as coverage.
  65718. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  65719. * If true, no extra effects are applied to transparent pixels.
  65720. */
  65721. transparencyAsCoverage: boolean;
  65722. /**
  65723. * Function called before loading a url referenced by the asset.
  65724. */
  65725. preprocessUrlAsync: (url: string) => Promise<string>;
  65726. /**
  65727. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65728. */
  65729. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  65730. private _onMeshLoadedObserver;
  65731. /**
  65732. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65733. */
  65734. onMeshLoaded: (mesh: AbstractMesh) => void;
  65735. /**
  65736. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  65737. */
  65738. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  65739. private _onTextureLoadedObserver;
  65740. /**
  65741. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  65742. */
  65743. onTextureLoaded: (texture: BaseTexture) => void;
  65744. /**
  65745. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  65746. */
  65747. readonly onMaterialLoadedObservable: Observable<Material>;
  65748. private _onMaterialLoadedObserver;
  65749. /**
  65750. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  65751. */
  65752. onMaterialLoaded: (material: Material) => void;
  65753. /**
  65754. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  65755. */
  65756. readonly onCameraLoadedObservable: Observable<Camera>;
  65757. private _onCameraLoadedObserver;
  65758. /**
  65759. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  65760. */
  65761. onCameraLoaded: (camera: Camera) => void;
  65762. /**
  65763. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  65764. * For assets with LODs, raised when all of the LODs are complete.
  65765. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65766. */
  65767. readonly onCompleteObservable: Observable<void>;
  65768. private _onCompleteObserver;
  65769. /**
  65770. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  65771. * For assets with LODs, raised when all of the LODs are complete.
  65772. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65773. */
  65774. onComplete: () => void;
  65775. /**
  65776. * Observable raised when an error occurs.
  65777. */
  65778. readonly onErrorObservable: Observable<any>;
  65779. private _onErrorObserver;
  65780. /**
  65781. * Callback raised when an error occurs.
  65782. */
  65783. onError: (reason: any) => void;
  65784. /**
  65785. * Observable raised after the loader is disposed.
  65786. */
  65787. readonly onDisposeObservable: Observable<void>;
  65788. private _onDisposeObserver;
  65789. /**
  65790. * Callback raised after the loader is disposed.
  65791. */
  65792. onDispose: () => void;
  65793. /**
  65794. * Observable raised after a loader extension is created.
  65795. * Set additional options for a loader extension in this event.
  65796. */
  65797. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  65798. private _onExtensionLoadedObserver;
  65799. /**
  65800. * Callback raised after a loader extension is created.
  65801. */
  65802. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  65803. /**
  65804. * Defines if the loader logging is enabled.
  65805. */
  65806. loggingEnabled: boolean;
  65807. /**
  65808. * Defines if the loader should capture performance counters.
  65809. */
  65810. capturePerformanceCounters: boolean;
  65811. /**
  65812. * Defines if the loader should validate the asset.
  65813. */
  65814. validate: boolean;
  65815. /**
  65816. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  65817. */
  65818. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  65819. private _onValidatedObserver;
  65820. /**
  65821. * Callback raised after a loader extension is created.
  65822. */
  65823. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  65824. private _loader;
  65825. /**
  65826. * Name of the loader ("gltf")
  65827. */
  65828. name: string;
  65829. /**
  65830. * Supported file extensions of the loader (.gltf, .glb)
  65831. */
  65832. extensions: ISceneLoaderPluginExtensions;
  65833. /**
  65834. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  65835. */
  65836. dispose(): void;
  65837. /** @hidden */
  65838. _clear(): void;
  65839. /**
  65840. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  65841. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65842. * @param scene the scene the meshes should be added to
  65843. * @param data the glTF data to load
  65844. * @param rootUrl root url to load from
  65845. * @param onProgress event that fires when loading progress has occured
  65846. * @param fileName Defines the name of the file to load
  65847. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65848. */
  65849. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65850. meshes: AbstractMesh[];
  65851. particleSystems: IParticleSystem[];
  65852. skeletons: Skeleton[];
  65853. animationGroups: AnimationGroup[];
  65854. }>;
  65855. /**
  65856. * Imports all objects from the loaded glTF data and adds them to the scene
  65857. * @param scene the scene the objects should be added to
  65858. * @param data the glTF data to load
  65859. * @param rootUrl root url to load from
  65860. * @param onProgress event that fires when loading progress has occured
  65861. * @param fileName Defines the name of the file to load
  65862. * @returns a promise which completes when objects have been loaded to the scene
  65863. */
  65864. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65865. /**
  65866. * Load into an asset container.
  65867. * @param scene The scene to load into
  65868. * @param data The data to import
  65869. * @param rootUrl The root url for scene and resources
  65870. * @param onProgress The callback when the load progresses
  65871. * @param fileName Defines the name of the file to load
  65872. * @returns The loaded asset container
  65873. */
  65874. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65875. /**
  65876. * If the data string can be loaded directly.
  65877. * @param data string contianing the file data
  65878. * @returns if the data can be loaded directly
  65879. */
  65880. canDirectLoad(data: string): boolean;
  65881. /**
  65882. * Rewrites a url by combining a root url and response url.
  65883. */
  65884. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  65885. /**
  65886. * Instantiates a glTF file loader plugin.
  65887. * @returns the created plugin
  65888. */
  65889. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  65890. /**
  65891. * The loader state or null if the loader is not active.
  65892. */
  65893. readonly loaderState: Nullable<GLTFLoaderState>;
  65894. /**
  65895. * Returns a promise that resolves when the asset is completely loaded.
  65896. * @returns a promise that resolves when the asset is completely loaded.
  65897. */
  65898. whenCompleteAsync(): Promise<void>;
  65899. private _parseAsync;
  65900. private _validateAsync;
  65901. private _getLoader;
  65902. private _unpackBinary;
  65903. private _unpackBinaryV1;
  65904. private _unpackBinaryV2;
  65905. private static _parseVersion;
  65906. private static _compareVersion;
  65907. private static _decodeBufferToText;
  65908. private static readonly _logSpaces;
  65909. private _logIndentLevel;
  65910. private _loggingEnabled;
  65911. /** @hidden */
  65912. _log: (message: string) => void;
  65913. /** @hidden */
  65914. _logOpen(message: string): void;
  65915. /** @hidden */
  65916. _logClose(): void;
  65917. private _logEnabled;
  65918. private _logDisabled;
  65919. private _capturePerformanceCounters;
  65920. /** @hidden */
  65921. _startPerformanceCounter: (counterName: string) => void;
  65922. /** @hidden */
  65923. _endPerformanceCounter: (counterName: string) => void;
  65924. private _startPerformanceCounterEnabled;
  65925. private _startPerformanceCounterDisabled;
  65926. private _endPerformanceCounterEnabled;
  65927. private _endPerformanceCounterDisabled;
  65928. }
  65929. }
  65930. declare module BABYLON.GLTF1 {
  65931. /**
  65932. * Enums
  65933. * @hidden
  65934. */
  65935. export enum EComponentType {
  65936. BYTE = 5120,
  65937. UNSIGNED_BYTE = 5121,
  65938. SHORT = 5122,
  65939. UNSIGNED_SHORT = 5123,
  65940. FLOAT = 5126
  65941. }
  65942. /** @hidden */
  65943. export enum EShaderType {
  65944. FRAGMENT = 35632,
  65945. VERTEX = 35633
  65946. }
  65947. /** @hidden */
  65948. export enum EParameterType {
  65949. BYTE = 5120,
  65950. UNSIGNED_BYTE = 5121,
  65951. SHORT = 5122,
  65952. UNSIGNED_SHORT = 5123,
  65953. INT = 5124,
  65954. UNSIGNED_INT = 5125,
  65955. FLOAT = 5126,
  65956. FLOAT_VEC2 = 35664,
  65957. FLOAT_VEC3 = 35665,
  65958. FLOAT_VEC4 = 35666,
  65959. INT_VEC2 = 35667,
  65960. INT_VEC3 = 35668,
  65961. INT_VEC4 = 35669,
  65962. BOOL = 35670,
  65963. BOOL_VEC2 = 35671,
  65964. BOOL_VEC3 = 35672,
  65965. BOOL_VEC4 = 35673,
  65966. FLOAT_MAT2 = 35674,
  65967. FLOAT_MAT3 = 35675,
  65968. FLOAT_MAT4 = 35676,
  65969. SAMPLER_2D = 35678
  65970. }
  65971. /** @hidden */
  65972. export enum ETextureWrapMode {
  65973. CLAMP_TO_EDGE = 33071,
  65974. MIRRORED_REPEAT = 33648,
  65975. REPEAT = 10497
  65976. }
  65977. /** @hidden */
  65978. export enum ETextureFilterType {
  65979. NEAREST = 9728,
  65980. LINEAR = 9728,
  65981. NEAREST_MIPMAP_NEAREST = 9984,
  65982. LINEAR_MIPMAP_NEAREST = 9985,
  65983. NEAREST_MIPMAP_LINEAR = 9986,
  65984. LINEAR_MIPMAP_LINEAR = 9987
  65985. }
  65986. /** @hidden */
  65987. export enum ETextureFormat {
  65988. ALPHA = 6406,
  65989. RGB = 6407,
  65990. RGBA = 6408,
  65991. LUMINANCE = 6409,
  65992. LUMINANCE_ALPHA = 6410
  65993. }
  65994. /** @hidden */
  65995. export enum ECullingType {
  65996. FRONT = 1028,
  65997. BACK = 1029,
  65998. FRONT_AND_BACK = 1032
  65999. }
  66000. /** @hidden */
  66001. export enum EBlendingFunction {
  66002. ZERO = 0,
  66003. ONE = 1,
  66004. SRC_COLOR = 768,
  66005. ONE_MINUS_SRC_COLOR = 769,
  66006. DST_COLOR = 774,
  66007. ONE_MINUS_DST_COLOR = 775,
  66008. SRC_ALPHA = 770,
  66009. ONE_MINUS_SRC_ALPHA = 771,
  66010. DST_ALPHA = 772,
  66011. ONE_MINUS_DST_ALPHA = 773,
  66012. CONSTANT_COLOR = 32769,
  66013. ONE_MINUS_CONSTANT_COLOR = 32770,
  66014. CONSTANT_ALPHA = 32771,
  66015. ONE_MINUS_CONSTANT_ALPHA = 32772,
  66016. SRC_ALPHA_SATURATE = 776
  66017. }
  66018. /** @hidden */
  66019. export interface IGLTFProperty {
  66020. extensions?: {
  66021. [key: string]: any;
  66022. };
  66023. extras?: Object;
  66024. }
  66025. /** @hidden */
  66026. export interface IGLTFChildRootProperty extends IGLTFProperty {
  66027. name?: string;
  66028. }
  66029. /** @hidden */
  66030. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  66031. bufferView: string;
  66032. byteOffset: number;
  66033. byteStride: number;
  66034. count: number;
  66035. type: string;
  66036. componentType: EComponentType;
  66037. max?: number[];
  66038. min?: number[];
  66039. name?: string;
  66040. }
  66041. /** @hidden */
  66042. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  66043. buffer: string;
  66044. byteOffset: number;
  66045. byteLength: number;
  66046. byteStride: number;
  66047. target?: number;
  66048. }
  66049. /** @hidden */
  66050. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  66051. uri: string;
  66052. byteLength?: number;
  66053. type?: string;
  66054. }
  66055. /** @hidden */
  66056. export interface IGLTFShader extends IGLTFChildRootProperty {
  66057. uri: string;
  66058. type: EShaderType;
  66059. }
  66060. /** @hidden */
  66061. export interface IGLTFProgram extends IGLTFChildRootProperty {
  66062. attributes: string[];
  66063. fragmentShader: string;
  66064. vertexShader: string;
  66065. }
  66066. /** @hidden */
  66067. export interface IGLTFTechniqueParameter {
  66068. type: number;
  66069. count?: number;
  66070. semantic?: string;
  66071. node?: string;
  66072. value?: number | boolean | string | Array<any>;
  66073. source?: string;
  66074. babylonValue?: any;
  66075. }
  66076. /** @hidden */
  66077. export interface IGLTFTechniqueCommonProfile {
  66078. lightingModel: string;
  66079. texcoordBindings: Object;
  66080. parameters?: Array<any>;
  66081. }
  66082. /** @hidden */
  66083. export interface IGLTFTechniqueStatesFunctions {
  66084. blendColor?: number[];
  66085. blendEquationSeparate?: number[];
  66086. blendFuncSeparate?: number[];
  66087. colorMask: boolean[];
  66088. cullFace: number[];
  66089. }
  66090. /** @hidden */
  66091. export interface IGLTFTechniqueStates {
  66092. enable: number[];
  66093. functions: IGLTFTechniqueStatesFunctions;
  66094. }
  66095. /** @hidden */
  66096. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  66097. parameters: {
  66098. [key: string]: IGLTFTechniqueParameter;
  66099. };
  66100. program: string;
  66101. attributes: {
  66102. [key: string]: string;
  66103. };
  66104. uniforms: {
  66105. [key: string]: string;
  66106. };
  66107. states: IGLTFTechniqueStates;
  66108. }
  66109. /** @hidden */
  66110. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  66111. technique?: string;
  66112. values: string[];
  66113. }
  66114. /** @hidden */
  66115. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  66116. attributes: {
  66117. [key: string]: string;
  66118. };
  66119. indices: string;
  66120. material: string;
  66121. mode?: number;
  66122. }
  66123. /** @hidden */
  66124. export interface IGLTFMesh extends IGLTFChildRootProperty {
  66125. primitives: IGLTFMeshPrimitive[];
  66126. }
  66127. /** @hidden */
  66128. export interface IGLTFImage extends IGLTFChildRootProperty {
  66129. uri: string;
  66130. }
  66131. /** @hidden */
  66132. export interface IGLTFSampler extends IGLTFChildRootProperty {
  66133. magFilter?: number;
  66134. minFilter?: number;
  66135. wrapS?: number;
  66136. wrapT?: number;
  66137. }
  66138. /** @hidden */
  66139. export interface IGLTFTexture extends IGLTFChildRootProperty {
  66140. sampler: string;
  66141. source: string;
  66142. format?: ETextureFormat;
  66143. internalFormat?: ETextureFormat;
  66144. target?: number;
  66145. type?: number;
  66146. babylonTexture?: Texture;
  66147. }
  66148. /** @hidden */
  66149. export interface IGLTFAmbienLight {
  66150. color?: number[];
  66151. }
  66152. /** @hidden */
  66153. export interface IGLTFDirectionalLight {
  66154. color?: number[];
  66155. }
  66156. /** @hidden */
  66157. export interface IGLTFPointLight {
  66158. color?: number[];
  66159. constantAttenuation?: number;
  66160. linearAttenuation?: number;
  66161. quadraticAttenuation?: number;
  66162. }
  66163. /** @hidden */
  66164. export interface IGLTFSpotLight {
  66165. color?: number[];
  66166. constantAttenuation?: number;
  66167. fallOfAngle?: number;
  66168. fallOffExponent?: number;
  66169. linearAttenuation?: number;
  66170. quadraticAttenuation?: number;
  66171. }
  66172. /** @hidden */
  66173. export interface IGLTFLight extends IGLTFChildRootProperty {
  66174. type: string;
  66175. }
  66176. /** @hidden */
  66177. export interface IGLTFCameraOrthographic {
  66178. xmag: number;
  66179. ymag: number;
  66180. zfar: number;
  66181. znear: number;
  66182. }
  66183. /** @hidden */
  66184. export interface IGLTFCameraPerspective {
  66185. aspectRatio: number;
  66186. yfov: number;
  66187. zfar: number;
  66188. znear: number;
  66189. }
  66190. /** @hidden */
  66191. export interface IGLTFCamera extends IGLTFChildRootProperty {
  66192. type: string;
  66193. }
  66194. /** @hidden */
  66195. export interface IGLTFAnimationChannelTarget {
  66196. id: string;
  66197. path: string;
  66198. }
  66199. /** @hidden */
  66200. export interface IGLTFAnimationChannel {
  66201. sampler: string;
  66202. target: IGLTFAnimationChannelTarget;
  66203. }
  66204. /** @hidden */
  66205. export interface IGLTFAnimationSampler {
  66206. input: string;
  66207. output: string;
  66208. interpolation?: string;
  66209. }
  66210. /** @hidden */
  66211. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  66212. channels?: IGLTFAnimationChannel[];
  66213. parameters?: {
  66214. [key: string]: string;
  66215. };
  66216. samplers?: {
  66217. [key: string]: IGLTFAnimationSampler;
  66218. };
  66219. }
  66220. /** @hidden */
  66221. export interface IGLTFNodeInstanceSkin {
  66222. skeletons: string[];
  66223. skin: string;
  66224. meshes: string[];
  66225. }
  66226. /** @hidden */
  66227. export interface IGLTFSkins extends IGLTFChildRootProperty {
  66228. bindShapeMatrix: number[];
  66229. inverseBindMatrices: string;
  66230. jointNames: string[];
  66231. babylonSkeleton?: Skeleton;
  66232. }
  66233. /** @hidden */
  66234. export interface IGLTFNode extends IGLTFChildRootProperty {
  66235. camera?: string;
  66236. children: string[];
  66237. skin?: string;
  66238. jointName?: string;
  66239. light?: string;
  66240. matrix: number[];
  66241. mesh?: string;
  66242. meshes?: string[];
  66243. rotation?: number[];
  66244. scale?: number[];
  66245. translation?: number[];
  66246. babylonNode?: Node;
  66247. }
  66248. /** @hidden */
  66249. export interface IGLTFScene extends IGLTFChildRootProperty {
  66250. nodes: string[];
  66251. }
  66252. /** @hidden */
  66253. export interface IGLTFRuntime {
  66254. extensions: {
  66255. [key: string]: any;
  66256. };
  66257. accessors: {
  66258. [key: string]: IGLTFAccessor;
  66259. };
  66260. buffers: {
  66261. [key: string]: IGLTFBuffer;
  66262. };
  66263. bufferViews: {
  66264. [key: string]: IGLTFBufferView;
  66265. };
  66266. meshes: {
  66267. [key: string]: IGLTFMesh;
  66268. };
  66269. lights: {
  66270. [key: string]: IGLTFLight;
  66271. };
  66272. cameras: {
  66273. [key: string]: IGLTFCamera;
  66274. };
  66275. nodes: {
  66276. [key: string]: IGLTFNode;
  66277. };
  66278. images: {
  66279. [key: string]: IGLTFImage;
  66280. };
  66281. textures: {
  66282. [key: string]: IGLTFTexture;
  66283. };
  66284. shaders: {
  66285. [key: string]: IGLTFShader;
  66286. };
  66287. programs: {
  66288. [key: string]: IGLTFProgram;
  66289. };
  66290. samplers: {
  66291. [key: string]: IGLTFSampler;
  66292. };
  66293. techniques: {
  66294. [key: string]: IGLTFTechnique;
  66295. };
  66296. materials: {
  66297. [key: string]: IGLTFMaterial;
  66298. };
  66299. animations: {
  66300. [key: string]: IGLTFAnimation;
  66301. };
  66302. skins: {
  66303. [key: string]: IGLTFSkins;
  66304. };
  66305. currentScene?: Object;
  66306. scenes: {
  66307. [key: string]: IGLTFScene;
  66308. };
  66309. extensionsUsed: string[];
  66310. extensionsRequired?: string[];
  66311. buffersCount: number;
  66312. shaderscount: number;
  66313. scene: Scene;
  66314. rootUrl: string;
  66315. loadedBufferCount: number;
  66316. loadedBufferViews: {
  66317. [name: string]: ArrayBufferView;
  66318. };
  66319. loadedShaderCount: number;
  66320. importOnlyMeshes: boolean;
  66321. importMeshesNames?: string[];
  66322. dummyNodes: Node[];
  66323. }
  66324. /** @hidden */
  66325. export interface INodeToRoot {
  66326. bone: Bone;
  66327. node: IGLTFNode;
  66328. id: string;
  66329. }
  66330. /** @hidden */
  66331. export interface IJointNode {
  66332. node: IGLTFNode;
  66333. id: string;
  66334. }
  66335. }
  66336. declare module BABYLON.GLTF1 {
  66337. /**
  66338. * Utils functions for GLTF
  66339. * @hidden
  66340. */
  66341. export class GLTFUtils {
  66342. /**
  66343. * Sets the given "parameter" matrix
  66344. * @param scene: the Scene object
  66345. * @param source: the source node where to pick the matrix
  66346. * @param parameter: the GLTF technique parameter
  66347. * @param uniformName: the name of the shader's uniform
  66348. * @param shaderMaterial: the shader material
  66349. */
  66350. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  66351. /**
  66352. * Sets the given "parameter" matrix
  66353. * @param shaderMaterial: the shader material
  66354. * @param uniform: the name of the shader's uniform
  66355. * @param value: the value of the uniform
  66356. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  66357. */
  66358. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  66359. /**
  66360. * Returns the wrap mode of the texture
  66361. * @param mode: the mode value
  66362. */
  66363. static GetWrapMode(mode: number): number;
  66364. /**
  66365. * Returns the byte stride giving an accessor
  66366. * @param accessor: the GLTF accessor objet
  66367. */
  66368. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  66369. /**
  66370. * Returns the texture filter mode giving a mode value
  66371. * @param mode: the filter mode value
  66372. */
  66373. static GetTextureFilterMode(mode: number): ETextureFilterType;
  66374. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  66375. /**
  66376. * Returns a buffer from its accessor
  66377. * @param gltfRuntime: the GLTF runtime
  66378. * @param accessor: the GLTF accessor
  66379. */
  66380. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  66381. /**
  66382. * Decodes a buffer view into a string
  66383. * @param view: the buffer view
  66384. */
  66385. static DecodeBufferToText(view: ArrayBufferView): string;
  66386. /**
  66387. * Returns the default material of gltf. Related to
  66388. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  66389. * @param scene: the Babylon.js scene
  66390. */
  66391. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  66392. private static _DefaultMaterial;
  66393. }
  66394. }
  66395. declare module BABYLON.GLTF1 {
  66396. /**
  66397. * Implementation of the base glTF spec
  66398. * @hidden
  66399. */
  66400. export class GLTFLoaderBase {
  66401. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  66402. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66403. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  66404. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66405. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  66406. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66407. }
  66408. /**
  66409. * glTF V1 Loader
  66410. * @hidden
  66411. */
  66412. export class GLTFLoader implements IGLTFLoader {
  66413. static Extensions: {
  66414. [name: string]: GLTFLoaderExtension;
  66415. };
  66416. static RegisterExtension(extension: GLTFLoaderExtension): void;
  66417. state: Nullable<GLTFLoaderState>;
  66418. dispose(): void;
  66419. private _importMeshAsync;
  66420. /**
  66421. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  66422. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66423. * @param scene the scene the meshes should be added to
  66424. * @param data gltf data containing information of the meshes in a loaded file
  66425. * @param rootUrl root url to load from
  66426. * @param onProgress event that fires when loading progress has occured
  66427. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66428. */
  66429. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  66430. meshes: AbstractMesh[];
  66431. particleSystems: IParticleSystem[];
  66432. skeletons: Skeleton[];
  66433. animationGroups: AnimationGroup[];
  66434. }>;
  66435. private _loadAsync;
  66436. /**
  66437. * Imports all objects from a loaded gltf file and adds them to the scene
  66438. * @param scene the scene the objects should be added to
  66439. * @param data gltf data containing information of the meshes in a loaded file
  66440. * @param rootUrl root url to load from
  66441. * @param onProgress event that fires when loading progress has occured
  66442. * @returns a promise which completes when objects have been loaded to the scene
  66443. */
  66444. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  66445. private _loadShadersAsync;
  66446. private _loadBuffersAsync;
  66447. private _createNodes;
  66448. }
  66449. /** @hidden */
  66450. export abstract class GLTFLoaderExtension {
  66451. private _name;
  66452. constructor(name: string);
  66453. readonly name: string;
  66454. /**
  66455. * Defines an override for loading the runtime
  66456. * Return true to stop further extensions from loading the runtime
  66457. */
  66458. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  66459. /**
  66460. * Defines an onverride for creating gltf runtime
  66461. * Return true to stop further extensions from creating the runtime
  66462. */
  66463. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  66464. /**
  66465. * Defines an override for loading buffers
  66466. * Return true to stop further extensions from loading this buffer
  66467. */
  66468. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  66469. /**
  66470. * Defines an override for loading texture buffers
  66471. * Return true to stop further extensions from loading this texture data
  66472. */
  66473. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66474. /**
  66475. * Defines an override for creating textures
  66476. * Return true to stop further extensions from loading this texture
  66477. */
  66478. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  66479. /**
  66480. * Defines an override for loading shader strings
  66481. * Return true to stop further extensions from loading this shader data
  66482. */
  66483. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66484. /**
  66485. * Defines an override for loading materials
  66486. * Return true to stop further extensions from loading this material
  66487. */
  66488. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66489. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  66490. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  66491. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66492. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66493. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  66494. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66495. private static LoadTextureBufferAsync;
  66496. private static CreateTextureAsync;
  66497. private static ApplyExtensions;
  66498. }
  66499. }
  66500. declare module BABYLON.GLTF1 {
  66501. /** @hidden */
  66502. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  66503. private _bin;
  66504. constructor();
  66505. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  66506. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66507. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66508. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66509. }
  66510. }
  66511. declare module BABYLON.GLTF1 {
  66512. /** @hidden */
  66513. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  66514. constructor();
  66515. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  66516. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66517. private _loadTexture;
  66518. }
  66519. }
  66520. declare module BABYLON.GLTF2.Loader {
  66521. /**
  66522. * Loader interface with an index field.
  66523. */
  66524. export interface IArrayItem {
  66525. /**
  66526. * The index of this item in the array.
  66527. */
  66528. index: number;
  66529. }
  66530. /**
  66531. * Loader interface with additional members.
  66532. */
  66533. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  66534. /** @hidden */
  66535. _data?: Promise<ArrayBufferView>;
  66536. /** @hidden */
  66537. _babylonVertexBuffer?: Promise<VertexBuffer>;
  66538. }
  66539. /**
  66540. * Loader interface with additional members.
  66541. */
  66542. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  66543. }
  66544. /** @hidden */
  66545. export interface _IAnimationSamplerData {
  66546. input: Float32Array;
  66547. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  66548. output: Float32Array;
  66549. }
  66550. /**
  66551. * Loader interface with additional members.
  66552. */
  66553. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  66554. /** @hidden */
  66555. _data?: Promise<_IAnimationSamplerData>;
  66556. }
  66557. /**
  66558. * Loader interface with additional members.
  66559. */
  66560. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  66561. channels: IAnimationChannel[];
  66562. samplers: IAnimationSampler[];
  66563. /** @hidden */
  66564. _babylonAnimationGroup?: AnimationGroup;
  66565. }
  66566. /**
  66567. * Loader interface with additional members.
  66568. */
  66569. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  66570. /** @hidden */
  66571. _data?: Promise<ArrayBufferView>;
  66572. }
  66573. /**
  66574. * Loader interface with additional members.
  66575. */
  66576. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  66577. /** @hidden */
  66578. _data?: Promise<ArrayBufferView>;
  66579. /** @hidden */
  66580. _babylonBuffer?: Promise<Buffer>;
  66581. }
  66582. /**
  66583. * Loader interface with additional members.
  66584. */
  66585. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  66586. }
  66587. /**
  66588. * Loader interface with additional members.
  66589. */
  66590. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  66591. /** @hidden */
  66592. _data?: Promise<ArrayBufferView>;
  66593. }
  66594. /**
  66595. * Loader interface with additional members.
  66596. */
  66597. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  66598. }
  66599. /**
  66600. * Loader interface with additional members.
  66601. */
  66602. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  66603. }
  66604. /**
  66605. * Loader interface with additional members.
  66606. */
  66607. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  66608. baseColorTexture?: ITextureInfo;
  66609. metallicRoughnessTexture?: ITextureInfo;
  66610. }
  66611. /**
  66612. * Loader interface with additional members.
  66613. */
  66614. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  66615. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66616. normalTexture?: IMaterialNormalTextureInfo;
  66617. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66618. emissiveTexture?: ITextureInfo;
  66619. /** @hidden */
  66620. _data?: {
  66621. [babylonDrawMode: number]: {
  66622. babylonMaterial: Material;
  66623. babylonMeshes: AbstractMesh[];
  66624. promise: Promise<void>;
  66625. };
  66626. };
  66627. }
  66628. /**
  66629. * Loader interface with additional members.
  66630. */
  66631. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  66632. primitives: IMeshPrimitive[];
  66633. }
  66634. /**
  66635. * Loader interface with additional members.
  66636. */
  66637. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  66638. /** @hidden */
  66639. _instanceData?: {
  66640. babylonSourceMesh: Mesh;
  66641. promise: Promise<any>;
  66642. };
  66643. }
  66644. /**
  66645. * Loader interface with additional members.
  66646. */
  66647. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  66648. /**
  66649. * The parent glTF node.
  66650. */
  66651. parent?: INode;
  66652. /** @hidden */
  66653. _babylonTransformNode?: TransformNode;
  66654. /** @hidden */
  66655. _primitiveBabylonMeshes?: AbstractMesh[];
  66656. /** @hidden */
  66657. _babylonBones?: Bone[];
  66658. /** @hidden */
  66659. _numMorphTargets?: number;
  66660. }
  66661. /** @hidden */
  66662. export interface _ISamplerData {
  66663. noMipMaps: boolean;
  66664. samplingMode: number;
  66665. wrapU: number;
  66666. wrapV: number;
  66667. }
  66668. /**
  66669. * Loader interface with additional members.
  66670. */
  66671. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  66672. /** @hidden */
  66673. _data?: _ISamplerData;
  66674. }
  66675. /**
  66676. * Loader interface with additional members.
  66677. */
  66678. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  66679. }
  66680. /**
  66681. * Loader interface with additional members.
  66682. */
  66683. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  66684. /** @hidden */
  66685. _data?: {
  66686. babylonSkeleton: Skeleton;
  66687. promise: Promise<void>;
  66688. };
  66689. }
  66690. /**
  66691. * Loader interface with additional members.
  66692. */
  66693. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  66694. }
  66695. /**
  66696. * Loader interface with additional members.
  66697. */
  66698. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  66699. }
  66700. /**
  66701. * Loader interface with additional members.
  66702. */
  66703. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  66704. accessors?: IAccessor[];
  66705. animations?: IAnimation[];
  66706. buffers?: IBuffer[];
  66707. bufferViews?: IBufferView[];
  66708. cameras?: ICamera[];
  66709. images?: IImage[];
  66710. materials?: IMaterial[];
  66711. meshes?: IMesh[];
  66712. nodes?: INode[];
  66713. samplers?: ISampler[];
  66714. scenes?: IScene[];
  66715. skins?: ISkin[];
  66716. textures?: ITexture[];
  66717. }
  66718. }
  66719. declare module BABYLON.GLTF2 {
  66720. /**
  66721. * Interface for a glTF loader extension.
  66722. */
  66723. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  66724. /**
  66725. * Called after the loader state changes to LOADING.
  66726. */
  66727. onLoading?(): void;
  66728. /**
  66729. * Called after the loader state changes to READY.
  66730. */
  66731. onReady?(): void;
  66732. /**
  66733. * Define this method to modify the default behavior when loading scenes.
  66734. * @param context The context when loading the asset
  66735. * @param scene The glTF scene property
  66736. * @returns A promise that resolves when the load is complete or null if not handled
  66737. */
  66738. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  66739. /**
  66740. * Define this method to modify the default behavior when loading nodes.
  66741. * @param context The context when loading the asset
  66742. * @param node The glTF node property
  66743. * @param assign A function called synchronously after parsing the glTF properties
  66744. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  66745. */
  66746. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66747. /**
  66748. * Define this method to modify the default behavior when loading cameras.
  66749. * @param context The context when loading the asset
  66750. * @param camera The glTF camera property
  66751. * @param assign A function called synchronously after parsing the glTF properties
  66752. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  66753. */
  66754. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66755. /**
  66756. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  66757. * @param context The context when loading the asset
  66758. * @param primitive The glTF mesh primitive property
  66759. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  66760. */
  66761. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66762. /**
  66763. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66764. * @param context The context when loading the asset
  66765. * @param name The mesh name when loading the asset
  66766. * @param node The glTF node when loading the asset
  66767. * @param mesh The glTF mesh when loading the asset
  66768. * @param primitive The glTF mesh primitive property
  66769. * @param assign A function called synchronously after parsing the glTF properties
  66770. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66771. */
  66772. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66773. /**
  66774. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  66775. * @param context The context when loading the asset
  66776. * @param material The glTF material property
  66777. * @param assign A function called synchronously after parsing the glTF properties
  66778. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  66779. */
  66780. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66781. /**
  66782. * Define this method to modify the default behavior when creating materials.
  66783. * @param context The context when loading the asset
  66784. * @param material The glTF material property
  66785. * @param babylonDrawMode The draw mode for the Babylon material
  66786. * @returns The Babylon material or null if not handled
  66787. */
  66788. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66789. /**
  66790. * Define this method to modify the default behavior when loading material properties.
  66791. * @param context The context when loading the asset
  66792. * @param material The glTF material property
  66793. * @param babylonMaterial The Babylon material
  66794. * @returns A promise that resolves when the load is complete or null if not handled
  66795. */
  66796. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66797. /**
  66798. * Define this method to modify the default behavior when loading texture infos.
  66799. * @param context The context when loading the asset
  66800. * @param textureInfo The glTF texture info property
  66801. * @param assign A function called synchronously after parsing the glTF properties
  66802. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  66803. */
  66804. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  66805. /**
  66806. * Define this method to modify the default behavior when loading animations.
  66807. * @param context The context when loading the asset
  66808. * @param animation The glTF animation property
  66809. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  66810. */
  66811. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  66812. /**
  66813. * @hidden Define this method to modify the default behavior when loading skins.
  66814. * @param context The context when loading the asset
  66815. * @param node The glTF node property
  66816. * @param skin The glTF skin property
  66817. * @returns A promise that resolves when the load is complete or null if not handled
  66818. */
  66819. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  66820. /**
  66821. * @hidden Define this method to modify the default behavior when loading uris.
  66822. * @param context The context when loading the asset
  66823. * @param property The glTF property associated with the uri
  66824. * @param uri The uri to load
  66825. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  66826. */
  66827. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  66828. }
  66829. }
  66830. declare module BABYLON.GLTF2 {
  66831. /**
  66832. * Helper class for working with arrays when loading the glTF asset
  66833. */
  66834. export class ArrayItem {
  66835. /**
  66836. * Gets an item from the given array.
  66837. * @param context The context when loading the asset
  66838. * @param array The array to get the item from
  66839. * @param index The index to the array
  66840. * @returns The array item
  66841. */
  66842. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  66843. /**
  66844. * Assign an `index` field to each item of the given array.
  66845. * @param array The array of items
  66846. */
  66847. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  66848. }
  66849. /**
  66850. * The glTF 2.0 loader
  66851. */
  66852. export class GLTFLoader implements IGLTFLoader {
  66853. /** @hidden */
  66854. _completePromises: Promise<any>[];
  66855. private _disposed;
  66856. private _parent;
  66857. private _state;
  66858. private _extensions;
  66859. private _rootUrl;
  66860. private _fileName;
  66861. private _uniqueRootUrl;
  66862. private _gltf;
  66863. private _babylonScene;
  66864. private _rootBabylonMesh;
  66865. private _defaultBabylonMaterialData;
  66866. private _progressCallback?;
  66867. private _requests;
  66868. private static readonly _DefaultSampler;
  66869. private static _ExtensionNames;
  66870. private static _ExtensionFactories;
  66871. /**
  66872. * Registers a loader extension.
  66873. * @param name The name of the loader extension.
  66874. * @param factory The factory function that creates the loader extension.
  66875. */
  66876. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  66877. /**
  66878. * Unregisters a loader extension.
  66879. * @param name The name of the loader extenion.
  66880. * @returns A boolean indicating whether the extension has been unregistered
  66881. */
  66882. static UnregisterExtension(name: string): boolean;
  66883. /**
  66884. * Gets the loader state.
  66885. */
  66886. readonly state: Nullable<GLTFLoaderState>;
  66887. /**
  66888. * The glTF object parsed from the JSON.
  66889. */
  66890. readonly gltf: IGLTF;
  66891. /**
  66892. * The Babylon scene when loading the asset.
  66893. */
  66894. readonly babylonScene: Scene;
  66895. /**
  66896. * The root Babylon mesh when loading the asset.
  66897. */
  66898. readonly rootBabylonMesh: Mesh;
  66899. /** @hidden */
  66900. constructor(parent: GLTFFileLoader);
  66901. /** @hidden */
  66902. dispose(): void;
  66903. /** @hidden */
  66904. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66905. meshes: AbstractMesh[];
  66906. particleSystems: IParticleSystem[];
  66907. skeletons: Skeleton[];
  66908. animationGroups: AnimationGroup[];
  66909. }>;
  66910. /** @hidden */
  66911. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66912. private _loadAsync;
  66913. private _loadData;
  66914. private _setupData;
  66915. private _loadExtensions;
  66916. private _checkExtensions;
  66917. private _setState;
  66918. private _createRootNode;
  66919. /**
  66920. * Loads a glTF scene.
  66921. * @param context The context when loading the asset
  66922. * @param scene The glTF scene property
  66923. * @returns A promise that resolves when the load is complete
  66924. */
  66925. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  66926. private _forEachPrimitive;
  66927. private _getMeshes;
  66928. private _getSkeletons;
  66929. private _getAnimationGroups;
  66930. private _startAnimations;
  66931. /**
  66932. * Loads a glTF node.
  66933. * @param context The context when loading the asset
  66934. * @param node The glTF node property
  66935. * @param assign A function called synchronously after parsing the glTF properties
  66936. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  66937. */
  66938. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  66939. private _loadMeshAsync;
  66940. /**
  66941. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66942. * @param context The context when loading the asset
  66943. * @param name The mesh name when loading the asset
  66944. * @param node The glTF node when loading the asset
  66945. * @param mesh The glTF mesh when loading the asset
  66946. * @param primitive The glTF mesh primitive property
  66947. * @param assign A function called synchronously after parsing the glTF properties
  66948. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66949. */
  66950. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66951. private _loadVertexDataAsync;
  66952. private _createMorphTargets;
  66953. private _loadMorphTargetsAsync;
  66954. private _loadMorphTargetVertexDataAsync;
  66955. private static _LoadTransform;
  66956. private _loadSkinAsync;
  66957. private _loadBones;
  66958. private _loadBone;
  66959. private _loadSkinInverseBindMatricesDataAsync;
  66960. private _updateBoneMatrices;
  66961. private _getNodeMatrix;
  66962. /**
  66963. * Loads a glTF camera.
  66964. * @param context The context when loading the asset
  66965. * @param camera The glTF camera property
  66966. * @param assign A function called synchronously after parsing the glTF properties
  66967. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  66968. */
  66969. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  66970. private _loadAnimationsAsync;
  66971. /**
  66972. * Loads a glTF animation.
  66973. * @param context The context when loading the asset
  66974. * @param animation The glTF animation property
  66975. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  66976. */
  66977. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  66978. /**
  66979. * @hidden Loads a glTF animation channel.
  66980. * @param context The context when loading the asset
  66981. * @param animationContext The context of the animation when loading the asset
  66982. * @param animation The glTF animation property
  66983. * @param channel The glTF animation channel property
  66984. * @param babylonAnimationGroup The babylon animation group property
  66985. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  66986. * @returns A void promise when the channel load is complete
  66987. */
  66988. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  66989. private _loadAnimationSamplerAsync;
  66990. private _loadBufferAsync;
  66991. /**
  66992. * Loads a glTF buffer view.
  66993. * @param context The context when loading the asset
  66994. * @param bufferView The glTF buffer view property
  66995. * @returns A promise that resolves with the loaded data when the load is complete
  66996. */
  66997. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  66998. private _loadAccessorAsync;
  66999. private _loadFloatAccessorAsync;
  67000. private _loadIndicesAccessorAsync;
  67001. private _loadVertexBufferViewAsync;
  67002. private _loadVertexAccessorAsync;
  67003. private _loadMaterialMetallicRoughnessPropertiesAsync;
  67004. /** @hidden */
  67005. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  67006. private _createDefaultMaterial;
  67007. /**
  67008. * Creates a Babylon material from a glTF material.
  67009. * @param context The context when loading the asset
  67010. * @param material The glTF material property
  67011. * @param babylonDrawMode The draw mode for the Babylon material
  67012. * @returns The Babylon material
  67013. */
  67014. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  67015. /**
  67016. * Loads properties from a glTF material into a Babylon material.
  67017. * @param context The context when loading the asset
  67018. * @param material The glTF material property
  67019. * @param babylonMaterial The Babylon material
  67020. * @returns A promise that resolves when the load is complete
  67021. */
  67022. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67023. /**
  67024. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  67025. * @param context The context when loading the asset
  67026. * @param material The glTF material property
  67027. * @param babylonMaterial The Babylon material
  67028. * @returns A promise that resolves when the load is complete
  67029. */
  67030. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67031. /**
  67032. * Loads the alpha properties from a glTF material into a Babylon material.
  67033. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  67034. * @param context The context when loading the asset
  67035. * @param material The glTF material property
  67036. * @param babylonMaterial The Babylon material
  67037. */
  67038. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  67039. /**
  67040. * Loads a glTF texture info.
  67041. * @param context The context when loading the asset
  67042. * @param textureInfo The glTF texture info property
  67043. * @param assign A function called synchronously after parsing the glTF properties
  67044. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  67045. */
  67046. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  67047. private _loadTextureAsync;
  67048. private _loadSampler;
  67049. /**
  67050. * Loads a glTF image.
  67051. * @param context The context when loading the asset
  67052. * @param image The glTF image property
  67053. * @returns A promise that resolves with the loaded data when the load is complete
  67054. */
  67055. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  67056. /**
  67057. * Loads a glTF uri.
  67058. * @param context The context when loading the asset
  67059. * @param property The glTF property associated with the uri
  67060. * @param uri The base64 or relative uri
  67061. * @returns A promise that resolves with the loaded data when the load is complete
  67062. */
  67063. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  67064. private _onProgress;
  67065. /**
  67066. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  67067. * @param babylonObject the Babylon object with metadata
  67068. * @param pointer the JSON pointer
  67069. */
  67070. static AddPointerMetadata(babylonObject: {
  67071. metadata: any;
  67072. }, pointer: string): void;
  67073. private static _GetTextureWrapMode;
  67074. private static _GetTextureSamplingMode;
  67075. private static _GetTypedArrayConstructor;
  67076. private static _GetTypedArray;
  67077. private static _GetNumComponents;
  67078. private static _ValidateUri;
  67079. private static _GetDrawMode;
  67080. private _compileMaterialsAsync;
  67081. private _compileShadowGeneratorsAsync;
  67082. private _forEachExtensions;
  67083. private _applyExtensions;
  67084. private _extensionsOnLoading;
  67085. private _extensionsOnReady;
  67086. private _extensionsLoadSceneAsync;
  67087. private _extensionsLoadNodeAsync;
  67088. private _extensionsLoadCameraAsync;
  67089. private _extensionsLoadVertexDataAsync;
  67090. private _extensionsLoadMeshPrimitiveAsync;
  67091. private _extensionsLoadMaterialAsync;
  67092. private _extensionsCreateMaterial;
  67093. private _extensionsLoadMaterialPropertiesAsync;
  67094. private _extensionsLoadTextureInfoAsync;
  67095. private _extensionsLoadAnimationAsync;
  67096. private _extensionsLoadSkinAsync;
  67097. private _extensionsLoadUriAsync;
  67098. /**
  67099. * Helper method called by a loader extension to load an glTF extension.
  67100. * @param context The context when loading the asset
  67101. * @param property The glTF property to load the extension from
  67102. * @param extensionName The name of the extension to load
  67103. * @param actionAsync The action to run
  67104. * @returns The promise returned by actionAsync or null if the extension does not exist
  67105. */
  67106. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67107. /**
  67108. * Helper method called by a loader extension to load a glTF extra.
  67109. * @param context The context when loading the asset
  67110. * @param property The glTF property to load the extra from
  67111. * @param extensionName The name of the extension to load
  67112. * @param actionAsync The action to run
  67113. * @returns The promise returned by actionAsync or null if the extra does not exist
  67114. */
  67115. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67116. /**
  67117. * Increments the indentation level and logs a message.
  67118. * @param message The message to log
  67119. */
  67120. logOpen(message: string): void;
  67121. /**
  67122. * Decrements the indentation level.
  67123. */
  67124. logClose(): void;
  67125. /**
  67126. * Logs a message
  67127. * @param message The message to log
  67128. */
  67129. log(message: string): void;
  67130. /**
  67131. * Starts a performance counter.
  67132. * @param counterName The name of the performance counter
  67133. */
  67134. startPerformanceCounter(counterName: string): void;
  67135. /**
  67136. * Ends a performance counter.
  67137. * @param counterName The name of the performance counter
  67138. */
  67139. endPerformanceCounter(counterName: string): void;
  67140. }
  67141. }
  67142. declare module BABYLON.GLTF2.Loader.Extensions {
  67143. /**
  67144. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  67145. */
  67146. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  67147. /** The name of this extension. */
  67148. readonly name: string;
  67149. /** Defines whether this extension is enabled. */
  67150. enabled: boolean;
  67151. private _loader;
  67152. private _lights?;
  67153. /** @hidden */
  67154. constructor(loader: GLTFLoader);
  67155. /** @hidden */
  67156. dispose(): void;
  67157. /** @hidden */
  67158. onLoading(): void;
  67159. /** @hidden */
  67160. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67161. private _loadLightAsync;
  67162. }
  67163. }
  67164. declare module BABYLON.GLTF2.Loader.Extensions {
  67165. /**
  67166. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  67167. */
  67168. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  67169. /** The name of this extension. */
  67170. readonly name: string;
  67171. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  67172. dracoCompression?: DracoCompression;
  67173. /** Defines whether this extension is enabled. */
  67174. enabled: boolean;
  67175. private _loader;
  67176. /** @hidden */
  67177. constructor(loader: GLTFLoader);
  67178. /** @hidden */
  67179. dispose(): void;
  67180. /** @hidden */
  67181. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67182. }
  67183. }
  67184. declare module BABYLON.GLTF2.Loader.Extensions {
  67185. /**
  67186. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  67187. */
  67188. export class KHR_lights implements IGLTFLoaderExtension {
  67189. /** The name of this extension. */
  67190. readonly name: string;
  67191. /** Defines whether this extension is enabled. */
  67192. enabled: boolean;
  67193. private _loader;
  67194. private _lights?;
  67195. /** @hidden */
  67196. constructor(loader: GLTFLoader);
  67197. /** @hidden */
  67198. dispose(): void;
  67199. /** @hidden */
  67200. onLoading(): void;
  67201. /** @hidden */
  67202. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67203. }
  67204. }
  67205. declare module BABYLON.GLTF2.Loader.Extensions {
  67206. /**
  67207. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  67208. */
  67209. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  67210. /** The name of this extension. */
  67211. readonly name: string;
  67212. /** Defines whether this extension is enabled. */
  67213. enabled: boolean;
  67214. private _loader;
  67215. /** @hidden */
  67216. constructor(loader: GLTFLoader);
  67217. /** @hidden */
  67218. dispose(): void;
  67219. /** @hidden */
  67220. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67221. private _loadSpecularGlossinessPropertiesAsync;
  67222. }
  67223. }
  67224. declare module BABYLON.GLTF2.Loader.Extensions {
  67225. /**
  67226. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  67227. */
  67228. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  67229. /** The name of this extension. */
  67230. readonly name: string;
  67231. /** Defines whether this extension is enabled. */
  67232. enabled: boolean;
  67233. private _loader;
  67234. /** @hidden */
  67235. constructor(loader: GLTFLoader);
  67236. /** @hidden */
  67237. dispose(): void;
  67238. /** @hidden */
  67239. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67240. private _loadUnlitPropertiesAsync;
  67241. }
  67242. }
  67243. declare module BABYLON.GLTF2.Loader.Extensions {
  67244. /**
  67245. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  67246. */
  67247. export class KHR_texture_transform implements IGLTFLoaderExtension {
  67248. /** The name of this extension. */
  67249. readonly name: string;
  67250. /** Defines whether this extension is enabled. */
  67251. enabled: boolean;
  67252. private _loader;
  67253. /** @hidden */
  67254. constructor(loader: GLTFLoader);
  67255. /** @hidden */
  67256. dispose(): void;
  67257. /** @hidden */
  67258. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67259. }
  67260. }
  67261. declare module BABYLON.GLTF2.Loader.Extensions {
  67262. /**
  67263. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  67264. */
  67265. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  67266. /** The name of this extension. */
  67267. readonly name: string;
  67268. /** Defines whether this extension is enabled. */
  67269. enabled: boolean;
  67270. private _loader;
  67271. private _clips;
  67272. private _emitters;
  67273. /** @hidden */
  67274. constructor(loader: GLTFLoader);
  67275. /** @hidden */
  67276. dispose(): void;
  67277. /** @hidden */
  67278. onLoading(): void;
  67279. /** @hidden */
  67280. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67281. /** @hidden */
  67282. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67283. /** @hidden */
  67284. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67285. private _loadClipAsync;
  67286. private _loadEmitterAsync;
  67287. private _getEventAction;
  67288. private _loadAnimationEventAsync;
  67289. }
  67290. }
  67291. declare module BABYLON.GLTF2.Loader.Extensions {
  67292. /**
  67293. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  67294. */
  67295. export class MSFT_lod implements IGLTFLoaderExtension {
  67296. /** The name of this extension. */
  67297. readonly name: string;
  67298. /** Defines whether this extension is enabled. */
  67299. enabled: boolean;
  67300. /**
  67301. * Maximum number of LODs to load, starting from the lowest LOD.
  67302. */
  67303. maxLODsToLoad: number;
  67304. /**
  67305. * Observable raised when all node LODs of one level are loaded.
  67306. * The event data is the index of the loaded LOD starting from zero.
  67307. * Dispose the loader to cancel the loading of the next level of LODs.
  67308. */
  67309. onNodeLODsLoadedObservable: Observable<number>;
  67310. /**
  67311. * Observable raised when all material LODs of one level are loaded.
  67312. * The event data is the index of the loaded LOD starting from zero.
  67313. * Dispose the loader to cancel the loading of the next level of LODs.
  67314. */
  67315. onMaterialLODsLoadedObservable: Observable<number>;
  67316. private _loader;
  67317. private _nodeIndexLOD;
  67318. private _nodeSignalLODs;
  67319. private _nodePromiseLODs;
  67320. private _materialIndexLOD;
  67321. private _materialSignalLODs;
  67322. private _materialPromiseLODs;
  67323. /** @hidden */
  67324. constructor(loader: GLTFLoader);
  67325. /** @hidden */
  67326. dispose(): void;
  67327. /** @hidden */
  67328. onReady(): void;
  67329. /** @hidden */
  67330. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67331. /** @hidden */
  67332. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67333. /** @hidden */
  67334. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67335. /**
  67336. * Gets an array of LOD properties from lowest to highest.
  67337. */
  67338. private _getLODs;
  67339. private _disposeUnusedMaterials;
  67340. }
  67341. }
  67342. declare module BABYLON.GLTF2.Loader.Extensions {
  67343. /** @hidden */
  67344. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  67345. readonly name: string;
  67346. enabled: boolean;
  67347. private _loader;
  67348. constructor(loader: GLTFLoader);
  67349. dispose(): void;
  67350. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67351. }
  67352. }
  67353. declare module BABYLON.GLTF2.Loader.Extensions {
  67354. /** @hidden */
  67355. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  67356. readonly name: string;
  67357. enabled: boolean;
  67358. private _loader;
  67359. constructor(loader: GLTFLoader);
  67360. dispose(): void;
  67361. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67362. }
  67363. }
  67364. declare module BABYLON.GLTF2.Loader.Extensions {
  67365. /**
  67366. * Store glTF extras (if present) in BJS objects' metadata
  67367. */
  67368. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  67369. /** The name of this extension. */
  67370. readonly name: string;
  67371. /** Defines whether this extension is enabled. */
  67372. enabled: boolean;
  67373. private _loader;
  67374. private _assignExtras;
  67375. /** @hidden */
  67376. constructor(loader: GLTFLoader);
  67377. /** @hidden */
  67378. dispose(): void;
  67379. /** @hidden */
  67380. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67381. /** @hidden */
  67382. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67383. /** @hidden */
  67384. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67385. }
  67386. }
  67387. declare module BABYLON {
  67388. /**
  67389. * Class reading and parsing the MTL file bundled with the obj file.
  67390. */
  67391. export class MTLFileLoader {
  67392. /**
  67393. * All material loaded from the mtl will be set here
  67394. */
  67395. materials: StandardMaterial[];
  67396. /**
  67397. * This function will read the mtl file and create each material described inside
  67398. * This function could be improve by adding :
  67399. * -some component missing (Ni, Tf...)
  67400. * -including the specific options available
  67401. *
  67402. * @param scene defines the scene the material will be created in
  67403. * @param data defines the mtl data to parse
  67404. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  67405. */
  67406. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  67407. /**
  67408. * Gets the texture for the material.
  67409. *
  67410. * If the material is imported from input file,
  67411. * We sanitize the url to ensure it takes the textre from aside the material.
  67412. *
  67413. * @param rootUrl The root url to load from
  67414. * @param value The value stored in the mtl
  67415. * @return The Texture
  67416. */
  67417. private static _getTexture;
  67418. }
  67419. /**
  67420. * Options for loading OBJ/MTL files
  67421. */
  67422. type MeshLoadOptions = {
  67423. /**
  67424. * Defines if UVs are optimized by default during load.
  67425. */
  67426. OptimizeWithUV: boolean;
  67427. /**
  67428. * Defines custom scaling of UV coordinates of loaded meshes.
  67429. */
  67430. UVScaling: Vector2;
  67431. /**
  67432. * Invert model on y-axis (does a model scaling inversion)
  67433. */
  67434. InvertY: boolean;
  67435. /**
  67436. * Invert Y-Axis of referenced textures on load
  67437. */
  67438. InvertTextureY: boolean;
  67439. /**
  67440. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67441. */
  67442. ImportVertexColors: boolean;
  67443. /**
  67444. * Compute the normals for the model, even if normals are present in the file.
  67445. */
  67446. ComputeNormals: boolean;
  67447. /**
  67448. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67449. */
  67450. SkipMaterials: boolean;
  67451. /**
  67452. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67453. */
  67454. MaterialLoadingFailsSilently: boolean;
  67455. };
  67456. /**
  67457. * OBJ file type loader.
  67458. * This is a babylon scene loader plugin.
  67459. */
  67460. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67461. /**
  67462. * Defines if UVs are optimized by default during load.
  67463. */
  67464. static OPTIMIZE_WITH_UV: boolean;
  67465. /**
  67466. * Invert model on y-axis (does a model scaling inversion)
  67467. */
  67468. static INVERT_Y: boolean;
  67469. /**
  67470. * Invert Y-Axis of referenced textures on load
  67471. */
  67472. static INVERT_TEXTURE_Y: boolean;
  67473. /**
  67474. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67475. */
  67476. static IMPORT_VERTEX_COLORS: boolean;
  67477. /**
  67478. * Compute the normals for the model, even if normals are present in the file.
  67479. */
  67480. static COMPUTE_NORMALS: boolean;
  67481. /**
  67482. * Defines custom scaling of UV coordinates of loaded meshes.
  67483. */
  67484. static UV_SCALING: Vector2;
  67485. /**
  67486. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67487. */
  67488. static SKIP_MATERIALS: boolean;
  67489. /**
  67490. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67491. *
  67492. * Defaults to true for backwards compatibility.
  67493. */
  67494. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  67495. /**
  67496. * Defines the name of the plugin.
  67497. */
  67498. name: string;
  67499. /**
  67500. * Defines the extension the plugin is able to load.
  67501. */
  67502. extensions: string;
  67503. /** @hidden */
  67504. obj: RegExp;
  67505. /** @hidden */
  67506. group: RegExp;
  67507. /** @hidden */
  67508. mtllib: RegExp;
  67509. /** @hidden */
  67510. usemtl: RegExp;
  67511. /** @hidden */
  67512. smooth: RegExp;
  67513. /** @hidden */
  67514. vertexPattern: RegExp;
  67515. /** @hidden */
  67516. normalPattern: RegExp;
  67517. /** @hidden */
  67518. uvPattern: RegExp;
  67519. /** @hidden */
  67520. facePattern1: RegExp;
  67521. /** @hidden */
  67522. facePattern2: RegExp;
  67523. /** @hidden */
  67524. facePattern3: RegExp;
  67525. /** @hidden */
  67526. facePattern4: RegExp;
  67527. /** @hidden */
  67528. facePattern5: RegExp;
  67529. private _meshLoadOptions;
  67530. /**
  67531. * Creates loader for .OBJ files
  67532. *
  67533. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  67534. */
  67535. constructor(meshLoadOptions?: MeshLoadOptions);
  67536. private static readonly currentMeshLoadOptions;
  67537. /**
  67538. * Calls synchronously the MTL file attached to this obj.
  67539. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  67540. * Without this function materials are not displayed in the first frame (but displayed after).
  67541. * In consequence it is impossible to get material information in your HTML file
  67542. *
  67543. * @param url The URL of the MTL file
  67544. * @param rootUrl
  67545. * @param onSuccess Callback function to be called when the MTL file is loaded
  67546. * @private
  67547. */
  67548. private _loadMTL;
  67549. /**
  67550. * Instantiates a OBJ file loader plugin.
  67551. * @returns the created plugin
  67552. */
  67553. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  67554. /**
  67555. * If the data string can be loaded directly.
  67556. *
  67557. * @param data string containing the file data
  67558. * @returns if the data can be loaded directly
  67559. */
  67560. canDirectLoad(data: string): boolean;
  67561. /**
  67562. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  67563. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67564. * @param scene the scene the meshes should be added to
  67565. * @param data the OBJ data to load
  67566. * @param rootUrl root url to load from
  67567. * @param onProgress event that fires when loading progress has occured
  67568. * @param fileName Defines the name of the file to load
  67569. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67570. */
  67571. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67572. meshes: AbstractMesh[];
  67573. particleSystems: IParticleSystem[];
  67574. skeletons: Skeleton[];
  67575. animationGroups: AnimationGroup[];
  67576. }>;
  67577. /**
  67578. * Imports all objects from the loaded OBJ data and adds them to the scene
  67579. * @param scene the scene the objects should be added to
  67580. * @param data the OBJ data to load
  67581. * @param rootUrl root url to load from
  67582. * @param onProgress event that fires when loading progress has occured
  67583. * @param fileName Defines the name of the file to load
  67584. * @returns a promise which completes when objects have been loaded to the scene
  67585. */
  67586. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67587. /**
  67588. * Load into an asset container.
  67589. * @param scene The scene to load into
  67590. * @param data The data to import
  67591. * @param rootUrl The root url for scene and resources
  67592. * @param onProgress The callback when the load progresses
  67593. * @param fileName Defines the name of the file to load
  67594. * @returns The loaded asset container
  67595. */
  67596. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67597. /**
  67598. * Read the OBJ file and create an Array of meshes.
  67599. * Each mesh contains all information given by the OBJ and the MTL file.
  67600. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  67601. *
  67602. * @param meshesNames
  67603. * @param scene Scene The scene where are displayed the data
  67604. * @param data String The content of the obj file
  67605. * @param rootUrl String The path to the folder
  67606. * @returns Array<AbstractMesh>
  67607. * @private
  67608. */
  67609. private _parseSolid;
  67610. }
  67611. }
  67612. declare module BABYLON {
  67613. /**
  67614. * STL file type loader.
  67615. * This is a babylon scene loader plugin.
  67616. */
  67617. export class STLFileLoader implements ISceneLoaderPlugin {
  67618. /** @hidden */
  67619. solidPattern: RegExp;
  67620. /** @hidden */
  67621. facetsPattern: RegExp;
  67622. /** @hidden */
  67623. normalPattern: RegExp;
  67624. /** @hidden */
  67625. vertexPattern: RegExp;
  67626. /**
  67627. * Defines the name of the plugin.
  67628. */
  67629. name: string;
  67630. /**
  67631. * Defines the extensions the stl loader is able to load.
  67632. * force data to come in as an ArrayBuffer
  67633. * we'll convert to string if it looks like it's an ASCII .stl
  67634. */
  67635. extensions: ISceneLoaderPluginExtensions;
  67636. /**
  67637. * Import meshes into a scene.
  67638. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  67639. * @param scene The scene to import into
  67640. * @param data The data to import
  67641. * @param rootUrl The root url for scene and resources
  67642. * @param meshes The meshes array to import into
  67643. * @param particleSystems The particle systems array to import into
  67644. * @param skeletons The skeletons array to import into
  67645. * @param onError The callback when import fails
  67646. * @returns True if successful or false otherwise
  67647. */
  67648. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  67649. /**
  67650. * Load into a scene.
  67651. * @param scene The scene to load into
  67652. * @param data The data to import
  67653. * @param rootUrl The root url for scene and resources
  67654. * @param onError The callback when import fails
  67655. * @returns true if successful or false otherwise
  67656. */
  67657. load(scene: Scene, data: any, rootUrl: string): boolean;
  67658. /**
  67659. * Load into an asset container.
  67660. * @param scene The scene to load into
  67661. * @param data The data to import
  67662. * @param rootUrl The root url for scene and resources
  67663. * @param onError The callback when import fails
  67664. * @returns The loaded asset container
  67665. */
  67666. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  67667. private _isBinary;
  67668. private _parseBinary;
  67669. private _parseASCII;
  67670. }
  67671. }
  67672. declare module BABYLON {
  67673. /**
  67674. * Class for generating OBJ data from a Babylon scene.
  67675. */
  67676. export class OBJExport {
  67677. /**
  67678. * Exports the geometry of a Mesh array in .OBJ file format (text)
  67679. * @param mesh defines the list of meshes to serialize
  67680. * @param materials defines if materials should be exported
  67681. * @param matlibname defines the name of the associated mtl file
  67682. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  67683. * @returns the OBJ content
  67684. */
  67685. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  67686. /**
  67687. * Exports the material(s) of a mesh in .MTL file format (text)
  67688. * @param mesh defines the mesh to extract the material from
  67689. * @returns the mtl content
  67690. */
  67691. static MTL(mesh: Mesh): string;
  67692. }
  67693. }
  67694. declare module BABYLON {
  67695. /** @hidden */
  67696. export var __IGLTFExporterExtension: number;
  67697. /**
  67698. * Interface for extending the exporter
  67699. * @hidden
  67700. */
  67701. export interface IGLTFExporterExtension {
  67702. /**
  67703. * The name of this extension
  67704. */
  67705. readonly name: string;
  67706. /**
  67707. * Defines whether this extension is enabled
  67708. */
  67709. enabled: boolean;
  67710. /**
  67711. * Defines whether this extension is required
  67712. */
  67713. required: boolean;
  67714. }
  67715. }
  67716. declare module BABYLON.GLTF2.Exporter {
  67717. /** @hidden */
  67718. export var __IGLTFExporterExtensionV2: number;
  67719. /**
  67720. * Interface for a glTF exporter extension
  67721. * @hidden
  67722. */
  67723. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  67724. /**
  67725. * Define this method to modify the default behavior before exporting a texture
  67726. * @param context The context when loading the asset
  67727. * @param babylonTexture The glTF texture info property
  67728. * @param mimeType The mime-type of the generated image
  67729. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  67730. */
  67731. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  67732. /**
  67733. * Define this method to modify the default behavior when exporting texture info
  67734. * @param context The context when loading the asset
  67735. * @param meshPrimitive glTF mesh primitive
  67736. * @param babylonSubMesh Babylon submesh
  67737. * @param binaryWriter glTF serializer binary writer instance
  67738. * @returns nullable IMeshPrimitive promise
  67739. */
  67740. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  67741. /**
  67742. * Define this method to modify the default behavior when exporting a node
  67743. * @param context The context when exporting the node
  67744. * @param node glTF node
  67745. * @param babylonNode BabylonJS node
  67746. * @returns nullable INode promise
  67747. */
  67748. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67749. /**
  67750. * Called after the exporter state changes to EXPORTING
  67751. */
  67752. onExporting?(): void;
  67753. }
  67754. }
  67755. declare module BABYLON.GLTF2.Exporter {
  67756. /**
  67757. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  67758. * @hidden
  67759. */
  67760. export class _GLTFMaterialExporter {
  67761. /**
  67762. * Represents the dielectric specular values for R, G and B
  67763. */
  67764. private static readonly _DielectricSpecular;
  67765. /**
  67766. * Allows the maximum specular power to be defined for material calculations
  67767. */
  67768. private static readonly _MaxSpecularPower;
  67769. /**
  67770. * Mapping to store textures
  67771. */
  67772. private _textureMap;
  67773. /**
  67774. * Numeric tolerance value
  67775. */
  67776. private static readonly _Epsilon;
  67777. /**
  67778. * Reference to the glTF Exporter
  67779. */
  67780. private _exporter;
  67781. constructor(exporter: _Exporter);
  67782. /**
  67783. * Specifies if two colors are approximately equal in value
  67784. * @param color1 first color to compare to
  67785. * @param color2 second color to compare to
  67786. * @param epsilon threshold value
  67787. */
  67788. private static FuzzyEquals;
  67789. /**
  67790. * Gets the materials from a Babylon scene and converts them to glTF materials
  67791. * @param scene babylonjs scene
  67792. * @param mimeType texture mime type
  67793. * @param images array of images
  67794. * @param textures array of textures
  67795. * @param materials array of materials
  67796. * @param imageData mapping of texture names to base64 textures
  67797. * @param hasTextureCoords specifies if texture coordinates are present on the material
  67798. */
  67799. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67800. /**
  67801. * Makes a copy of the glTF material without the texture parameters
  67802. * @param originalMaterial original glTF material
  67803. * @returns glTF material without texture parameters
  67804. */
  67805. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  67806. /**
  67807. * Specifies if the material has any texture parameters present
  67808. * @param material glTF Material
  67809. * @returns boolean specifying if texture parameters are present
  67810. */
  67811. _hasTexturesPresent(material: IMaterial): boolean;
  67812. /**
  67813. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  67814. * @param babylonStandardMaterial
  67815. * @returns glTF Metallic Roughness Material representation
  67816. */
  67817. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  67818. /**
  67819. * Computes the metallic factor
  67820. * @param diffuse diffused value
  67821. * @param specular specular value
  67822. * @param oneMinusSpecularStrength one minus the specular strength
  67823. * @returns metallic value
  67824. */
  67825. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  67826. /**
  67827. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  67828. * @param glTFMaterial glTF material
  67829. * @param babylonMaterial Babylon material
  67830. */
  67831. private static _SetAlphaMode;
  67832. /**
  67833. * Converts a Babylon Standard Material to a glTF Material
  67834. * @param babylonStandardMaterial BJS Standard Material
  67835. * @param mimeType mime type to use for the textures
  67836. * @param images array of glTF image interfaces
  67837. * @param textures array of glTF texture interfaces
  67838. * @param materials array of glTF material interfaces
  67839. * @param imageData map of image file name to data
  67840. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67841. */
  67842. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67843. /**
  67844. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67845. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  67846. * @param mimeType mime type to use for the textures
  67847. * @param images array of glTF image interfaces
  67848. * @param textures array of glTF texture interfaces
  67849. * @param materials array of glTF material interfaces
  67850. * @param imageData map of image file name to data
  67851. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67852. */
  67853. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67854. /**
  67855. * Converts an image typed array buffer to a base64 image
  67856. * @param buffer typed array buffer
  67857. * @param width width of the image
  67858. * @param height height of the image
  67859. * @param mimeType mimetype of the image
  67860. * @returns base64 image string
  67861. */
  67862. private _createBase64FromCanvasAsync;
  67863. /**
  67864. * Generates a white texture based on the specified width and height
  67865. * @param width width of the texture in pixels
  67866. * @param height height of the texture in pixels
  67867. * @param scene babylonjs scene
  67868. * @returns white texture
  67869. */
  67870. private _createWhiteTexture;
  67871. /**
  67872. * Resizes the two source textures to the same dimensions. If a texture is null, a default white texture is generated. If both textures are null, returns null
  67873. * @param texture1 first texture to resize
  67874. * @param texture2 second texture to resize
  67875. * @param scene babylonjs scene
  67876. * @returns resized textures or null
  67877. */
  67878. private _resizeTexturesToSameDimensions;
  67879. /**
  67880. * Converts an array of pixels to a Float32Array
  67881. * Throws an error if the pixel format is not supported
  67882. * @param pixels - array buffer containing pixel values
  67883. * @returns Float32 of pixels
  67884. */
  67885. private _convertPixelArrayToFloat32;
  67886. /**
  67887. * Convert Specular Glossiness Textures to Metallic Roughness
  67888. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  67889. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  67890. * @param diffuseTexture texture used to store diffuse information
  67891. * @param specularGlossinessTexture texture used to store specular and glossiness information
  67892. * @param factors specular glossiness material factors
  67893. * @param mimeType the mime type to use for the texture
  67894. * @returns pbr metallic roughness interface or null
  67895. */
  67896. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  67897. /**
  67898. * Converts specular glossiness material properties to metallic roughness
  67899. * @param specularGlossiness interface with specular glossiness material properties
  67900. * @returns interface with metallic roughness material properties
  67901. */
  67902. private _convertSpecularGlossinessToMetallicRoughness;
  67903. /**
  67904. * Calculates the surface reflectance, independent of lighting conditions
  67905. * @param color Color source to calculate brightness from
  67906. * @returns number representing the perceived brightness, or zero if color is undefined
  67907. */
  67908. private _getPerceivedBrightness;
  67909. /**
  67910. * Returns the maximum color component value
  67911. * @param color
  67912. * @returns maximum color component value, or zero if color is null or undefined
  67913. */
  67914. private _getMaxComponent;
  67915. /**
  67916. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  67917. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67918. * @param mimeType mime type to use for the textures
  67919. * @param images array of glTF image interfaces
  67920. * @param textures array of glTF texture interfaces
  67921. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  67922. * @param imageData map of image file name to data
  67923. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67924. * @returns glTF PBR Metallic Roughness factors
  67925. */
  67926. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  67927. private _getGLTFTextureSampler;
  67928. private _getGLTFTextureWrapMode;
  67929. private _getGLTFTextureWrapModesSampler;
  67930. /**
  67931. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  67932. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67933. * @param mimeType mime type to use for the textures
  67934. * @param images array of glTF image interfaces
  67935. * @param textures array of glTF texture interfaces
  67936. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  67937. * @param imageData map of image file name to data
  67938. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67939. * @returns glTF PBR Metallic Roughness factors
  67940. */
  67941. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  67942. /**
  67943. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67944. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67945. * @param mimeType mime type to use for the textures
  67946. * @param images array of glTF image interfaces
  67947. * @param textures array of glTF texture interfaces
  67948. * @param materials array of glTF material interfaces
  67949. * @param imageData map of image file name to data
  67950. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67951. */
  67952. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67953. private setMetallicRoughnessPbrMaterial;
  67954. private getPixelsFromTexture;
  67955. /**
  67956. * Extracts a texture from a Babylon texture into file data and glTF data
  67957. * @param babylonTexture Babylon texture to extract
  67958. * @param mimeType Mime Type of the babylonTexture
  67959. * @return glTF texture info, or null if the texture format is not supported
  67960. */
  67961. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  67962. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  67963. /**
  67964. * Builds a texture from base64 string
  67965. * @param base64Texture base64 texture string
  67966. * @param baseTextureName Name to use for the texture
  67967. * @param mimeType image mime type for the texture
  67968. * @param images array of images
  67969. * @param textures array of textures
  67970. * @param imageData map of image data
  67971. * @returns glTF texture info, or null if the texture format is not supported
  67972. */
  67973. private _getTextureInfoFromBase64;
  67974. }
  67975. }
  67976. declare module BABYLON {
  67977. /**
  67978. * Class for holding and downloading glTF file data
  67979. */
  67980. export class GLTFData {
  67981. /**
  67982. * Object which contains the file name as the key and its data as the value
  67983. */
  67984. glTFFiles: {
  67985. [fileName: string]: string | Blob;
  67986. };
  67987. /**
  67988. * Initializes the glTF file object
  67989. */
  67990. constructor();
  67991. /**
  67992. * Downloads the glTF data as files based on their names and data
  67993. */
  67994. downloadFiles(): void;
  67995. }
  67996. }
  67997. declare module BABYLON {
  67998. /**
  67999. * Holds a collection of exporter options and parameters
  68000. */
  68001. export interface IExportOptions {
  68002. /**
  68003. * Function which indicates whether a babylon node should be exported or not
  68004. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  68005. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  68006. */
  68007. shouldExportNode?(node: Node): boolean;
  68008. /**
  68009. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  68010. * @param metadata source metadata to read from
  68011. * @returns the data to store to glTF node extras
  68012. */
  68013. metadataSelector?(metadata: any): any;
  68014. /**
  68015. * The sample rate to bake animation curves
  68016. */
  68017. animationSampleRate?: number;
  68018. /**
  68019. * Begin serialization without waiting for the scene to be ready
  68020. */
  68021. exportWithoutWaitingForScene?: boolean;
  68022. }
  68023. /**
  68024. * Class for generating glTF data from a Babylon scene.
  68025. */
  68026. export class GLTF2Export {
  68027. /**
  68028. * Exports the geometry of the scene to .gltf file format asynchronously
  68029. * @param scene Babylon scene with scene hierarchy information
  68030. * @param filePrefix File prefix to use when generating the glTF file
  68031. * @param options Exporter options
  68032. * @returns Returns an object with a .gltf file and associates texture names
  68033. * as keys and their data and paths as values
  68034. */
  68035. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68036. private static _PreExportAsync;
  68037. private static _PostExportAsync;
  68038. /**
  68039. * Exports the geometry of the scene to .glb file format asychronously
  68040. * @param scene Babylon scene with scene hierarchy information
  68041. * @param filePrefix File prefix to use when generating glb file
  68042. * @param options Exporter options
  68043. * @returns Returns an object with a .glb filename as key and data as value
  68044. */
  68045. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68046. }
  68047. }
  68048. declare module BABYLON.GLTF2.Exporter {
  68049. /**
  68050. * @hidden
  68051. */
  68052. export class _GLTFUtilities {
  68053. /**
  68054. * Creates a buffer view based on the supplied arguments
  68055. * @param bufferIndex index value of the specified buffer
  68056. * @param byteOffset byte offset value
  68057. * @param byteLength byte length of the bufferView
  68058. * @param byteStride byte distance between conequential elements
  68059. * @param name name of the buffer view
  68060. * @returns bufferView for glTF
  68061. */
  68062. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  68063. /**
  68064. * Creates an accessor based on the supplied arguments
  68065. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  68066. * @param name The name of the accessor
  68067. * @param type The type of the accessor
  68068. * @param componentType The datatype of components in the attribute
  68069. * @param count The number of attributes referenced by this accessor
  68070. * @param byteOffset The offset relative to the start of the bufferView in bytes
  68071. * @param min Minimum value of each component in this attribute
  68072. * @param max Maximum value of each component in this attribute
  68073. * @returns accessor for glTF
  68074. */
  68075. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  68076. /**
  68077. * Calculates the minimum and maximum values of an array of position floats
  68078. * @param positions Positions array of a mesh
  68079. * @param vertexStart Starting vertex offset to calculate min and max values
  68080. * @param vertexCount Number of vertices to check for min and max values
  68081. * @returns min number array and max number array
  68082. */
  68083. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  68084. min: number[];
  68085. max: number[];
  68086. };
  68087. /**
  68088. * Converts a new right-handed Vector3
  68089. * @param vector vector3 array
  68090. * @returns right-handed Vector3
  68091. */
  68092. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  68093. /**
  68094. * Converts a Vector3 to right-handed
  68095. * @param vector Vector3 to convert to right-handed
  68096. */
  68097. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  68098. /**
  68099. * Converts a three element number array to right-handed
  68100. * @param vector number array to convert to right-handed
  68101. */
  68102. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  68103. /**
  68104. * Converts a new right-handed Vector3
  68105. * @param vector vector3 array
  68106. * @returns right-handed Vector3
  68107. */
  68108. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  68109. /**
  68110. * Converts a Vector3 to right-handed
  68111. * @param vector Vector3 to convert to right-handed
  68112. */
  68113. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  68114. /**
  68115. * Converts a three element number array to right-handed
  68116. * @param vector number array to convert to right-handed
  68117. */
  68118. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  68119. /**
  68120. * Converts a Vector4 to right-handed
  68121. * @param vector Vector4 to convert to right-handed
  68122. */
  68123. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  68124. /**
  68125. * Converts a Vector4 to right-handed
  68126. * @param vector Vector4 to convert to right-handed
  68127. */
  68128. static _GetRightHandedArray4FromRef(vector: number[]): void;
  68129. /**
  68130. * Converts a Quaternion to right-handed
  68131. * @param quaternion Source quaternion to convert to right-handed
  68132. */
  68133. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  68134. /**
  68135. * Converts a Quaternion to right-handed
  68136. * @param quaternion Source quaternion to convert to right-handed
  68137. */
  68138. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  68139. static _NormalizeTangentFromRef(tangent: Vector4): void;
  68140. }
  68141. }
  68142. declare module BABYLON.GLTF2.Exporter {
  68143. /**
  68144. * Converts Babylon Scene into glTF 2.0.
  68145. * @hidden
  68146. */
  68147. export class _Exporter {
  68148. /**
  68149. * Stores the glTF to export
  68150. */
  68151. _glTF: IGLTF;
  68152. /**
  68153. * Stores all generated buffer views, which represents views into the main glTF buffer data
  68154. */
  68155. _bufferViews: IBufferView[];
  68156. /**
  68157. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  68158. */
  68159. _accessors: IAccessor[];
  68160. /**
  68161. * Stores all the generated nodes, which contains transform and/or mesh information per node
  68162. */
  68163. private _nodes;
  68164. /**
  68165. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  68166. */
  68167. private _scenes;
  68168. /**
  68169. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  68170. */
  68171. private _meshes;
  68172. /**
  68173. * Stores all the generated material information, which represents the appearance of each primitive
  68174. */
  68175. _materials: IMaterial[];
  68176. _materialMap: {
  68177. [materialID: number]: number;
  68178. };
  68179. /**
  68180. * Stores all the generated texture information, which is referenced by glTF materials
  68181. */
  68182. _textures: ITexture[];
  68183. /**
  68184. * Stores all the generated image information, which is referenced by glTF textures
  68185. */
  68186. _images: IImage[];
  68187. /**
  68188. * Stores all the texture samplers
  68189. */
  68190. _samplers: ISampler[];
  68191. /**
  68192. * Stores all the generated animation samplers, which is referenced by glTF animations
  68193. */
  68194. /**
  68195. * Stores the animations for glTF models
  68196. */
  68197. private _animations;
  68198. /**
  68199. * Stores the total amount of bytes stored in the glTF buffer
  68200. */
  68201. private _totalByteLength;
  68202. /**
  68203. * Stores a reference to the Babylon scene containing the source geometry and material information
  68204. */
  68205. _babylonScene: Scene;
  68206. /**
  68207. * Stores a map of the image data, where the key is the file name and the value
  68208. * is the image data
  68209. */
  68210. _imageData: {
  68211. [fileName: string]: {
  68212. data: Uint8Array;
  68213. mimeType: ImageMimeType;
  68214. };
  68215. };
  68216. /**
  68217. * Stores a map of the unique id of a node to its index in the node array
  68218. */
  68219. private _nodeMap;
  68220. /**
  68221. * Specifies if the Babylon scene should be converted to right-handed on export
  68222. */
  68223. _convertToRightHandedSystem: boolean;
  68224. /**
  68225. * Baked animation sample rate
  68226. */
  68227. private _animationSampleRate;
  68228. private _options;
  68229. private _localEngine;
  68230. _glTFMaterialExporter: _GLTFMaterialExporter;
  68231. private _extensions;
  68232. private static _ExtensionNames;
  68233. private static _ExtensionFactories;
  68234. private _applyExtensions;
  68235. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  68236. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68237. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68238. private _forEachExtensions;
  68239. private _extensionsOnExporting;
  68240. /**
  68241. * Load glTF serializer extensions
  68242. */
  68243. private _loadExtensions;
  68244. /**
  68245. * Creates a glTF Exporter instance, which can accept optional exporter options
  68246. * @param babylonScene Babylon scene object
  68247. * @param options Options to modify the behavior of the exporter
  68248. */
  68249. constructor(babylonScene: Scene, options?: IExportOptions);
  68250. /**
  68251. * Registers a glTF exporter extension
  68252. * @param name Name of the extension to export
  68253. * @param factory The factory function that creates the exporter extension
  68254. */
  68255. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  68256. /**
  68257. * Un-registers an exporter extension
  68258. * @param name The name fo the exporter extension
  68259. * @returns A boolean indicating whether the extension has been un-registered
  68260. */
  68261. static UnregisterExtension(name: string): boolean;
  68262. /**
  68263. * Lazy load a local engine with premultiplied alpha set to false
  68264. */
  68265. _getLocalEngine(): Engine;
  68266. private reorderIndicesBasedOnPrimitiveMode;
  68267. /**
  68268. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  68269. * clock-wise during export to glTF
  68270. * @param submesh BabylonJS submesh
  68271. * @param primitiveMode Primitive mode of the mesh
  68272. * @param sideOrientation the winding order of the submesh
  68273. * @param vertexBufferKind The type of vertex attribute
  68274. * @param meshAttributeArray The vertex attribute data
  68275. * @param byteOffset The offset to the binary data
  68276. * @param binaryWriter The binary data for the glTF file
  68277. */
  68278. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  68279. /**
  68280. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  68281. * clock-wise during export to glTF
  68282. * @param submesh BabylonJS submesh
  68283. * @param primitiveMode Primitive mode of the mesh
  68284. * @param sideOrientation the winding order of the submesh
  68285. * @param vertexBufferKind The type of vertex attribute
  68286. * @param meshAttributeArray The vertex attribute data
  68287. * @param byteOffset The offset to the binary data
  68288. * @param binaryWriter The binary data for the glTF file
  68289. */
  68290. private reorderTriangleFillMode;
  68291. /**
  68292. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  68293. * clock-wise during export to glTF
  68294. * @param submesh BabylonJS submesh
  68295. * @param primitiveMode Primitive mode of the mesh
  68296. * @param sideOrientation the winding order of the submesh
  68297. * @param vertexBufferKind The type of vertex attribute
  68298. * @param meshAttributeArray The vertex attribute data
  68299. * @param byteOffset The offset to the binary data
  68300. * @param binaryWriter The binary data for the glTF file
  68301. */
  68302. private reorderTriangleStripDrawMode;
  68303. /**
  68304. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  68305. * clock-wise during export to glTF
  68306. * @param submesh BabylonJS submesh
  68307. * @param primitiveMode Primitive mode of the mesh
  68308. * @param sideOrientation the winding order of the submesh
  68309. * @param vertexBufferKind The type of vertex attribute
  68310. * @param meshAttributeArray The vertex attribute data
  68311. * @param byteOffset The offset to the binary data
  68312. * @param binaryWriter The binary data for the glTF file
  68313. */
  68314. private reorderTriangleFanMode;
  68315. /**
  68316. * Writes the vertex attribute data to binary
  68317. * @param vertices The vertices to write to the binary writer
  68318. * @param byteOffset The offset into the binary writer to overwrite binary data
  68319. * @param vertexAttributeKind The vertex attribute type
  68320. * @param meshAttributeArray The vertex attribute data
  68321. * @param binaryWriter The writer containing the binary data
  68322. */
  68323. private writeVertexAttributeData;
  68324. /**
  68325. * Writes mesh attribute data to a data buffer
  68326. * Returns the bytelength of the data
  68327. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  68328. * @param meshAttributeArray Array containing the attribute data
  68329. * @param binaryWriter The buffer to write the binary data to
  68330. * @param indices Used to specify the order of the vertex data
  68331. */
  68332. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  68333. /**
  68334. * Generates glTF json data
  68335. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  68336. * @param glTFPrefix Text to use when prefixing a glTF file
  68337. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  68338. * @returns json data as string
  68339. */
  68340. private generateJSON;
  68341. /**
  68342. * Generates data for .gltf and .bin files based on the glTF prefix string
  68343. * @param glTFPrefix Text to use when prefixing a glTF file
  68344. * @returns GLTFData with glTF file data
  68345. */
  68346. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  68347. /**
  68348. * Creates a binary buffer for glTF
  68349. * @returns array buffer for binary data
  68350. */
  68351. private _generateBinaryAsync;
  68352. /**
  68353. * Pads the number to a multiple of 4
  68354. * @param num number to pad
  68355. * @returns padded number
  68356. */
  68357. private _getPadding;
  68358. /**
  68359. * Generates a glb file from the json and binary data
  68360. * Returns an object with the glb file name as the key and data as the value
  68361. * @param glTFPrefix
  68362. * @returns object with glb filename as key and data as value
  68363. */
  68364. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  68365. /**
  68366. * Sets the TRS for each node
  68367. * @param node glTF Node for storing the transformation data
  68368. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  68369. */
  68370. private setNodeTransformation;
  68371. private getVertexBufferFromMesh;
  68372. /**
  68373. * Creates a bufferview based on the vertices type for the Babylon mesh
  68374. * @param kind Indicates the type of vertices data
  68375. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  68376. * @param binaryWriter The buffer to write the bufferview data to
  68377. */
  68378. private createBufferViewKind;
  68379. /**
  68380. * The primitive mode of the Babylon mesh
  68381. * @param babylonMesh The BabylonJS mesh
  68382. */
  68383. private getMeshPrimitiveMode;
  68384. /**
  68385. * Sets the primitive mode of the glTF mesh primitive
  68386. * @param meshPrimitive glTF mesh primitive
  68387. * @param primitiveMode The primitive mode
  68388. */
  68389. private setPrimitiveMode;
  68390. /**
  68391. * Sets the vertex attribute accessor based of the glTF mesh primitive
  68392. * @param meshPrimitive glTF mesh primitive
  68393. * @param attributeKind vertex attribute
  68394. * @returns boolean specifying if uv coordinates are present
  68395. */
  68396. private setAttributeKind;
  68397. /**
  68398. * Sets data for the primitive attributes of each submesh
  68399. * @param mesh glTF Mesh object to store the primitive attribute information
  68400. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  68401. * @param binaryWriter Buffer to write the attribute data to
  68402. */
  68403. private setPrimitiveAttributesAsync;
  68404. /**
  68405. * Creates a glTF scene based on the array of meshes
  68406. * Returns the the total byte offset
  68407. * @param babylonScene Babylon scene to get the mesh data from
  68408. * @param binaryWriter Buffer to write binary data to
  68409. */
  68410. private createSceneAsync;
  68411. /**
  68412. * Creates a mapping of Node unique id to node index and handles animations
  68413. * @param babylonScene Babylon Scene
  68414. * @param nodes Babylon transform nodes
  68415. * @param binaryWriter Buffer to write binary data to
  68416. * @returns Node mapping of unique id to index
  68417. */
  68418. private createNodeMapAndAnimationsAsync;
  68419. /**
  68420. * Creates a glTF node from a Babylon mesh
  68421. * @param babylonMesh Source Babylon mesh
  68422. * @param binaryWriter Buffer for storing geometry data
  68423. * @returns glTF node
  68424. */
  68425. private createNodeAsync;
  68426. }
  68427. /**
  68428. * @hidden
  68429. *
  68430. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  68431. */
  68432. export class _BinaryWriter {
  68433. /**
  68434. * Array buffer which stores all binary data
  68435. */
  68436. private _arrayBuffer;
  68437. /**
  68438. * View of the array buffer
  68439. */
  68440. private _dataView;
  68441. /**
  68442. * byte offset of data in array buffer
  68443. */
  68444. private _byteOffset;
  68445. /**
  68446. * Initialize binary writer with an initial byte length
  68447. * @param byteLength Initial byte length of the array buffer
  68448. */
  68449. constructor(byteLength: number);
  68450. /**
  68451. * Resize the array buffer to the specified byte length
  68452. * @param byteLength
  68453. */
  68454. private resizeBuffer;
  68455. /**
  68456. * Get an array buffer with the length of the byte offset
  68457. * @returns ArrayBuffer resized to the byte offset
  68458. */
  68459. getArrayBuffer(): ArrayBuffer;
  68460. /**
  68461. * Get the byte offset of the array buffer
  68462. * @returns byte offset
  68463. */
  68464. getByteOffset(): number;
  68465. /**
  68466. * Stores an UInt8 in the array buffer
  68467. * @param entry
  68468. * @param byteOffset If defined, specifies where to set the value as an offset.
  68469. */
  68470. setUInt8(entry: number, byteOffset?: number): void;
  68471. /**
  68472. * Gets an UInt32 in the array buffer
  68473. * @param entry
  68474. * @param byteOffset If defined, specifies where to set the value as an offset.
  68475. */
  68476. getUInt32(byteOffset: number): number;
  68477. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68478. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68479. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68480. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68481. /**
  68482. * Stores a Float32 in the array buffer
  68483. * @param entry
  68484. */
  68485. setFloat32(entry: number, byteOffset?: number): void;
  68486. /**
  68487. * Stores an UInt32 in the array buffer
  68488. * @param entry
  68489. * @param byteOffset If defined, specifies where to set the value as an offset.
  68490. */
  68491. setUInt32(entry: number, byteOffset?: number): void;
  68492. }
  68493. }
  68494. declare module BABYLON.GLTF2.Exporter {
  68495. /**
  68496. * @hidden
  68497. * Interface to store animation data.
  68498. */
  68499. export interface _IAnimationData {
  68500. /**
  68501. * Keyframe data.
  68502. */
  68503. inputs: number[];
  68504. /**
  68505. * Value data.
  68506. */
  68507. outputs: number[][];
  68508. /**
  68509. * Animation interpolation data.
  68510. */
  68511. samplerInterpolation: AnimationSamplerInterpolation;
  68512. /**
  68513. * Minimum keyframe value.
  68514. */
  68515. inputsMin: number;
  68516. /**
  68517. * Maximum keyframe value.
  68518. */
  68519. inputsMax: number;
  68520. }
  68521. /**
  68522. * @hidden
  68523. */
  68524. export interface _IAnimationInfo {
  68525. /**
  68526. * The target channel for the animation
  68527. */
  68528. animationChannelTargetPath: AnimationChannelTargetPath;
  68529. /**
  68530. * The glTF accessor type for the data.
  68531. */
  68532. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  68533. /**
  68534. * Specifies if quaternions should be used.
  68535. */
  68536. useQuaternion: boolean;
  68537. }
  68538. /**
  68539. * @hidden
  68540. * Utility class for generating glTF animation data from BabylonJS.
  68541. */
  68542. export class _GLTFAnimation {
  68543. /**
  68544. * @ignore
  68545. *
  68546. * Creates glTF channel animation from BabylonJS animation.
  68547. * @param babylonTransformNode - BabylonJS mesh.
  68548. * @param animation - animation.
  68549. * @param animationChannelTargetPath - The target animation channel.
  68550. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  68551. * @param useQuaternion - Specifies if quaternions are used.
  68552. * @returns nullable IAnimationData
  68553. */
  68554. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  68555. private static _DeduceAnimationInfo;
  68556. /**
  68557. * @ignore
  68558. * Create node animations from the transform node animations
  68559. * @param babylonNode
  68560. * @param runtimeGLTFAnimation
  68561. * @param idleGLTFAnimations
  68562. * @param nodeMap
  68563. * @param nodes
  68564. * @param binaryWriter
  68565. * @param bufferViews
  68566. * @param accessors
  68567. * @param convertToRightHandedSystem
  68568. */
  68569. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  68570. [key: number]: number;
  68571. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68572. /**
  68573. * @ignore
  68574. * Create node animations from the animation groups
  68575. * @param babylonScene
  68576. * @param glTFAnimations
  68577. * @param nodeMap
  68578. * @param nodes
  68579. * @param binaryWriter
  68580. * @param bufferViews
  68581. * @param accessors
  68582. * @param convertToRightHandedSystem
  68583. */
  68584. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  68585. [key: number]: number;
  68586. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68587. private static AddAnimation;
  68588. /**
  68589. * Create a baked animation
  68590. * @param babylonTransformNode BabylonJS mesh
  68591. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  68592. * @param animationChannelTargetPath animation target channel
  68593. * @param minFrame minimum animation frame
  68594. * @param maxFrame maximum animation frame
  68595. * @param fps frames per second of the animation
  68596. * @param inputs input key frames of the animation
  68597. * @param outputs output key frame data of the animation
  68598. * @param convertToRightHandedSystem converts the values to right-handed
  68599. * @param useQuaternion specifies if quaternions should be used
  68600. */
  68601. private static _CreateBakedAnimation;
  68602. private static _ConvertFactorToVector3OrQuaternion;
  68603. private static _SetInterpolatedValue;
  68604. /**
  68605. * Creates linear animation from the animation key frames
  68606. * @param babylonTransformNode BabylonJS mesh
  68607. * @param animation BabylonJS animation
  68608. * @param animationChannelTargetPath The target animation channel
  68609. * @param frameDelta The difference between the last and first frame of the animation
  68610. * @param inputs Array to store the key frame times
  68611. * @param outputs Array to store the key frame data
  68612. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68613. * @param useQuaternion Specifies if quaternions are used in the animation
  68614. */
  68615. private static _CreateLinearOrStepAnimation;
  68616. /**
  68617. * Creates cubic spline animation from the animation key frames
  68618. * @param babylonTransformNode BabylonJS mesh
  68619. * @param animation BabylonJS animation
  68620. * @param animationChannelTargetPath The target animation channel
  68621. * @param frameDelta The difference between the last and first frame of the animation
  68622. * @param inputs Array to store the key frame times
  68623. * @param outputs Array to store the key frame data
  68624. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68625. * @param useQuaternion Specifies if quaternions are used in the animation
  68626. */
  68627. private static _CreateCubicSplineAnimation;
  68628. private static _GetBasePositionRotationOrScale;
  68629. /**
  68630. * Adds a key frame value
  68631. * @param keyFrame
  68632. * @param animation
  68633. * @param outputs
  68634. * @param animationChannelTargetPath
  68635. * @param basePositionRotationOrScale
  68636. * @param convertToRightHandedSystem
  68637. * @param useQuaternion
  68638. */
  68639. private static _AddKeyframeValue;
  68640. /**
  68641. * Determine the interpolation based on the key frames
  68642. * @param keyFrames
  68643. * @param animationChannelTargetPath
  68644. * @param useQuaternion
  68645. */
  68646. private static _DeduceInterpolation;
  68647. /**
  68648. * Adds an input tangent or output tangent to the output data
  68649. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  68650. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  68651. * @param outputs The animation data by keyframe
  68652. * @param animationChannelTargetPath The target animation channel
  68653. * @param interpolation The interpolation type
  68654. * @param keyFrame The key frame with the animation data
  68655. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  68656. * @param useQuaternion Specifies if quaternions are used
  68657. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  68658. */
  68659. private static AddSplineTangent;
  68660. /**
  68661. * Get the minimum and maximum key frames' frame values
  68662. * @param keyFrames animation key frames
  68663. * @returns the minimum and maximum key frame value
  68664. */
  68665. private static calculateMinMaxKeyFrames;
  68666. }
  68667. }
  68668. declare module BABYLON.GLTF2.Exporter {
  68669. /** @hidden */
  68670. export var textureTransformPixelShader: {
  68671. name: string;
  68672. shader: string;
  68673. };
  68674. }
  68675. declare module BABYLON.GLTF2.Exporter.Extensions {
  68676. /**
  68677. * @hidden
  68678. */
  68679. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  68680. /** Name of this extension */
  68681. readonly name: string;
  68682. /** Defines whether this extension is enabled */
  68683. enabled: boolean;
  68684. /** Defines whether this extension is required */
  68685. required: boolean;
  68686. /** Reference to the glTF exporter */
  68687. private _exporter;
  68688. constructor(exporter: _Exporter);
  68689. dispose(): void;
  68690. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68691. /**
  68692. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  68693. * @param babylonTexture
  68694. * @param offset
  68695. * @param rotation
  68696. * @param scale
  68697. * @param scene
  68698. */
  68699. private _textureTransformTextureAsync;
  68700. }
  68701. }
  68702. declare module BABYLON.GLTF2.Exporter.Extensions {
  68703. /**
  68704. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  68705. */
  68706. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  68707. /** The name of this extension. */
  68708. readonly name: string;
  68709. /** Defines whether this extension is enabled. */
  68710. enabled: boolean;
  68711. /** Defines whether this extension is required */
  68712. required: boolean;
  68713. /** Reference to the glTF exporter */
  68714. private _exporter;
  68715. private _lights;
  68716. /** @hidden */
  68717. constructor(exporter: _Exporter);
  68718. /** @hidden */
  68719. dispose(): void;
  68720. /** @hidden */
  68721. onExporting(): void;
  68722. /**
  68723. * Define this method to modify the default behavior when exporting a node
  68724. * @param context The context when exporting the node
  68725. * @param node glTF node
  68726. * @param babylonNode BabylonJS node
  68727. * @returns nullable INode promise
  68728. */
  68729. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68730. }
  68731. }
  68732. declare module BABYLON {
  68733. /**
  68734. * Class for generating STL data from a Babylon scene.
  68735. */
  68736. export class STLExport {
  68737. /**
  68738. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  68739. * @param meshes list defines the mesh to serialize
  68740. * @param download triggers the automatic download of the file.
  68741. * @param fileName changes the downloads fileName.
  68742. * @param binary changes the STL to a binary type.
  68743. * @param isLittleEndian toggle for binary type exporter.
  68744. * @returns the STL as UTF8 string
  68745. */
  68746. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  68747. }
  68748. }
  68749. /**
  68750. * @ignoreChildren
  68751. * @ignore
  68752. */
  68753. declare module "babylonjs-gltf2interface" {
  68754. export = BABYLON.GLTF2;
  68755. }
  68756. /**
  68757. * Module for glTF 2.0 Interface
  68758. * @ignoreChildren
  68759. * @ignore
  68760. */
  68761. declare module BABYLON.GLTF2 {
  68762. /**
  68763. * The datatype of the components in the attribute
  68764. */
  68765. const enum AccessorComponentType {
  68766. /**
  68767. * Byte
  68768. */
  68769. BYTE = 5120,
  68770. /**
  68771. * Unsigned Byte
  68772. */
  68773. UNSIGNED_BYTE = 5121,
  68774. /**
  68775. * Short
  68776. */
  68777. SHORT = 5122,
  68778. /**
  68779. * Unsigned Short
  68780. */
  68781. UNSIGNED_SHORT = 5123,
  68782. /**
  68783. * Unsigned Int
  68784. */
  68785. UNSIGNED_INT = 5125,
  68786. /**
  68787. * Float
  68788. */
  68789. FLOAT = 5126,
  68790. }
  68791. /**
  68792. * Specifies if the attirbute is a scalar, vector, or matrix
  68793. */
  68794. const enum AccessorType {
  68795. /**
  68796. * Scalar
  68797. */
  68798. SCALAR = "SCALAR",
  68799. /**
  68800. * Vector2
  68801. */
  68802. VEC2 = "VEC2",
  68803. /**
  68804. * Vector3
  68805. */
  68806. VEC3 = "VEC3",
  68807. /**
  68808. * Vector4
  68809. */
  68810. VEC4 = "VEC4",
  68811. /**
  68812. * Matrix2x2
  68813. */
  68814. MAT2 = "MAT2",
  68815. /**
  68816. * Matrix3x3
  68817. */
  68818. MAT3 = "MAT3",
  68819. /**
  68820. * Matrix4x4
  68821. */
  68822. MAT4 = "MAT4",
  68823. }
  68824. /**
  68825. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68826. */
  68827. const enum AnimationChannelTargetPath {
  68828. /**
  68829. * Translation
  68830. */
  68831. TRANSLATION = "translation",
  68832. /**
  68833. * Rotation
  68834. */
  68835. ROTATION = "rotation",
  68836. /**
  68837. * Scale
  68838. */
  68839. SCALE = "scale",
  68840. /**
  68841. * Weights
  68842. */
  68843. WEIGHTS = "weights",
  68844. }
  68845. /**
  68846. * Interpolation algorithm
  68847. */
  68848. const enum AnimationSamplerInterpolation {
  68849. /**
  68850. * The animated values are linearly interpolated between keyframes
  68851. */
  68852. LINEAR = "LINEAR",
  68853. /**
  68854. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  68855. */
  68856. STEP = "STEP",
  68857. /**
  68858. * The animation's interpolation is computed using a cubic spline with specified tangents
  68859. */
  68860. CUBICSPLINE = "CUBICSPLINE",
  68861. }
  68862. /**
  68863. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68864. */
  68865. const enum CameraType {
  68866. /**
  68867. * A perspective camera containing properties to create a perspective projection matrix
  68868. */
  68869. PERSPECTIVE = "perspective",
  68870. /**
  68871. * An orthographic camera containing properties to create an orthographic projection matrix
  68872. */
  68873. ORTHOGRAPHIC = "orthographic",
  68874. }
  68875. /**
  68876. * The mime-type of the image
  68877. */
  68878. const enum ImageMimeType {
  68879. /**
  68880. * JPEG Mime-type
  68881. */
  68882. JPEG = "image/jpeg",
  68883. /**
  68884. * PNG Mime-type
  68885. */
  68886. PNG = "image/png",
  68887. }
  68888. /**
  68889. * The alpha rendering mode of the material
  68890. */
  68891. const enum MaterialAlphaMode {
  68892. /**
  68893. * The alpha value is ignored and the rendered output is fully opaque
  68894. */
  68895. OPAQUE = "OPAQUE",
  68896. /**
  68897. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  68898. */
  68899. MASK = "MASK",
  68900. /**
  68901. * The alpha value is used to composite the source and destination areas. The rendered output is combined with the background using the normal painting operation (i.e. the Porter and Duff over operator)
  68902. */
  68903. BLEND = "BLEND",
  68904. }
  68905. /**
  68906. * The type of the primitives to render
  68907. */
  68908. const enum MeshPrimitiveMode {
  68909. /**
  68910. * Points
  68911. */
  68912. POINTS = 0,
  68913. /**
  68914. * Lines
  68915. */
  68916. LINES = 1,
  68917. /**
  68918. * Line Loop
  68919. */
  68920. LINE_LOOP = 2,
  68921. /**
  68922. * Line Strip
  68923. */
  68924. LINE_STRIP = 3,
  68925. /**
  68926. * Triangles
  68927. */
  68928. TRIANGLES = 4,
  68929. /**
  68930. * Triangle Strip
  68931. */
  68932. TRIANGLE_STRIP = 5,
  68933. /**
  68934. * Triangle Fan
  68935. */
  68936. TRIANGLE_FAN = 6,
  68937. }
  68938. /**
  68939. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  68940. */
  68941. const enum TextureMagFilter {
  68942. /**
  68943. * Nearest
  68944. */
  68945. NEAREST = 9728,
  68946. /**
  68947. * Linear
  68948. */
  68949. LINEAR = 9729,
  68950. }
  68951. /**
  68952. * Minification filter. All valid values correspond to WebGL enums
  68953. */
  68954. const enum TextureMinFilter {
  68955. /**
  68956. * Nearest
  68957. */
  68958. NEAREST = 9728,
  68959. /**
  68960. * Linear
  68961. */
  68962. LINEAR = 9729,
  68963. /**
  68964. * Nearest Mip-Map Nearest
  68965. */
  68966. NEAREST_MIPMAP_NEAREST = 9984,
  68967. /**
  68968. * Linear Mipmap Nearest
  68969. */
  68970. LINEAR_MIPMAP_NEAREST = 9985,
  68971. /**
  68972. * Nearest Mipmap Linear
  68973. */
  68974. NEAREST_MIPMAP_LINEAR = 9986,
  68975. /**
  68976. * Linear Mipmap Linear
  68977. */
  68978. LINEAR_MIPMAP_LINEAR = 9987,
  68979. }
  68980. /**
  68981. * S (U) wrapping mode. All valid values correspond to WebGL enums
  68982. */
  68983. const enum TextureWrapMode {
  68984. /**
  68985. * Clamp to Edge
  68986. */
  68987. CLAMP_TO_EDGE = 33071,
  68988. /**
  68989. * Mirrored Repeat
  68990. */
  68991. MIRRORED_REPEAT = 33648,
  68992. /**
  68993. * Repeat
  68994. */
  68995. REPEAT = 10497,
  68996. }
  68997. /**
  68998. * glTF Property
  68999. */
  69000. interface IProperty {
  69001. /**
  69002. * Dictionary object with extension-specific objects
  69003. */
  69004. extensions?: {
  69005. [key: string]: any;
  69006. };
  69007. /**
  69008. * Application-Specific data
  69009. */
  69010. extras?: any;
  69011. }
  69012. /**
  69013. * glTF Child of Root Property
  69014. */
  69015. interface IChildRootProperty extends IProperty {
  69016. /**
  69017. * The user-defined name of this object
  69018. */
  69019. name?: string;
  69020. }
  69021. /**
  69022. * Indices of those attributes that deviate from their initialization value
  69023. */
  69024. interface IAccessorSparseIndices extends IProperty {
  69025. /**
  69026. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69027. */
  69028. bufferView: number;
  69029. /**
  69030. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69031. */
  69032. byteOffset?: number;
  69033. /**
  69034. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  69035. */
  69036. componentType: AccessorComponentType;
  69037. }
  69038. /**
  69039. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  69040. */
  69041. interface IAccessorSparseValues extends IProperty {
  69042. /**
  69043. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69044. */
  69045. bufferView: number;
  69046. /**
  69047. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69048. */
  69049. byteOffset?: number;
  69050. }
  69051. /**
  69052. * Sparse storage of attributes that deviate from their initialization value
  69053. */
  69054. interface IAccessorSparse extends IProperty {
  69055. /**
  69056. * The number of attributes encoded in this sparse accessor
  69057. */
  69058. count: number;
  69059. /**
  69060. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  69061. */
  69062. indices: IAccessorSparseIndices;
  69063. /**
  69064. * Array of size count times number of components, storing the displaced accessor attributes pointed by indices. Substituted values must have the same componentType and number of components as the base accessor
  69065. */
  69066. values: IAccessorSparseValues;
  69067. }
  69068. /**
  69069. * A typed view into a bufferView. A bufferView contains raw binary data. An accessor provides a typed view into a bufferView or a subset of a bufferView similar to how WebGL's vertexAttribPointer() defines an attribute in a buffer
  69070. */
  69071. interface IAccessor extends IChildRootProperty {
  69072. /**
  69073. * The index of the bufferview
  69074. */
  69075. bufferView?: number;
  69076. /**
  69077. * The offset relative to the start of the bufferView in bytes
  69078. */
  69079. byteOffset?: number;
  69080. /**
  69081. * The datatype of components in the attribute
  69082. */
  69083. componentType: AccessorComponentType;
  69084. /**
  69085. * Specifies whether integer data values should be normalized
  69086. */
  69087. normalized?: boolean;
  69088. /**
  69089. * The number of attributes referenced by this accessor
  69090. */
  69091. count: number;
  69092. /**
  69093. * Specifies if the attribute is a scalar, vector, or matrix
  69094. */
  69095. type: AccessorType;
  69096. /**
  69097. * Maximum value of each component in this attribute
  69098. */
  69099. max?: number[];
  69100. /**
  69101. * Minimum value of each component in this attribute
  69102. */
  69103. min?: number[];
  69104. /**
  69105. * Sparse storage of attributes that deviate from their initialization value
  69106. */
  69107. sparse?: IAccessorSparse;
  69108. }
  69109. /**
  69110. * Targets an animation's sampler at a node's property
  69111. */
  69112. interface IAnimationChannel extends IProperty {
  69113. /**
  69114. * The index of a sampler in this animation used to compute the value for the target
  69115. */
  69116. sampler: number;
  69117. /**
  69118. * The index of the node and TRS property to target
  69119. */
  69120. target: IAnimationChannelTarget;
  69121. }
  69122. /**
  69123. * The index of the node and TRS property that an animation channel targets
  69124. */
  69125. interface IAnimationChannelTarget extends IProperty {
  69126. /**
  69127. * The index of the node to target
  69128. */
  69129. node: number;
  69130. /**
  69131. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69132. */
  69133. path: AnimationChannelTargetPath;
  69134. }
  69135. /**
  69136. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69137. */
  69138. interface IAnimationSampler extends IProperty {
  69139. /**
  69140. * The index of an accessor containing keyframe input values, e.g., time
  69141. */
  69142. input: number;
  69143. /**
  69144. * Interpolation algorithm
  69145. */
  69146. interpolation?: AnimationSamplerInterpolation;
  69147. /**
  69148. * The index of an accessor, containing keyframe output values
  69149. */
  69150. output: number;
  69151. }
  69152. /**
  69153. * A keyframe animation
  69154. */
  69155. interface IAnimation extends IChildRootProperty {
  69156. /**
  69157. * An array of channels, each of which targets an animation's sampler at a node's property
  69158. */
  69159. channels: IAnimationChannel[];
  69160. /**
  69161. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69162. */
  69163. samplers: IAnimationSampler[];
  69164. }
  69165. /**
  69166. * Metadata about the glTF asset
  69167. */
  69168. interface IAsset extends IChildRootProperty {
  69169. /**
  69170. * A copyright message suitable for display to credit the content creator
  69171. */
  69172. copyright?: string;
  69173. /**
  69174. * Tool that generated this glTF model. Useful for debugging
  69175. */
  69176. generator?: string;
  69177. /**
  69178. * The glTF version that this asset targets
  69179. */
  69180. version: string;
  69181. /**
  69182. * The minimum glTF version that this asset targets
  69183. */
  69184. minVersion?: string;
  69185. }
  69186. /**
  69187. * A buffer points to binary geometry, animation, or skins
  69188. */
  69189. interface IBuffer extends IChildRootProperty {
  69190. /**
  69191. * The uri of the buffer. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri
  69192. */
  69193. uri?: string;
  69194. /**
  69195. * The length of the buffer in bytes
  69196. */
  69197. byteLength: number;
  69198. }
  69199. /**
  69200. * A view into a buffer generally representing a subset of the buffer
  69201. */
  69202. interface IBufferView extends IChildRootProperty {
  69203. /**
  69204. * The index of the buffer
  69205. */
  69206. buffer: number;
  69207. /**
  69208. * The offset into the buffer in bytes
  69209. */
  69210. byteOffset?: number;
  69211. /**
  69212. * The lenth of the bufferView in bytes
  69213. */
  69214. byteLength: number;
  69215. /**
  69216. * The stride, in bytes
  69217. */
  69218. byteStride?: number;
  69219. }
  69220. /**
  69221. * An orthographic camera containing properties to create an orthographic projection matrix
  69222. */
  69223. interface ICameraOrthographic extends IProperty {
  69224. /**
  69225. * The floating-point horizontal magnification of the view. Must not be zero
  69226. */
  69227. xmag: number;
  69228. /**
  69229. * The floating-point vertical magnification of the view. Must not be zero
  69230. */
  69231. ymag: number;
  69232. /**
  69233. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  69234. */
  69235. zfar: number;
  69236. /**
  69237. * The floating-point distance to the near clipping plane
  69238. */
  69239. znear: number;
  69240. }
  69241. /**
  69242. * A perspective camera containing properties to create a perspective projection matrix
  69243. */
  69244. interface ICameraPerspective extends IProperty {
  69245. /**
  69246. * The floating-point aspect ratio of the field of view
  69247. */
  69248. aspectRatio?: number;
  69249. /**
  69250. * The floating-point vertical field of view in radians
  69251. */
  69252. yfov: number;
  69253. /**
  69254. * The floating-point distance to the far clipping plane
  69255. */
  69256. zfar?: number;
  69257. /**
  69258. * The floating-point distance to the near clipping plane
  69259. */
  69260. znear: number;
  69261. }
  69262. /**
  69263. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69264. */
  69265. interface ICamera extends IChildRootProperty {
  69266. /**
  69267. * An orthographic camera containing properties to create an orthographic projection matrix
  69268. */
  69269. orthographic?: ICameraOrthographic;
  69270. /**
  69271. * A perspective camera containing properties to create a perspective projection matrix
  69272. */
  69273. perspective?: ICameraPerspective;
  69274. /**
  69275. * Specifies if the camera uses a perspective or orthographic projection
  69276. */
  69277. type: CameraType;
  69278. }
  69279. /**
  69280. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  69281. */
  69282. interface IImage extends IChildRootProperty {
  69283. /**
  69284. * The uri of the image. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri. The image format must be jpg or png
  69285. */
  69286. uri?: string;
  69287. /**
  69288. * The image's MIME type
  69289. */
  69290. mimeType?: ImageMimeType;
  69291. /**
  69292. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  69293. */
  69294. bufferView?: number;
  69295. }
  69296. /**
  69297. * Material Normal Texture Info
  69298. */
  69299. interface IMaterialNormalTextureInfo extends ITextureInfo {
  69300. /**
  69301. * The scalar multiplier applied to each normal vector of the normal texture
  69302. */
  69303. scale?: number;
  69304. }
  69305. /**
  69306. * Material Occlusion Texture Info
  69307. */
  69308. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  69309. /**
  69310. * A scalar multiplier controlling the amount of occlusion applied
  69311. */
  69312. strength?: number;
  69313. }
  69314. /**
  69315. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  69316. */
  69317. interface IMaterialPbrMetallicRoughness {
  69318. /**
  69319. * The material's base color factor
  69320. */
  69321. baseColorFactor?: number[];
  69322. /**
  69323. * The base color texture
  69324. */
  69325. baseColorTexture?: ITextureInfo;
  69326. /**
  69327. * The metalness of the material
  69328. */
  69329. metallicFactor?: number;
  69330. /**
  69331. * The roughness of the material
  69332. */
  69333. roughnessFactor?: number;
  69334. /**
  69335. * The metallic-roughness texture
  69336. */
  69337. metallicRoughnessTexture?: ITextureInfo;
  69338. }
  69339. /**
  69340. * The material appearance of a primitive
  69341. */
  69342. interface IMaterial extends IChildRootProperty {
  69343. /**
  69344. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology. When not specified, all the default values of pbrMetallicRoughness apply
  69345. */
  69346. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69347. /**
  69348. * The normal map texture
  69349. */
  69350. normalTexture?: IMaterialNormalTextureInfo;
  69351. /**
  69352. * The occlusion map texture
  69353. */
  69354. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69355. /**
  69356. * The emissive map texture
  69357. */
  69358. emissiveTexture?: ITextureInfo;
  69359. /**
  69360. * The RGB components of the emissive color of the material. These values are linear. If an emissiveTexture is specified, this value is multiplied with the texel values
  69361. */
  69362. emissiveFactor?: number[];
  69363. /**
  69364. * The alpha rendering mode of the material
  69365. */
  69366. alphaMode?: MaterialAlphaMode;
  69367. /**
  69368. * The alpha cutoff value of the material
  69369. */
  69370. alphaCutoff?: number;
  69371. /**
  69372. * Specifies whether the material is double sided
  69373. */
  69374. doubleSided?: boolean;
  69375. }
  69376. /**
  69377. * Geometry to be rendered with the given material
  69378. */
  69379. interface IMeshPrimitive extends IProperty {
  69380. /**
  69381. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  69382. */
  69383. attributes: {
  69384. [name: string]: number;
  69385. };
  69386. /**
  69387. * The index of the accessor that contains the indices
  69388. */
  69389. indices?: number;
  69390. /**
  69391. * The index of the material to apply to this primitive when rendering
  69392. */
  69393. material?: number;
  69394. /**
  69395. * The type of primitives to render. All valid values correspond to WebGL enums
  69396. */
  69397. mode?: MeshPrimitiveMode;
  69398. /**
  69399. * An array of Morph Targets, each Morph Target is a dictionary mapping attributes (only POSITION, NORMAL, and TANGENT supported) to their deviations in the Morph Target
  69400. */
  69401. targets?: {
  69402. [name: string]: number;
  69403. }[];
  69404. }
  69405. /**
  69406. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  69407. */
  69408. interface IMesh extends IChildRootProperty {
  69409. /**
  69410. * An array of primitives, each defining geometry to be rendered with a material
  69411. */
  69412. primitives: IMeshPrimitive[];
  69413. /**
  69414. * Array of weights to be applied to the Morph Targets
  69415. */
  69416. weights?: number[];
  69417. }
  69418. /**
  69419. * A node in the node hierarchy
  69420. */
  69421. interface INode extends IChildRootProperty {
  69422. /**
  69423. * The index of the camera referenced by this node
  69424. */
  69425. camera?: number;
  69426. /**
  69427. * The indices of this node's children
  69428. */
  69429. children?: number[];
  69430. /**
  69431. * The index of the skin referenced by this node
  69432. */
  69433. skin?: number;
  69434. /**
  69435. * A floating-point 4x4 transformation matrix stored in column-major order
  69436. */
  69437. matrix?: number[];
  69438. /**
  69439. * The index of the mesh in this node
  69440. */
  69441. mesh?: number;
  69442. /**
  69443. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  69444. */
  69445. rotation?: number[];
  69446. /**
  69447. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  69448. */
  69449. scale?: number[];
  69450. /**
  69451. * The node's translation along the x, y, and z axes
  69452. */
  69453. translation?: number[];
  69454. /**
  69455. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  69456. */
  69457. weights?: number[];
  69458. }
  69459. /**
  69460. * Texture sampler properties for filtering and wrapping modes
  69461. */
  69462. interface ISampler extends IChildRootProperty {
  69463. /**
  69464. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69465. */
  69466. magFilter?: TextureMagFilter;
  69467. /**
  69468. * Minification filter. All valid values correspond to WebGL enums
  69469. */
  69470. minFilter?: TextureMinFilter;
  69471. /**
  69472. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69473. */
  69474. wrapS?: TextureWrapMode;
  69475. /**
  69476. * T (V) wrapping mode. All valid values correspond to WebGL enums
  69477. */
  69478. wrapT?: TextureWrapMode;
  69479. }
  69480. /**
  69481. * The root nodes of a scene
  69482. */
  69483. interface IScene extends IChildRootProperty {
  69484. /**
  69485. * The indices of each root node
  69486. */
  69487. nodes: number[];
  69488. }
  69489. /**
  69490. * Joints and matrices defining a skin
  69491. */
  69492. interface ISkin extends IChildRootProperty {
  69493. /**
  69494. * The index of the accessor containing the floating-point 4x4 inverse-bind matrices. The default is that each matrix is a 4x4 identity matrix, which implies that inverse-bind matrices were pre-applied
  69495. */
  69496. inverseBindMatrices?: number;
  69497. /**
  69498. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  69499. */
  69500. skeleton?: number;
  69501. /**
  69502. * Indices of skeleton nodes, used as joints in this skin. The array length must be the same as the count property of the inverseBindMatrices accessor (when defined)
  69503. */
  69504. joints: number[];
  69505. }
  69506. /**
  69507. * A texture and its sampler
  69508. */
  69509. interface ITexture extends IChildRootProperty {
  69510. /**
  69511. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  69512. */
  69513. sampler?: number;
  69514. /**
  69515. * The index of the image used by this texture
  69516. */
  69517. source: number;
  69518. }
  69519. /**
  69520. * Reference to a texture
  69521. */
  69522. interface ITextureInfo extends IProperty {
  69523. /**
  69524. * The index of the texture
  69525. */
  69526. index: number;
  69527. /**
  69528. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  69529. */
  69530. texCoord?: number;
  69531. }
  69532. /**
  69533. * The root object for a glTF asset
  69534. */
  69535. interface IGLTF extends IProperty {
  69536. /**
  69537. * An array of accessors. An accessor is a typed view into a bufferView
  69538. */
  69539. accessors?: IAccessor[];
  69540. /**
  69541. * An array of keyframe animations
  69542. */
  69543. animations?: IAnimation[];
  69544. /**
  69545. * Metadata about the glTF asset
  69546. */
  69547. asset: IAsset;
  69548. /**
  69549. * An array of buffers. A buffer points to binary geometry, animation, or skins
  69550. */
  69551. buffers?: IBuffer[];
  69552. /**
  69553. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  69554. */
  69555. bufferViews?: IBufferView[];
  69556. /**
  69557. * An array of cameras
  69558. */
  69559. cameras?: ICamera[];
  69560. /**
  69561. * Names of glTF extensions used somewhere in this asset
  69562. */
  69563. extensionsUsed?: string[];
  69564. /**
  69565. * Names of glTF extensions required to properly load this asset
  69566. */
  69567. extensionsRequired?: string[];
  69568. /**
  69569. * An array of images. An image defines data used to create a texture
  69570. */
  69571. images?: IImage[];
  69572. /**
  69573. * An array of materials. A material defines the appearance of a primitive
  69574. */
  69575. materials?: IMaterial[];
  69576. /**
  69577. * An array of meshes. A mesh is a set of primitives to be rendered
  69578. */
  69579. meshes?: IMesh[];
  69580. /**
  69581. * An array of nodes
  69582. */
  69583. nodes?: INode[];
  69584. /**
  69585. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  69586. */
  69587. samplers?: ISampler[];
  69588. /**
  69589. * The index of the default scene
  69590. */
  69591. scene?: number;
  69592. /**
  69593. * An array of scenes
  69594. */
  69595. scenes?: IScene[];
  69596. /**
  69597. * An array of skins. A skin is defined by joints and matrices
  69598. */
  69599. skins?: ISkin[];
  69600. /**
  69601. * An array of textures
  69602. */
  69603. textures?: ITexture[];
  69604. }
  69605. /**
  69606. * The glTF validation results
  69607. */
  69608. interface IGLTFValidationResults {
  69609. info: {
  69610. generator: string;
  69611. hasAnimations: boolean;
  69612. hasDefaultScene: boolean;
  69613. hasMaterials: boolean;
  69614. hasMorphTargets: boolean;
  69615. hasSkins: boolean;
  69616. hasTextures: boolean;
  69617. maxAttributesUsed: number;
  69618. primitivesCount: number
  69619. };
  69620. issues: {
  69621. messages: Array<string>;
  69622. numErrors: number;
  69623. numHints: number;
  69624. numInfos: number;
  69625. numWarnings: number;
  69626. truncated: boolean
  69627. };
  69628. mimeType: string;
  69629. uri: string;
  69630. validatedAt: string;
  69631. validatorVersion: string;
  69632. }
  69633. /**
  69634. * The glTF validation options
  69635. */
  69636. interface IGLTFValidationOptions {
  69637. uri?: string;
  69638. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  69639. validateAccessorData?: boolean;
  69640. maxIssues?: number;
  69641. ignoredIssues?: Array<string>;
  69642. severityOverrides?: Object;
  69643. }
  69644. /**
  69645. * The glTF validator object
  69646. */
  69647. interface IGLTFValidator {
  69648. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69649. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69650. }
  69651. }
  69652. declare module BABYLON {
  69653. /** @hidden */
  69654. export var cellPixelShader: {
  69655. name: string;
  69656. shader: string;
  69657. };
  69658. }
  69659. declare module BABYLON {
  69660. /** @hidden */
  69661. export var cellVertexShader: {
  69662. name: string;
  69663. shader: string;
  69664. };
  69665. }
  69666. declare module BABYLON {
  69667. export class CellMaterial extends BABYLON.PushMaterial {
  69668. private _diffuseTexture;
  69669. diffuseTexture: BABYLON.BaseTexture;
  69670. diffuseColor: BABYLON.Color3;
  69671. _computeHighLevel: boolean;
  69672. computeHighLevel: boolean;
  69673. private _disableLighting;
  69674. disableLighting: boolean;
  69675. private _maxSimultaneousLights;
  69676. maxSimultaneousLights: number;
  69677. private _renderId;
  69678. constructor(name: string, scene: BABYLON.Scene);
  69679. needAlphaBlending(): boolean;
  69680. needAlphaTesting(): boolean;
  69681. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69682. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69683. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69684. getAnimatables(): BABYLON.IAnimatable[];
  69685. getActiveTextures(): BABYLON.BaseTexture[];
  69686. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69687. dispose(forceDisposeEffect?: boolean): void;
  69688. getClassName(): string;
  69689. clone(name: string): CellMaterial;
  69690. serialize(): any;
  69691. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  69692. }
  69693. }
  69694. declare module BABYLON {
  69695. export class CustomShaderStructure {
  69696. FragmentStore: string;
  69697. VertexStore: string;
  69698. constructor();
  69699. }
  69700. export class ShaderSpecialParts {
  69701. constructor();
  69702. Fragment_Begin: string;
  69703. Fragment_Definitions: string;
  69704. Fragment_MainBegin: string;
  69705. Fragment_Custom_Diffuse: string;
  69706. Fragment_Before_Lights: string;
  69707. Fragment_Before_Fog: string;
  69708. Fragment_Custom_Alpha: string;
  69709. Fragment_Before_FragColor: string;
  69710. Vertex_Begin: string;
  69711. Vertex_Definitions: string;
  69712. Vertex_MainBegin: string;
  69713. Vertex_Before_PositionUpdated: string;
  69714. Vertex_Before_NormalUpdated: string;
  69715. Vertex_MainEnd: string;
  69716. }
  69717. export class CustomMaterial extends BABYLON.StandardMaterial {
  69718. static ShaderIndexer: number;
  69719. CustomParts: ShaderSpecialParts;
  69720. _isCreatedShader: boolean;
  69721. _createdShaderName: string;
  69722. _customUniform: string[];
  69723. _newUniforms: string[];
  69724. _newUniformInstances: any[];
  69725. _newSamplerInstances: BABYLON.Texture[];
  69726. FragmentShader: string;
  69727. VertexShader: string;
  69728. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69729. ReviewUniform(name: string, arr: string[]): string[];
  69730. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  69731. constructor(name: string, scene: BABYLON.Scene);
  69732. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  69733. Fragment_Begin(shaderPart: string): CustomMaterial;
  69734. Fragment_Definitions(shaderPart: string): CustomMaterial;
  69735. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  69736. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  69737. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  69738. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  69739. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  69740. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  69741. Vertex_Begin(shaderPart: string): CustomMaterial;
  69742. Vertex_Definitions(shaderPart: string): CustomMaterial;
  69743. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  69744. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  69745. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  69746. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  69747. }
  69748. }
  69749. declare module BABYLON {
  69750. export class ShaderAlebdoParts {
  69751. constructor();
  69752. Fragment_Begin: string;
  69753. Fragment_Definitions: string;
  69754. Fragment_MainBegin: string;
  69755. Fragment_Custom_Albedo: string;
  69756. Fragment_Before_Lights: string;
  69757. Fragment_Custom_MetallicRoughness: string;
  69758. Fragment_Custom_MicroSurface: string;
  69759. Fragment_Before_Fog: string;
  69760. Fragment_Custom_Alpha: string;
  69761. Fragment_Before_FragColor: string;
  69762. Vertex_Begin: string;
  69763. Vertex_Definitions: string;
  69764. Vertex_MainBegin: string;
  69765. Vertex_Before_PositionUpdated: string;
  69766. Vertex_Before_NormalUpdated: string;
  69767. Vertex_MainEnd: string;
  69768. }
  69769. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  69770. static ShaderIndexer: number;
  69771. CustomParts: ShaderAlebdoParts;
  69772. _isCreatedShader: boolean;
  69773. _createdShaderName: string;
  69774. _customUniform: string[];
  69775. _newUniforms: string[];
  69776. _newUniformInstances: any[];
  69777. _newSamplerInstances: BABYLON.Texture[];
  69778. FragmentShader: string;
  69779. VertexShader: string;
  69780. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69781. ReviewUniform(name: string, arr: string[]): string[];
  69782. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  69783. constructor(name: string, scene: BABYLON.Scene);
  69784. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  69785. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  69786. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  69787. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  69788. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  69789. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  69790. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  69791. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  69792. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  69793. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  69794. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  69795. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  69796. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  69797. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  69798. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  69799. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  69800. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  69801. }
  69802. }
  69803. declare module BABYLON {
  69804. /** @hidden */
  69805. export var firePixelShader: {
  69806. name: string;
  69807. shader: string;
  69808. };
  69809. }
  69810. declare module BABYLON {
  69811. /** @hidden */
  69812. export var fireVertexShader: {
  69813. name: string;
  69814. shader: string;
  69815. };
  69816. }
  69817. declare module BABYLON {
  69818. export class FireMaterial extends BABYLON.PushMaterial {
  69819. private _diffuseTexture;
  69820. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69821. private _distortionTexture;
  69822. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69823. private _opacityTexture;
  69824. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69825. diffuseColor: BABYLON.Color3;
  69826. speed: number;
  69827. private _scaledDiffuse;
  69828. private _renderId;
  69829. private _lastTime;
  69830. constructor(name: string, scene: BABYLON.Scene);
  69831. needAlphaBlending(): boolean;
  69832. needAlphaTesting(): boolean;
  69833. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69834. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69835. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69836. getAnimatables(): BABYLON.IAnimatable[];
  69837. getActiveTextures(): BABYLON.BaseTexture[];
  69838. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69839. getClassName(): string;
  69840. dispose(forceDisposeEffect?: boolean): void;
  69841. clone(name: string): FireMaterial;
  69842. serialize(): any;
  69843. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  69844. }
  69845. }
  69846. declare module BABYLON {
  69847. /** @hidden */
  69848. export var furPixelShader: {
  69849. name: string;
  69850. shader: string;
  69851. };
  69852. }
  69853. declare module BABYLON {
  69854. /** @hidden */
  69855. export var furVertexShader: {
  69856. name: string;
  69857. shader: string;
  69858. };
  69859. }
  69860. declare module BABYLON {
  69861. export class FurMaterial extends BABYLON.PushMaterial {
  69862. private _diffuseTexture;
  69863. diffuseTexture: BABYLON.BaseTexture;
  69864. private _heightTexture;
  69865. heightTexture: BABYLON.BaseTexture;
  69866. diffuseColor: BABYLON.Color3;
  69867. furLength: number;
  69868. furAngle: number;
  69869. furColor: BABYLON.Color3;
  69870. furOffset: number;
  69871. furSpacing: number;
  69872. furGravity: BABYLON.Vector3;
  69873. furSpeed: number;
  69874. furDensity: number;
  69875. furOcclusion: number;
  69876. furTexture: BABYLON.DynamicTexture;
  69877. private _disableLighting;
  69878. disableLighting: boolean;
  69879. private _maxSimultaneousLights;
  69880. maxSimultaneousLights: number;
  69881. highLevelFur: boolean;
  69882. _meshes: BABYLON.AbstractMesh[];
  69883. private _renderId;
  69884. private _furTime;
  69885. constructor(name: string, scene: BABYLON.Scene);
  69886. furTime: number;
  69887. needAlphaBlending(): boolean;
  69888. needAlphaTesting(): boolean;
  69889. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69890. updateFur(): void;
  69891. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69892. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69893. getAnimatables(): BABYLON.IAnimatable[];
  69894. getActiveTextures(): BABYLON.BaseTexture[];
  69895. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69896. dispose(forceDisposeEffect?: boolean): void;
  69897. clone(name: string): FurMaterial;
  69898. serialize(): any;
  69899. getClassName(): string;
  69900. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  69901. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  69902. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  69903. }
  69904. }
  69905. declare module BABYLON {
  69906. /** @hidden */
  69907. export var gradientPixelShader: {
  69908. name: string;
  69909. shader: string;
  69910. };
  69911. }
  69912. declare module BABYLON {
  69913. /** @hidden */
  69914. export var gradientVertexShader: {
  69915. name: string;
  69916. shader: string;
  69917. };
  69918. }
  69919. declare module BABYLON {
  69920. export class GradientMaterial extends BABYLON.PushMaterial {
  69921. private _maxSimultaneousLights;
  69922. maxSimultaneousLights: number;
  69923. topColor: BABYLON.Color3;
  69924. topColorAlpha: number;
  69925. bottomColor: BABYLON.Color3;
  69926. bottomColorAlpha: number;
  69927. offset: number;
  69928. scale: number;
  69929. smoothness: number;
  69930. private _disableLighting;
  69931. disableLighting: boolean;
  69932. private _renderId;
  69933. constructor(name: string, scene: BABYLON.Scene);
  69934. needAlphaBlending(): boolean;
  69935. needAlphaTesting(): boolean;
  69936. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69937. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69938. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69939. getAnimatables(): BABYLON.IAnimatable[];
  69940. dispose(forceDisposeEffect?: boolean): void;
  69941. clone(name: string): GradientMaterial;
  69942. serialize(): any;
  69943. getClassName(): string;
  69944. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  69945. }
  69946. }
  69947. declare module BABYLON {
  69948. /** @hidden */
  69949. export var gridPixelShader: {
  69950. name: string;
  69951. shader: string;
  69952. };
  69953. }
  69954. declare module BABYLON {
  69955. /** @hidden */
  69956. export var gridVertexShader: {
  69957. name: string;
  69958. shader: string;
  69959. };
  69960. }
  69961. declare module BABYLON {
  69962. /**
  69963. * The grid materials allows you to wrap any shape with a grid.
  69964. * Colors are customizable.
  69965. */
  69966. export class GridMaterial extends BABYLON.PushMaterial {
  69967. /**
  69968. * Main color of the grid (e.g. between lines)
  69969. */
  69970. mainColor: BABYLON.Color3;
  69971. /**
  69972. * Color of the grid lines.
  69973. */
  69974. lineColor: BABYLON.Color3;
  69975. /**
  69976. * The scale of the grid compared to unit.
  69977. */
  69978. gridRatio: number;
  69979. /**
  69980. * Allows setting an offset for the grid lines.
  69981. */
  69982. gridOffset: BABYLON.Vector3;
  69983. /**
  69984. * The frequency of thicker lines.
  69985. */
  69986. majorUnitFrequency: number;
  69987. /**
  69988. * The visibility of minor units in the grid.
  69989. */
  69990. minorUnitVisibility: number;
  69991. /**
  69992. * The grid opacity outside of the lines.
  69993. */
  69994. opacity: number;
  69995. /**
  69996. * Determine RBG output is premultiplied by alpha value.
  69997. */
  69998. preMultiplyAlpha: boolean;
  69999. private _opacityTexture;
  70000. opacityTexture: BABYLON.BaseTexture;
  70001. private _gridControl;
  70002. private _renderId;
  70003. /**
  70004. * constructor
  70005. * @param name The name given to the material in order to identify it afterwards.
  70006. * @param scene The scene the material is used in.
  70007. */
  70008. constructor(name: string, scene: BABYLON.Scene);
  70009. /**
  70010. * Returns wehter or not the grid requires alpha blending.
  70011. */
  70012. needAlphaBlending(): boolean;
  70013. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70014. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70015. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70016. /**
  70017. * Dispose the material and its associated resources.
  70018. * @param forceDisposeEffect will also dispose the used effect when true
  70019. */
  70020. dispose(forceDisposeEffect?: boolean): void;
  70021. clone(name: string): GridMaterial;
  70022. serialize(): any;
  70023. getClassName(): string;
  70024. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  70025. }
  70026. }
  70027. declare module BABYLON {
  70028. /** @hidden */
  70029. export var lavaPixelShader: {
  70030. name: string;
  70031. shader: string;
  70032. };
  70033. }
  70034. declare module BABYLON {
  70035. /** @hidden */
  70036. export var lavaVertexShader: {
  70037. name: string;
  70038. shader: string;
  70039. };
  70040. }
  70041. declare module BABYLON {
  70042. export class LavaMaterial extends BABYLON.PushMaterial {
  70043. private _diffuseTexture;
  70044. diffuseTexture: BABYLON.BaseTexture;
  70045. noiseTexture: BABYLON.BaseTexture;
  70046. fogColor: BABYLON.Color3;
  70047. speed: number;
  70048. movingSpeed: number;
  70049. lowFrequencySpeed: number;
  70050. fogDensity: number;
  70051. private _lastTime;
  70052. diffuseColor: BABYLON.Color3;
  70053. private _disableLighting;
  70054. disableLighting: boolean;
  70055. private _unlit;
  70056. unlit: boolean;
  70057. private _maxSimultaneousLights;
  70058. maxSimultaneousLights: number;
  70059. private _scaledDiffuse;
  70060. private _renderId;
  70061. constructor(name: string, scene: BABYLON.Scene);
  70062. needAlphaBlending(): boolean;
  70063. needAlphaTesting(): boolean;
  70064. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70065. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70066. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70067. getAnimatables(): BABYLON.IAnimatable[];
  70068. getActiveTextures(): BABYLON.BaseTexture[];
  70069. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70070. dispose(forceDisposeEffect?: boolean): void;
  70071. clone(name: string): LavaMaterial;
  70072. serialize(): any;
  70073. getClassName(): string;
  70074. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  70075. }
  70076. }
  70077. declare module BABYLON {
  70078. /** @hidden */
  70079. export var mixPixelShader: {
  70080. name: string;
  70081. shader: string;
  70082. };
  70083. }
  70084. declare module BABYLON {
  70085. /** @hidden */
  70086. export var mixVertexShader: {
  70087. name: string;
  70088. shader: string;
  70089. };
  70090. }
  70091. declare module BABYLON {
  70092. export class MixMaterial extends BABYLON.PushMaterial {
  70093. /**
  70094. * Mix textures
  70095. */
  70096. private _mixTexture1;
  70097. mixTexture1: BABYLON.BaseTexture;
  70098. private _mixTexture2;
  70099. mixTexture2: BABYLON.BaseTexture;
  70100. /**
  70101. * Diffuse textures
  70102. */
  70103. private _diffuseTexture1;
  70104. diffuseTexture1: BABYLON.Texture;
  70105. private _diffuseTexture2;
  70106. diffuseTexture2: BABYLON.Texture;
  70107. private _diffuseTexture3;
  70108. diffuseTexture3: BABYLON.Texture;
  70109. private _diffuseTexture4;
  70110. diffuseTexture4: BABYLON.Texture;
  70111. private _diffuseTexture5;
  70112. diffuseTexture5: BABYLON.Texture;
  70113. private _diffuseTexture6;
  70114. diffuseTexture6: BABYLON.Texture;
  70115. private _diffuseTexture7;
  70116. diffuseTexture7: BABYLON.Texture;
  70117. private _diffuseTexture8;
  70118. diffuseTexture8: BABYLON.Texture;
  70119. /**
  70120. * Uniforms
  70121. */
  70122. diffuseColor: BABYLON.Color3;
  70123. specularColor: BABYLON.Color3;
  70124. specularPower: number;
  70125. private _disableLighting;
  70126. disableLighting: boolean;
  70127. private _maxSimultaneousLights;
  70128. maxSimultaneousLights: number;
  70129. private _renderId;
  70130. constructor(name: string, scene: BABYLON.Scene);
  70131. needAlphaBlending(): boolean;
  70132. needAlphaTesting(): boolean;
  70133. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70134. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70135. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70136. getAnimatables(): BABYLON.IAnimatable[];
  70137. getActiveTextures(): BABYLON.BaseTexture[];
  70138. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70139. dispose(forceDisposeEffect?: boolean): void;
  70140. clone(name: string): MixMaterial;
  70141. serialize(): any;
  70142. getClassName(): string;
  70143. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  70144. }
  70145. }
  70146. declare module BABYLON {
  70147. /** @hidden */
  70148. export var normalPixelShader: {
  70149. name: string;
  70150. shader: string;
  70151. };
  70152. }
  70153. declare module BABYLON {
  70154. /** @hidden */
  70155. export var normalVertexShader: {
  70156. name: string;
  70157. shader: string;
  70158. };
  70159. }
  70160. declare module BABYLON {
  70161. export class NormalMaterial extends BABYLON.PushMaterial {
  70162. private _diffuseTexture;
  70163. diffuseTexture: BABYLON.BaseTexture;
  70164. diffuseColor: BABYLON.Color3;
  70165. private _disableLighting;
  70166. disableLighting: boolean;
  70167. private _maxSimultaneousLights;
  70168. maxSimultaneousLights: number;
  70169. private _renderId;
  70170. constructor(name: string, scene: BABYLON.Scene);
  70171. needAlphaBlending(): boolean;
  70172. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70173. needAlphaTesting(): boolean;
  70174. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70175. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70176. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70177. getAnimatables(): BABYLON.IAnimatable[];
  70178. getActiveTextures(): BABYLON.BaseTexture[];
  70179. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70180. dispose(forceDisposeEffect?: boolean): void;
  70181. clone(name: string): NormalMaterial;
  70182. serialize(): any;
  70183. getClassName(): string;
  70184. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  70185. }
  70186. }
  70187. declare module BABYLON {
  70188. /** @hidden */
  70189. export var shadowOnlyPixelShader: {
  70190. name: string;
  70191. shader: string;
  70192. };
  70193. }
  70194. declare module BABYLON {
  70195. /** @hidden */
  70196. export var shadowOnlyVertexShader: {
  70197. name: string;
  70198. shader: string;
  70199. };
  70200. }
  70201. declare module BABYLON {
  70202. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  70203. private _renderId;
  70204. private _activeLight;
  70205. constructor(name: string, scene: BABYLON.Scene);
  70206. shadowColor: BABYLON.Color3;
  70207. needAlphaBlending(): boolean;
  70208. needAlphaTesting(): boolean;
  70209. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70210. activeLight: BABYLON.IShadowLight;
  70211. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70212. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70213. clone(name: string): ShadowOnlyMaterial;
  70214. serialize(): any;
  70215. getClassName(): string;
  70216. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  70217. }
  70218. }
  70219. declare module BABYLON {
  70220. /** @hidden */
  70221. export var simplePixelShader: {
  70222. name: string;
  70223. shader: string;
  70224. };
  70225. }
  70226. declare module BABYLON {
  70227. /** @hidden */
  70228. export var simpleVertexShader: {
  70229. name: string;
  70230. shader: string;
  70231. };
  70232. }
  70233. declare module BABYLON {
  70234. export class SimpleMaterial extends BABYLON.PushMaterial {
  70235. private _diffuseTexture;
  70236. diffuseTexture: BABYLON.BaseTexture;
  70237. diffuseColor: BABYLON.Color3;
  70238. private _disableLighting;
  70239. disableLighting: boolean;
  70240. private _maxSimultaneousLights;
  70241. maxSimultaneousLights: number;
  70242. private _renderId;
  70243. constructor(name: string, scene: BABYLON.Scene);
  70244. needAlphaBlending(): boolean;
  70245. needAlphaTesting(): boolean;
  70246. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70247. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70248. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70249. getAnimatables(): BABYLON.IAnimatable[];
  70250. getActiveTextures(): BABYLON.BaseTexture[];
  70251. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70252. dispose(forceDisposeEffect?: boolean): void;
  70253. clone(name: string): SimpleMaterial;
  70254. serialize(): any;
  70255. getClassName(): string;
  70256. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  70257. }
  70258. }
  70259. declare module BABYLON {
  70260. /** @hidden */
  70261. export var skyPixelShader: {
  70262. name: string;
  70263. shader: string;
  70264. };
  70265. }
  70266. declare module BABYLON {
  70267. /** @hidden */
  70268. export var skyVertexShader: {
  70269. name: string;
  70270. shader: string;
  70271. };
  70272. }
  70273. declare module BABYLON {
  70274. /**
  70275. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  70276. * @see https://doc.babylonjs.com/extensions/sky
  70277. */
  70278. export class SkyMaterial extends BABYLON.PushMaterial {
  70279. /**
  70280. * Defines the overall luminance of sky in interval ]0, 1[.
  70281. */
  70282. luminance: number;
  70283. /**
  70284. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  70285. */
  70286. turbidity: number;
  70287. /**
  70288. * Defines the sky appearance (light intensity).
  70289. */
  70290. rayleigh: number;
  70291. /**
  70292. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  70293. */
  70294. mieCoefficient: number;
  70295. /**
  70296. * Defines the amount of haze particles following the Mie scattering theory.
  70297. */
  70298. mieDirectionalG: number;
  70299. /**
  70300. * Defines the distance of the sun according to the active scene camera.
  70301. */
  70302. distance: number;
  70303. /**
  70304. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  70305. * "inclined".
  70306. */
  70307. inclination: number;
  70308. /**
  70309. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  70310. * an object direction and a reference direction.
  70311. */
  70312. azimuth: number;
  70313. /**
  70314. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  70315. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  70316. */
  70317. sunPosition: BABYLON.Vector3;
  70318. /**
  70319. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  70320. * .sunPosition property.
  70321. */
  70322. useSunPosition: boolean;
  70323. /**
  70324. * Defines an offset vector used to get a horizon offset.
  70325. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  70326. */
  70327. cameraOffset: BABYLON.Vector3;
  70328. private _cameraPosition;
  70329. private _renderId;
  70330. /**
  70331. * Instantiates a new sky material.
  70332. * This material allows to create dynamic and texture free
  70333. * effects for skyboxes by taking care of the atmosphere state.
  70334. * @see https://doc.babylonjs.com/extensions/sky
  70335. * @param name Define the name of the material in the scene
  70336. * @param scene Define the scene the material belong to
  70337. */
  70338. constructor(name: string, scene: BABYLON.Scene);
  70339. /**
  70340. * Specifies if the material will require alpha blending
  70341. * @returns a boolean specifying if alpha blending is needed
  70342. */
  70343. needAlphaBlending(): boolean;
  70344. /**
  70345. * Specifies if this material should be rendered in alpha test mode
  70346. * @returns false as the sky material doesn't need alpha testing.
  70347. */
  70348. needAlphaTesting(): boolean;
  70349. /**
  70350. * Get the texture used for alpha test purpose.
  70351. * @returns null as the sky material has no texture.
  70352. */
  70353. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70354. /**
  70355. * Get if the submesh is ready to be used and all its information available.
  70356. * Child classes can use it to update shaders
  70357. * @param mesh defines the mesh to check
  70358. * @param subMesh defines which submesh to check
  70359. * @param useInstances specifies that instances should be used
  70360. * @returns a boolean indicating that the submesh is ready or not
  70361. */
  70362. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70363. /**
  70364. * Binds the submesh to this material by preparing the effect and shader to draw
  70365. * @param world defines the world transformation matrix
  70366. * @param mesh defines the mesh containing the submesh
  70367. * @param subMesh defines the submesh to bind the material to
  70368. */
  70369. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70370. /**
  70371. * Get the list of animatables in the material.
  70372. * @returns the list of animatables object used in the material
  70373. */
  70374. getAnimatables(): BABYLON.IAnimatable[];
  70375. /**
  70376. * Disposes the material
  70377. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  70378. */
  70379. dispose(forceDisposeEffect?: boolean): void;
  70380. /**
  70381. * Makes a duplicate of the material, and gives it a new name
  70382. * @param name defines the new name for the duplicated material
  70383. * @returns the cloned material
  70384. */
  70385. clone(name: string): SkyMaterial;
  70386. /**
  70387. * Serializes this material in a JSON representation
  70388. * @returns the serialized material object
  70389. */
  70390. serialize(): any;
  70391. /**
  70392. * Gets the current class name of the material e.g. "SkyMaterial"
  70393. * Mainly use in serialization.
  70394. * @returns the class name
  70395. */
  70396. getClassName(): string;
  70397. /**
  70398. * Creates a sky material from parsed material data
  70399. * @param source defines the JSON representation of the material
  70400. * @param scene defines the hosting scene
  70401. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70402. * @returns a new sky material
  70403. */
  70404. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  70405. }
  70406. }
  70407. declare module BABYLON {
  70408. /** @hidden */
  70409. export var terrainPixelShader: {
  70410. name: string;
  70411. shader: string;
  70412. };
  70413. }
  70414. declare module BABYLON {
  70415. /** @hidden */
  70416. export var terrainVertexShader: {
  70417. name: string;
  70418. shader: string;
  70419. };
  70420. }
  70421. declare module BABYLON {
  70422. export class TerrainMaterial extends BABYLON.PushMaterial {
  70423. private _mixTexture;
  70424. mixTexture: BABYLON.BaseTexture;
  70425. private _diffuseTexture1;
  70426. diffuseTexture1: BABYLON.Texture;
  70427. private _diffuseTexture2;
  70428. diffuseTexture2: BABYLON.Texture;
  70429. private _diffuseTexture3;
  70430. diffuseTexture3: BABYLON.Texture;
  70431. private _bumpTexture1;
  70432. bumpTexture1: BABYLON.Texture;
  70433. private _bumpTexture2;
  70434. bumpTexture2: BABYLON.Texture;
  70435. private _bumpTexture3;
  70436. bumpTexture3: BABYLON.Texture;
  70437. diffuseColor: BABYLON.Color3;
  70438. specularColor: BABYLON.Color3;
  70439. specularPower: number;
  70440. private _disableLighting;
  70441. disableLighting: boolean;
  70442. private _maxSimultaneousLights;
  70443. maxSimultaneousLights: number;
  70444. private _renderId;
  70445. constructor(name: string, scene: BABYLON.Scene);
  70446. needAlphaBlending(): boolean;
  70447. needAlphaTesting(): boolean;
  70448. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70449. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70450. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70451. getAnimatables(): BABYLON.IAnimatable[];
  70452. getActiveTextures(): BABYLON.BaseTexture[];
  70453. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70454. dispose(forceDisposeEffect?: boolean): void;
  70455. clone(name: string): TerrainMaterial;
  70456. serialize(): any;
  70457. getClassName(): string;
  70458. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  70459. }
  70460. }
  70461. declare module BABYLON {
  70462. /** @hidden */
  70463. export var triplanarPixelShader: {
  70464. name: string;
  70465. shader: string;
  70466. };
  70467. }
  70468. declare module BABYLON {
  70469. /** @hidden */
  70470. export var triplanarVertexShader: {
  70471. name: string;
  70472. shader: string;
  70473. };
  70474. }
  70475. declare module BABYLON {
  70476. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  70477. mixTexture: BABYLON.BaseTexture;
  70478. private _diffuseTextureX;
  70479. diffuseTextureX: BABYLON.BaseTexture;
  70480. private _diffuseTextureY;
  70481. diffuseTextureY: BABYLON.BaseTexture;
  70482. private _diffuseTextureZ;
  70483. diffuseTextureZ: BABYLON.BaseTexture;
  70484. private _normalTextureX;
  70485. normalTextureX: BABYLON.BaseTexture;
  70486. private _normalTextureY;
  70487. normalTextureY: BABYLON.BaseTexture;
  70488. private _normalTextureZ;
  70489. normalTextureZ: BABYLON.BaseTexture;
  70490. tileSize: number;
  70491. diffuseColor: BABYLON.Color3;
  70492. specularColor: BABYLON.Color3;
  70493. specularPower: number;
  70494. private _disableLighting;
  70495. disableLighting: boolean;
  70496. private _maxSimultaneousLights;
  70497. maxSimultaneousLights: number;
  70498. private _renderId;
  70499. constructor(name: string, scene: BABYLON.Scene);
  70500. needAlphaBlending(): boolean;
  70501. needAlphaTesting(): boolean;
  70502. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70503. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70504. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70505. getAnimatables(): BABYLON.IAnimatable[];
  70506. getActiveTextures(): BABYLON.BaseTexture[];
  70507. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70508. dispose(forceDisposeEffect?: boolean): void;
  70509. clone(name: string): TriPlanarMaterial;
  70510. serialize(): any;
  70511. getClassName(): string;
  70512. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  70513. }
  70514. }
  70515. declare module BABYLON {
  70516. /** @hidden */
  70517. export var waterPixelShader: {
  70518. name: string;
  70519. shader: string;
  70520. };
  70521. }
  70522. declare module BABYLON {
  70523. /** @hidden */
  70524. export var waterVertexShader: {
  70525. name: string;
  70526. shader: string;
  70527. };
  70528. }
  70529. declare module BABYLON {
  70530. export class WaterMaterial extends BABYLON.PushMaterial {
  70531. renderTargetSize: BABYLON.Vector2;
  70532. private _bumpTexture;
  70533. bumpTexture: BABYLON.BaseTexture;
  70534. diffuseColor: BABYLON.Color3;
  70535. specularColor: BABYLON.Color3;
  70536. specularPower: number;
  70537. private _disableLighting;
  70538. disableLighting: boolean;
  70539. private _maxSimultaneousLights;
  70540. maxSimultaneousLights: number;
  70541. /**
  70542. * @param {number}: Represents the wind force
  70543. */
  70544. windForce: number;
  70545. /**
  70546. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  70547. */
  70548. windDirection: BABYLON.Vector2;
  70549. /**
  70550. * @param {number}: Wave height, represents the height of the waves
  70551. */
  70552. waveHeight: number;
  70553. /**
  70554. * @param {number}: Bump height, represents the bump height related to the bump map
  70555. */
  70556. bumpHeight: number;
  70557. /**
  70558. * @param {boolean}: Add a smaller moving bump to less steady waves.
  70559. */
  70560. private _bumpSuperimpose;
  70561. bumpSuperimpose: boolean;
  70562. /**
  70563. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  70564. */
  70565. private _fresnelSeparate;
  70566. fresnelSeparate: boolean;
  70567. /**
  70568. * @param {boolean}: bump Waves modify the reflection.
  70569. */
  70570. private _bumpAffectsReflection;
  70571. bumpAffectsReflection: boolean;
  70572. /**
  70573. * @param {number}: The water color blended with the refraction (near)
  70574. */
  70575. waterColor: BABYLON.Color3;
  70576. /**
  70577. * @param {number}: The blend factor related to the water color
  70578. */
  70579. colorBlendFactor: number;
  70580. /**
  70581. * @param {number}: The water color blended with the reflection (far)
  70582. */
  70583. waterColor2: BABYLON.Color3;
  70584. /**
  70585. * @param {number}: The blend factor related to the water color (reflection, far)
  70586. */
  70587. colorBlendFactor2: number;
  70588. /**
  70589. * @param {number}: Represents the maximum length of a wave
  70590. */
  70591. waveLength: number;
  70592. /**
  70593. * @param {number}: Defines the waves speed
  70594. */
  70595. waveSpeed: number;
  70596. /**
  70597. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  70598. * will avoid calculating useless pixels in the pixel shader of the water material.
  70599. */
  70600. disableClipPlane: boolean;
  70601. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  70602. private _mesh;
  70603. private _refractionRTT;
  70604. private _reflectionRTT;
  70605. private _reflectionTransform;
  70606. private _lastTime;
  70607. private _lastDeltaTime;
  70608. private _renderId;
  70609. private _useLogarithmicDepth;
  70610. private _waitingRenderList;
  70611. private _imageProcessingConfiguration;
  70612. private _imageProcessingObserver;
  70613. /**
  70614. * Gets a boolean indicating that current material needs to register RTT
  70615. */
  70616. readonly hasRenderTargetTextures: boolean;
  70617. /**
  70618. * Constructor
  70619. */
  70620. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  70621. useLogarithmicDepth: boolean;
  70622. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70623. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70624. addToRenderList(node: any): void;
  70625. enableRenderTargets(enable: boolean): void;
  70626. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  70627. readonly renderTargetsEnabled: boolean;
  70628. needAlphaBlending(): boolean;
  70629. needAlphaTesting(): boolean;
  70630. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70631. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70632. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70633. private _createRenderTargets;
  70634. getAnimatables(): BABYLON.IAnimatable[];
  70635. getActiveTextures(): BABYLON.BaseTexture[];
  70636. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70637. dispose(forceDisposeEffect?: boolean): void;
  70638. clone(name: string): WaterMaterial;
  70639. serialize(): any;
  70640. getClassName(): string;
  70641. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  70642. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  70643. }
  70644. }
  70645. declare module BABYLON {
  70646. /** @hidden */
  70647. export var asciiartPixelShader: {
  70648. name: string;
  70649. shader: string;
  70650. };
  70651. }
  70652. declare module BABYLON {
  70653. /**
  70654. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  70655. *
  70656. * It basically takes care rendering the font front the given font size to a texture.
  70657. * This is used later on in the postprocess.
  70658. */
  70659. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  70660. private _font;
  70661. private _text;
  70662. private _charSize;
  70663. /**
  70664. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70665. */
  70666. readonly charSize: number;
  70667. /**
  70668. * Create a new instance of the Ascii Art FontTexture class
  70669. * @param name the name of the texture
  70670. * @param font the font to use, use the W3C CSS notation
  70671. * @param text the caracter set to use in the rendering.
  70672. * @param scene the scene that owns the texture
  70673. */
  70674. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70675. /**
  70676. * Gets the max char width of a font.
  70677. * @param font the font to use, use the W3C CSS notation
  70678. * @return the max char width
  70679. */
  70680. private getFontWidth;
  70681. /**
  70682. * Gets the max char height of a font.
  70683. * @param font the font to use, use the W3C CSS notation
  70684. * @return the max char height
  70685. */
  70686. private getFontHeight;
  70687. /**
  70688. * Clones the current AsciiArtTexture.
  70689. * @return the clone of the texture.
  70690. */
  70691. clone(): AsciiArtFontTexture;
  70692. /**
  70693. * Parses a json object representing the texture and returns an instance of it.
  70694. * @param source the source JSON representation
  70695. * @param scene the scene to create the texture for
  70696. * @return the parsed texture
  70697. */
  70698. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  70699. }
  70700. /**
  70701. * Option available in the Ascii Art Post Process.
  70702. */
  70703. export interface IAsciiArtPostProcessOptions {
  70704. /**
  70705. * The font to use following the w3c font definition.
  70706. */
  70707. font?: string;
  70708. /**
  70709. * The character set to use in the postprocess.
  70710. */
  70711. characterSet?: string;
  70712. /**
  70713. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70714. * This number is defined between 0 and 1;
  70715. */
  70716. mixToTile?: number;
  70717. /**
  70718. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70719. * This number is defined between 0 and 1;
  70720. */
  70721. mixToNormal?: number;
  70722. }
  70723. /**
  70724. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  70725. *
  70726. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70727. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  70728. */
  70729. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  70730. /**
  70731. * The font texture used to render the char in the post process.
  70732. */
  70733. private _asciiArtFontTexture;
  70734. /**
  70735. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70736. * This number is defined between 0 and 1;
  70737. */
  70738. mixToTile: number;
  70739. /**
  70740. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70741. * This number is defined between 0 and 1;
  70742. */
  70743. mixToNormal: number;
  70744. /**
  70745. * Instantiates a new Ascii Art Post Process.
  70746. * @param name the name to give to the postprocess
  70747. * @camera the camera to apply the post process to.
  70748. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  70749. */
  70750. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  70751. }
  70752. }
  70753. declare module BABYLON {
  70754. /** @hidden */
  70755. export var digitalrainPixelShader: {
  70756. name: string;
  70757. shader: string;
  70758. };
  70759. }
  70760. declare module BABYLON {
  70761. /**
  70762. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  70763. *
  70764. * It basically takes care rendering the font front the given font size to a texture.
  70765. * This is used later on in the postprocess.
  70766. */
  70767. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  70768. private _font;
  70769. private _text;
  70770. private _charSize;
  70771. /**
  70772. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70773. */
  70774. readonly charSize: number;
  70775. /**
  70776. * Create a new instance of the Digital Rain FontTexture class
  70777. * @param name the name of the texture
  70778. * @param font the font to use, use the W3C CSS notation
  70779. * @param text the caracter set to use in the rendering.
  70780. * @param scene the scene that owns the texture
  70781. */
  70782. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70783. /**
  70784. * Gets the max char width of a font.
  70785. * @param font the font to use, use the W3C CSS notation
  70786. * @return the max char width
  70787. */
  70788. private getFontWidth;
  70789. /**
  70790. * Gets the max char height of a font.
  70791. * @param font the font to use, use the W3C CSS notation
  70792. * @return the max char height
  70793. */
  70794. private getFontHeight;
  70795. /**
  70796. * Clones the current DigitalRainFontTexture.
  70797. * @return the clone of the texture.
  70798. */
  70799. clone(): DigitalRainFontTexture;
  70800. /**
  70801. * Parses a json object representing the texture and returns an instance of it.
  70802. * @param source the source JSON representation
  70803. * @param scene the scene to create the texture for
  70804. * @return the parsed texture
  70805. */
  70806. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  70807. }
  70808. /**
  70809. * Option available in the Digital Rain Post Process.
  70810. */
  70811. export interface IDigitalRainPostProcessOptions {
  70812. /**
  70813. * The font to use following the w3c font definition.
  70814. */
  70815. font?: string;
  70816. /**
  70817. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70818. * This number is defined between 0 and 1;
  70819. */
  70820. mixToTile?: number;
  70821. /**
  70822. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70823. * This number is defined between 0 and 1;
  70824. */
  70825. mixToNormal?: number;
  70826. }
  70827. /**
  70828. * DigitalRainPostProcess helps rendering everithing in digital rain.
  70829. *
  70830. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70831. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  70832. */
  70833. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  70834. /**
  70835. * The font texture used to render the char in the post process.
  70836. */
  70837. private _digitalRainFontTexture;
  70838. /**
  70839. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70840. * This number is defined between 0 and 1;
  70841. */
  70842. mixToTile: number;
  70843. /**
  70844. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70845. * This number is defined between 0 and 1;
  70846. */
  70847. mixToNormal: number;
  70848. /**
  70849. * Instantiates a new Digital Rain Post Process.
  70850. * @param name the name to give to the postprocess
  70851. * @camera the camera to apply the post process to.
  70852. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  70853. */
  70854. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  70855. }
  70856. }
  70857. declare module BABYLON {
  70858. /** @hidden */
  70859. export var oceanPostProcessPixelShader: {
  70860. name: string;
  70861. shader: string;
  70862. };
  70863. }
  70864. declare module BABYLON {
  70865. /**
  70866. * Option available in the Ocean Post Process.
  70867. */
  70868. export interface IOceanPostProcessOptions {
  70869. /**
  70870. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70871. */
  70872. reflectionSize?: number | {
  70873. width: number;
  70874. height: number;
  70875. } | {
  70876. ratio: number;
  70877. };
  70878. /**
  70879. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70880. */
  70881. refractionSize?: number | {
  70882. width: number;
  70883. height: number;
  70884. } | {
  70885. ratio: number;
  70886. };
  70887. }
  70888. /**
  70889. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  70890. *
  70891. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70892. * Example usage:
  70893. * var pp = new OceanPostProcess("myOcean", camera);
  70894. * pp.reflectionEnabled = true;
  70895. * pp.refractionEnabled = true;
  70896. */
  70897. export class OceanPostProcess extends BABYLON.PostProcess {
  70898. /**
  70899. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  70900. */
  70901. /**
  70902. * Sets weither or not the real-time reflection is enabled on the ocean.
  70903. * Is set to true, the reflection mirror texture will be used as reflection texture.
  70904. */
  70905. reflectionEnabled: boolean;
  70906. /**
  70907. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  70908. */
  70909. /**
  70910. * Sets weither or not the real-time refraction is enabled on the ocean.
  70911. * Is set to true, the refraction render target texture will be used as refraction texture.
  70912. */
  70913. refractionEnabled: boolean;
  70914. /**
  70915. * Gets wether or not the post-processes is supported by the running hardware.
  70916. * This requires draw buffer supports.
  70917. */
  70918. readonly isSupported: boolean;
  70919. /**
  70920. * This is the reflection mirror texture used to display reflections on the ocean.
  70921. * By default, render list is empty.
  70922. */
  70923. reflectionTexture: BABYLON.MirrorTexture;
  70924. /**
  70925. * This is the refraction render target texture used to display refraction on the ocean.
  70926. * By default, render list is empty.
  70927. */
  70928. refractionTexture: BABYLON.RenderTargetTexture;
  70929. private _time;
  70930. private _cameraRotation;
  70931. private _cameraViewMatrix;
  70932. private _reflectionEnabled;
  70933. private _refractionEnabled;
  70934. private _geometryRenderer;
  70935. /**
  70936. * Instantiates a new Ocean Post Process.
  70937. * @param name the name to give to the postprocess.
  70938. * @camera the camera to apply the post process to.
  70939. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  70940. */
  70941. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  70942. /**
  70943. * Returns the appropriate defines according to the current configuration.
  70944. */
  70945. private _getDefines;
  70946. /**
  70947. * Computes the current camera rotation as the shader requires a camera rotation.
  70948. */
  70949. private _computeCameraRotation;
  70950. }
  70951. }
  70952. declare module BABYLON {
  70953. /** @hidden */
  70954. export var brickProceduralTexturePixelShader: {
  70955. name: string;
  70956. shader: string;
  70957. };
  70958. }
  70959. declare module BABYLON {
  70960. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  70961. private _numberOfBricksHeight;
  70962. private _numberOfBricksWidth;
  70963. private _jointColor;
  70964. private _brickColor;
  70965. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70966. updateShaderUniforms(): void;
  70967. numberOfBricksHeight: number;
  70968. numberOfBricksWidth: number;
  70969. jointColor: BABYLON.Color3;
  70970. brickColor: BABYLON.Color3;
  70971. /**
  70972. * Serializes this brick procedural texture
  70973. * @returns a serialized brick procedural texture object
  70974. */
  70975. serialize(): any;
  70976. /**
  70977. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  70978. * @param parsedTexture defines parsed texture data
  70979. * @param scene defines the current scene
  70980. * @param rootUrl defines the root URL containing brick procedural texture information
  70981. * @returns a parsed Brick Procedural BABYLON.Texture
  70982. */
  70983. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  70984. }
  70985. }
  70986. declare module BABYLON {
  70987. /** @hidden */
  70988. export var cloudProceduralTexturePixelShader: {
  70989. name: string;
  70990. shader: string;
  70991. };
  70992. }
  70993. declare module BABYLON {
  70994. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  70995. private _skyColor;
  70996. private _cloudColor;
  70997. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70998. updateShaderUniforms(): void;
  70999. skyColor: BABYLON.Color4;
  71000. cloudColor: BABYLON.Color4;
  71001. /**
  71002. * Serializes this cloud procedural texture
  71003. * @returns a serialized cloud procedural texture object
  71004. */
  71005. serialize(): any;
  71006. /**
  71007. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  71008. * @param parsedTexture defines parsed texture data
  71009. * @param scene defines the current scene
  71010. * @param rootUrl defines the root URL containing cloud procedural texture information
  71011. * @returns a parsed Cloud Procedural BABYLON.Texture
  71012. */
  71013. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  71014. }
  71015. }
  71016. declare module BABYLON {
  71017. /** @hidden */
  71018. export var fireProceduralTexturePixelShader: {
  71019. name: string;
  71020. shader: string;
  71021. };
  71022. }
  71023. declare module BABYLON {
  71024. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  71025. private _time;
  71026. private _speed;
  71027. private _autoGenerateTime;
  71028. private _fireColors;
  71029. private _alphaThreshold;
  71030. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71031. updateShaderUniforms(): void;
  71032. render(useCameraPostProcess?: boolean): void;
  71033. static readonly PurpleFireColors: BABYLON.Color3[];
  71034. static readonly GreenFireColors: BABYLON.Color3[];
  71035. static readonly RedFireColors: BABYLON.Color3[];
  71036. static readonly BlueFireColors: BABYLON.Color3[];
  71037. autoGenerateTime: boolean;
  71038. fireColors: BABYLON.Color3[];
  71039. time: number;
  71040. speed: BABYLON.Vector2;
  71041. alphaThreshold: number;
  71042. /**
  71043. * Serializes this fire procedural texture
  71044. * @returns a serialized fire procedural texture object
  71045. */
  71046. serialize(): any;
  71047. /**
  71048. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  71049. * @param parsedTexture defines parsed texture data
  71050. * @param scene defines the current scene
  71051. * @param rootUrl defines the root URL containing fire procedural texture information
  71052. * @returns a parsed Fire Procedural BABYLON.Texture
  71053. */
  71054. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  71055. }
  71056. }
  71057. declare module BABYLON {
  71058. /** @hidden */
  71059. export var grassProceduralTexturePixelShader: {
  71060. name: string;
  71061. shader: string;
  71062. };
  71063. }
  71064. declare module BABYLON {
  71065. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  71066. private _grassColors;
  71067. private _groundColor;
  71068. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71069. updateShaderUniforms(): void;
  71070. grassColors: BABYLON.Color3[];
  71071. groundColor: BABYLON.Color3;
  71072. /**
  71073. * Serializes this grass procedural texture
  71074. * @returns a serialized grass procedural texture object
  71075. */
  71076. serialize(): any;
  71077. /**
  71078. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  71079. * @param parsedTexture defines parsed texture data
  71080. * @param scene defines the current scene
  71081. * @param rootUrl defines the root URL containing grass procedural texture information
  71082. * @returns a parsed Grass Procedural BABYLON.Texture
  71083. */
  71084. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  71085. }
  71086. }
  71087. declare module BABYLON {
  71088. /** @hidden */
  71089. export var marbleProceduralTexturePixelShader: {
  71090. name: string;
  71091. shader: string;
  71092. };
  71093. }
  71094. declare module BABYLON {
  71095. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  71096. private _numberOfTilesHeight;
  71097. private _numberOfTilesWidth;
  71098. private _amplitude;
  71099. private _jointColor;
  71100. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71101. updateShaderUniforms(): void;
  71102. numberOfTilesHeight: number;
  71103. amplitude: number;
  71104. numberOfTilesWidth: number;
  71105. jointColor: BABYLON.Color3;
  71106. /**
  71107. * Serializes this marble procedural texture
  71108. * @returns a serialized marble procedural texture object
  71109. */
  71110. serialize(): any;
  71111. /**
  71112. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  71113. * @param parsedTexture defines parsed texture data
  71114. * @param scene defines the current scene
  71115. * @param rootUrl defines the root URL containing marble procedural texture information
  71116. * @returns a parsed Marble Procedural BABYLON.Texture
  71117. */
  71118. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  71119. }
  71120. }
  71121. declare module BABYLON {
  71122. /** @hidden */
  71123. export var normalMapProceduralTexturePixelShader: {
  71124. name: string;
  71125. shader: string;
  71126. };
  71127. }
  71128. declare module BABYLON {
  71129. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  71130. private _baseTexture;
  71131. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71132. updateShaderUniforms(): void;
  71133. render(useCameraPostProcess?: boolean): void;
  71134. resize(size: any, generateMipMaps: any): void;
  71135. baseTexture: BABYLON.Texture;
  71136. /**
  71137. * Serializes this normal map procedural texture
  71138. * @returns a serialized normal map procedural texture object
  71139. */
  71140. serialize(): any;
  71141. /**
  71142. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  71143. * @param parsedTexture defines parsed texture data
  71144. * @param scene defines the current scene
  71145. * @param rootUrl defines the root URL containing normal map procedural texture information
  71146. * @returns a parsed Normal Map Procedural BABYLON.Texture
  71147. */
  71148. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  71149. }
  71150. }
  71151. declare module BABYLON {
  71152. /** @hidden */
  71153. export var perlinNoiseProceduralTexturePixelShader: {
  71154. name: string;
  71155. shader: string;
  71156. };
  71157. }
  71158. declare module BABYLON {
  71159. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  71160. time: number;
  71161. timeScale: number;
  71162. translationSpeed: number;
  71163. private _currentTranslation;
  71164. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71165. updateShaderUniforms(): void;
  71166. render(useCameraPostProcess?: boolean): void;
  71167. resize(size: any, generateMipMaps: any): void;
  71168. /**
  71169. * Serializes this perlin noise procedural texture
  71170. * @returns a serialized perlin noise procedural texture object
  71171. */
  71172. serialize(): any;
  71173. /**
  71174. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  71175. * @param parsedTexture defines parsed texture data
  71176. * @param scene defines the current scene
  71177. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  71178. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  71179. */
  71180. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  71181. }
  71182. }
  71183. declare module BABYLON {
  71184. /** @hidden */
  71185. export var roadProceduralTexturePixelShader: {
  71186. name: string;
  71187. shader: string;
  71188. };
  71189. }
  71190. declare module BABYLON {
  71191. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  71192. private _roadColor;
  71193. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71194. updateShaderUniforms(): void;
  71195. roadColor: BABYLON.Color3;
  71196. /**
  71197. * Serializes this road procedural texture
  71198. * @returns a serialized road procedural texture object
  71199. */
  71200. serialize(): any;
  71201. /**
  71202. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  71203. * @param parsedTexture defines parsed texture data
  71204. * @param scene defines the current scene
  71205. * @param rootUrl defines the root URL containing road procedural texture information
  71206. * @returns a parsed Road Procedural BABYLON.Texture
  71207. */
  71208. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  71209. }
  71210. }
  71211. declare module BABYLON {
  71212. /** @hidden */
  71213. export var starfieldProceduralTexturePixelShader: {
  71214. name: string;
  71215. shader: string;
  71216. };
  71217. }
  71218. declare module BABYLON {
  71219. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  71220. private _time;
  71221. private _alpha;
  71222. private _beta;
  71223. private _zoom;
  71224. private _formuparam;
  71225. private _stepsize;
  71226. private _tile;
  71227. private _brightness;
  71228. private _darkmatter;
  71229. private _distfading;
  71230. private _saturation;
  71231. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71232. updateShaderUniforms(): void;
  71233. time: number;
  71234. alpha: number;
  71235. beta: number;
  71236. formuparam: number;
  71237. stepsize: number;
  71238. zoom: number;
  71239. tile: number;
  71240. brightness: number;
  71241. darkmatter: number;
  71242. distfading: number;
  71243. saturation: number;
  71244. /**
  71245. * Serializes this starfield procedural texture
  71246. * @returns a serialized starfield procedural texture object
  71247. */
  71248. serialize(): any;
  71249. /**
  71250. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  71251. * @param parsedTexture defines parsed texture data
  71252. * @param scene defines the current scene
  71253. * @param rootUrl defines the root URL containing startfield procedural texture information
  71254. * @returns a parsed Starfield Procedural BABYLON.Texture
  71255. */
  71256. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  71257. }
  71258. }
  71259. declare module BABYLON {
  71260. /** @hidden */
  71261. export var woodProceduralTexturePixelShader: {
  71262. name: string;
  71263. shader: string;
  71264. };
  71265. }
  71266. declare module BABYLON {
  71267. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  71268. private _ampScale;
  71269. private _woodColor;
  71270. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71271. updateShaderUniforms(): void;
  71272. ampScale: number;
  71273. woodColor: BABYLON.Color3;
  71274. /**
  71275. * Serializes this wood procedural texture
  71276. * @returns a serialized wood procedural texture object
  71277. */
  71278. serialize(): any;
  71279. /**
  71280. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  71281. * @param parsedTexture defines parsed texture data
  71282. * @param scene defines the current scene
  71283. * @param rootUrl defines the root URL containing wood procedural texture information
  71284. * @returns a parsed Wood Procedural BABYLON.Texture
  71285. */
  71286. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  71287. }
  71288. }